Rotating the Bloch sphere around an axis
Rotations of the Bloch sphere can move a qubit from any point on the sphere’s surface to any other point on the surface. This section will show you some of Qiskit’s most useful rotation commands.
Experimenting with rotations
Qiskit provides many functions that rotate the Bloch sphere and change a qubit’s state. For hands-on practice with some of these rotations, open a new Qiskit notebook and follow these steps:
- Run the following code:
from qiskit import QuantumRegister, QuantumCircuit from math import pi reg = QuantumRegister(1) circuit = QuantumCircuit(reg) circuit.ry(pi/2, reg[0]) display(circuit.draw('latex'))
Figure 3.18 shows you the circuit diagram that this code generates:
Figure 3.18 – Rotating by radians about the Y-axis
The circuit’s one and only qubit begins its life in the |0⟩ state. Then, the circuit.ry(pi/2, reg[0])
statement...