Phase is an angular position within a repeating pattern. For a sinusoid A cos(2πft + φ), φ is its horizontal shift at t = 0; frequency counts cycles, while amplitude sets peak height. Sine and cosine have the same shape but differ by a phase shift of π/2. section 7.1.1
In a quantum state, phase is the direction of a complex amplitude. An amplitude z = x + iy has a magnitude and direction; its squared magnitude gives an outcome probability, whereas its direction can carry information not visible in probabilities alone. Python's atan2(z.imag, z.real) returns that direction in radians. section 3.1.1 section 3.1.3
Treat phase as an angle on the complex plane. Multiplying an amplitude by cos(φ) + i sin(φ) preserves its magnitude and adds φ to its direction. This gives a direct implementation model for phase rotations: magnitudes multiply, directions add. section 3.2.1
Encode and recover a value in one amplitude's phase
To encode x = 273.5 from a 0–1000 range, set θ = πx/1000. Apply a Hadamard gate to an initial qubit, then a phase gate P(θ). Outcome 1 retains magnitude 1/√2 and receives phase θ; atan2 can recover x by converting θ/π back to the original scale. section 3.5.2
Phase can represent a periodic sequence across many amplitudes. A geometric sequence state assigns outcome k the phase kθ while keeping every amplitude at magnitude 1/√N. As k advances, the phases trace rotations around the unit circle; their repetition and total rotation describe the sequence frequency. section 7.1.2
Figure 7.8 Unit color wheel representation of the geometric sequence state for θ = π/3
The unit color wheel makes the phase progression for θ = π/3 visible as successive angular steps and repeated directions. section 7.1.2
A phase-encoded state may have equal measurement probabilities, so direct sampling cannot reveal its angle. A final Hadamard gate can convert a single-qubit phase difference θ into magnitudes cos(θ/2) and sin(θ/2), producing probabilities from which the encoded angle can be inferred. This is the simplest phase-to-magnitude pattern of the quantum Fourier transform. section 7.2
For multi-qubit states, store one complex amplitude per outcome in a list of length 2ⁿ. Build a table with each outcome, its phase from atan2, magnitude, and squared magnitude; the phase-and-probability columns can also reconstruct the complex amplitudes, up to rounding. section 4.2.2
