Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Numbers as turns
Stand facing forward. Turn around (180°) and you face backwards. Turn around again and you face forward. Two half-turns make a full turn.
Now think of the number line. Multiplying by is like turning around: 3 becomes −3, pointing the other way. Doing it twice brings you back, because .
Here’s a puzzle: is there a number that’s half of a turn-around? A quarter-turn, so that doing it twice gives ? On the number line, no: any number times itself is positive. But if we allow ourselves to step off the line and turn sideways, yes! That sideways quarter-turn is called , the imaginary unit.
Numbers on a map
With , numbers live on a flat map instead of a line. “3 steps east and 2 steps north” is the number . Every point on the map is a number, called a complex number.
A robot on the floor has a position (a point on the map) and a heading (which way it’s facing). Complex numbers handle both. Turning the robot is just multiplying by a complex number.
- 1. You face north and make two quarter-turns to the right. Which way do you face?
- 2. How many quarter-turns bring you back to facing the same way?
- 3. What does i × i equal?
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.The rules
| Operation | Rule | Example |
|---|---|---|
| Add | add real and imaginary parts | |
| Multiply | expand and use | |
| Conjugate | flip the sign of the imaginary part | |
| Modulus (length) | ||
| Divide | multiply top and bottom by the conjugate |
Powers of cycle with period 4: .
A useful identity: , which is always a non-negative real number.
The complex plane
Plot at the point . The horizontal axis is real, and the vertical axis is imaginary. Adding complex numbers is like adding arrows tip to tail, just like vectors.
Solving the “impossible” equations
has no real solution, but it has two complex ones: . The quadratic formula always works if we allow complex answers. For : .
- 1. (1 + i)(1 − i) = ?
- 2. |−5 + 12i| = ?
- 3. i⁷ = ?
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.Polar form
Every complex number is an arrow with a length and an angle , measured from the positive real axis:
Don’t compute the angle with . It can’t tell from . Use atan2(b, a), which looks at both signs.
Euler’s formula
So the polar form is simply . Setting gives the famous .
Multiplication = rotate and scale
Lengths multiply, and angles add. Multiplying by (length 1) is a pure rotation by .
De Moivre’s formula: . For example, .
Roots of unity
The solutions of are points equally spaced around the unit circle:
They’re the building blocks of the Fourier transform (Level 4).
Rotations in 2D robotics
A robot at position (a complex number) with heading that drives forward a distance ends up at . Turning by multiplies its heading by . Complex numbers are the cleanest way to write 2D poses.
Rotary position embeddings (RoPE), used in most modern LLMs, treat pairs of features as complex numbers and rotate them by an angle proportional to the token’s position. Because rotations compose by adding angles, the attention score between two tokens depends only on how far apart they are (Su et al., 2021). You’ll build this in Practice Code 5.
- 1. What is e^{iπ/2}?
- 2. z has length 2 and angle 30°; w has length 3 and angle 60°. What is zw?
- 3. How many solutions does z⁵ = 1 have in the complex numbers?
Level 3: Advanced
★★★★☆ Advanced⏱ 45 minGraduate level, with full derivations and proofs.Proving Euler’s formula
For all real : .
Proof via power series. Use (A1-4) with , and the cycle . Split even and odd terms:
The two brackets are the Taylor series of cosine and sine (A3). ∎ Both series converge for every , so the rearrangement is justified.
Proof via a differential equation. Let . Differentiating, . So is constant, and . ∎
Consequences
- De Moivre, by induction or directly: .
- Trig identities for free. Compare real and imaginary parts of to get and the matching sine formula.
- and .
For , the -th roots of unity sum to zero: with .
Proof. It’s a geometric series (A1-3) with ratio : . ∎
, , , and .
Proof of the first. . ∎ The triangle inequality is proved in A1-6.
If a polynomial has real coefficients and is a root, then is also a root.
Proof. If with real , take conjugates: . ∎
Every non-constant polynomial with complex coefficients has a complex root. Hence a degree- polynomial has exactly roots, counted with multiplicity.
(First essentially proved by Gauss in 1799. A full proof needs analysis or topology and is beyond this page.) It’s why every square matrix has complex eigenvalues (A2.3).
Exercise 3.1: Use Euler’s formula to derive sin(2θ) = 2 sin θ cos θ
. Its imaginary part must equal . ∎
Exercise 3.2: Show that multiplying by e^(iθ) is the same as multiplying (x, y) by the rotation matrix
, which is . ∎
- 1. A real polynomial has root 2 − 3i. Which must also be a root?
- 2. How many complex roots (with multiplicity) does z⁷ − 3z + 1 have?
- 3. cos θ written with exponentials is…
Level 4: Expert
★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.The Fourier transform: signals as sums of rotating arrows
The discrete Fourier transform (DFT) writes any list of numbers as a sum of rotating complex exponentials:
Each measures how much of frequency is in the signal. Computing it directly costs . The fast Fourier transform (Cooley and Tukey, 1965) uses the symmetry of the roots of unity to do it in , one of the most important algorithms ever written. It powers vibration analysis of spacecraft and robot joints, radar and sonar, image compression, and fast convolutions in CNNs (A10).
Stability lives in the complex plane
The behaviour of a linear system , such as a robot joint under feedback control, is set by the eigenvalues of , which are usually complex. An eigenvalue produces a motion like . That’s an oscillation at frequency whose amplitude grows if and decays if . A linear system is stable exactly when every eigenvalue (pole) has a negative real part. Control engineers design by moving poles in the complex plane (S1, S2).
Beyond complex numbers: quaternions
Hamilton (1843) looked for a 3D version of complex numbers and found quaternions with . Multiplication is no longer commutative. Unit quaternions represent 3D rotations without the gimbal lock of Euler angles, and they’re the standard for spacecraft attitude, drones, VR headsets and robot arms (R2). Beware: two conventions (Hamilton vs JPL) multiply in opposite orders. Sommer et al. (2018) explain the confusion this causes.
Complex numbers in modern ML
- RoPE (Su et al., 2021): rotating query and key features by position-dependent angles makes attention depend on relative position. Its frequencies and extensions for long context are an active research area (F4).
- Fourier features (Tancik et al., 2020): mapping inputs through and lets MLPs learn high-frequency detail, which is key to NeRF (G4).
- Fourier Neural Operators (J4) learn PDE solutions by multiplying Fourier coefficients.
- Complex-valued networks are used for radar (SAR) and MRI data, which are naturally complex.
References
- G. Cardano (1545). Ars Magna. (First use of square roots of negative numbers to solve cubics.)
- L. Euler (1748). Introductio in analysin infinitorum. (Euler’s formula.)
- C. F. Gauss (1799). Doctoral dissertation, Helmstedt. (Early proof of the fundamental theorem of algebra.)
- W. R. Hamilton (1844). “On quaternions; or on a new system of imaginaries in algebra.” Philosophical Magazine, 25.
- J. Cooley and J. Tukey (1965). “An algorithm for the machine calculation of complex Fourier series.” Mathematics of Computation, 19(90).
- T. Needham (1997). Visual Complex Analysis. Oxford University Press.
- H. Sommer, I. Gilitschenski, M. Bloesch, S. Weiss, R. Siegwart, J. Nieto (2018). “Why and how to avoid the flipped quaternion multiplication.” Aerospace, 5(3).
- M. Tancik et al. (2020). “Fourier features let networks learn high frequency functions in low dimensional domains.” NeurIPS.
- J. Su, Y. Lu, S. Pan, A. Murtadha, B. Wen, Y. Liu (2021). “RoFormer: Enhanced Transformer with rotary position embedding.” arXiv:2104.09864 (published in Neurocomputing, 2024).