Skip to content
The Lumenary
Grades 9–12Ages 15–18 75 min

Complex numbers

What if x2=−1x^2 = -1 had a solution? One new number turns the plane into a number system in which multiplying means rotating — and in which every polynomial equation can be solved.

Formally verified · 20 LeanComputationally tested · 2 PythonAI-drafted · awaiting human reviewMathematically reviewed: Awaiting human review

Your guides: Chloe, Margaret, Gideon

MotivationH

A square root that would not go away

In 1545 Gerolamo Cardano published a formula for solving cubic equations. For an equation x3=px+qx^3 = px + q it reads

x=q2+q24−p3273+q2−q24−p3273.x = \sqrt[3]{\frac q2 + \sqrt{\frac{q^2}{4} - \frac{p^3}{27}}} + \sqrt[3]{\frac q2 - \sqrt{\frac{q^2}{4} - \frac{p^3}{27}}}.

Rafael Bombelli tried it on x3=15x+4x^3 = 15x + 4, which obviously has the solution x=4x = 4 (since 64=60+464 = 60 + 4). The formula gives

x=2+−1213+2−−1213.x = \sqrt[3]{2 + \sqrt{-121}} + \sqrt[3]{2 - \sqrt{-121}}.

A square root of a negative number! Bombelli did not give up. In his Algebra (1572) he calculated boldly with a "number" −1\sqrt{-1} obeying the usual rules plus (−1)2=−1\big(\sqrt{-1}\big)^2 = -1, and noticed that (2+−1)3=2+11−1=2+−121\big(2 + \sqrt{-1}\big)^3 = 2 + 11\sqrt{-1} = 2 + \sqrt{-121}. So the two cube roots are 2+−12 + \sqrt{-1} and 2−−12 - \sqrt{-1}, and their sum is 44. The "impossible" numbers were needed to reach a perfectly real answer.

Today these numbers are indispensable: electrical engineers use them for alternating currents, physicists write quantum mechanics with them, and the images of the Mandelbrot set are pictures of complex arithmetic. In this lesson we build them carefully, see what they look like, and prove their main properties.

IntuitionH

Numbers you can turn

Think of multiplication by −1-1 as a motion of the number line: it swaps 33 and −3-3, 11 and −1-1 — it is a half turn about 00. Doing it twice is a full turn: (−1)(−1)=1(-1)(-1) = 1.

Now ask for a number ii with i2=−1i^2 = -1: "multiplying by ii twice is a half turn". On the line that is impossible. But in the plane there is an obvious candidate: a quarter turn about 00. Two quarter turns make a half turn. So we let numbers live in a plane: the real numbers along the horizontal axis, and ii one unit up. Then 1→×ii→×i−1→×i−i→×i11 \xrightarrow{\times i} i \xrightarrow{\times i} -1 \xrightarrow{\times i} -i \xrightarrow{\times i} 1 walks around a square.

DefinitionsH

Definitions

Definition— complex number

A complex number is an expression z=a+biz = a + bi with a,b∈Ra, b \in \R. The number a=Re⁡za = \operatorname{Re} z is its real part and b=Im⁡zb = \operatorname{Im} z its imaginary part; two complex numbers are equal when their real parts are equal and their imaginary parts are equal. The set of complex numbers is C\C. We identify the real number aa with a+0ia + 0i, so R⊆C\R \subseteq \C.

Arithmetic follows the usual rules of algebra together with i2=−1i^2 = -1:

(a+bi)+(c+di)=(a+c)+(b+d)i,(a+bi)(c+di)=(ac−bd)+(ad+bc)i.(a + bi) + (c + di) = (a + c) + (b + d)i, \qquad (a + bi)(c + di) = (ac - bd) + (ad + bc)i.

(Expand the product and replace bd i2bd\,i^2 by −bd-bd.) Formally one can define C\C as the set of pairs (a,b)(a, b) of reals with these two operations and check every law of arithmetic — commutativity, associativity, distributivity — directly. That is how Hamilton defined complex numbers in 1837, and how Mathlib defines them.

Definition— complex plane

The complex number a+bia + bi is drawn as the point (a,b)(a, b) — or the arrow from 00 to it — in the complex plane (also called an Argand diagram). The horizontal axis is the real axis, the vertical axis the imaginary axis.

Definition— conjugate, modulus and argument

For z=a+biz = a + bi:

  • the conjugate is zˉ=a−bi\bar z = a - bi, the mirror image of zz in the real axis;
  • the modulus is ∣z∣=a2+b2|z| = \sqrt{a^2 + b^2}, the distance from 00 to zz (Pythagoras);
  • for z≠0z \ne 0, an argument arg⁡z\arg z is an angle θ\theta from the positive real axis to the arrow 0z0z, measured anticlockwise in radians. It is defined only up to adding multiples of 2π2\pi; the principal argument is the one in (−π,π](-\pi, \pi]. The number 00 has no argument.

Definition— polar form

If ∣z∣=r|z| = r and θ\theta is an argument of zz, then a=rcos⁡θa = r\cos\theta and b=rsin⁡θb = r\sin\theta, so

z=r(cos⁡θ+isin⁡θ)=rcis⁡θ,where cis⁡θ=cos⁡θ+isin⁡θ.z = r(\cos\theta + i \sin\theta) = r \operatorname{cis}\theta, \qquad \text{where } \operatorname{cis}\theta = \cos\theta + i\sin\theta.

This is the polar form of zz. The number cis⁡θ\operatorname{cis}\theta is the point at angle θ\theta on the unit circle ∣z∣=1|z| = 1.

You need the trigonometry of the unit circle and the addition formulas from Trigonometry, and the quadratic formula from Quadratic equations.

Worked examplesH

Worked examples

Example— Arithmetic

  • (3+2i)+(1−4i)=4−2i(3 + 2i) + (1 - 4i) = 4 - 2i.
  • (3+2i)(1−4i)=3−12i+2i−8i2=3−10i+8=11−10i(3 + 2i)(1 - 4i) = 3 - 12i + 2i - 8i^2 = 3 - 10i + 8 = 11 - 10i.
  • Powers of ii repeat with period 44: i1=ii^1 = i, i2=−1i^2 = -1, i3=−ii^3 = -i, i4=1i^4 = 1, i5=i,…i^5 = i, \dots So i2026=i4⋅506+2=i2=−1i^{2026} = i^{4 \cdot 506 + 2} = i^2 = -1.

Example— Division with the conjugate

To divide, multiply the top and bottom by the conjugate of the bottom, which makes the bottom real:

3+4i1+2i=(3+4i)(1−2i)(1+2i)(1−2i)=3−6i+4i−8i21−4i2=11−2i5=115−25i.\frac{3 + 4i}{1 + 2i} = \frac{(3 + 4i)(1 - 2i)}{(1 + 2i)(1 - 2i)} = \frac{3 - 6i + 4i - 8i^2}{1 - 4i^2} = \frac{11 - 2i}{5} = \frac{11}{5} - \frac25 i.

In general zzˉ=(a+bi)(a−bi)=a2+b2=∣z∣2z \bar z = (a + bi)(a - bi) = a^2 + b^2 = |z|^2, so 1z=zˉ∣z∣2\dfrac1z = \dfrac{\bar z}{|z|^2} for every z≠0z \ne 0. Every non-zero complex number has an inverse: C\C is a field.

