Show code cell content
import mmf_setup;mmf_setup.nbinit()
import logging;logging.getLogger('matplotlib').setLevel(logging.CRITICAL)
%matplotlib inline
import numpy as np, matplotlib.pyplot as plt
This cell adds /home/docs/checkouts/readthedocs.org/user_builds/physics-555-quantum-technologies/checkouts/latest/src to your path, and contains some definitions for equations and some CSS for styling the notebook. If things look a bit strange, please try the following:
- Choose "Trust Notebook" from the "File" menu.
- Re-execute this cell.
- Reload the notebook.
Bloch Sphere#
The Bloch sphere is an extremely useful and accurate way of visualizing the information in a qubit. Mathematically it is not so transparent, but it is very intuitive. Formally, we represent a quantum state \(\ket{\psi}\) in spherical coordinates as a point with angles \(\theta\) and \(\phi\) on the unit sphere \(r=1\):
# :tags: [hide-input]
from qiskit.visualization import plot_bloch_vector
def get_vec(psi):
"""Return the Bloch vector from psi."""
gamma = np.angle(psi[0])
psi = np.exp(-1j*gamma) * np.asarray(psi)
phi = np.angle(psi[1]) - np.angle(psi[0])
theta = 2*np.arctan2(psi[0].real,
(np.exp(-1j*phi)*psi[1]).real)
x = np.sin(theta)*np.cos(phi)
y = np.sin(theta)*np.sin(phi)
z = np.cos(theta)
return (x, y, z)
fig = plt.figure(figsize=(3*10, 10))
ax = fig.add_subplot(1, 3, 1, projection='3d')
plot_bloch_vector(get_vec([1, 1]), ax=ax, title=r"$|Ψ⟩ = \frac{|0⟩ + |1⟩}{\sqrt{2}}$")
ax = fig.add_subplot(1, 3, 2, projection='3d')
plot_bloch_vector(get_vec([1, -1]), ax=ax, title=r"$|Ψ⟩ = \frac{|0⟩ - |1⟩}{\sqrt{2}}$")
ax = fig.add_subplot(1, 3, 3, projection='3d')
plot_bloch_vector(get_vec([1, 1j]), ax=ax, title=r"$|Ψ⟩ = \frac{|0⟩ + \mathrm{i}|1⟩}{\sqrt{2}}$")
Note
Some important questions:
Why does the phase \(\gamma\) not affect the position on the Bloch sphere?
Why is the angle \(\theta/2\), half of what one would normally use?
Related: Why are the “orthogonal” vectors \(\ket{0}\) and \(\ket{1}\) not at right angles?
[Williams, 2011] has a nice discussion of these confusions in §1.3.3.
Intuitive Picture#
The Bloch sphere is nice because it not only provides a complete and faithful representation of a single qubit state, but arbitrary single-qubit operations (gates) have a simple picture. Specifically, any single-qubit gate can be expressed in terms of a clockwise rotation \(\vec{\theta} = \theta \uvec{n}\) of \(\theta\) radians about an axis \(\uvec{n}\) as:
In terms of spin-½ particles, this is easily implemented using an external magnetic field pointing in the \(\uvec{n}\) direction.
In component form:
Alternatively, redefine \(\theta = \omega\), express \(\hat{n}\) in polar coordinates, and let \(\eta\) be the phase of \(u_0\):
The magnitude of \(u_0\) (the denominator of \(e^{\I\eta}\) above) can be simplified by introducing a new angle \(\chi\), which describes how the vector \(\ket{0}\) is rotated:
QuTiP#
import qutip
b = qutip.Bloch()
b.make_sphere()
display(b)
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[3], line 1
----> 1 import qutip
2 b = qutip.Bloch()
3 b.make_sphere()
ModuleNotFoundError: No module named 'qutip'