How to transform the U3 gate of parameters (theta, phi, lambda) to an Operator. (in qiskit) The following code don't work

theta = Parameter('theta')
phi   = Parameter('phi')
lamb  = Parameter('lam')


1 Answer 1


You can use CircuitOp from Qiskit's Operator Flow:

from qiskit.opflow import CircuitOp

UO = CircuitOp(UGate(theta, phi, lamb))

You can use assign_parameters() method for parameter binding:

import numpy as np
op = UO.assign_parameters({theta: np.pi / 2, phi: 0, lamb: np.pi})

from qiskit.visualization import array_to_latex

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.