Skip to content

Complex Numbers in One Page

Complex numbers appear in this module for exactly one reason, and it is worth stating up front so you know how much of this page you need.

A matrix full of real numbers can have eigenvalues that are not real. A rotation is the standard example: it turns every vector, so there is no direction it merely stretches, so there is no real eigenvector — and yet the characteristic polynomial still has roots, because polynomials always do once you allow complex numbers. §4.2 hits this on its second example, and a reader who has never seen ii stalls there.

That is the whole motivation. This page covers what you need for it and stops.

  • What ii is, and why it was invented.
  • The complex plane, and why multiplication by a complex number is a rotation-and-scale.
  • Modulus and argument, and Euler’s formula tying them to cos⁡\cos and sin⁡\sin.
  • Conjugates, and why complex eigenvalues of a real matrix always come in pairs.
  • The precise reason a rotation matrix has no real eigenvalues.

Real numbers live on a line. Multiplying by a positive real stretches along that line; multiplying by −1-1 flips it — a rotation by 180°180°.

So ask: what would rotate by 90°90°? Doing it twice must give the 180°180° flip, so it must be a number whose square is −1-1. No real number qualifies, so we name one:

i2=−1i^2 = -1

Read ii as “the quarter turn” rather than “the square root of minus one”. That reading makes everything below obvious instead of mysterious, and it is exactly the reading that connects complex numbers to rotation matrices.

diagram Diagram mermaid

A complex number is a pair of reals wearing one symbol:

z=a+bi,a=Re⁡(z),b=Im⁡(z)z = a + bi, \qquad a = \operatorname{Re}(z),\quad b = \operatorname{Im}(z)

Plot aa horizontally and bb vertically and you have the complex plane. A complex number is a point in R2\mathbb{R}^2 — with one extra piece of structure real pairs do not have: a way to multiply two of them together and get a third.

Addition is componentwise, exactly like vectors:

(a+bi)+(c+di)=(a+c)+(b+d)i(a + bi) + (c + di) = (a + c) + (b + d)i

Multiplication is where the structure is. Expand and use i2=−1i^2 = -1:

(a+bi)(c+di)=ac+adi+bci+bdi2=(ac−bd)+(ad+bc)i(a + bi)(c + di) = ac + adi + bci + bdi^2 = (ac - bd) + (ad + bc)i

The minus sign in ac−bdac - bd is the entire content of i2=−1i^2 = -1, and it is the reason multiplication rotates.

∣z∣=a2+b2,arg⁡(z)=atan2⁡(b,a)\lvert z\rvert = \sqrt{a^2 + b^2}, \qquad \arg(z) = \operatorname{atan2}(b, a)

The modulus is the distance from the origin — the Euclidean norm of the pair, which is why §3.1’s norms carry over unchanged. The argument is the angle from the positive real axis.

In these terms, multiplication is simple:

∣z1z2∣=∣z1∣ ∣z2∣,arg⁡(z1z2)=arg⁡(z1)+arg⁡(z2)\lvert z_1 z_2\rvert = \lvert z_1\rvert\,\lvert z_2\rvert, \qquad \arg(z_1 z_2) = \arg(z_1) + \arg(z_2)

Moduli multiply, arguments add. Multiplying by zz scales by ∣z∣\lvert z\rvert and rotates by arg⁡(z)\arg(z). Check it on ii: modulus 11, argument 90°90°. So multiplying by ii rotates by a quarter turn and changes no length — which is what we asked for at the start.

eiθ=cos⁡θ+isin⁡θe^{i\theta} = \cos\theta + i\sin\theta

So any complex number factors into “how big” times “which way”:

z=∣z∣ eiarg⁡(z)z = \lvert z\rvert\, e^{i\arg(z)}

Two consequences used later:

  • eiθe^{i\theta} always has modulus 11 — it is a point on the unit circle, and θ\theta is the angle.
  • Multiplying two of them adds the exponents, which is the “arguments add” rule again, now as ordinary index arithmetic.

Setting θ=π\theta = \pi gives eiπ=−1e^{i\pi} = -1: a half turn is multiplication by −1-1, as promised.

zˉ=a−bi\bar{z} = a - bi

Reflection across the real axis. Two properties do real work:

zzˉ=a2+b2=∣z∣2,z1z2‾=z1ˉ z2ˉz\bar{z} = a^2 + b^2 = \lvert z\rvert^2, \qquad \overline{z_1 z_2} = \bar{z_1}\,\bar{z_2}

The first says a complex number times its conjugate is real and non-negative — which is how you divide by a complex number, and the reason ∣z∣2\lvert z\rvert^2 appears wherever a magnitude is needed.

