23  Complex numbers

What lives where the number line doesn’t go

You’ve been solving quadratic equations. Most of them have real solutions. But every now and then the discriminant — the bit under the square root — comes out negative.

Try \(x^2 + 1 = 0\). Rearrange: \(x^2 = -1\). Take the square root: \(x = \sqrt{-1}\).

That’s impossible on the number line. There is no real number whose square is negative. Positive times positive is positive. Negative times negative is also positive. Nothing multiplied by itself gives \(-1\).

So for a long time, equations like this were said to have “no solution.”

That answer was unsatisfying, and mathematicians knew it. The fix was the same fix that introduced negative numbers, fractions, and irrational numbers: give the new thing a name, and work out its arithmetic.

The name for \(\sqrt{-1}\) is \(i\).

Once you do that, something unexpected happens. The same number system that lets you give \(x^2 + 1 = 0\) an answer also turns out to describe oscillating voltages in electrical circuits, the quantum states of particles, and the algorithm that your phone uses to process audio. None of that was the motivation. It fell out of the arithmetic.

There’s also this: \(e^{i\pi} + 1 = 0\). Five of the most important numbers in mathematics — \(e\), \(i\), \(\pi\), \(1\), \(0\) — in one equation. We’ll see why by the end of this chapter.

23.1 What the notation is saying

23.1.1 The imaginary unit

Define \(i\) by one rule:

\[i^2 = -1\]

That’s the whole definition. \(i\) is the number whose square is \(-1\). It’s not a number on the real number line — it’s something new.

From this one rule, powers of \(i\) cycle in a pattern:

\[i^1 = i \qquad i^2 = -1 \qquad i^3 = -i \qquad i^4 = 1 \qquad i^5 = i \qquad \ldots\]

Every four powers, the cycle repeats. That’s a hint that \(i\) has something to do with rotation — four quarter-turns bring you back to where you started.

23.1.2 Complex numbers

A complex number is a number of the form:

\[z = a + bi\]

Read it as: “the real part \(a\), plus \(b\) times \(i\).” Here \(a\) and \(b\) are ordinary real numbers. \(a\) is called the real part of \(z\), written \(\operatorname{Re}(z)\). \(b\) is called the imaginary part, written \(\operatorname{Im}(z)\).

Examples: \(3 + 4i\), \(-2 + i\), \(5\) (which is \(5 + 0i\)), \(3i\) (which is \(0 + 3i\)).

Real numbers are a special case: they’re complex numbers where \(b = 0\).

23.1.3 The complex plane

Every complex number \(a + bi\) corresponds to a point in a plane. Put the real axis horizontal and the imaginary axis vertical. The number \(3 + 4i\) is the point three units right and four units up.

This is the Argand diagram, or the complex plane. The horizontal axis is the real line you already know. The vertical axis is entirely imaginary numbers. Every complex number lives at exactly one point in this plane.

23.2 The method

Complex numbers in 2D graphics

Complex numbers appear in physics and engineering, but their geometry is already useful in 2D graphics. Rotating a sprite on a screen by angle \(\theta\) is the same as multiplying its position (written as a complex number \(x + yi\)) by \(\cos\theta + i\sin\theta\). Game engines doing this in bulk use the same arithmetic you are about to practise.

23.2.1 Part 1: Arithmetic

Adding and subtracting complex numbers works the way you’d expect: add the real parts together, add the imaginary parts together.

\[(3 + 4i) + (1 - 2i) = (3 + 1) + (4 - 2)i = 4 + 2i\]

\[(3 + 4i) - (1 - 2i) = (3 - 1) + (4 - (-2))i = 2 + 6i\]

Multiplying uses FOIL (expand like brackets), then replace every \(i^2\) with \(-1\).

\[(3 + 4i)(1 - 2i) = 3 \cdot 1 + 3 \cdot (-2i) + 4i \cdot 1 + 4i \cdot (-2i)\]

