For example, we can create a single qubit state with a polar angle of $\pi/2$ with the Hadamard gate. But, can we create a state such as this,

$$\Psi = \cos(\pi/8)|0\rangle + \sin(\pi/8)|1\rangle$$

where the polar angle does not equal $\pi/2$, in QISkit?


1 Answer 1


You use the standard rotations. In this case, you're looking for the ry operator (rotation around the y-axis). To rotate the state vector counter-clockwise around the unit circle by $\theta$, call ry with $2\theta$ or in your case $\frac{2\pi}{8}$ applied to state $|0\rangle$.

from qiskit import *
import numpy as np
q = QuantumRegister(1)
qc = QuantumCircuit(q)

Your Answer

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

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