Bloch Sphere in QuTiP and QiskitΒΆ
Plotting the Bloch sphere with QuTiP
bloch = Bloch()
bloch.show()
bloch.axes.set_box_aspect(box_aspect)
up = basis(2, 0)
down = basis(2, 1)
bloch.clear()
bloch.add_states([up, down])
bloch.show()
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()
Plotting the Bloch sphere with Qiskit.
plot_bloch_vector([1,0,0], title="Bloch Sphere")
Download this code: bloch_sphere.ipynb
.