10 Complex Numbers

10.1 Basics

A complex number zz is defined as z=a+ibz = a + ib where jj or i=−1i = \sqrt{-1}.
Re(zz) = a, Im(zz) = b.
By Fundamental Theorem of Algebra, every polynomial of degree nn is now guaranteed to have exactly nn roots. For example, a quadratic equation will always yield two roots—if they aren’t real, they will be complex.

10.1.1 Algebra w/ ii

i1=ii^1 = i, i2=−1i^2 = -1, i3=−ii^3 = -i, i4=1i^4 = 1.
Inverse of ii: 1i=−i\frac{1}{i} = -i.

The rule AB=AB\sqrt{A}\sqrt{B} = \sqrt{AB} only works if at least one of the numbers is positive.
If both are negative, we have to pull the ii out first.
For example, find −4−9\sqrt{-4}\sqrt{-9}. Wrong way is: −4−9=−4⋅−9=36=6\sqrt{-4}\sqrt{-9} = \sqrt{-4\cdot -9} =\sqrt{36} = 6.
Instead, do −4−9=i4⋅i9=2i⋅3i=6i2=−6\sqrt{-4}\sqrt{-9} = i\sqrt{4}\cdot i\sqrt{9} = 2i\cdot 3i = 6i^2 = -6.

10.1.2 Representing complex numbers

Representation of complex number on Argand diagram

3 ways to represent complex numbers:

  1. Rectangular/Cartesian form: z=a+ibz = a + ib.
    Best for addition/subtraction, and geometrically represents vector addition.

    • Multiplication: z1⋅z2=(a1a2−b1b2)+i(b1a2+a1b2)z_1 \cdot z_2 = (a_1a_2 - b_1b_2) + i(b_1a_2 + a_1b_2)

    • Division: z1z2=a1a2+b1b2a22+b22+jb1a2−a1b2a22+b22\frac{z_1}{z_2} = \frac{a_1a_2 + b_1b_2}{a_2^2 + b_2^2} + j\frac{b_1a_2 - a_1b_2}{a_2^2 + b_2^2}

  2. Polar form z=r∠θ=cos⁡θ+isin⁡θz = r\angle\theta = \cos\theta + i\sin\theta.
    The modulus is r=|z|=a2+b2r = |z| = \sqrt{a^2 + b^2}.
    The argument is θ\theta, measured anti-clockwise from the positive real axis.

    • Because angles loop every 2π2\pi radians (360∘360^\circ), an argument isn’t uniquely defined. To fix this, Principal Argument is limited to the range (−π,π](-\pi, \pi].

  3. Exponential z=reiθz = re^{i\theta}.
    Best for multiplication/division.

    • Multiplication: z1z2=(r1⋅r2)ei(θ1+θ2)z_1z_2 = (r_1 \cdot r_2)e^{i(\theta_1 + \theta_2)}

    • Division: z1z2=r1r2ei(θ1−θ2)\frac{z_1}{z_2} = \frac{r_1}{r_2}e^{i(\theta_1 - \theta_2)}

10.1.3 Complex conjugate

The complex conjugate of z=a+ibz = a + ib is z¯=a−ib\overline{z} = a - ib Geometrically, this complex vector is reflected in the Real axis.

10.2 De Moivre’s Theorem

Euler’s formula: eiθ=cos⁡(θ)+isin⁡(θ)e^{i\theta} = \cos(\theta) + i\sin(\theta) De Moivre’s Theorem: For a complex number zz and any integer nn, zn=(reiθ)n=rneinθ=rn(cos⁡(nθ)+isin⁡(nθ))z^n = (r e^{i\theta})^n = r^n e^{in\theta} = r^n(\cos(n\theta) + i\sin(n\theta)) De Moivre’s Theorem applied to roots:
z1/n=r1/nej(θ+2πkn)for k=0,1,…,n−1z^{1/n} = r^{1/n} e^{j(\frac{\theta + 2\pi k}{n})} \quad \text{for } k = 0, 1, \dots, n-1 So taking the nn-th root of a complex number will give nn distinct angles.