\[= 3 - 6i + 4i - 8i^2\]

Now replace \(i^2 = -1\):

\[= 3 - 6i + 4i - 8(-1) = 3 - 6i + 4i + 8 = 11 - 2i\]

The key move: \(i^2\) always becomes \(-1\). That’s the entire rule for complex multiplication.

Dividing requires a trick. A complex denominator means the fraction can’t be split into real and imaginary parts yet — you need a real number on the bottom. Multiplying by the conjugate achieves this, because \((a + bi)(a - bi) = a^2 + b^2\), which is always real. The tool is the complex conjugate: if \(z = a + bi\), its conjugate is \(\bar{z} = a - bi\) — same real part, imaginary part negated.

Multiplying a complex number by its conjugate always gives a real number:

\[(a + bi)(a - bi) = a^2 - (bi)^2 = a^2 - b^2 i^2 = a^2 + b^2\]

To divide, multiply numerator and denominator by the conjugate of the denominator.

\[\frac{3 + 4i}{1 - 2i} \cdot \frac{1 + 2i}{1 + 2i} = \frac{(3 + 4i)(1 + 2i)}{(1 - 2i)(1 + 2i)}\]

Denominator: \((1)^2 + (2)^2 = 5\)

Numerator: \(3 + 6i + 4i + 8i^2 = 3 + 10i - 8 = -5 + 10i\)

Result: \(\dfrac{-5 + 10i}{5} = -1 + 2i\)

23.2.2 Part 2: Modulus and argument

The modulus of \(z = a + bi\), written \(|z|\), is its distance from the origin in the complex plane. By Pythagoras:

\[|z| = \sqrt{a^2 + b^2}\]

For \(z = 3 + 4i\): \(|z| = \sqrt{9 + 16} = \sqrt{25} = 5\).

The argument of \(z\), written \(\arg(z)\), is the angle the line from the origin to \(z\) makes with the positive real axis. Measured in radians (or degrees):

\[\arg(z) = \arctan\!\left(\frac{b}{a}\right)\]

Be careful with the quadrant. The \(\arctan\) function returns values in the range \((-\pi/2, \pi/2)\), so you need to check whether \(z\) is in the left half of the plane and adjust by \(\pm \pi\) if so.

For \(z = 3 + 4i\): \(\arg(z) = \arctan(4/3) \approx 0.927\) radians (\(\approx 53.1°\)).

Together, modulus and argument give two ways to describe the same point: Cartesian form \(a + bi\) and polar form \(r \angle \theta\).

23.2.3 Part 3: Polar form and Euler’s formula

On the unit circle (where \(r = 1\)), the real part of a complex number at angle \(\theta\) is \(\cos\theta\) and the imaginary part is \(\sin\theta\) — by the same definition of cosine and sine used in trigonometry. So any point at distance \(r\) from the origin at angle \(\theta\) is \(r\) times that unit-circle point.

A complex number with modulus \(r\) and argument \(\theta\) can be written as:

\[z = r(\cos\theta + i\sin\theta)\]

This is polar form. Read it as: go distance \(r\) from the origin, at angle \(\theta\) from the positive real axis.

Now for the extraordinary fact. Euler’s formula says:

\[e^{i\theta} = \cos\theta + i\sin\theta\]

This connects the exponential function — which you know from growth and decay — to the trigonometric functions. The proof belongs to calculus (it comes from comparing the Taylor series of \(e^x\), \(\cos x\), and \(\sin x\)), but you can use the result here.

With Euler’s formula, polar form becomes simply:

\[z = re^{i\theta}\]

This is often the cleanest way to write a complex number when you’re multiplying, dividing, or raising to a power.

The famous identity \(e^{i\pi} + 1 = 0\) is just the special case \(\theta = \pi\): \(e^{i\pi} = \cos\pi + i\sin\pi = -1 + 0i = -1\).