The second gives the fact §4.2 depends on:

The rotation matrix by angle θ\theta:

R(θ)=[cos⁡θ−sin⁡θsin⁡θcos⁡θ]\mathbf{R}(\theta) = \begin{bmatrix}\cos\theta & -\sin\theta \\ \sin\theta & \cos\theta\end{bmatrix}

Its characteristic polynomial is

det⁡(R−λI)=(cos⁡θ−λ)2+sin⁡2θ=λ2−2λcos⁡θ+1\det(\mathbf{R} - \lambda\mathbf{I}) = (\cos\theta - \lambda)^2 + \sin^2\theta = \lambda^2 - 2\lambda\cos\theta + 1

with discriminant

4cos⁡2θ−4=−4sin⁡2θ  ≤  04\cos^2\theta - 4 = -4\sin^2\theta \;\le\; 0

Negative whenever sin⁡θ≠0\sin\theta \neq 0. So for any rotation that is not by 0°0° or 180°180° the eigenvalues are complex:

λ=cos⁡θ±isin⁡θ=e±iθ\lambda = \cos\theta \pm i\sin\theta = e^{\pm i\theta}

Look at what that says. The eigenvalues of a rotation by θ\theta are e±iθe^{\pm i\theta}: modulus 11, argument ±θ\pm\theta. The matrix rotates by θ\theta; its eigenvalues are the rotation by θ\theta, written as complex numbers. Modulus 11 says lengths are preserved, which is exactly §3.9’s claim that rotations are orthogonal transformations — recovered from the eigenvalues.

And “no real eigenvalue” now has a geometric meaning rather than an algebraic one: a rotation turns every direction, so there is no direction it merely scales.

Take θ=90°\theta = 90°, so R=[0−110]\mathbf{R} = \begin{bmatrix}0 & -1\\ 1 & 0\end{bmatrix}.

Characteristic polynomial: λ2−2λcos⁡90°+1=λ2+1\lambda^2 - 2\lambda\cos 90° + 1 = \lambda^2 + 1. Roots λ=±i\lambda = \pm i.

Check the eigenvector for λ=i\lambda = i. We need (R−iI)v=0(\mathbf{R} - i\mathbf{I})\mathbf{v} = \mathbf{0}:

[−i−11−i][v1v2]=0\begin{bmatrix}-i & -1\\ 1 & -i\end{bmatrix}\begin{bmatrix}v_1\\ v_2\end{bmatrix} = \mathbf{0}

The second row gives v1=iv2v_1 = i v_2. Take v2=1v_2 = 1, so v=(i,1)⊤\mathbf{v} = (i, 1)^\top. Verify:

Rv=[0−110][i1]=[−1i]=i[i1]=iv✓\mathbf{R}\mathbf{v} = \begin{bmatrix}0 & -1\\ 1 & 0\end{bmatrix}\begin{bmatrix}i\\ 1\end{bmatrix} = \begin{bmatrix}-1\\ i\end{bmatrix} = i\begin{bmatrix}i\\ 1\end{bmatrix} = i\mathbf{v} \quad\checkmark

using i⋅i=−1i\cdot i = -1 in the top entry. And the conjugate pair: λˉ=−i\bar{\lambda} = -i with vˉ=(−i,1)⊤\bar{\mathbf{v}} = (-i, 1)^\top.

Now arithmetic on z=3+4iz = 3 + 4i and w=1−2iw = 1 - 2i, every quantity by hand:

quantityworkingresult
z+wz + w(3+1)+(4−2)i(3+1) + (4-2)i4+2i4 + 2i
zwzw(3⋅1−4⋅(−2))+(3⋅(−2)+4⋅1)i(3\cdot1 - 4\cdot(-2)) + (3\cdot(-2) + 4\cdot1)i11−2i11 - 2i
∣z∣\lvert z\rvert9+16\sqrt{9 + 16}55
∣w∣\lvert w\rvert1+4\sqrt{1 + 4}5≈2.2360680\sqrt5 \approx 2.2360680
∣zw∣\lvert zw\rvert555\sqrt5≈11.1803399\approx 11.1803399
arg⁡(z)\arg(z)atan2⁡(4,3)\operatorname{atan2}(4, 3)≈0.9272952\approx 0.9272952 rad, 53.13°53.13°
arg⁡(w)\arg(w)atan2⁡(−2,1)\operatorname{atan2}(-2, 1)≈−1.1071487\approx -1.1071487 rad, −63.43°-63.43°
arg⁡(zw)\arg(zw)0.9272952+(−1.1071487)0.9272952 + (-1.1071487)≈−0.1798535\approx -0.1798535 rad, −10.30°-10.30°
zzˉz\bar{z}(3+4i)(3−4i)=9+16(3+4i)(3-4i) = 9 + 1625=∣z∣225 = \lvert z\rvert^2

