Complex Numbers Refresher
Fourier analysis is written in complex numbers because one complex exponential carries both the cosine and the sine of an oscillation, and multiplying complex numbers adds their angles. This refresher covers exactly what the course needs: Cartesian and polar forms, Euler's formula, conjugates and roots of unity. A longer treatment is in Calculus: Complex Numbers.
Two forms
A complex number (with ) is a point in the plane. In polar form , where is the magnitude and the angle. Euler's formula connects them:
Multiplying multiplies magnitudes and adds angles: .
import cmath, math
z = 3 + 4j
r, theta = abs(z), cmath.phase(z)
print("z =", z, " |z| =", r, " angle =", round(theta, 4), "rad =", round(math.degrees(theta), 2), "deg")
print("back from polar:", cmath.rect(r, theta))
w = cmath.exp(1j * math.pi / 2) # e^{i pi/2} = i
print("e^(i pi/2) =", complex(round(w.real, 12), round(w.imag, 12)))
print("z * i =", z * 1j, " angle grew by 90 deg:", round(math.degrees(cmath.phase(z * 1j)), 2))
print("Euler's identity e^(i pi) + 1 =", cmath.exp(1j * math.pi) + 1)z = (3+4j) |z| = 5.0 angle = 0.9273 rad = 53.13 deg
back from polar: (3.0000000000000004+3.9999999999999996j)
e^(i pi/2) = 1j
z * i = (-4+3j) angle grew by 90 deg: 143.13
Euler's identity e^(i pi) + 1 = 1.2246467991473532e-16j
The last line is up to rounding, a tiny imaginary part of about .
Conjugates
The conjugate reflects across the real axis. Useful facts: , , and so
A real cosine is the sum of two complex exponentials with opposite frequencies. That is why real signals have spectra at both and .
Roots of unity
The solutions of are for , equally spaced on the unit circle. They are the frequencies of the DFT, and their key property is that they sum to zero:
import numpy as np
N = 8
w = np.exp(2j * np.pi * np.arange(N) / N)
print("8th roots of unity:", [complex(round(z.real, 3) + 0.0, round(z.imag, 3) + 0.0) for z in w])
for m in (0, 1, 3, 8):
s = np.sum(w ** m)
print(f"sum of w^({m}k): {complex(round(s.real, 10) + 0.0, round(s.imag, 10) + 0.0)}")8th roots of unity: [(1+0j), (0.707+0.707j), 1j, (-0.707+0.707j), (-1+0j), (-0.707-0.707j), -1j, (0.707-0.707j)]
sum of w^(0k): (8+0j)
sum of w^(1k): 0j
sum of w^(3k): 0j
sum of w^(8k): (8+0j)
This orthogonality of roots of unity is the whole reason the DFT can be inverted.
In software
- Python has
complexand thecmathmodule built in; NumPy arrays usecomplex128(1jis the imaginary unit). Electrical engineers often write instead of , and so does Python. np.abs,np.angle,np.conj,np.real,np.imagwork element-wise on arrays.
Exercises
Exercise 1: Polar form
Write in polar form.
Answer
.
Solution
, and the point lies in the second quadrant at angle .
Exercise 2: Powers by angles
Compute using polar form.
Answer
Solution
, so .
Exercise 3: Cosine from exponentials (code)
Check numerically that for .
Answer
Both give 0.764842 (with zero imaginary part).
Solution
import cmath, math
th = 0.7
z = (cmath.exp(1j * th) + cmath.exp(-1j * th)) / 2
print(round(z.real, 6), round(z.imag, 12) + 0.0, round(math.cos(th), 6))0.764842 0.0 0.764842
Test yourself
Multiplying a complex number by …
- doubles its magnitude
- rotates it by 90 degrees
- conjugates it
- makes it real
Euler's formula states
The sum of all -th roots of unity () is…
- 1
- 0