Example Find (1+j)−1/3(1+j)^{-1/3}.
First convert to exponential form. Magnitude r=12+12=2=21/2r = \sqrt{1^2 + 1^2} = \sqrt{2} = 2^{1/2}. Angle θ=arctan⁡(11)=π/4\theta = \arctan(\frac{1}{1}) = \pi/4.
Hence 1+j=2ejπ/41+j = \sqrt{2}e^{j\pi/4}.
Then we have zk=(2)−1/3ej(π/4+2πk−3)for k=0,1,2z_k = (\sqrt{2})^{-1/3} e^{j(\frac{\pi/4 + 2\pi k}{-3})} \quad \text{for } k = 0, 1, 2 Then for k=0k=0, z0=2−1/6e−jπ/12z_0 = 2^{-1/6} e^{-j\pi/12}, for k=1k=1, z1=2−1/6e−j3π/4z_1 = 2^{-1/6} e^{-j3\pi/4}, and for k=2k=2, z2=2−1/6ej7π/12z_2 = 2^{-1/6} e^{j7\pi/12}.
Geoemetrically, the three roots are spaced 2π3\frac{2\pi}{3} radians apart on a circle of radius 0.89.

10.3 Discrete Fourier Transform (DFT)

10.3.1 Complex exponentials & vectors

Think of complex numbers as moving geometric objects.
A complex exponential like eiθe^{i\theta} can be thought of as a rotating clock hand in the argand plane, around the centre.
eiθ=eiωne^{i\theta} = e^{i\omega n} Replacing the static angle θ\theta with ωn\omega n, where ω\omega can be thought of as the angular frequency (how many radians per sample) and nn is the sample we are measuring.
A complex vector then represents snapshots of the rotating clock hand. For example, a vector like z=[1i−1−i]⊤z = \begin{bmatrix} 1 & i & -1 & -i \end{bmatrix}^\top tell us that at each time-step (nn increasing by 1), we rotate anti-clockwise by π2\frac{\pi}{2} radians.
Further, stack these 2D snapshots on top of each other, and pull them forward along a time axis. We get a 3D spiral.

Visualisation of complex vectors/exponential

10.3.2 Inner product and inverse of complex matrices

If we have a complex vector like [1i]⊤\begin{bmatrix} 1 & i \end{bmatrix}^\top, and taking the dot product with itself, we get 1+(−1)=01 + (-1) = 0, which is impossible as the length of that vector is non-zero.
Instead, if we multiply a complex number with its conjugate, like (a+ib)(a−ib)=a2+b2(a+ib)(a-ib) = a^2 + b^2, we get the positive result desired.
Therefore, the inner product of complex vectors 𝒂\mathbf{a} and 𝒃\mathbf{b} is ⟨a,b⟩=bHa\langle a, b \rangle = b^H a where 𝒃H\mathbf{b}^H (Hermitian/conjugate transpose) transposes 𝒃\mathbf{b} and takes the conjugate of every imaginary number in it.
In the context of DFT, the inner product reveals the relationship between some signal wave and a basis wave. Two complex vectors are considered to be pointing in the same direction if they are rotating at the exact same frequency.
If the inner product outputs 0, the signal vector has zero component in the direction of the basis vector (orthogonal). In DFT, this means the specific frequency does not exist in the signal.
Otherwise, the complex scalar output reveals the magnitude and phase-shift to shift the signal wave so as to align it to the basis vector.

10.3.3 The real meat

A real-world signal is made of multiple pure waves

The idea of DFT is that any discrete time-signal x[n]x[n] of length NN can be decomposed into/rebuilt using NN basic waves.

The original signal is x[n]x[n] of length NN. This means we sampled NN discrete times from the original signal, and the values form the vector of NN complex numbers.

How to represent the basic waves?
Each basis vector contains NN complex numbers (same as the original signal).
We generate a basis vector for every harmonic frequency. There are NN of these basis vectors (indexed by k=0,1,…,N−1k = 0, 1, \ldots, N-1).
So to build the kk-th basis vector, we take NN time-steps through that basis vector, using the formula: ek[n]=ei2πNkne_k[n] = e^{i\frac{2\pi}{N}kn} Each basis vector thus looks like this: ek=[ei2πNk(0)ei2πNk(1)ei2πNk(2)⋮ei2πNk(N−1)]e_k = \begin{bmatrix} e^{i\frac{2\pi}{N}k(0)} \\ e^{i\frac{2\pi}{N}k(1)} \\ e^{i\frac{2\pi}{N}k(2)} \\ \vdots \\ e^{i\frac{2\pi}{N}k(N-1)} \end{bmatrix}
We use that specific complex exponential because:

