Skip to content

Complex numbers are the gateway to quantum

Multiplying by i is a quarter turn, Euler's formula is the unit circle, and suddenly the imaginary number is the thing you measure.

A complex plane with a unit circle and axes labeled one, minus one, i, and minus i.
Multiplying by i is a quarter turn. Phase is just an angle on this circle.

The last time I used a complex number before this year, I was in high school, and I was fairly sure I would never see one again. They had that flavour of school math that feels invented to fill a textbook. A made up number whose entire job was to be the square root of something that has no square root. Fine. Noted. Never used it once in years of building real software.

Then I started quantum, and complex numbers turned out to be the native language. Not a footnote. The actual thing the amplitudes are made of. You cannot read a quantum state without them. So I went back, expecting a slog, and found that the slice you actually need is small and, once you see it the right way, genuinely beautiful. Here is that slice.

What a complex number actually is

Strip away the school baggage and the definition is one line. A complex number is a + bi, where a and b are ordinary numbers and i is a special symbol defined by a single rule: i² = −1. That is the whole of it. i is just the name we give to a thing that squares to minus one, which no ordinary number does.

The useful picture is not algebra, it is geometry. Ordinary numbers live on a line, left to right. Complex numbers add a second axis going up and down, the imaginary direction, and that turns the line into a plane. So a complex number is a point on a plane. The a tells you how far right, the b how far up. 3 + 4i is the point three across and four up. That is it. A complex number is a location, and once you hold that picture, everything else falls into place.

It helps to know these were not invented to torment students. Mathematicians ran into them centuries ago while solving ordinary equations, the kind with real answers, where the only way to reach the real solution led through the square root of a negative number along the way. The imaginary part was a bridge you had to cross to get to a perfectly real destination. The name imaginary is a historical insult that stuck, from a time when they were distrusted as not quite real. They are as real as any other number, they just live on a plane instead of a line, and the plane is exactly what makes them able to describe rotation, which is the only reason we care here.

The one idea that unlocks it: multiplying by i is a quarter turn

This is the thing nobody told me in school, and it is the thing that makes complex numbers click for quantum. Multiplying by i rotates a number ninety degrees, counterclockwise, around the origin. Watch it go.

Start at 1, sitting on the right. Multiply by i and you get i, which sits straight up. Multiply by i again and you get i², which is −1, sitting on the left. Again, and you are at −i, straight down. One more, and you are back at 1. Four multiplications by i, four quarter turns, one full circle.

for k in range(4):
    print(1j**k)     # (1+0j), 1j, (-1+0j), (-0-1j)

Run it. Right, up, left, down. The last line prints a minus zero on the real part, which is a floating point artefact of raising to a power rather than a fourth direction. Multiplying by i is a rotation, full stop. This is why complex numbers and quantum fit together so naturally. Quantum is full of rotations of a state, and complex numbers are the most natural language of rotation there is. The moment I saw i as a quarter turn instead of a mysterious symbol, half the strangeness drained out of the whole subject.

Doing the arithmetic, and what it means geometrically

Adding and multiplying complex numbers is mechanical, but each operation has a picture, and the pictures are the part worth keeping. Adding is the easy one: you add the real parts and the imaginary parts separately, which geometrically just slides one point by the other, the same way you add arrows. (2 + 3i) + (1 + i) is 3 + 4i. Nothing surprising.

Multiplying is where it gets interesting. You expand it like any pair of brackets, remembering that i² is −1:

print((2 + 3j) * (1 + 1j))   # (-1+5j)

Run it. You get −1 + 5i. But the mechanical answer hides the beautiful part. Multiplying two complex numbers rotates and scales. The angles add, and the lengths multiply. Multiplying by i, which sits at ninety degrees with length one, adds ninety degrees and leaves the length alone, which is exactly the quarter turn from before. That was just the special case. In general, every complex multiplication is a turn by one number's angle and a stretch by its length. Hold onto that, because it is the single idea that makes the next form click.

Length and angle: the polar form

If multiplication is really about angles and lengths, then the natural way to write a complex number is not right and up, but length and angle. This is the polar form: every complex number is r times e^(iθ), where r is the length and θ is the angle. Do not worry about the e yet. For now read e^(iθ) as a label that means turned by the angle θ, and I will show you in two sections what that label actually equals. The point 3 + 3i, for instance, sits at forty five degrees with a length of about 4.24.