Check the last modulus directly: ∣11−2i∣=121+4=125=55\lvert 11 - 2i\rvert = \sqrt{121 + 4} = \sqrt{125} = 5\sqrt5. Matches. Moduli multiplied and arguments added, exactly as claimed.

Drag the two complex numbers and watch the product. The dashed circle has radius ∣z1∣∣z2∣\lvert z_1\rvert\lvert z_2\rvert: the product always lands on it, because moduli multiply. The angles add head to tail.

sketch Multiplying complex numbers scales and rotates p5.js
Drag the modulus and argument of each factor. The product's modulus is the two moduli multiplied and its argument is the two arguments added, so it always sits on the dashed circle.

Set both moduli to 11. The product stays on the unit circle no matter how you turn the arguments — pure rotation, no scaling. Those unit-modulus complex numbers are precisely the eigenvalues e±iθe^{\pm i\theta} of R(θ)\mathbf{R}(\theta), and “modulus one” is “lengths preserved”.

complex_numbers.py
import numpy as np
 
z, w = 3 + 4j, 1 - 2j          # Python writes the imaginary unit as j, not i
 
print("z + w :", z + w)                       # (4+2j)
print("z * w :", z * w)                       # (11-2j)
print("|z|   :", abs(z), " |w|:", round(abs(w), 7))
print("|zw| == |z||w| :", np.isclose(abs(z * w), abs(z) * abs(w)))
print("arg z :", round(np.angle(z), 7), " arg w:", round(np.angle(w), 7))
print("arg zw == arg z + arg w :",
      np.isclose(np.angle(z * w), np.angle(z) + np.angle(w)))
print("z * conj(z) :", z * z.conjugate(), " == |z|^2 =", abs(z) ** 2)
 
# Euler's formula, checked numerically.
theta = np.pi / 3
print("e^{i.theta} == cos + i sin :",
      np.isclose(np.exp(1j * theta), np.cos(theta) + 1j * np.sin(theta)))
print("e^{i.pi} :", np.round(np.exp(1j * np.pi), 12))
 
# The rotation matrix: real entries, complex eigenvalues.
theta = np.pi / 2
R = np.array([[np.cos(theta), -np.sin(theta)],
              [np.sin(theta),  np.cos(theta)]])
vals, vecs = np.linalg.eig(R)
print("R is real:", np.isrealobj(R), " eigenvalues:", np.round(vals, 10))
print("moduli all 1:", np.allclose(np.abs(vals), 1.0))
print("conjugate pair:", np.isclose(vals[0], vals[1].conjugate()))
print("eigenvalues equal exp(+-i.theta):",
      np.allclose(np.sort_complex(vals),
                  np.sort_complex(np.array([np.exp(1j*theta), np.exp(-1j*theta)]))))
 
# Odd size forces a real eigenvalue: rotation about the z axis in 3-D.
R3 = np.array([[np.cos(theta), -np.sin(theta), 0.0],
               [np.sin(theta),  np.cos(theta), 0.0],
               [0.0,            0.0,           1.0]])
v3 = np.linalg.eigvals(R3)
print("3x3 rotation eigenvalues:", np.round(v3, 10))
print("has a real one (the axis):", np.any(np.isclose(v3.imag, 0.0)))
text
z + w : (4+2j)
z * w : (11-2j)
|z|   : 5.0  |w|: 2.236068
|zw| == |z||w| : True
arg z : 0.9272952  arg w: -1.1071487
arg zw == arg z + arg w : True
z * conj(z) : (25+0j)  == |z|^2 = 25.0
e^{i.theta} == cos + i sin : True
e^{i.pi} : (-1+0j)
R is real: True  eigenvalues: [0.+1.j 0.-1.j]
moduli all 1: True
conjugate pair: True
eigenvalues equal exp(+-i.theta): True
3x3 rotation eigenvalues: [0.+1.j 0.-1.j 1.+0.j]
has a real one (the axis): True

The last two lines are the counting argument, executed. The 2×22\times2 rotation has no real eigenvalue; the 3×33\times3 one has exactly one, and it is 11 — the axis, which the rotation leaves completely alone.