As noted above, every basis vector is orthogonal to each other. ⟨ek,em⟩=∑n=0N−1ei2πNkn⋅e−i2πNmn=∑n=0N−1ei2πN(k−m)n=0[taking N evenly spaced points around a circle,and adding them up, will cancel each other out]\begin{align*} \langle e_k, e_m \rangle &= \sum_{n=0}^{N-1} e^{i\frac{2\pi}{N}kn} \cdot e^{-i\frac{2\pi}{N}mn}\\ &= \sum_{n=0}^{N-1} e^{i\frac{2\pi}{N}(k-m)n}\\ &= 0 \quad [\text{taking $N$ evenly spaced points around a circle,}\\ & \quad \text{and adding them up, will cancel each other out}] \end{align*}
Forward DFT (Analysis)
Forward DFT is breaking down the messy signal to find the frequencies that make up that signal.
From xx, we want XX, a column vector of NN frequency bins. Each term in XX, denoted as X[k]X[k] is a complex number.
The magnitude |X[k]||X[k]| tells us the amplitude of that specific frequency, and the phase ∠X[k]\angle X[k] tells us how much it is shifted left or right.
X=[X[0]X[1]X[2]⋮X[N−1]]=[DC Offset (0 Hz)1st Harmonic2nd Harmonic⋮Highest frequency]X = \begin{bmatrix} X[0] \\ X[1] \\ X[2] \\ \vdots \\ X[N-1] \end{bmatrix} = \begin{bmatrix} \text{DC Offset (0 Hz)} \\ \text{1st Harmonic} \\ \text{2nd Harmonic} \\ \vdots \\ \text{Highest frequency} \end{bmatrix} The forward DFT has the following matrix equation: X=WxX = Wx WW is an N×NN \times N matrix. Representing WN=e−j2πNW_N = e^{-j\frac{2\pi}{N}}, the formula for any term in WW is just WNknW_N^{kn}, at row kk and column nn. W=[WN0⋅0WN0⋅1WN0⋅2…WN0⋅(N−1)WN1⋅0WN1⋅1WN1⋅2…WN1⋅(N−1)WN2⋅0WN2⋅1WN2⋅2…WN2⋅(N−1)⋮⋮⋮⋱⋮WN(N−1)⋅0WN(N−1)⋅1WN(N−1)⋅2…WN(N−1)⋅(N−1)]=n increases →[111…11e−i2πN(1)(1)e−i2πN(1)(2)…e−i2πN(1)(N−1)1e−i2πN(2)(1)e−i2πN(2)(2)…e−i2πN(2)(N−1)⋮⋮⋮⋱⋮1e−i2πN(N−1)(1)e−i2πN(N−1)(2)…e−i2πN(N−1)(N−1)]kincreases↓\begin{align*} W &= \begin{bmatrix} W_N^{0\cdot0} & W_N^{0\cdot1} & W_N^{0\cdot2} & \dots & W_N^{0\cdot(N-1)} \\ W_N^{1\cdot0} & W_N^{1\cdot1} & W_N^{1\cdot2} & \dots & W_N^{1\cdot(N-1)} \\ W_N^{2\cdot0} & W_N^{2\cdot1} & W_N^{2\cdot2} & \dots & W_N^{2\cdot(N-1)} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ W_N^{(N-1)\cdot0} & W_N^{(N-1)\cdot1} & W_N^{(N-1)\cdot2} & \dots & W_N^{(N-1)\cdot(N-1)} \end{bmatrix}\\ % &= \begin{bmatrix} % 1 & 1 & 1 & \dots & 1 \\ % 1 & e^{-i\frac{2\pi}{N}(1)(1)} & e^{-i\frac{2\pi}{N}(1)(2)} & \dots & e^{-i\frac{2\pi}{N}(1)(N-1)} \\ % 1 & e^{-i\frac{2\pi}{N}(2)(1)} & e^{-i\frac{2\pi}{N}(2)(2)} & \dots & e^{-i\frac{2\pi}{N}(2)(N-1)} \\ % \vdots & \vdots & \vdots & \ddots & \vdots \\ % 1 & e^{-i\frac{2\pi}{N}(N-1)(1)} & e^{-i\frac{2\pi}{N}(N-1)(2)} & \dots & e^{-i\frac{2\pi}{N}(N-1)(N-1)} % \end{bmatrix} \\ &= \begin{matrix} \begin{matrix} n \text{ increases } \longrightarrow \end{matrix} \\ \begin{bmatrix} 1 & 1 & 1 & \dots & 1 \\ 1 & e^{-i\frac{2\pi}{N}(1)(1)} & e^{-i\frac{2\pi}{N}(1)(2)} & \dots & e^{-i\frac{2\pi}{N}(1)(N-1)} \\ 1 & e^{-i\frac{2\pi}{N}(2)(1)} & e^{-i\frac{2\pi}{N}(2)(2)} & \dots & e^{-i\frac{2\pi}{N}(2)(N-1)} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 1 & e^{-i\frac{2\pi}{N}(N-1)(1)} & e^{-i\frac{2\pi}{N}(N-1)(2)} & \dots & e^{-i\frac{2\pi}{N}(N-1)(N-1)} \end{bmatrix} \begin{matrix} k \\ \text{increases} \\ \downarrow \end{matrix} \end{matrix} \end{align*}
Note that every row is one basis vector/wave.
The exponents are negative so as to take the complex conjugate of the actual basis vector, for valid inner products. However, intuitively, if a signal contains some harmonic kk, it is spinning anti-clockwise at speed of 2πNk\frac{2\pi}{N}k. Our basis vector should then spin in the opposite direction (negative exponent) at the same speed, effectively unwinding that specific frequency. Mathematically, eiθ⋅e−iθ=e0=1e^{i\theta}\cdot e^{-i\theta} = e^0 = 1 Then adding up all the constant values, we get a massive spike for that frequency bin.
On the other hand, if the test wave spins at different speeds, it doesn’t perfectly unwind the signal, and the positive and negative peaks cancel out to 0.