In particular, \(i = e^{i\pi/2}\) (since \(\cos(\pi/2) = 0\) and \(\sin(\pi/2) = 1\)). Because multiplication adds arguments, multiplying any complex number by \(i\) adds \(\pi/2\) to its angle — a 90° anticlockwise rotation in the plane.

23.2.4 Part 4: De Moivre’s theorem

Because \(z = re^{i\theta}\), raising \(z\) to the power \(n\) is clean:

\[z^n = (re^{i\theta})^n = r^n e^{in\theta} = r^n(\cos n\theta + i\sin n\theta)\]

This is de Moivre’s theorem. To find the \(n\)th power of a complex number: raise the modulus to the \(n\)th power, multiply the argument by \(n\).

Example: find \((1 + i)^4\).

First, convert to polar form. \(|1 + i| = \sqrt{2}\). For the argument: \(\arg(1 + i) = \arctan(1/1) = \arctan(1) = \pi/4\).

So \(1 + i = \sqrt{2}\,e^{i\pi/4}\).

Then:

\[(1 + i)^4 = (\sqrt{2})^4 \cdot e^{i \cdot 4 \cdot \pi/4} = 4 \cdot e^{i\pi} = 4 \cdot (-1) = -4\]

Check by direct multiplication: \((1+i)^2 = 1 + 2i - 1 = 2i\). Then \((2i)^2 = 4i^2 = -4\). Matches.

Why this works

Multiplying any complex number by \(i\) adds \(\pi/2\) to its angle — a 90° anticlockwise rotation in the complex plane. That’s why \(i^4 = 1\): four quarter-turns bring you back.

Complex multiplication in general is a rotation and scaling operation. When you multiply \(z_1 \cdot z_2\), the moduli multiply (scaling) and the arguments add (rotation). This is exactly why complex numbers are the natural language for anything involving oscillation, phase, and rotation — from AC circuits to quantum wavefunctions to signal processing. The arithmetic of complex numbers is the arithmetic of rotations.

23.3 Worked examples

23.3.1 Example 1 — Engineering: AC circuit impedance

An AC circuit has a resistor and a capacitor in series. The resistor has impedance \(Z_R = 50\,\Omega\) (purely real). The capacitor has impedance \(Z_C = -30i\,\Omega\) (purely imaginary, negative because capacitors shift the phase of current).

The total series impedance is:

\[Z = Z_R + Z_C = 50 + (-30i) = 50 - 30i\,\Omega\]

The magnitude of the impedance — how much the circuit resists current overall — is the modulus:

\[|Z| = \sqrt{50^2 + 30^2} = \sqrt{2500 + 900} = \sqrt{3400} \approx 58.3\,\Omega\]

The phase angle — how much voltage leads current — is the argument:

\[\arg(Z) = \arctan\!\left(\frac{-30}{50}\right) \approx -30.96°\]

The negative angle means the voltage lags behind the current by about 31°, which is the expected behaviour for a capacitive circuit.


23.3.2 Example 2 — Physics: Quantum wavefunction amplitude

In quantum mechanics, a particle in a particular state has a probability amplitude that is a complex number. The probability of measuring that state is the square of the modulus of the amplitude.

Suppose the amplitude is \(\psi = \frac{3}{5} + \frac{4}{5}i\).

The probability is:

\[|\psi|^2 = \left(\frac{3}{5}\right)^2 + \left(\frac{4}{5}\right)^2 = \frac{9}{25} + \frac{16}{25} = \frac{25}{25} = 1\]

A probability of 1 means the particle is certain to be found in this state. The amplitude is normalised — its modulus is 1. This is a constraint quantum mechanics imposes on all valid probability amplitudes: \(|\psi| = 1\).


23.3.3 Example 3 — Computing: FFT butterfly

