Skip to content
Quantum ComputingAN INTERACTIVE OPEN TEXTBOOK
charithj.com.au

Essential mathematics — complex numbers

Two real numbers, one amplitude, and a useful way to describe phase.

16 min readDr. Charith Jayasekara↓ Chapter PDF
By the end, you’ll be able to
  • Add and multiply simple complex numbers.
  • Calculate squared magnitude and distinguish it from an amplitude.

The number ii satisfies i2=−1i^2=-1. A complex number z=a+biz=a+bi has a real part aa and an imaginary part bb. You can picture it as the point (a,b)(a,b) on a plane.

Addition works component by component:

(1+2i)+(3−i)=4+i.(1+2i)+(3-i)=4+i.

Multiplication uses ordinary expansion and i2=−1i^2=-1:

(1+i)(1−i)=1−i+i−i2=2.(1+i)(1-i)=1-i+i-i^2=2.

The conjugate of z=a+biz=a+bi is z∗=a−biz^*=a-bi. The squared magnitude is

∣z∣2=z∗z=a2+b2.|z|^2=z^*z=a^2+b^2.

If an amplitude is α=(1+i)/2\alpha=(1+i)/2, then ∣α∣2=(1/2)2+(1/2)2=1/2|\alpha|^2=(1/2)^2+(1/2)^2=1/2. It is the squared magnitude, not the real part and not the amplitude itself, that becomes a basis-measurement probability.

A unit-magnitude complex number can be written

eiϕ=cos⁡ϕ+isin⁡ϕ.e^{i\phi}=\cos\phi+i\sin\phi.

Multiplication by this number rotates an amplitude in the complex plane. For example, multiplying 11 by ii rotates by π/2\pi/2 radians, or 90 degrees. Its magnitude stays one.

In a quantum state, relative phase between amplitudes affects interference. Multiplying the whole state by the same unit phase does not change physical predictions.

For ∣ψ⟩=(3/2)∣0⟩+(i/2)∣1⟩\lvert\psi\rangle=(\sqrt3/2)\lvert0\rangle+(i/2)\lvert1\rangle, the probabilities are 3/43/4 and 1/41/4. They sum to one. Replacing i/2i/2 with −i/2-i/2 keeps those Z probabilities but changes the relative phase.

Try it: calculate ∣3+4i∣2|3+4i|^2, then divide 3+4i3+4i by 5. The results are 25 and a unit-magnitude complex number, respectively.

Why complex arithmetic appears in a quantum lesson

Section titled “Why complex arithmetic appears in a quantum lesson”
WORKED DIAGRAM · F03An amplitude in the complex plane
An amplitude in the complex planeThe point α = 0.5 + 0.5i has squared magnitude 0.5 and phase π/4. The circle has unit radius. The horizontal and vertical components are numbers, not separate measurement probabilities.ReImα0.50.5α = 0.5 + 0.5i|α|² = 0.25 + 0.25 = 0.5arg(α) = π/4 = 45°|α| = 1/√2
The point α = 0.5 + 0.5i has squared magnitude 0.5 and phase π/4. The circle has unit radius. The horizontal and vertical components are numbers, not separate measurement probabilities.

A real probability needs only a position on a number line between zero and one. An amplitude needs both a magnitude and a phase. The complex plane provides a compact way to carry those two pieces through additions and multiplications. When a gate combines paths, the directions of the amplitudes determine whether they reinforce or cancel. Taking magnitudes too early would erase precisely the information the calculation needs.

In the diagram, the amplitude has real and imaginary parts of one half. Its distance from the origin is the square root of one half, and its phase is 45 degrees. Its probability contribution is one half. These are three different quantities: the Cartesian components, the distance, and the squared distance. Keep their units and roles separate when checking numerical output.

Worked calculation: conjugation before squaring

Section titled “Worked calculation: conjugation before squaring”

For a complex amplitude, the probability uses multiplication by the conjugate. With an amplitude of one half plus one half times i, the conjugate changes the imaginary sign. Multiplying them gives a real result because the cross terms cancel:

