If I have a normalized $(\alpha,\beta)$ as $(0.24506+0.9633i,0.0046238+0.10943i)$ for a qubit $\left| \psi \right> = (\alpha_1 + i\alpha_2 ) \left|0\right> + (\beta_1 + i\beta_2 )\left|1\right>$, how can I generate angles for a unitary gate by using above data and can I run this on qiskit?


1 Answer 1


Here is my attempt.

First, let's create the statevector:

from qiskit.quantum_info.states import Statevector
alpha = complex(0.24506488, 0.9633)
beta = complex(0.0046248, 0.10943)
sv = Statevector([alpha,beta])

$ \begin{bmatrix} 0.24506 + 0.9633i & 0.00462 + 0.10943i \\ \end{bmatrix} $

Then, we can initialize a circuit in that state and transpile it to a rotation-only basis:

from qiskit import QuantumCircuit, transpile

qc = QuantumCircuit(1)
qc.initialize(sv, [0])
transpile(qc, basis_gates=['rx', 'ry', 'rz']).draw()

enter image description here

  • $\begingroup$ Thank you for responding ,When I try to run a state vector or qasm simulator I am getting error. $\endgroup$
    – boran
    Mar 9, 2021 at 16:58
  • $\begingroup$ sounds like an independent question. What's the error? $\endgroup$
    – luciano
    Mar 13, 2021 at 19:53

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.