Complex numbers
Real numbers are not enough for quantum computing: the amplitudes of a qubit are complex numbers. The good news is that the central idea fits in one picture: a complex number is a point in a plane, and multiplying by a number "of size 1" rotates that plane.
The number and the form
No real number squared gives . So we invent one: , defined by
A complex number is any with and real. We call the real part () and the imaginary part (). Example: in , and (the imaginary part is the number , without the ).
Adding means adding like parts: . Multiplying means distributing, remembering that :
What is the real part of ?
Mini-challenge
The complex plane, modulus and conjugate
Draw as the point : on the horizontal axis, on the vertical one. This is the complex plane. The number is the point .
The modulus is the distance from the point to the origin, given by the Pythagorean theorem:
For : .
The conjugate flips the sign of the imaginary part: . In the plane, it is the mirror image of the point across the horizontal axis. A very useful fact:
That is why, in quantum physics, the probability of an amplitude is .
What is the modulus of ?
Mini-challenge
What is the conjugate of ?
Mini-challenge
Polar form
A point can also be described by distance and direction: the modulus and the angle that the segment makes with the horizontal axis. By trigonometry, and , so
Example: has and , because . Angles can also be measured in radians: rad, so and .
What is the angle, in degrees, of (between and )? Draw the point: it is in the second quadrant.
Mini-challenge
Euler's formula
There is a shorter notation for :
Accept it as a definition for now (it comes from the power series of , which we do not need here). A few values:
With this, every complex number is written . And something crucial holds: always has modulus 1, since
That is, lives on the unit circle, the circle of radius 1. Quantum phases are exactly numbers of this kind.
Write in the form : what is in radians (between 0 and )? Use and answer with a decimal.
Mini-challenge
Multiplying is rotating
Multiply by . The moduli multiply and the angles add:
If has modulus 1, the product keeps the size of and only rotates the point by . Test: multiplying by rotates by ; .
How much is ?
Mini-challenge
What is the modulus of , for any real ?
Mini-challenge
In Python
Write a function that receives a complex number and returns np.array([modulus, angle]), with the angle in radians between and . Hint: np.abs(z) and np.angle(z).
Mini-challenge · Python
Input
zcomplexformat: a nonzero complex number
example:
3 + 4j
Output
polarnp.ndarrayformat: [modulus, angle in radians], floats, shape (2,)
example:
np.array([1.4142135623730951, 0.7853981633974483])
Tests
Test 1 Example Not run yet
Call:
polar(1 + 1j)Expected output:
np.array([1.4142135623730951, 0.7853981633974483])Test 2 Hidden Not run yet
Test 3 Hidden Not run yet
To go further: B. Valiron, Introduction to Quantum Algorithms and Quantum Programming (2025), section 2.3; T. G. Wong, Introduction to Classical and Quantum Computing (2022), section 3.3.3.
Solve this mini-lesson's mini-challenge to continue.