import cmath, numpy as np
r, theta = abs(3 + 3j), cmath.phase(3 + 3j)
print(round(r, 3), round(np.degrees(theta), 1))   # 4.243  45.0

Run it. Length 4.24, angle 45 degrees, the same point seen in terms of how far and which way instead of across and up. And in this form, the rule for multiplication becomes almost trivial: to multiply, add the angles and multiply the lengths. Two points each at e^(iπ/4) multiply to one at e^(iπ/2), because the angles simply add.

print(np.round(np.exp(1j*np.pi/4) * np.exp(1j*np.pi/4), 10))   # 1j  =  e^{i pi/2}

Run it. Two eighth turns make a quarter turn, by addition of angles, just as you would hope. This is the form quantum lives in, because an amplitude is most naturally described by a length, which becomes a probability, and an angle, which is the phase. Polar form is not extra theory. It is the form the physics actually wants.

The modulus is the length, and the length becomes probability

If a complex number is a point on a plane, it has a distance from the origin, and that distance has a name: the modulus, written |z|. You get it the way you get any distance, with the Pythagorean theorem. For z = a + bi, the modulus is the square root of a² + b².

print(abs(3 + 4j))   # 5.0

Run it. The point 3 + 4i is exactly five units from the origin, a three four five triangle hiding in the plane. Now here is why you care. In quantum, the amplitudes are complex numbers, and the probability of an outcome is the modulus of its amplitude, squared. That is the Born rule again, the one I worked out by hand in the post on why measurement is not magic. So the modulus is the bridge. It is the operation that takes a complex amplitude, which you cannot measure directly, and turns it into a real probability, which you can. Every histogram you read is moduli, squared.

Euler's formula: the unit circle in one line

Now I can pay off the e I asked you to take on trust. The polar form gave you length and angle, and it is the form quantum actually uses most, but it left e^(iθ) sitting there as a label with no meaning attached. Euler's formula is what that label equals:

e^(iθ) = cos θ + i sin θ

Do not let the e scare you. The useful reading is pure geometry. e^(iθ) means stand on the unit circle and turn by the angle θ. At θ = 0 you are at 1, on the right. At θ = π/2, a quarter turn, you are at i, straight up. At θ = π, a half turn, you are at −1.

import numpy as np
print(np.round(np.exp(1j*np.pi),   10))   # -1, a half turn
print(np.round(np.exp(1j*np.pi/2), 10))   #  i, a quarter turn

Run it. A half turn lands you at minus one, a quarter turn at i, exactly matching the rotation picture from before. This is the famous identity people put on t shirts, e to the i pi equals minus one, but the t shirt hides the point. The point is that e^(iθ) is just a clean way to name a direction on the circle. And that angle θ has a name you will hear constantly. It is the phase.

Why this is suddenly the thing you measure

Here is where it all pays off, and why real numbers simply will not do for quantum.

A complex amplitude carries two pieces of information at once. Its modulus, the length, which becomes the probability when you square it. And its angle, the phase, which is the direction it points on the circle. One number, two facts.

When you measure, you only see the first one. The probability comes from the modulus, and the phase is invisible to a single measurement. So you might think the phase does not matter. It matters enormously. The phase is what the next gate sees. Two amplitudes with the same length but different phases will behave completely differently when they meet, reinforcing or cancelling, and that cancellation is interference, which is the real reason a qubit is not a coin under a cup. I will give phase its own post, because the difference between phase that matters and phase that does not is one of the real hinges of the subject. For now, the takeaway is this. The phase is real, it is carried by the angle of a complex number, and no real number could hold it. That is why quantum is built on complex numbers and not the ones I learned to count with. They are the only objects that carry magnitude and phase together.

Make it concrete with a real amplitude. Suppose one outcome has amplitude e^(iπ/4) divided by √2. In polar form that is length 1/√2 at an angle of π/4. The probability is the length squared:

import numpy as np
amp = np.exp(1j*np.pi/4) / np.sqrt(2)
print(round(abs(amp)**2, 6))   # 0.5

