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=(acbd)+(ad+bc)i(a + bi)(c + di) = ac + adi + bci + bdi^2 = (ac - bd) + (ad + bc)i

The minus sign in acbdac - 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=z1z2,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=zeiarg(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ˉ=abi\bar{z} = a - bi

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

zzˉ=a2+b2=z2,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 z2\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+sin2θ=λ22λcosθ+1\det(\mathbf{R} - \lambda\mathbf{I}) = (\cos\theta - \lambda)^2 + \sin^2\theta = \lambda^2 - 2\lambda\cos\theta + 1

with discriminant

4cos2θ4=4sin2θ    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° 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=[0110]\mathbf{R} = \begin{bmatrix}0 & -1\\ 1 & 0\end{bmatrix}.

Characteristic polynomial: λ22λcos90°+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 (RiI)v=0(\mathbf{R} - i\mathbf{I})\mathbf{v} = \mathbf{0}:

[i11i][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=[0110][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 ii=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=12iw = 1 - 2i, every quantity by hand:

quantityworkingresult
z+wz + w(3+1)+(42)i(3+1) + (4-2)i4+2i4 + 2i
zwzw(314(2))+(3(2)+41)i(3\cdot1 - 4\cdot(-2)) + (3\cdot(-2) + 4\cdot1)i112i11 - 2i
z\lvert z\rvert9+16\sqrt{9 + 16}55
w\lvert w\rvert1+4\sqrt{1 + 4}52.2360680\sqrt5 \approx 2.2360680
zw\lvert zw\rvert555\sqrt511.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)(34i)=9+16(3+4i)(3-4i) = 9 + 1625=z225 = \lvert z\rvert^2

Check the last modulus directly: 112i=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 z1z2\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.

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