Bloch Sphere in QuTiP and QiskitΒΆ
Plotting the Bloch sphere with QuTiP
bloch = Bloch()
bloch.show()
bloch.axes.set_box_aspect(box_aspect)
![../_images/bloch_sphere_1_0.png](../_images/bloch_sphere_1_0.png)
up = basis(2, 0)
down = basis(2, 1)
bloch.clear()
bloch.add_states([up, down])
bloch.show()
![../_images/bloch_sphere_2_0.png](../_images/bloch_sphere_2_0.png)
Apply a rotation of \(\frac{\pi}{2}\) around the \(y\) axis.
phi = ry(np.pi / 2) * up
phi
\[\begin{split}Quantum object: dims = [[2], [1]], shape = (2, 1), type = ket\begin{equation*}\left(\begin{array}{*{11}c}0.707\\0.707\\\end{array}\right)\end{equation*}\end{split}\]
bloch.clear()
bloch.add_states([up, phi])
bloch.show()
![../_images/bloch_sphere_4_0.png](../_images/bloch_sphere_4_0.png)
Plotting the Bloch sphere with Qiskit.
plot_bloch_vector([1,0,0], title="Bloch Sphere")
![../_images/bloch_sphere_6_0.png](../_images/bloch_sphere_6_0.png)
Download this code: bloch_sphere.ipynb
.