(12+i2)(12−i2)=14+14=12.\left(\frac12+\frac i2\right)\left(\frac12-\frac i2\right) =\frac14+\frac14=\frac12.

Squaring the amplitude itself would instead give an imaginary result. That cannot be a probability. The distinction between an ordinary square and a squared magnitude is therefore essential, even when both operations happen to agree for real positive examples. A negative real amplitude is also a useful check: its squared magnitude is positive, while its sign must still be kept during later gate operations.

Consider a complete state with first amplitude one half plus one half times i and second amplitude one over the square root of two. Their squared magnitudes sum to one, so the state is normalised. Multiplying both amplitudes by the same unit complex number rotates the entire description without changing any measurement prediction. Multiplying only the second amplitude changes its phase relative to the first and can change an interference result.

Euler’s relation writes a unit complex number as a cosine plus i times a sine. Multiplying an amplitude by this number preserves its magnitude and adds to its phase. Multiplication by i is a quarter turn: a positive real amplitude becomes positive imaginary, a positive imaginary amplitude becomes negative real, and four such turns return the original value. This is the arithmetic behind the phase gate S.

To see why signs are phases, compare a positive real number with its negative. They have equal magnitudes, but their directions differ by half a turn. The minus sign in the minus state therefore carries a relative phase of pi radians. It is not a negative chance of seeing one. A phase of zero and a phase of two pi describe the same direction, which is why the explorer’s 0-degree and 360-degree settings agree.

Zero is a special case. Its magnitude is zero, so there is no direction to assign. A phase readout for a zero amplitude should say it is undefined. Small floating-point remnants near zero should not be interpreted as meaningful phase evidence. The statevector table applies a numerical tolerance so that a theoretically absent component does not acquire a misleading angle from rounding error.

The lab opens at polar angle 90 degrees and relative phase 45 degrees. The zero amplitude is positive real, while the one amplitude has equal positive real and imaginary parts. Calculate those parts before revealing the model. Their common value is one half; each basis probability is one half. The relative phase appears in the one amplitude, even though the two probabilities are equal.

After checking the initial preparation, apply S. Predict the new real and imaginary parts of the one amplitude by multiplying by i. Then reveal and compare. The histogram should stay fixed while the amplitude moves in the complex plane. Apply S three more times to complete a full turn. The final state should return to its initial amplitudes within rounding tolerance.

L01 · INTERACTIVE LABRuns on your device

Qubit explorer

Prepare a pure qubit, apply gates, then compare amplitudes, phases and Z-basis probabilities. Reset restores the initial preparation shown by the lesson’s controls.

Experiment controls

Predict the amplitudes and Z-basis probabilities for the preparation and gates you have chosen. If starting from |0⟩, what will H do?

Record a prediction to enable the results.

Results are hidden.

Prepare your experiment using the controls. Record a prediction, then reveal the statevector or run the experiment.

Changing the preparation or circuit starts a new prediction.

MODEL · Ideal pure-state vector, complex double precisionORDER · q0 is the leftmost bit
Take it further

Prepare θ = 120°, φ = 90°. Predict both complex amplitudes. Then change φ without changing θ.

Practice: cancellation needs the whole amplitude

Section titled “Practice: cancellation needs the whole amplitude”

Two contributions to the same output are one half plus one half times i and one half minus one half times i. Add them first, then calculate the squared magnitude. Compare that with adding their separate squared magnitudes. Explain why those operations answer different questions.

Check your reasoning

The sum is one, whose squared magnitude is one. Each separate contribution has squared magnitude one half, so their separate probabilities also sum to one in this particular example. That numerical agreement is accidental. If the second contribution were negative one half minus one half times i, the coherent sum would be zero while the separate squared magnitudes would still sum to one. Coherent alternatives combine as amplitudes; alternatives distinguished by a classical record require the appropriate probability description.

PAUSE & THINK

What is the squared magnitude of 0.5 + 0.5i?

Choose your answer

Reference: IBM Quantum — Quantum information.

ONE IDEA FURTHER

Ready for the next step?

Your progress stays in this browser.