figure The worked example, drawn matplotlib
Two panels. Left, the complex plane with arrows to 3 plus 4i, 1 minus 2i and their product 11 minus 2i, each sitting on a dotted circle of its own modulus 5, 2.236 and 11.180. Right, a horizontal bar chart of the three arguments in radians, 0.927, minus 1.107 and minus 0.180, with a note that the first two sum to the third. Two panels. Left, the complex plane with arrows to 3 plus 4i, 1 minus 2i and their product 11 minus 2i, each sitting on a dotted circle of its own modulus 5, 2.236 and 11.180. Right, a horizontal bar chart of the three arguments in radians, 0.927, minus 1.107 and minus 0.180, with a note that the first two sum to the third.
The same z and w computed by hand above. The product's modulus is 11.1803399, which is 5 times 2.2360680 to every digit shown, and its argument is the sum of the two arguments to within 5.6e-17.
figure Why the eigenvalues of a rotation cannot be real matplotlib
Three panels. Left, the discriminant minus 4 sine squared theta plotted against theta, touching zero only at 0, 180 and 360 degrees. Middle, the unit circle with eigenvalue pairs marked for 30, 90 and 120 degrees and squares at plus and minus one. Right, sixteen grey arrows and their sixteen rotated green images, none of them parallel. Three panels. Left, the discriminant minus 4 sine squared theta plotted against theta, touching zero only at 0, 180 and 360 degrees. Middle, the unit circle with eigenvalue pairs marked for 30, 90 and 120 degrees and squares at plus and minus one. Right, sixteen grey arrows and their sixteen rotated green images, none of them parallel.
The discriminant is negative for every rotation angle except 0 and 180 degrees. Geometrically: at 36 degrees all sixteen sampled directions turn, and the smallest cross product between a direction and its image is 0.587785 rather than zero.
figure Conjugate pairs, and the axis an odd dimension must keep matplotlib
Two panels. Left, a scatter of two thousand eigenvalues of random real five-by-five matrices, visibly symmetric about the real axis. Right, for five hundred random three-by-three rotations, the absolute imaginary part of the conjugate pair plotted against the recovered rotation angle, lying exactly on the dashed absolute-sine curve. Two panels. Left, a scatter of two thousand eigenvalues of random real five-by-five matrices, visibly symmetric about the real axis. Right, for five hundred random three-by-three rotations, the absolute imaginary part of the conjugate pair plotted against the recovered rotation angle, lying exactly on the dashed absolute-sine curve.
Of 2000 eigenvalues of real 5x5 matrices, 864 are real and the remainder are exactly mirror-symmetric. Every one of 500 random 3x3 rotations kept a real eigenvalue at 1, to within 2.2e-15, whose eigenvector the rotation fixes to within 1.4e-15.

The first figure is the hand calculation, checked. The three dotted circles have radii ∣z∣=5\lvert z\rvert = 5, ∣w∣=2.2360680\lvert w\rvert = 2.2360680 and ∣zw∣=11.1803399\lvert zw\rvert = 11.1803399, and the third is the product of the first two — not approximately, to every digit plotted. The right panel is the part worth staring at: arg⁡z=0.9272952\arg z = 0.9272952 and arg⁡w=−1.1071487\arg w = -1.1071487 sum to −0.1798535-0.1798535, which is arg⁡zw\arg zw with a discrepancy of 5.6×10−175.6 \times 10^{-17}, i.e. one unit in the last place of a float64. Notice what the panel does not show: any interaction between modulus and argument. They are two independent channels, and that separation is exactly what makes reiθre^{i\theta} a better way to write a complex number than a+bia + bi when you are multiplying.

The second figure is the page’s central claim, from three angles. The left panel plots −4sin⁡2θ-4\sin^2\theta, which is a square with a minus sign in front, so it is negative everywhere it is not zero — and it is zero only where sin⁡θ=0\sin\theta = 0, at 0°0° and 180°180°. Those are the two “rotations” that are not really rotations: the identity and a point reflection. The middle panel puts the roots where they belong, on the unit circle at angle ±θ\pm\theta; the amber squares at ±1\pm 1 mark the only two real values a rotation’s eigenvalue is ever allowed to take. The right panel is the same fact with no algebra in it. Sixteen directions, sixteen images, and not one image parallel to its source. The measured cross product ∣v1(Rv)2−v2(Rv)1∣\lvert v_1(\mathbf{R}v)_2 - v_2(\mathbf{R}v)_1\rvert is 0.5877850.587785 for every direction sampled — it is sin⁡θ\sin\theta identically, independent of vv — which is a stronger statement than “no eigenvector was found”: there is no direction where it is even small.