Example— Polar forms

  • 1+i1 + i: modulus 1+1=2\sqrt{1 + 1} = \sqrt 2, argument π4\tfrac\pi4, so 1+i=2cis⁡π41 + i = \sqrt 2 \operatorname{cis}\tfrac\pi4.
  • −1=cis⁡π-1 = \operatorname{cis}\pi, and i=cis⁡π2i = \operatorname{cis}\tfrac\pi2.
  • −3+i-\sqrt 3 + i: modulus 3+1=2\sqrt{3 + 1} = 2; the point is in the second quadrant with cos⁡θ=−32\cos\theta = -\tfrac{\sqrt3}2, sin⁡θ=12\sin\theta = \tfrac12, so θ=5π6\theta = \tfrac{5\pi}{6} and −3+i=2cis⁡5π6-\sqrt 3 + i = 2\operatorname{cis}\tfrac{5\pi}6.
  • Careful: tan⁡θ=ba\tan\theta = \tfrac ba alone does not determine θ\theta. For −1−i-1 - i, ba=1\tfrac ba = 1, but the point is in the third quadrant: its principal argument is −3π4-\tfrac{3\pi}{4}, not π4\tfrac\pi4.
Explore

Explore: arithmetic as geometry

Drag zz and ww. Addition is the parallelogram rule — complex numbers add like arrows (vectors). Then switch to the product: watch the lengths multiply and the angles add.

Multiplying complex numbers

Compare |zw| with |z||w|, and arg(zw) with arg z + arg w. Then try the quotient and the conjugate.

18.4°63.4°81.9°zwzw

Drag the points, or focus one with Tab and use the arrow keys (hold Shift for small steps).

z =+i
w =+i
NumberModulusArgument
z1.5 + 0.5i1.58118.4°0.322 rad
w0.5 + i1.11863.4°1.107 rad
zw0.25 + 1.75i1.76881.9°1.429 rad

Lengths multiply: 1.581 × 1.118 = 1.768

Angles add: 18.4° + 63.4° = 81.9°

Multiplying by w stretches by |w| and turns by arg w: lengths multiply and angles add.

Multiplication by a fixed number w=a+biw = a + bi moves the whole plane: it rotates by arg⁡w\arg w and scales by ∣w∣|w|. As a map of the plane (x,y)↦(ax−by, bx+ay)(x, y) \mapsto (ax - by,\, bx + ay) it is the matrix (a−bba)\begin{pmatrix} a & -b \\ b & a \end{pmatrix}. Here is multiplication by 1+i1 + i: a rotation by 45∘45^\circ and a stretch by 2\sqrt 2.

Multiplication by 1 + i

The determinant is a² + b² = |w|². Which matrices of the form [[a, −b], [b, a]] are pure rotations?

Your own matrix
Ae₁Ae₂
  • image of the grid
  • image of the unit square
  • image of the flag
  • before the transformation
Entries of the matrix A
A =

The columns of A are the images of e₁ = (1, 0) and e₂ = (0, 1): Ae₁ = (1, 1), Ae₂ = (−1, 1)

det A = ad − bc = 2

The unit square (area 1) becomes a parallelogram of area |det A| = 2. Since det A > 0, orientation is preserved.

Invariant lines (real eigenvectors)

λ = 1 ± 1i

No real eigenvectors: A turns every direction, so no line through 0 stays put. The eigenvalues are complex.

ProofH

Theorems and proofs

Theorem— Theorem 1 (moduli multiply)

For all complex numbers z,wz, w:   ∣zw∣=∣z∣ ∣w∣\;|zw| = |z|\,|w|.

Proof

Write z=a+biz = a + bi, w=c+diw = c + di, so zw=(ac−bd)+(ad+bc)izw = (ac - bd) + (ad + bc)i. Expanding both sides shows the two-squares identity

(a2+b2)(c2+d2)=(ac−bd)2+(ad+bc)2,(a^2 + b^2)(c^2 + d^2) = (ac - bd)^2 + (ad + bc)^2,

since both sides equal a2c2+a2d2+b2c2+b2d2a^2c^2 + a^2d^2 + b^2c^2 + b^2d^2 (the cross terms ∓2abcd\mp 2abcd cancel on the right). That says ∣z∣2∣w∣2=∣zw∣2|z|^2 |w|^2 = |zw|^2. Taking non-negative square roots gives ∣zw∣=∣z∣ ∣w∣|zw| = |z|\,|w|.

∎

Theorem— Theorem 2 (multiplication in polar form)

For all real α,β\alpha, \beta:   cis⁡α⋅cis⁡β=cis⁡(α+β)\;\operatorname{cis}\alpha \cdot \operatorname{cis}\beta = \operatorname{cis}(\alpha + \beta). Consequently

rcis⁡α⋅scis⁡β=rscis⁡(α+β):r\operatorname{cis}\alpha \cdot s\operatorname{cis}\beta = rs\operatorname{cis}(\alpha + \beta):

to multiply complex numbers, multiply the moduli and add the arguments.

Proof

By the multiplication rule,

(cos⁡α+isin⁡α)(cos⁡β+isin⁡β)=(cos⁡αcos⁡β−sin⁡αsin⁡β)+i(sin⁡αcos⁡β+cos⁡αsin⁡β).(\cos\alpha + i\sin\alpha)(\cos\beta + i\sin\beta) = (\cos\alpha\cos\beta - \sin\alpha\sin\beta) + i(\sin\alpha\cos\beta + \cos\alpha\sin\beta).

By the addition formulas of trigonometry the real part is cos⁡(α+β)\cos(\alpha + \beta) and the imaginary part is sin⁡(α+β)\sin(\alpha + \beta). The second statement follows by multiplying by rsrs.

∎

So the addition formulas for sine and cosine are "really" the statement that angles add when complex numbers multiply. In particular cis⁡θ⋅cis⁡(−θ)=cis⁡0=1\operatorname{cis}\theta \cdot \operatorname{cis}(-\theta) = \operatorname{cis} 0 = 1, so cis⁡(−θ)=(cis⁡θ)−1\operatorname{cis}(-\theta) = (\operatorname{cis}\theta)^{-1}; it is also the conjugate cis⁡θ‾\overline{\operatorname{cis}\theta}.

Theorem— Theorem 3 (De Moivre)

For every real θ\theta and every integer nn:

(cos⁡θ+isin⁡θ)n=cos⁡nθ+isin⁡nθ.(\cos\theta + i\sin\theta)^n = \cos n\theta + i\sin n\theta.

Proof

First let n≥0n \ge 0; we use induction on nn. For n=0n = 0 both sides are 11. If cis⁡kθ=cis⁡(kθ)\operatorname{cis}^k\theta = \operatorname{cis}(k\theta), then by Theorem 2

cis⁡k+1θ=cis⁡kθ⋅cis⁡θ=cis⁡(kθ)cis⁡θ=cis⁡((k+1)θ).\operatorname{cis}^{k+1}\theta = \operatorname{cis}^k\theta \cdot \operatorname{cis}\theta = \operatorname{cis}(k\theta)\operatorname{cis}\theta = \operatorname{cis}\big((k + 1)\theta\big).

