TExcelTAD
Home › Linear Algebra & Matrix Theory › The Complex Numbers

The Complex Numbers

The complex numbers extend the reals with one new number ii whose square is −1. With them every polynomial has roots, every matrix has eigenvalues, and rotations become multiplications. This appendix collects the facts the rest of the course uses.

Definition and arithmetic

A complex number is z=a+biz = a + bi with real a,ba, b, where i2=−1i^2 = -1. We call a=Re⁡za = \operatorname{Re} z the real part and b=Im⁡zb = \operatorname{Im} z the imaginary part. The set of all of them is C\mathbb{C}. Arithmetic follows the usual rules of algebra, replacing i2i^2 by −1 whenever it appears:

Operation Rule
Addition (a+bi)+(c+di)=(a+c)+(b+d)i(a + bi) + (c + di) = (a + c) + (b + d)i
Multiplication (a+bi)(c+di)=(ac−bd)+(ad+bc)i(a + bi)(c + di) = (ac - bd) + (ad + bc)i
Conjugate a+bi‾=zˉ=a−bi\overline{a + bi} = \bar{z} = a - bi
Modulus ∣z∣=a2+b2\lvert z \rvert = \sqrt{a^2 + b^2}, and zzˉ=∣z∣2z\bar{z} = \lvert z \rvert^2
Division z/w=zwˉ/∣w∣2z / w = z\bar{w} / \lvert w \rvert^2 for w≠0w \ne 0

For example, (2+3i)(1−i)=2−2i+3i−3i2=2+i+3=5+i(2 + 3i)(1 - i) = 2 - 2i + 3i - 3i^2 = 2 + i + 3 = 5 + i, and

5+i1−i=(5+i)(1+i)∣1−i∣2=5+5i+i+i22=4+6i2=2+3i\frac{5 + i}{1 - i} = \frac{(5 + i)(1 + i)}{\lvert 1 - i \rvert^2} = \frac{5 + 5i + i + i^2}{2} = \frac{4 + 6i}{2} = 2 + 3i

which undoes the multiplication, as it should.

C\mathbb{C} is a field

Addition and multiplication of complex numbers satisfy every field axiom: both are commutative and associative, multiplication distributes over addition, 0 and 1 are the identities, and every nonzero zz has an inverse 1/z=zˉ/∣z∣21/z = \bar{z}/\lvert z \rvert^2. So everything in this course that only used field operations, Gaussian elimination, inverses, determinants, works unchanged over C\mathbb{C}. One thing C\mathbb{C} does not have is an ordering: there is no sensible way to say i>0i > 0 or i<0i < 0.

Useful conjugate rules: z+w‾=zˉ+wˉ\overline{z + w} = \bar{z} + \bar{w}, zw‾=zˉ wˉ\overline{zw} = \bar{z}\,\bar{w}, z+zˉ=2Re⁡zz + \bar{z} = 2\operatorname{Re} z, z−zˉ=2iIm⁡zz - \bar{z} = 2i\operatorname{Im} z, and zz is real exactly when z=zˉz = \bar{z}.

Complex numbers in Python

