The Bloch sphere
Every state of a single qubit can be drawn as a point on the surface of a sphere. It turns gates from matrices into something you can picture: each one is a rotation.
Two angles describe any qubit
An overall phase on the whole state cannot be measured, so it can be dropped. What is left of fits in two angles:
is the latitude, measured down from the north pole, and is the longitude around the equator. alone sets the measurement odds; is the relative phase.
Landmarks
| State | Angles | Where it sits |
|---|---|---|
| North pole | ||
| South pole | ||
| On the equator, facing +X | ||
| On the equator, facing −X | ||
| On the equator, facing +Y |
The poles are the basis states. Every point on the equator is an equal superposition, differing only in phase.
Gates are rotations
| Gate | Rotation | Method |
|---|---|---|
qc.x(q) | ||
qc.y(q) | ||
qc.z(q) | ||
qc.s(q) | ||
qc.t(q) | ||
qc.h(q) | ||
qc.rx(q, theta) | ||
qc.p(q, lam) |
A quarter turn about X takes the north pole to the equator, at the point facing −Y:
import math
import qsengine
qc = qsengine.QuantumCircuit(1)
qc.rx(0, math.pi / 2)
print(qc.statevector())
print(qc.probabilities())Output
[0.70710678+0.j 0. -0.70710678j]
[0.5 0.5]The second amplitude is −i/√2, exactly as the formula says, and the odds are 50/50.
Where the picture stops
The sphere describes one qubit on its own. Two or more qubits that are entangled have no point on any sphere, which is exactly what makes them interesting. That is the subject of the next pages.