For negative n=−mn = -m with m>0m > 0: cis⁡−mθ=(cis⁡mθ)−1=(cis⁡(mθ))−1=cis⁡(−mθ)\operatorname{cis}^{-m}\theta = \big(\operatorname{cis}^m\theta\big)^{-1} = \big(\operatorname{cis}(m\theta)\big)^{-1} = \operatorname{cis}(-m\theta), using the remark after Theorem 2.

∎

De Moivre's theorem turns powers into multiplication of angles. Expanding (cos⁡θ+isin⁡θ)3(\cos\theta + i\sin\theta)^3 with the binomial theorem and comparing real parts gives cos⁡3θ=4cos⁡3θ−3cos⁡θ\cos 3\theta = 4\cos^3\theta - 3\cos\theta — a trigonometric identity obtained by pure algebra (the experiment below lets SymPy do it).

Theorem— Theorem 4 (roots of unity)

Let n≥1n \ge 1. The equation zn=1z^n = 1 has exactly nn complex solutions,

ωk=cis⁡2πkn,k=0,1,…,n−1,\omega_k = \operatorname{cis}\frac{2\pi k}{n}, \qquad k = 0, 1, \dots, n - 1,

the nn-th roots of unity. They are the vertices of a regular nn-gon inscribed in the unit circle, with one vertex at 11. For n≥2n \ge 2 they add up to 00.

Proof

Each ωk\omega_k is a solution: by De Moivre, ωkn=cis⁡(2πk)=cos⁡2πk+isin⁡2πk=1\omega_k^n = \operatorname{cis}(2\pi k) = \cos 2\pi k + i \sin 2\pi k = 1.

There are no others: if zn=1z^n = 1 then ∣z∣n=∣zn∣=1|z|^n = |z^n| = 1 by Theorem 1, so ∣z∣=1|z| = 1 and z=cis⁡θz = \operatorname{cis}\theta for some θ\theta. De Moivre gives cos⁡nθ+isin⁡nθ=1\cos n\theta + i\sin n\theta = 1, so cos⁡nθ=1\cos n\theta = 1, which forces nθ=2πkn\theta = 2\pi k for an integer kk, i.e. θ=2πkn\theta = \tfrac{2\pi k}{n}. Since cis⁡\operatorname{cis} repeats with period 2π2\pi, only k=0,…,n−1k = 0, \dots, n - 1 give different numbers, and these nn angles all lie in [0,2π)[0, 2\pi), so they give nn distinct points.

Regular polygon: consecutive ωk\omega_k are at angles differing by 2πn\tfrac{2\pi}{n} on the unit circle.

Sum: let ω=ω1≠1\omega = \omega_1 \ne 1 (as n≥2n \ge 2), so ωk=ωk\omega_k = \omega^k. The geometric sum S=1+ω+⋯+ωn−1S = 1 + \omega + \dots + \omega^{n-1} satisfies (ω−1)S=ωn−1=0(\omega - 1)S = \omega^n - 1 = 0, and ω−1≠0\omega - 1 \ne 0, so S=0S = 0.

∎

The same idea finds all nn-th roots of any non-zero w=Rcis⁡φw = R\operatorname{cis}\varphi: they are R1/ncis⁡φ+2πknR^{1/n}\operatorname{cis}\dfrac{\varphi + 2\pi k}{n} for k=0,…,n−1k = 0, \dots, n - 1, again a regular nn-gon. For example the square roots of i=cis⁡π2i = \operatorname{cis}\tfrac\pi2 are ±cis⁡π4=±1+i2\pm\operatorname{cis}\tfrac\pi4 = \pm\tfrac{1 + i}{\sqrt 2}.

The sixth roots of unity

Change n, then move c away from 1 to see the n-th roots of other numbers.

Try
60°w₀w₁w₂w₃w₄w₅c

Drag the points, or focus one with Tab and use the arrow keys (hold Shift for small steps).

c =+i

Solutions of wⁿ = c for n = 6:

  • w₀ = 1
  • w₁ = 0.5 + 0.866i
  • w₂ = −0.5 + 0.866i
  • w₃ = −1
  • w₄ = −0.5 − 0.866i
  • w₅ = 0.5 − 0.866i

All roots lie on the circle of radius |c|^(1/n) ≈ 1.

Neighbouring roots are 60° apart: 360° ÷ 6.

w₀ is the principal root, at the angle (arg c)/n; the others follow by equal turns.

Because c = 1, these are the roots of unity of order 6.

The roots add up to 0, so the regular polygon is balanced around the origin.

Theorem— Theorem 5 (quadratics with negative discriminant)

Let a,b,ca, b, c be real, a≠0a \ne 0, and Δ=b2−4ac<0\Delta = b^2 - 4ac < 0. Then az2+bz+c=0az^2 + bz + c = 0 has the two complex solutions

z=−b±i−Δ2a,z = \frac{-b \pm i\sqrt{-\Delta}}{2a},

which are conjugates of each other.

Proof

Let s=−Δ=4ac−b2s = \sqrt{-\Delta} = \sqrt{4ac - b^2}, a positive real number, and z=−b+is2az = \tfrac{-b + is}{2a}. Put w=2az=−b+isw = 2az = -b + is. Multiplying the equation by 4a4a,

4a(az2+bz+c)=(2az)2+2b(2az)+4ac=w2+2bw+4ac.4a(az^2 + bz + c) = (2az)^2 + 2b(2az) + 4ac = w^2 + 2bw + 4ac.

Now w2=b2−2bsi+s2i2=b2−2bsi−s2w^2 = b^2 - 2bsi + s^2 i^2 = b^2 - 2bsi - s^2 and 2bw=−2b2+2bsi2bw = -2b^2 + 2bsi, so w2+2bw+4ac=−b2−s2+4ac=0w^2 + 2bw + 4ac = -b^2 - s^2 + 4ac = 0, because s2=4ac−b2s^2 = 4ac - b^2. As 4a≠04a \ne 0, az2+bz+c=0az^2 + bz + c = 0. The other root is obtained by replacing ss with −s-s, which conjugates zz.

∎

For example z2+2z+5=0z^2 + 2z + 5 = 0 has Δ=4−20=−16\Delta = 4 - 20 = -16, so z=−2±4i2=−1±2iz = \tfrac{-2 \pm 4i}{2} = -1 \pm 2i. Check: (−1+2i)2+2(−1+2i)+5=(1−4i−4)+(−2+4i)+5=0(-1 + 2i)^2 + 2(-1 + 2i) + 5 = (1 - 4i - 4) + (-2 + 4i) + 5 = 0.

Quadratics are only the beginning:

Theorem— Fundamental theorem of algebra (statement)

Every non-constant polynomial with complex coefficients has at least one complex root. Consequently a polynomial of degree n≥1n \ge 1 factors into nn linear factors over C\C.

We do not prove it here: every proof needs a substantial idea from analysis or topology (a sketch of one appears among the viewpoints below). It is why the complex numbers are the natural home of algebra: inventing ii to solve x2+1=0x^2 + 1 = 0 turns out to make every polynomial equation solvable.