The third figure proves the pairing rule and then uses it. The left scatter is the spectrum of random real matrices, and its symmetry about the real axis is not a sampling accident: the characteristic polynomial of a real matrix has real coefficients, so its complex roots must occur in conjugate pairs. Of the 20002000 eigenvalues drawn, 864864 are exactly real and the other 11361136 form 568568 mirror pairs. Now count. A 3×33 \times 3 real matrix has three eigenvalues, pairs come in twos, and three is odd — so at least one eigenvalue has to be real. The right panel confirms it on rotations specifically: all 500500 have a real eigenvalue equal to 11 within 2.2×10−152.2\times10^{-15}, its eigenvector satisfies Qa=a\mathbf{Q}\mathbf{a} = \mathbf{a} within 1.4×10−151.4\times10^{-15}, and the remaining conjugate pair has imaginary part exactly ∣sin⁡θ∣\lvert\sin\theta\rvert for the angle of the rotation. That fixed eigenvector is the axis. Euler’s rotation theorem — every 3D rotation has an axis — is this parity argument and nothing more.

matrix propertyeigenvaluespractical consequence
real symmetricall real, orthogonal eigenvectorsuse eigh; the spectral theorem applies (§4.2)
real, not symmetricmay be complex, in conjugate pairsuse eig; expect a complex dtype
rotation R(θ)\mathbf{R}(\theta)e±iθe^{\pm i\theta}, modulus 11length preserving; no real invariant direction (§3.9)
real, odd sizeat least one real eigenvaluea 3-D rotation always has an axis
covariance matrixreal, all ≥0\ge 0it is symmetric positive semidefinite (§6.4)

The first and last rows are the reason most of machine learning never meets a complex number: covariance matrices, Gram matrices and Hessians are all symmetric, and symmetric real matrices have real eigenvalues. Complex arithmetic shows up when a matrix is not symmetric — a rotation, a transition matrix, the Jacobian of a dynamical system.

pch.quizTag Check yourself
  1. What happens to modulus and argument when two complex numbers are multiplied?

    pch.quizShowAnswer

    C — Moduli multiply and arguments add — Which is why multiplying by a complex number is a scale-and-rotate, and why a unit-modulus factor is a pure rotation.

  2. Why can a real matrix have complex eigenvalues?

    pch.quizShowAnswer

    B — Because the characteristic polynomial can have no real roots, even though its coefficients are real — A rotation's characteristic polynomial has discriminant minus four sine squared, which is negative for any genuine rotation. Real coefficients, complex roots, and the eigenvalues turn out to be e to the plus or minus i theta.

  3. A real five-by-five matrix must have at least one real eigenvalue. Why?

    pch.quizShowAnswer

    B — Complex eigenvalues of a real matrix come in conjugate pairs, and five cannot be made entirely of pairs — Conjugating the eigenvalue equation shows the conjugate is also an eigenvalue, so complex ones arrive two at a time. An odd count leaves at least one unpaired, which therefore must be real — this is why a 3-D rotation always has an axis.

  4. You call np.linalg.eig on a real covariance matrix and get a complex dtype with negligible imaginary parts. What is the right response?

    pch.quizShowAnswer

    B — Use eigh instead, which exploits symmetry and returns real values — A covariance matrix is symmetric, so the spectral theorem guarantees real eigenvalues; the imaginary parts are pure numerical noise from the general-purpose routine. eigh assumes symmetry, is faster, and returns real values by construction.

Exercise 1 – Multiplying by i is a quarter turn

Section titled “Exercise 1 – Multiplying by i is a quarter turn”

Exercise 5 – Symmetric matrices stay real

Section titled “Exercise 5 – Symmetric matrices stay real”
  • Read ii as the quarter turn, not as the square root of minus one — the geometry then explains the algebra.
  • A complex number is a point in the plane with one extra structure real pairs lack: a multiplication.
  • Multiplying multiplies moduli and adds arguments, so multiplication is a scale-and-rotate and a unit-modulus factor is a pure rotation.
  • Euler’s formula — e to the i theta is the unit-circle point at angle theta, so any complex number factors into size times direction.
  • A number times its conjugate is its modulus squared, real and non-negative.
  • Complex eigenvalues of a real matrix come in conjugate pairs, because conjugating the eigenvalue equation leaves a real matrix alone.
  • An odd-sized real matrix therefore has at least one real eigenvalue — which is why a 3-D rotation always has an axis.
  • A rotation by theta has eigenvalues e to the plus or minus i theta — modulus one, meaning lengths are preserved, with no real invariant direction.
  • Symmetric real matrices always have real eigenvalues, which is why covariance matrices, Gram matrices and Hessians never need complex arithmetic. Use eigh, not eig.
  • There is no ordering on the complex numbers, so “largest eigenvalue” always means largest modulus.

Next: the tool you will check every derivation against — NumPy for Mathematics.

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading