Lesson 3 of 15

Bloch Sphere Coordinates

The Bloch Sphere

Every pure single-qubit state can be represented as a point on the surface of the Bloch sphere — a unit sphere in 3D space.

Parametrization

Any normalized qubit state can be written as:

ψ=cosθ20+eiϕsinθ21|\psi\rangle = \cos\frac{\theta}{2}|0\rangle + e^{i\phi}\sin\frac{\theta}{2}|1\rangle

where:

  • θ[0,π]\theta \in [0, \pi] is the polar angle (latitude from the north pole)
  • ϕ[0,2π)\phi \in [0, 2\pi) is the azimuthal angle (longitude)

Key Points on the Bloch Sphere

Stateθ\thetaϕ\phiLocation
$0\rangle$00any
$1\rangle$π\piany
$+\rangle = \frac{0\rangle+1\rangle}{\sqrt{2}}$
$-\rangle = \frac{0\rangle-1\rangle}{\sqrt{2}}$
$L\rangle = \frac{0\rangle+i1\rangle}{\sqrt{2}}$
$R\rangle = \frac{0\rangle-i1\rangle}{\sqrt{2}}$

Extracting Angles from a State

Given a normalized state [α,β][\alpha, \beta]:

θ=2arccos(α)\theta = 2\arccos(|\alpha|)

ϕ=arg(β)arg(α)(mod2π)\phi = \arg(\beta) - \arg(\alpha) \pmod{2\pi}

When α0|\alpha| \approx 0 (i.e., the state is near 1|1\rangle), α\alpha has no well-defined argument, so we set ϕ=0\phi = 0 by convention.

Implementation

import cmath, math

def bloch_angles(state):
    alpha = complex(state[0])
    beta = complex(state[1])
    theta = 2 * math.acos(min(abs(alpha), 1.0))
    if abs(alpha) < 1e-10:
        phi = 0.0
    else:
        phi = (cmath.phase(beta) - cmath.phase(alpha)) % (2 * math.pi)
    return (theta, phi)

Why the Bloch Sphere Matters

  • Gate actions become geometric rotations: X is a π\pi-rotation around the X axis, H is a π\pi-rotation around the (X+Z)/2(X+Z)/\sqrt{2} axis.
  • Decoherence contracts the Bloch sphere inward — mixed states live inside the sphere.
  • Visualization makes it easy to reason about the effect of gate sequences.

Your Task

Implement bloch_angles(state) that returns (theta, phi) for a normalized qubit state.

Python runtime loading...
Loading...
Click "Run" to execute your code.