Finally, one thing is lost. The real numbers are ordered compatibly with arithmetic: positive times positive is positive, and every non-zero number is positive or negative, but not both. Not so for C\C.

Theorem— Theorem 6 (ℂ cannot be ordered)

There is no set P⊆CP \subseteq \C ("the positive numbers") such that products of elements of PP lie in PP and every z≠0z \ne 0 satisfies exactly one of z∈Pz \in P, −z∈P-z \in P.

Proof

Suppose PP were such a set. Since i≠0i \ne 0, either i∈Pi \in P or −i∈P-i \in P. In the first case i⋅i=−1∈Pi \cdot i = -1 \in P; in the second (−i)(−i)=i2=−1∈P(-i)(-i) = i^2 = -1 \in P. Either way −1∈P-1 \in P. Then 1=(−1)(−1)∈P1 = (-1)(-1) \in P too. But then both 11 and −1=−(1)-1 = -(1) are in PP, which is forbidden.

∎

So statements like "i>0i > 0" or "2+i<32 + i < 3" have no meaning in C\C. We can compare moduli — ∣2+i∣=5<3|2 + i| = \sqrt5 < 3 — because those are real numbers.

Formal mathematicsF

Complex numbers in Lean

Mathlib defines ℂ as pairs of real numbers ⟨re, im⟩, with I = ⟨0, 1⟩, and proves that it is a field. So i2=−1i^2 = -1 is a theorem, not an assumption:

i_sqLean 4Applies a library theoremFormally verified
/-- The defining property of `i`: `i² = -1`. This applies Mathlib's `Complex.I_sq`; in Mathlib,
`I` is the pair `⟨0, 1⟩` and the equation is a computation with the multiplication rule for
pairs. -/
theorem i_sq : I ^ 2 = -1 := Complex.I_sq
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor

The multiplication rule and our division example. The tactic linear_combination checks that two sides differ by a multiple of i2+1i^2 + 1, which is exactly "replace i2i^2 by −1-1":

mul_ruleLean 4Proved here from basic factsFormally verified
/-- **The multiplication rule.** `(a + bi)(c + di) = (ac − bd) + (ad + bc)i`: expand with the
distributive law and replace `i²` by `-1`. The `linear_combination` step says precisely that
the two sides differ by `bd (i² + 1)`, which is `0`. -/
theorem mul_rule (a b c d : ℝ) :
    ((a : ℂ) + b * I) * (c + d * I) = (a * c - b * d) + (a * d + b * c) * I := by
  linear_combination ((b : ℂ) * d) * I_sq
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor
div_exampleLean 4Proved here from basic factsFormally verified
/-- **Division by the conjugate trick.** `(3 + 4i)/(1 + 2i) = 11/5 − (2/5) i`, because
`(3 + 4i)(1 − 2i) = 11 − 2i` and `(1 + 2i)(1 − 2i) = 5`. Lean checks the equivalent statement
`3 + 4i = (11/5 − (2/5)i)(1 + 2i)`. -/
theorem div_example : (3 + 4 * I) / (1 + 2 * I) = 11 / 5 - 2 / 5 * I := by
  have h : (1 + 2 * I) ≠ 0 := by
    intro h
    have := congrArg Complex.re h
    simp at this
  rw [div_eq_iff h]
  linear_combination (4 / 5 : ℂ) * I_sq
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor
mul_conjLean 4Applies a library theoremFormally verified
/-- `z · z̄ = |z|²`, a real number: this is why multiplying by the conjugate clears
denominators. Mathlib's `Complex.mul_conj` states it with `normSq z = a² + b²`. -/
theorem mul_conj (z : ℂ) : z * (starRingEnd ℂ) z = (normSq z : ℂ) := Complex.mul_conj z
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor

Theorem 1, via the two-squares identity. Mathlib writes normSq z for ∣z∣2=a2+b2|z|^2 = a^2 + b^2 and ‖z‖ for the modulus ∣z∣|z|:

two_squares_identityLean 4Proved here from basic factsFormally verified
/-- **The two-squares identity** (Brahmagupta; Fibonacci's *Liber Quadratorum*):
`(a² + b²)(c² + d²) = (ac − bd)² + (ad + bc)²`. A product of two sums of two squares is again a
sum of two squares. It holds in every commutative ring; `ring` checks it. -/
theorem two_squares_identity {R : Type*} [CommRing R] (a b c d : R) :
    (a ^ 2 + b ^ 2) * (c ^ 2 + d ^ 2) = (a * c - b * d) ^ 2 + (a * d + b * c) ^ 2 := by
  ring
Axioms used: propext, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor
normSq_mulLean 4Proved here from basic factsFormally verified
/-- **`|zw|² = |z|² |w|²`.** With `z = a + bi` and `w = c + di`, `zw = (ac − bd) + (ad + bc)i`,
so this *is* the two-squares identity. (Mathlib: `Complex.normSq_mul`.) -/
theorem normSq_mul (z w : ℂ) : normSq (z * w) = normSq z * normSq w := by
  simp only [normSq_apply, mul_re, mul_im]
  ring
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor
norm_mulLean 4Applies a library theoremFormally verified
/-- **Moduli multiply:** `|zw| = |z| |w|` (Mathlib writes `‖z‖` for the modulus). This applies
Mathlib's `Complex.norm_mul`; it follows from `normSq_mul` by taking square roots. -/
theorem norm_mul (z w : ℂ) : ‖z * w‖ = ‖z‖ * ‖w‖ := Complex.norm_mul z w
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor

Mathlib has no cis, so we define it, prove that it lies on the unit circle and that it turns multiplication into addition of angles (Theorem 2), and prove De Moivre's theorem by induction for natural numbers nn (the extension to negative nn is not formalised here):

cisLean 4Formally verified
/-- `cis θ = cos θ + i sin θ`, the point at angle `θ` on the unit circle. A number with modulus
`r` and argument `θ` is `r · cis θ`. (Mathlib has no `cis`; it uses `exp (θ * I)`, see
`cis_eq_exp`.) -/
noncomputable def cis (θ : ℝ) : ℂ := Real.cos θ + Real.sin θ * I
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor
norm_cisLean 4Proved here from basic factsFormally verified
/-- `cis θ` lies on the unit circle: `|cis θ| = √(cos² θ + sin² θ) = 1`. -/
theorem norm_cis (θ : ℝ) : ‖cis θ‖ = 1 := by
  rw [cis, Complex.norm_add_mul_I]
  simp [Real.cos_sq_add_sin_sq]
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor
cis_addLean 4Proved here from basic factsFormally verified
/-- **Multiplying adds angles:** `cis (α + β) = cis α · cis β`. Expand the right side with the
multiplication rule: its real part is `cos α cos β − sin α sin β = cos (α + β)` and its
imaginary part is `sin α cos β + cos α sin β = sin (α + β)` — the addition formulas of
trigonometry. -/
theorem cis_add (α β : ℝ) : cis (α + β) = cis α * cis β := by
  simp only [cis, Real.cos_add, Real.sin_add, Complex.ofReal_add, Complex.ofReal_mul,
    Complex.ofReal_sub]
  linear_combination (-(Real.sin α : ℂ) * Real.sin β) * I_sq
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor
polar_mulLean 4Proved here from basic factsFormally verified
/-- **Multiplication in polar form:** `(r cis α)(s cis β) = (rs) cis (α + β)`. Moduli multiply
and arguments add: a rotation combined with a scaling. -/
theorem polar_mul (r s α β : ℝ) :
    ((r : ℂ) * cis α) * ((s : ℂ) * cis β) = ((r * s : ℝ) : ℂ) * cis (α + β) := by
  rw [cis_add]
  push_cast
  ring
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor
de_moivreLean 4Proved here from basic factsFormally verified
/-- **De Moivre's theorem:** `(cos θ + i sin θ)ⁿ = cos nθ + i sin nθ` for every natural number
`n`. Induction on `n`: the case `0` is `1 = cis 0`, and
`cis θ ^ (k + 1) = cis θ ^ k · cis θ = cis (kθ) · cis θ = cis (kθ + θ)` by `cis_add`.
(Mathlib: `Complex.cos_add_sin_mul_I_pow`.) -/
theorem de_moivre (θ : ℝ) (n : ℕ) : cis θ ^ n = cis (n * θ) := by
  induction n with
  | zero => simp [cis]
  | succ k ih =>
    rw [pow_succ, ih, ← cis_add]
    congr 1
    push_cast
    ring
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor
cis_eq_expLean 4Applies a library theoremFormally verified
/-- **Euler's formula** `e^{iθ} = cos θ + i sin θ`: our `cis θ` is Mathlib's `exp (θ * I)`.
This applies `Complex.exp_mul_I` and the fact that `cos` and `sin` of a real number are real. -/
theorem cis_eq_exp (θ : ℝ) : cis θ = Complex.exp (θ * I) := by
  rw [Complex.exp_mul_I, cis, Complex.ofReal_cos, Complex.ofReal_sin]
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor

Roots of unity. We prove that each cis⁡2πkn\operatorname{cis}\tfrac{2\pi k}{n} is an nn-th root of unity and that roots of unity other than 11 sum to 00; that there are exactly nn of them we take from Mathlib, whose rootsOfUnity n ℂ is the group of all ζ\zeta with ζn=1\zeta^n = 1:

cis_root_of_unityLean 4Proved here from basic factsFormally verified
/-- **`cis (2πk/n)` is an `n`-th root of unity.** By De Moivre,
`cis (2πk/n) ^ n = cis (2πk) = cos 2πk + i sin 2πk = 1`. Together with `norm_cis`, the `n`
numbers `cis (2πk/n)`, `k = 0, …, n − 1`, sit on the unit circle at equal angles `2π/n`:
the vertices of a regular `n`-gon. -/
theorem cis_root_of_unity (n k : ℕ) (hn : n ≠ 0) : cis (2 * Real.pi * k / n) ^ n = 1 := by
  rw [de_moivre]
  have h : (n : ℝ) * (2 * Real.pi * k / n) = k * (2 * Real.pi) := by
    field_simp
  have hsin : Real.sin (k * (2 * Real.pi)) = 0 := by
    rw [show (k : ℝ) * (2 * Real.pi) = ((2 * k : ℕ) : ℝ) * Real.pi by push_cast; ring]
    exact Real.sin_nat_mul_pi _
  rw [h, cis, Real.cos_nat_mul_two_pi, hsin]
  simp
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor
sum_roots_of_unityLean 4Proved here from basic factsFormally verified
/-- **The `n`-th roots of unity add up to `0`.** If `ω ^ n = 1` and `ω ≠ 1`, then
`1 + ω + ⋯ + ω^(n−1) = 0`: multiplying the sum by `ω − 1` telescopes to `ωⁿ − 1 = 0`
(Mathlib's `geom_sum_mul`), and `ω − 1 ≠ 0`. With `ω = cis (2π/n)` this says the vertices of a
regular `n`-gon centred at `0` balance at the centre. -/
theorem sum_roots_of_unity {ω : ℂ} {n : ℕ} (hω : ω ^ n = 1) (h1 : ω ≠ 1) :
    ∑ k ∈ Finset.range n, ω ^ k = 0 := by
  have h := geom_sum_mul ω n
  rw [hω, sub_self] at h
  exact (mul_eq_zero.mp h).resolve_right (sub_ne_zero.mpr h1)
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor
card_roots_of_unityLean 4Applies a library theoremFormally verified
/-- **There are exactly `n` complex `n`-th roots of unity** (for `n ≥ 1`). This applies
Mathlib's `Complex.card_rootsOfUnity`; `rootsOfUnity n ℂ` is the group of units `ζ` with
`ζ ^ n = 1`. -/
theorem card_roots_of_unity (n : ℕ) [NeZero n] : Nat.card (rootsOfUnity n ℂ) = n :=
  Complex.card_rootsOfUnity n
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor

Quadratics with negative discriminant (Theorem 5), and the fundamental theorem of algebra, which Mathlib proves using complex analysis:

quadratic_exampleLean 4Proved here from basic factsFormally verified
/-- `z² + 2z + 5 = 0` has discriminant `4 − 20 = −16 < 0`, so no real roots — but
`z = −1 + 2i` is a complex root: `(−1 + 2i)² + 2(−1 + 2i) + 5 = 4 + 4i² = 0`. -/
theorem quadratic_example : (-1 + 2 * I) ^ 2 + 2 * (-1 + 2 * I) + 5 = 0 := by
  linear_combination (4 : ℂ) * I_sq
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor
quadratic_formula_neg_discLean 4Proved here from basic factsFormally verified
/-- **The quadratic formula when `Δ = b² − 4ac < 0`.** With `s = √(4ac − b²)` (a real number),
`z = (−b + s i)/(2a)` solves `az² + bz + c = 0`. Proof: put `w = 2az = −b + si`; then
`4a(az² + bz + c) = w² + 2bw + 4ac = −b² + s² i² + 4ac = −b² − s² + 4ac = 0`. -/
theorem quadratic_formula_neg_disc (a b c : ℝ) (ha : a ≠ 0) (hΔ : b ^ 2 - 4 * a * c < 0)
    (z : ℂ) (hz : z = (-b + Real.sqrt (4 * a * c - b ^ 2) * I) / (2 * a)) :
    a * z ^ 2 + b * z + c = 0 := by
  set s := Real.sqrt (4 * a * c - b ^ 2) with hsdef
  have hs : s ^ 2 = 4 * a * c - b ^ 2 := Real.sq_sqrt (by linarith)
  have hs' : (s : ℂ) ^ 2 = 4 * a * c - b ^ 2 := by exact_mod_cast hs
  have ha' : (a : ℂ) ≠ 0 := by exact_mod_cast ha
  have hw : 2 * (a : ℂ) * z = -b + s * I := by
    rw [hz]
    field_simp
  have h4 : 4 * (a : ℂ) * (a * z ^ 2 + b * z + c) = 0 := by
    linear_combination (2 * a * z + (-b + s * I) + 2 * b) * hw + (s : ℂ) ^ 2 * I_sq - hs'
  have h4a : (4 * (a : ℂ)) ≠ 0 := mul_ne_zero (by norm_num) ha'
  exact (mul_eq_zero.mp h4).resolve_left h4a
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor
fundamental_theorem_of_algebraLean 4Applies a library theoremFormally verified
/-- **The fundamental theorem of algebra:** every non-constant polynomial with complex
coefficients has a complex root. This applies Mathlib's `Complex.exists_root`, whose proof
uses analysis (Liouville's theorem), well beyond this lesson. -/
theorem fundamental_theorem_of_algebra {f : Polynomial ℂ} (hf : 0 < f.degree) :
    ∃ z : ℂ, f.IsRoot z :=
  Complex.exists_root hf
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor

And Theorem 6. An ordering compatible with arithmetic is described by its set P of positive elements, so "no such P" is the formal content of "ℂ cannot be ordered":

no_positive_coneLean 4Proved here from basic factsFormally verified
/-- **ℂ cannot be made into an ordered field.** An ordering compatible with arithmetic is the
same as a set `P` of "positive" numbers closed under multiplication, such that every `z ≠ 0`
has `z ∈ P` or `-z ∈ P`, but never both. No such `P` exists in `ℂ`: whether `i ∈ P` or
`-i ∈ P`, the product of that number with itself is `i² = (-i)² = -1`, so `-1 ∈ P`; then
`1 = (-1)(-1) ∈ P` as well — but `1` and `-1` cannot both be positive. -/
theorem no_positive_cone (P : Set ℂ) (mul_mem : ∀ a b, a ∈ P → b ∈ P → a * b ∈ P)
    (total : ∀ z : ℂ, z ≠ 0 → z ∈ P ∨ -z ∈ P) (not_both : ∀ z : ℂ, z ∈ P → -z ∉ P) :
    False := by
  have hm1 : (-1 : ℂ) ∈ P := by
    rcases total I I_ne_zero with h | h
    · have := mul_mem _ _ h h
      rwa [← sq, I_sq] at this
    · have := mul_mem _ _ h h
      rwa [neg_mul_neg, ← sq, I_sq] at this
  have h1 : (1 : ℂ) ∈ P := by
    have := mul_mem _ _ hm1 hm1
    rwa [neg_mul_neg, one_mul] at this
  exact not_both 1 h1 hm1
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexNumbers.leanTry it in the Lean web editor

(Mathlib does put a partial order on ℂ, available after open scoped ComplexOrder: z≤wz \le w means Re⁡z≤Re⁡w\operatorname{Re} z \le \operatorname{Re} w and Im⁡z=Im⁡w\operatorname{Im} z = \operatorname{Im} w. It is useful, but most pairs, such as 11 and ii, are incomparable — consistent with Theorem 6.)

ComputationC

Computing with complex numbers

Roots of unity and De Moivre's theoremPythonNumerical approximationSymbolic computationComputationally tested
"""Roots of unity, De Moivre's theorem and a square-root trap.

Numerically: the n numbers cos(2 pi k/n) + i sin(2 pi k/n) satisfy z^n = 1
up to rounding, add up to 0, multiply to (-1)^(n+1), and are spaced 2 sin(pi/n)
apart (a regular n-gon). Symbolically (SymPy): the exact cube roots of 1, and
the triple-angle formula cos 3t = 4 cos^3 t - 3 cos t read off from De
Moivre's theorem. Finally the trap: with principal square roots,
sqrt(-1) * sqrt(-1) = -1 while sqrt((-1) * (-1)) = 1.
"""

import cmath
import math

import sympy

def roots_of_unity(n):
    """The n complex numbers cis(2 pi k / n), k = 0, ..., n - 1."""
    if n < 1:
        raise ValueError("n must be at least 1")
    return [cmath.rect(1.0, 2 * math.pi * k / n) for k in range(n)]

def max_error_power(n):
    """max |z^n - 1| over the computed n-th roots of unity (rounding only)."""
    return max(abs(z ** n - 1) for z in roots_of_unity(n))

def root_sum(n):
    """Sum of the n-th roots of unity (exactly 0 for n >= 2)."""
    return sum(roots_of_unity(n))

def root_product(n):
    """Product of the n-th roots of unity (exactly (-1)^(n+1))."""
    product = 1
    for z in roots_of_unity(n):
        product *= z
    return product

def side_length(n):
    """Distance between neighbouring n-th roots of unity."""
    zs = roots_of_unity(n)
    return abs(zs[1 % n] - zs[0])

def exact_cube_roots():
    """The roots of z^3 - 1 as exact SymPy expressions, sorted by argument."""
    z = sympy.symbols("z")
    roots = sympy.solve(z ** 3 - 1, z)
    return sorted(roots, key=lambda r: float(sympy.arg(r)) % (2 * math.pi))

def triple_angle():
    """Real and imaginary parts of (cos t + i sin t)^3, in terms of cos, sin."""
    t = sympy.symbols("t", real=True)
    c, s = sympy.cos(t), sympy.sin(t)
    w = sympy.expand((c + sympy.I * s) ** 3)
    re_part = sympy.re(w).subs(s ** 2, 1 - c ** 2)
    im_part = sympy.im(w).subs(c ** 2, 1 - s ** 2)
    return sympy.expand(re_part), sympy.expand(im_part)

def main():
    print(" n  max|z^n - 1|  |sum|    |prod - (-1)^(n+1)|  side      2 sin(pi/n)")
    for n in range(3, 9):
        prod_err = abs(root_product(n) - (-1) ** (n + 1))
        print(
            f"{n:2d}  {max_error_power(n):.1e}      {abs(root_sum(n)):.1e}"
            f"  {prod_err:.1e}              {side_length(n):.6f}"
            f"  {2 * math.sin(math.pi / n):.6f}"
        )
    print("Errors of about 1e-15 are floating-point rounding, not mathematics.")
    print()
    roots = ", ".join(str(r) for r in exact_cube_roots())
    print(f"Exact cube roots of 1 (SymPy): {roots}")
    re_part, im_part = triple_angle()
    print("De Moivre, n = 3: (cos t + i sin t)^3 = cos 3t + i sin 3t, so")
    print(f"  cos 3t = {re_part}")
    print(f"  sin 3t = {im_part}")
    print()
    a = cmath.sqrt(-1) * cmath.sqrt(-1)
    b = cmath.sqrt((-1) * (-1))
    print(f"sqrt(-1) * sqrt(-1) = {a.real:+.0f}   but   sqrt((-1)(-1)) = {b.real:+.0f}")
    print("So sqrt(ab) = sqrt(a) sqrt(b) fails when a and b are negative.")
    print()
    print("Epistemic status: the table is numerical evidence for n = 3..8 only;")
    print("the lesson proves z^n = 1, the sum and the spacing for every n. The")
    print("SymPy results are exact symbolic computations, as trustworthy as")
    print("SymPy's algebra; De Moivre's theorem itself is proved by induction.")

if __name__ == "__main__":
    main()
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

The tiny errors in the table, around 10−1510^{-15}, come from rounding in floating-point arithmetic, not from the mathematics: Theorem 4 says the true errors are exactly 00. The table is evidence for six values of nn; the theorem covers all of them.

Theorem 1 has a beautiful consequence for whole numbers. If a,b,c,da, b, c, d are integers, the two-squares identity says that a product of two sums of two squares is again a sum of two squares — and complex multiplication tells you which squares:

Complex multiplication and sums of two squaresPythonExact computationExhaustive finite checkComputationally tested
"""Multiplying complex numbers multiplies sums of two squares.

For Gaussian integers z = a + bi (a, b whole numbers) the squared modulus
N(z) = a^2 + b^2 is a sum of two squares, and |zw|^2 = |z|^2 |w|^2 says that
(a^2 + b^2)(c^2 + d^2) = (ac - bd)^2 + (ad + bc)^2. The experiment checks this
exhaustively on a grid of Gaussian integers (exact integer arithmetic), then
uses complex multiplication to *produce* new sums of two squares, e.g.
65 = 5 * 13 = 1^2 + 8^2 = 4^2 + 7^2 from (1 + 2i)(2 + 3i) and (1 + 2i)(2 - 3i).
"""

import math

def gauss_mul(z, w):
    """Product of Gaussian integers given as pairs (a, b) meaning a + bi."""
    (a, b), (c, d) = z, w
    return (a * c - b * d, a * d + b * c)

def norm(z):
    """N(a + bi) = a^2 + b^2, the squared modulus."""
    a, b = z
    return a * a + b * b

def grid(radius):
    """All Gaussian integers a + bi with |a|, |b| <= radius."""
    if radius < 0:
        raise ValueError("radius must be non-negative")
    values = range(-radius, radius + 1)
    return [(a, b) for a in values for b in values]

def check_multiplicative(radius):
    """Return (pairs checked, failures) for N(zw) == N(z) N(w) on the grid."""
    points = grid(radius)
    failures = [
        (z, w)
        for z in points
        for w in points
        if norm(gauss_mul(z, w)) != norm(z) * norm(w)
    ]
    return len(points) ** 2, failures

def two_square_reps(n):
    """All (a, b) with 0 <= a <= b and a^2 + b^2 = n."""
    reps = []
    for a in range(math.isqrt(n // 2) + 1):
        b2 = n - a * a
        b = math.isqrt(b2)
        if b * b == b2 and a <= b:
            reps.append((a, b))
    return reps

def normalise(z):
    """Sort |real|, |imag| so a representation reads (small, large)."""
    a, b = abs(z[0]), abs(z[1])
    return (min(a, b), max(a, b))

def show(z):
    """Write the pair (a, b) as the text a + bi (or a - bi)."""
    a, b = z
    sign = "-" if b < 0 else "+"
    return f"{a} {sign} {abs(b)}i"

def square(x):
    """x^2 as text, with brackets around negative x."""
    return f"({x})^2" if x < 0 else f"{x}^2"

def main():
    cases, failures = check_multiplicative(6)
    print("N(zw) = N(z)N(w) for all z, w with coordinates in -6..6:")
    print(f"  {cases} pairs checked, {len(failures)} failures")
    print()
    z, w = (1, 2), (2, 3)
    w_bar = (2, -3)
    for v in (w, w_bar):
        p = gauss_mul(z, v)
        print(f"({show(z)})({show(v)}) = {show(p)},  "
              f"N = {square(p[0])} + {square(p[1])} = {norm(p)}")
    print("So 5 * 13 = 65 has two representations:", two_square_reps(65))
    print()
    print("n   = a^2 + b^2   (all representations with 0 <= a <= b)")
    for n in [5, 13, 25, 65, 85, 325, 1105]:
        reps = two_square_reps(n)
        shown = ", ".join(f"{a}^2+{b}^2" for a, b in reps)
        print(f"{n:<5} {shown}")
    print("3, 7, 21 have none:", [two_square_reps(n) for n in (3, 7, 21)])
    print()
    print("Epistemic status: the grid check is exhaustive but finite; the")
    print("identity (a^2+b^2)(c^2+d^2) = (ac-bd)^2+(ad+bc)^2 is proved for all")
    print("numbers by expanding both sides (and in Lean). Which n are sums of")
    print("two squares is a theorem of Fermat and Euler, not shown here.")

if __name__ == "__main__":
    main()
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.
Exercises

Exercises

1. Complex numbers

Warm-upHuman

Compute (4−3i)(2+5i)(4 - 3i)(2 + 5i) and enter its real part.

2. Complex numbers

Warm-upHuman

What is i2027i^{2027}?

Choose one

3. Complex numbers

Warm-upHuman

Compute ∣(3+4i)(5−12i)∣\left|(3 + 4i)(5 - 12i)\right| — ideally without multiplying out first.

4. Complex numbers

CoreHuman

Which is the polar form of z=−1+i3z = -1 + i\sqrt 3?

Choose one

5. Complex numbers

CoreHuman

Solve z2−4z+13=0z^2 - 4z + 13 = 0.

Choose one

6. Complex numbers

CoreHuman

Which of the following are sixth roots of unity, i.e. solutions of z6=1z^6 = 1? (Choose all that apply.)

Choose all that apply

7. Complex numbers

StretchHuman

What is wrong with this "proof" that 1=−11 = -1? 1=1=(−1)(−1)=−1 −1=i⋅i=−1.1 = \sqrt 1 = \sqrt{(-1)(-1)} = \sqrt{-1}\,\sqrt{-1} = i \cdot i = -1.

Choose one

8. Complex numbers

CoreFormal

In the Lean module, cis θ means cos⁡θ+isin⁡θ\cos\theta + i\sin\theta and n : ℕ. Which Lean statement is De Moivre's theorem?

Choose one

9. Complex numbers

StretchComputational

Write nth_roots(w, n) that returns a list of the nn complex nn-th roots of a non-zero complex number w, using polar form: if w=Rcis⁡φw = R\operatorname{cis}\varphi, the roots are R1/ncis⁡φ+2πknR^{1/n}\operatorname{cis}\frac{\varphi + 2\pi k}{n} for k=0,…,n−1k = 0, \dots, n-1. Python's cmath.polar(w) returns (R,φ)(R, \varphi) and cmath.rect(r, theta) returns rcis⁡θr\operatorname{cis}\theta.

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.
Common misconceptionsH

Common misconceptions

Misconception

"Imaginary numbers are fake." The word "imaginary" (Descartes' term, meant dismissively) is a historical accident. Complex numbers are as legitimate as negative numbers or 2\sqrt 2: they can be constructed from real numbers (as pairs), they obey precise laws, and they describe real phenomena — alternating currents, waves, quantum amplitudes.

Misconception

"ab=a b\sqrt{ab} = \sqrt a\,\sqrt b always." It holds for a,b≥0a, b \ge 0, but not for negative numbers: with −1=i\sqrt{-1} = i, we get −1⋅−1=i2=−1\sqrt{-1}\cdot\sqrt{-1} = i^2 = -1, while (−1)(−1)=1=1\sqrt{(-1)(-1)} = \sqrt 1 = 1. Every non-zero complex number has two square roots, and no choice of "the" square root can make the product rule work everywhere. Treat −4\sqrt{-4} as 2i2i, and simplify before multiplying.

Misconception

"C\C can be ordered like R\R." Theorem 6 shows no ordering is compatible with multiplication. Inequalities between complex numbers are meaningless; inequalities between their moduli, real parts or imaginary parts (all real numbers) are fine.

Misconception

"∣a+bi∣=a+b|a + bi| = a + b" or "∣a+bi∣=a2−b2|a + bi| = \sqrt{a^2 - b^2}". The modulus is a distance in the plane: ∣a+bi∣=a2+b2|a + bi| = \sqrt{a^2 + b^2}. For example ∣3−4i∣=5|3 - 4i| = 5.

Misconception

"The argument is arctan⁡ba\arctan\tfrac ba." That gives an angle in (−π2,π2)(-\tfrac\pi2, \tfrac\pi2) only, so it is wrong for points with a<0a < 0, and undefined when a=0a = 0. Always check the quadrant: arg⁡(−1−i)=−3π4\arg(-1 - i) = -\tfrac{3\pi}{4}, not π4\tfrac\pi4.

ViewpointsH

Other ways of seeing

Geometry— Similarities of the plane

Multiplication by w≠0w \ne 0 is a rotation by arg⁡w\arg w combined with a scaling by ∣w∣|w|, and z↦wz+cz \mapsto wz + c is a similarity of the plane fixing orientation; z↦zˉz \mapsto \bar z is a reflection. Every rigid motion of the plane is z↦wz+cz \mapsto wz + c or z↦wzˉ+cz \mapsto w\bar z + c with ∣w∣=1|w| = 1. Geometry problems about rotations become algebra: for instance, z1,z2,z3z_1, z_2, z_3 form an equilateral triangle (or all coincide) exactly when z1+ωz2+ω2z3=0z_1 + \omega z_2 + \omega^2 z_3 = 0 for ω=cis⁡2π3\omega = \operatorname{cis}\tfrac{2\pi}{3} or ω=cis⁡(−2π3)\omega = \operatorname{cis}(-\tfrac{2\pi}{3}), the two choices corresponding to the two orientations.

Algebra— Adjoining a root

Algebraically, C\C is what you get by adjoining to R\R a root of x2+1x^2 + 1: the quotient ring R[x]/(x2+1)\R[x]/(x^2 + 1), where polynomials are computed modulo x2+1x^2 + 1, so xx plays the role of ii. Conjugation a+bi↦a−bia + bi \mapsto a - bi respects addition and multiplication and fixes R\R — it is a field automorphism, and the two automorphisms of C\C fixing R\R form the first example of a Galois group. The matrices (a−bba)\begin{pmatrix} a & -b \\ b & a\end{pmatrix} give yet another model of C\C, inside 2×22 \times 2 real matrices. See Fields and Galois theory.

Number theory— Gaussian integers

The numbers a+bia + bi with a,b∈Za, b \in \Z form the Gaussian integers Z[i]\Z[i], where factorisation behaves differently: 5=(2+i)(2−i)5 = (2 + i)(2 - i) and 13=(3+2i)(3−2i)13 = (3 + 2i)(3 - 2i), while 33 cannot be split. Since N(z)=∣z∣2=a2+b2N(z) = |z|^2 = a^2 + b^2 is multiplicative (Theorem 1), a prime pp factors in Z[i]\Z[i] exactly when p=a2+b2p = a^2 + b^2 for some integers a,ba, b. Fermat's theorem that odd primes of the form 4k+14k + 1 are sums of two squares (proved by Euler) is the starting point of algebraic number theory.

Topology— Why every polynomial has a root: a winding argument

Here is the idea of one proof of the fundamental theorem of algebra — a sketch, not a proof. Let p(z)=zn+an−1zn−1+⋯+a0p(z) = z^n + a_{n-1}z^{n-1} + \dots + a_0 with n≥1n \ge 1, and suppose pp had no root. For a huge circle ∣z∣=R|z| = R, the term znz^n dominates, so as zz goes once around the circle, p(z)p(z) winds nn times around 00. Now shrink the circle continuously to the point 00: the image curve deforms continuously, never passing through 00 (no roots!), so its winding number cannot jump — yet at the end the curve is the single point p(0)≠0p(0) \ne 0, which winds 00 times. Since n≠0n \ne 0, contradiction. Making "winding number" and "cannot jump" precise is a job for the fundamental group or complex analysis.

Counting how often a curve winds around a point

How many times does the curve wind around the point p? Count the turns of an arrow, or the signed crossings of a ray.

Curve
+1p
  • winding number 1

Drag the points, or focus one with Tab and use the arrow keys (hold Shift for small steps).

p =+i

Winding number around p: 1

By the angle: as the gold point goes once around the curve, the arrow from p turns 1 full turns (counter-clockwise counts as positive).

By the ray: signed crossings (+1) = 1

Each crossing of the dashed ray counts +1 where the curve passes upwards (counter-clockwise around p) and −1 where it passes downwards (clockwise).

Both counts are computed on the curve sampled at 720 points.

Physics— Rotating arrows for waves

An alternating voltage V0cos⁡(ωt+φ)V_0\cos(\omega t + \varphi) is the real part of the rotating complex number V0cis⁡(ωt+φ)V_0 \operatorname{cis}(\omega t + \varphi) (a "phasor"). Adding waves of the same frequency becomes adding complex numbers, and the effect of a capacitor or inductor becomes multiplication by a complex impedance. In quantum mechanics complex numbers are not a convenience but part of the theory: states are described by complex amplitudes whose squared moduli give probabilities.

Wonder Trails

Wonder Trails

History & global context

History and global context

  • Early encounters. Heron of Alexandria (1st century CE) met the square root of a negative number in a calculation about a truncated pyramid and passed over it. The Indian mathematician Mahāvīra (9th century) stated that a negative number has no square root, since it is not a square.
  • Renaissance Italy. Gerolamo Cardano's Ars Magna (1545) contains the cubic formula and, in another problem, the "sophisticated" numbers 5±−155 \pm \sqrt{-15}, which have sum 1010 and product 4040. Rafael Bombelli's Algebra (1572) gave the first systematic rules for calculating with them, motivated by x3=15x+4x^3 = 15x + 4.
  • Names and symbols. René Descartes called such roots "imaginary" in La Géométrie (1637). Abraham de Moivre found formulas equivalent to his theorem in the early 18th century; Leonhard Euler stated eiθ=cos⁡θ+isin⁡θe^{i\theta} = \cos\theta + i\sin\theta in his Introductio (1748) and introduced the symbol ii (1777).
  • The plane. The surveyor Caspar Wessel (1799, in Danish), Jean-Robert Argand (1806) and Carl Friedrich Gauss (1831) described complex numbers as points of a plane. Gauss's doctoral thesis (1799) was devoted to the fundamental theorem of algebra; its proof was later seen to leave a topological point unproved, and Gauss gave further proofs. William Rowan Hamilton defined complex numbers as pairs of reals (1837).
Further reading

Further reading

  • Tristan Needham, Visual Complex Analysis (1997) — complex numbers as geometry, beautifully illustrated; chapter 1 suits this lesson.
  • Paul J. Nahin, An Imaginary Tale: The Story of √−1 (1998) — the history, from Cardano to modern physics.
  • Richard Courant and Herbert Robbins, What Is Mathematics? (1941), chapter II, §5 on complex numbers.
  • John Stillwell, Mathematics and Its History (1989), the chapters on complex numbers in algebra and geometry.
  • Lars Ahlfors, Complex Analysis (1953), chapter 1 — for the next step.