By basic matrix multiplication, the kk-th entry of XX, X[k]X[k] is the inner product of the kk-th row of WW and the column vector xx. Hence we get the summation form of the forward DFT: X[k]=∑n=0N−1x[n]e−i2πNknX[k] = \sum_{n=0}^{N-1} x[n] e^{-i \frac{2\pi}{N} kn} Hence, we get XX from xx using WW, the matrix of basis vectors. Note that WW is fixed, and we can construct WW (from the complex exponential) so long as we know NN (from length of xx).

Backward DFT (Synthesis)
Now we have XX, the mix of different frequencies, and we want to get back xx, the original signal.
The matrix equation here is: x=1NWHXx = \frac{1}{N} W^H X Recall that WHW^H is the conjugate transpose of WW.
The exponents are positive, i.e. exp⁡i2πNkn\exp^{i\frac{2\pi}{N}kn}. Also, the columns of WHW^H are now the basis vectors.
So xx is the linear combination of the columns of WHW^H, and XX provides the weights to scale each corresponding frequency by.
Note that we need to multiply by 1N\frac{1}{N}. Since WH⋅W=NIW^H\cdot W = NI, and X=WxX = Wx, hence 1NWH⋅Wx=x\frac{1}{N}W^H\cdot W x = x balances the equation.
Each term of WHW^H is now ei2πNkne^{i\frac{2\pi}{N}k n} and the full matrix WHW^H is WH=k increases →[111…11ei2πN(1)(1)ei2πN(2)(1)…ei2πN(N−1)(1)1ei2πN(1)(2)ei2πN(2)(2)…ei2πN(N−1)(2)⋮⋮⋮⋱⋮1ei2πN(1)(N−1)ei2πN(2)(N−1)…ei2πN(N−1)(N−1)]nincreases↓W^H = \begin{matrix} \begin{matrix} k \text{ increases } \longrightarrow \end{matrix} \\ \begin{bmatrix} 1 & 1 & 1 & \dots & 1 \\ 1 & e^{i\frac{2\pi}{N}(1)(1)} & e^{i\frac{2\pi}{N}(2)(1)} & \dots & e^{i\frac{2\pi}{N}(N-1)(1)} \\ 1 & e^{i\frac{2\pi}{N}(1)(2)} & e^{i\frac{2\pi}{N}(2)(2)} & \dots & e^{i\frac{2\pi}{N}(N-1)(2)} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 1 & e^{i\frac{2\pi}{N}(1)(N-1)} & e^{i\frac{2\pi}{N}(2)(N-1)} & \dots & e^{i\frac{2\pi}{N}(N-1)(N-1)} \end{bmatrix} \begin{matrix} n \\ \text{increases} \\ \downarrow \end{matrix} \end{matrix} By matrix multiplication, the nn-th entry of xx is obtained by taking inner product of nn-th row of WHW^H and the column vector XX. I.e. the sum of all same time snapshot nn across all the different frequencies.

A note on the matrix WW, as we progress down the rows, kk increases. The waves spin faster.
For a purely real-valued xx, X[N−k]=X[k]¯X[N-k] = \overline{X[k]} I.e. frequencies that are symmetrical around the N/2N/2 point look like negative frequencies (spinning backwards).
Hence, a real-valued signal xx has unique information in rows 0 to N/2N/2, while rows N/2+1N/2 + 1 to N−1N-1 are redundant.
If xx is complex, every single one of the NN rows is unique and necessary