Python has complex numbers built in, written with j (the engineers' letter) instead of ii. NumPy handles complex arrays, and SymPy uses I for exact work.

python · try it yourself
import cmath

z, w = 2 + 3j, 1 - 1j
print("z * w      =", z * w)
print("(z*w) / w  =", (z * w) / w)
print("conjugate  =", z.conjugate(), "  |z| =", round(abs(z), 4))
print("z * conj z =", z * z.conjugate())
print("sqrt(-4)   =", cmath.sqrt(-4))
print("Re, Im     =", z.real, z.imag)
z * w      = (5+1j)
(z*w) / w  = (2+3j)
conjugate  = (2-3j)   |z| = 3.6056
z * conj z = (13+0j)
sqrt(-4)   = 2j
Re, Im     = 2.0 3.0

math.sqrt(-4) raises an error; cmath.sqrt works in C\mathbb{C}. SymPy gives exact results:

python · try it yourself
from sympy import I, sqrt, simplify, expand, conjugate, Abs, solve, symbols

z = 2 + 3*I
print("1/z =", simplify(1 / z))
print("(1 + I)**8 =", expand((1 + I)**8))
print("|z| =", Abs(z), "  conj =", conjugate(z))
x = symbols("x")
print("roots of x**2 + 2*x + 5:", solve(x**2 + 2*x + 5, x))
1/z = 2/13 - 3*I/13
(1 + I)**8 = 16
|z| = sqrt(13)   conj = 2 - 3*I
roots of x**2 + 2*x + 5: [-1 - 2*I, -1 + 2*I]

Solving quadratics

With complex numbers the quadratic formula always works. For ax2+bx+c=0ax^2 + bx + c = 0 with real coefficients and negative discriminant D=b2−4ac<0D = b^2 - 4ac < 0, the roots are

x=−b±i−D2ax = \frac{-b \pm i\sqrt{-D}}{2a}

a conjugate pair. In general, if a polynomial has real coefficients and zz is a root, then so is zˉ\bar{z} (conjugate both sides of p(z)=0p(z) = 0). This is why real matrices have their complex eigenvalues in conjugate pairs.

Matrices of complex numbers

Since C\mathbb{C} is a field, matrices with complex entries can be added, multiplied, row-reduced and inverted as usual:

python · try it yourself
import numpy as np

A = np.array([[1, 1j], [2, 1 + 1j]])
b = np.array([1, 0])
x = np.linalg.solve(A, b)
print("det A =", np.round(np.linalg.det(A), 10))
print("x =", np.round(x, 4), "  check A x =", np.round(A @ x, 10) + 0)
det A = (1-1j)
x = [ 0.+1.j -1.-1.j]   check A x = [1.+0.j 0.+0.j]

(det⁡A=1⋅(1+i)−i⋅2=1−i\det A = 1 \cdot (1 + i) - i \cdot 2 = 1 - i.)

In software

  • Signal processing and audio. FFT output is complex: the modulus is the amplitude of a frequency, the angle its phase.
  • Electronics. AC circuit analysis uses complex impedances, so that capacitors and inductors become "complex resistors" in the same linear equations as resistor networks.
  • Graphics. 2D rotations are multiplication by complex numbers of modulus 1 (next lesson); fractals like the Mandelbrot set iterate z→z2+cz \to z^2 + c.
  • Quantum computing. Amplitudes are complex numbers (Unitary and Hermitian Matrices).

Exercises

Exercise 1: Multiply and divide

Compute (3−2i)(4+i)(3 - 2i)(4 + i) and (3−2i)/(4+i)(3 - 2i)/(4 + i).

Answer

14−5i14 - 5i and (10−11i)/17(10 - 11i)/17.

Solution
(3−2i)(4+i)=12+3i−8i−2i2=12−5i+2=14−5i3−2i4+i=(3−2i)(4−i)17=12−3i−8i+2i217=10−11i17\begin{aligned} (3 - 2i)(4 + i) &= 12 + 3i - 8i - 2i^2 = 12 - 5i + 2 = 14 - 5i \\ \frac{3 - 2i}{4 + i} &= \frac{(3 - 2i)(4 - i)}{17} = \frac{12 - 3i - 8i + 2i^2}{17} = \frac{10 - 11i}{17} \end{aligned}

Exercise 2: Powers of ii

What is i2026i^{2026}?

Answer

−1.

Solution

Powers of ii repeat with period 4: i,−1,−i,1i, -1, -i, 1. 2026=4⋅506+22026 = 4 \cdot 506 + 2, so i2026=i2=−1i^{2026} = i^2 = -1.

Exercise 3: Complex roots

Solve x2−4x+13=0x^2 - 4x + 13 = 0.

Answer

x=2±3ix = 2 \pm 3i.

Solution

D=16−52=−36D = 16 - 52 = -36, −D=6\sqrt{-D} = 6, so x=4±6i2=2±3ix = \frac{4 \pm 6i}{2} = 2 \pm 3i. Check: (2+3i)2=4+12i−9=−5+12i(2 + 3i)^2 = 4 + 12i - 9 = -5 + 12i, and −5+12i−4(2+3i)+13=−5+12i−8−12i+13=0-5 + 12i - 4(2 + 3i) + 13 = -5 + 12i - 8 - 12i + 13 = 0.

Exercise 4: Inverse of a complex matrix (code)

Find the inverse of [1ii2]\begin{bmatrix} 1 & i \\ i & 2 \end{bmatrix}.

Answer

13[2−i−i1]\frac{1}{3}\begin{bmatrix} 2 & -i \\ -i & 1 \end{bmatrix}.

Solution

det⁡=1⋅2−i⋅i=2+1=3\det = 1 \cdot 2 - i \cdot i = 2 + 1 = 3. The 2×22 \times 2 formula swaps the diagonal and negates the off-diagonal entries, then divides by det⁡\det.

python · try it yourself
from sympy import Matrix, I
A = Matrix([[1, I], [I, 2]])
print(A.det(), A.inv().tolist())
3 [[2/3, -I/3], [-I/3, 1/3]]

Test yourself

What is (1+i)2(1 + i)^2?

  1. 2
  2. 2i2i
  3. 0
  4. 1+i21 + i^2

If 3−4i3 - 4i is a root of a polynomial with real coefficients, which other number must be a root?

  1. −3+4i-3 + 4i
  2. 4−3i4 - 3i
  3. 3+4i3 + 4i
  4. None necessarily

How do you write the imaginary unit in plain Python?

  1. i
  2. 1j
  3. I
  4. sqrt(-1)