Run it. The probability is one half, set entirely by the length, while the angle π/4 sits there as the phase, doing nothing to the odds but waiting to matter the instant another gate acts. Two outcomes could both report a probability of one half and yet be completely different states, because their phases differ. The histogram cannot tell them apart. The next gate can. That gap between what the probability shows and what the amplitude actually holds is the whole reason the phase is worth caring about.

The conjugate, briefly

One small operation rounds out the slice. The conjugate of a + bi is a − bi. You just flip the sign of the imaginary part, which geometrically is a mirror flip across the horizontal axis.

print((2 + 3j).conjugate())   # (2-3j)

Run it. Two reasons it shows up. First, the modulus squared is a number times its own conjugate, which is the tidy way the probability actually gets computed. Second, the inner product from the measurement post conjugates the first state, the bra, and now you know exactly what that conjugation is doing. It is this mirror flip, nothing more.

Where this lands: a qubit is two complex numbers

Now connect the whole slice back to the thing we are actually here for. A qubit's state is written α|0⟩ + β|1⟩, and α and β, the amplitudes, are complex numbers. That is it. A qubit is, mathematically, a pair of complex numbers, tied together by the rule that their squared lengths add to one. Everything in this post was really about understanding those two numbers.

Each amplitude carries a length and an angle, as we have seen. The lengths, squared, are the probabilities of measuring 0 or 1. The angles are the phases. And here is the subtle part that the complex view makes obvious. What matters physically is not the two angles on their own, but the difference between them, the relative phase. If you turned both amplitudes by the same angle, every probability would stay identical and so would every future measurement, so that shared turn, the global phase, is invisible and physically meaningless. But a difference in phase between the two amplitudes is very real, and it is exactly what gates exploit to make interference happen. I keep promising a whole post on this, and now you can see why it earns one. The difference between a phase that is global and therefore invisible, and a phase that is relative and therefore everything, is a distinction you can only even state once you see a qubit as two complex numbers with two angles. The complex numbers are not decoration on top of the physics. They are the structure that makes the physics expressible at all.

The slice you need, and what to skip

So here is the honest boundary, the same way I drew it for the Python you actually need for quantum and for the rest of the math.

You need four things. The picture of a complex number as a point on a plane. Multiplication by i as a quarter turn. The modulus, because squared it is your probability. And Euler's form e^(iθ), because the angle is the phase. The conjugate is a small bonus that makes the other two cleaner. That is the entire complex number toolkit for getting started in quantum.

What you can skip, possibly forever, is everything that made complex analysis a hard university course. Contour integrals. Residues. Analytic functions. The deep theory is gorgeous and you will not touch it to read a quantum state. As I keep saying, the integrals can wait. The slice is small on purpose, and the small slice is the part that is actually beautiful anyway.

A quick test before you move on

Close this and answer in your own words.

What does multiplying by i do to a number, geometrically? If your answer is not turns it ninety degrees, go back to the rotation section, because that one idea carries the most weight.

If an amplitude is 1/√2 times e^(iθ), which part becomes the probability and which part is the phase? If you cannot split the magnitude from the angle, that is the gap.

And why can a real number not do an amplitude's job? If the words magnitude and phase together are not in your answer, reread the section on why you measure this.

Where I am learning it

Free and, for this topic especially, worth it for the visuals. 3Blue1Brown has the clearest videos I have found on what a complex number is and on Euler's formula, and seeing i rotate a point in an animation did more than any page of algebra ever did for me. Khan Academy covers the mechanics if you want to drill the arithmetic until it is automatic. And as always, I keep a NumPy file where I check every one of these by hand, because a rotation I have only watched is not a rotation I trust until I have made the number move myself.

The detour that was the destination

I spent years thinking complex numbers were a piece of school math I had safely left behind. A clever trick with no use outside an exam. It turns out they were not a detour at all. They are the language the whole subject is written in, the only numbers that can hold a magnitude and a direction at the same time, which is exactly what a quantum amplitude is.

The square root of minus one stopped being a riddle the moment I saw it as a quarter turn. And the thing I was sure I would never use again turned out to be the gateway. Funny how often that is how it goes.