The Fast Fourier Transform (FFT) is an algorithm that decomposes a signal into its frequency components. Its key step multiplies a complex number by a ‘twiddle factor’ \(W\) — which is just a complex number on the unit circle — to rotate it by a precise angle.

The FFT processes a signal by repeatedly multiplying values by twiddle factors of the form \(W = e^{-2\pi i k/N}\) for various integers \(k\) and \(N\).

For an 8-point FFT with \(k = 1\), \(N = 8\):

\[W = e^{-2\pi i / 8} = e^{-i\pi/4} = \cos\!\left(-\frac{\pi}{4}\right) + i\sin\!\left(-\frac{\pi}{4}\right) = \frac{1}{\sqrt{2}} - \frac{i}{\sqrt{2}}\]

One butterfly step multiplies a signal value \(X = 3 + 2i\) by this twiddle factor:

\[X \cdot W = (3 + 2i)\!\left(\frac{1}{\sqrt{2}} - \frac{i}{\sqrt{2}}\right)\]

\[= \frac{1}{\sqrt{2}}\bigl(3 + 2i\bigr)(1 - i) = \frac{1}{\sqrt{2}}(3 - 3i + 2i - 2i^2)\]

\[= \frac{1}{\sqrt{2}}(3 - i + 2) = \frac{1}{\sqrt{2}}(5 - i) = \frac{5}{\sqrt{2}} - \frac{i}{\sqrt{2}} \approx 3.54 - 0.71i\]

In polar terms: multiplication by \(W\) kept the modulus the same (since \(|W| = 1\)) and rotated the point by \(-45°\). The FFT is, at its core, a very efficient way to apply many such rotations simultaneously.

23.4 Where this goes

Polynomials (Vol 3 Ch 3) — every polynomial with real coefficients that has no real roots has complex roots. The quadratic formula \(x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}\) gives complex answers when \(b^2 - 4ac < 0\). You can now say exactly what those answers are and verify them by substituting back in. The discriminant is no longer a dead end.

Complex analysis (Vol 7) extends calculus to complex-valued functions. It turns out that calculus in the complex plane is extraordinarily powerful — more constrained than real calculus in ways that produce surprising results, including a method for evaluating real integrals that seem impossible by ordinary means. The Cauchy integral theorem, residues, and conformal mapping all live here. Euler’s formula is the entry point.

Differential calculus (Vol 5) — Euler’s formula \(e^{i\theta} = \cos\theta + i\sin\theta\) is proved by comparing the Taylor series expansions of each side. That proof belongs to calculus, but once you have it, it explains why \(e\), \(i\), \(\pi\), \(1\), and \(0\) are connected: they’re all special values of the same exponential function operating on the complex plane.

Where this shows up

  • An electrical engineer analysing an AC circuit writes impedance as a complex number, computes its modulus to find the magnitude, and its argument to find the phase shift. The letter \(j\) is used instead of \(i\) in electrical engineering (because \(i\) is already taken for current), but the mathematics is identical.

  • A physicist writing down the Schrödinger equation is working with a complex-valued wavefunction. The probability of measurement outcomes is the squared modulus of that function.

  • A software engineer implementing a digital audio filter uses the Discrete Fourier Transform — which is an algorithm entirely built on complex multiplication. The FFT makes this computation fast enough to run in real time.

  • A control engineer analysing whether a feedback system is stable places poles in the complex plane. Poles in the left half-plane mean the system is stable; poles in the right half-plane mean it oscillates out of control.

23.5 Exercises

These are puzzles. Each one has a clean answer. The interesting part is knowing which form of a complex number to use for which operation.

1. Compute \((2 + 3i)(4 - i)\).

2. Find the modulus and argument of \(z = -1 + \sqrt{3}\,i\).

3. Convert \(z = 4e^{i\pi/6}\) to Cartesian form \(a + bi\).

4. Compute \((-1 + i)^6\) using de Moivre’s theorem.

5. Divide \(\dfrac{2 + i}{3 - 4i}\).