---
title: The complex Fourier series
heading: Spinning phasors for every harmonic
eyebrow: A10 · Lesson 3 · The complex Fourier series
xp: 40
---

::: hook
A sine and a cosine at the same frequency are really one phasor seen two ways (A3). So the Fourier series, with its separate cosine and sine coefficients, can be rewritten with a single complex coefficient per harmonic: one spinning phasor $c_ne^{jn\omega_0t}$ for each frequency, positive and negative. The formulas get shorter, the magnitudes and phases come out directly, and everything in the rest of the course (transforms, transfer functions, the FFT) uses this form.
:::

::: play
- A pulse train is high for a fraction $D$ of each 1 ms period. Its spectrum shows the size $|c_n|$ of each harmonic, doubled for the one-sided view.
- The tops of the lines follow a sinc curve. Where does the first null fall?
- At $D = 0.5$ (a square wave), every even harmonic vanishes. Why?
:::
:::

```sim plot
view: spectrum
x: t = 0..10m s
y: v = -0.5..1.5 V
samples: 1024
freq: f = 0..20k Hz
slider: D = 0.05..0.5 step 0.05 = 0.2
plot: step(cos(2*pi*1000*t) - cos(pi*D)) | label: pulse train
marker: f = 1000/D | label: first null
readout: DC level c0 = D | digits: 3
readout: first harmonic size 2|c1| = 2*D*abs(sin(pi*D)/(pi*D)) | digits: 3
```

::: predict
## A square wave switching between $+1$ and $-1$ is an odd function of time. What kind of numbers are its complex coefficients $c_n$?

- [ ] Real
- [x] Purely imaginary
- [ ] Zero
- [ ] Complex with equal real and imaginary parts

::: reveal
Purely imaginary. An odd signal is made only of sines, and $\sin\theta = \frac{e^{j\theta} - e^{-j\theta}}{2j}$, so each sine contributes imaginary coefficients. For the square wave, $c_n = \frac{2}{j\pi n}$ for odd $n$ and 0 for even $n$. Even signals, made of cosines, have real coefficients.
:::
:::

::: nameit
## The complex form

A periodic signal with period $T$ and $\omega_0 = 2\pi/T$ is

$$x(t) = \sum_{n=-\infty}^{\infty}c_ne^{jn\omega_0t}, \qquad c_n = \frac{1}{T}\int_0^Tx(t)e^{-jn\omega_0t}\,dt$$

Multiplying by $e^{-jn\omega_0t}$ and averaging picks out one harmonic, because the exponentials at different harmonics are orthogonal (A6, lesson 2).

## Connecting to sines and cosines

For a real signal, $c_{-n} = c_n^*$, so each pair of terms adds to a real sinusoid:

$$c_ne^{jn\omega_0t} + c_{-n}e^{-jn\omega_0t} = 2|c_n|\cos(n\omega_0t + \angle c_n)$$

So the $n$th harmonic has amplitude $2|c_n|$ and phase $\angle c_n$, and $c_n = \frac{a_n - jb_n}{2}$ in terms of the cosine and sine coefficients. $c_0$ is the average (DC) value.

## Symmetry shortcuts

| Symmetry | Coefficients |
|---|---|
| even, $x(-t) = x(t)$ | real: cosines only |
| odd, $x(-t) = -x(t)$ | imaginary: sines only |
| half-wave, $x(t + T/2) = -x(t)$ | odd harmonics only |

## The pulse train

A pulse train of height 1 that's on for a fraction $D$ of each period has

$$c_n = D\,\text{sinc}(nD) = D\frac{\sin(\pi nD)}{\pi nD}$$

The DC level is $D$, and the harmonics' sizes follow a sinc curve whose first null is at $n = 1/D$. Narrow pulses spread their energy over many harmonics.
:::

::: example
## Find the complex coefficients of the $\pm 1$ square wave.

::: solution
1. **Set up the integral.** Over one period it's $+1$ for the first half and $-1$ for the second, so for $n \ne 0$
   $$\begin{aligned} c_n &= \frac{1}{T}\int_0^{T/2}e^{-jn\omega_0t}dt \\ &\quad - \frac{1}{T}\int_{T/2}^Te^{-jn\omega_0t}dt \end{aligned}$$
2. **Evaluate it.**
   $$c_n = \frac{1 - (-1)^n}{j\pi n}$$
3. **Odd and even $n$.** That's $\frac{2}{j\pi n}$ for odd $n$ and 0 for even $n$.
4. **Check against the sine series.** The amplitudes match the sine series from lesson 1:
   $$2|c_n| = \frac{4}{\pi n}$$

**Answer:** $c_n = \frac{2}{j\pi n}$ for odd $n$ and 0 for even $n$.
:::
:::

::: example
## A 1 kHz pulse train of height 5 V has 20% duty. What are its DC level and the amplitude of its 1 kHz harmonic?

::: solution
1. **The DC level.**
   $$\begin{aligned} c_0 &= 5\ \text{V} \times 0.2 \\ &= 1\ \text{V} \end{aligned}$$
2. **The first coefficient.**
   $$\begin{aligned} c_1 &= 5 \times 0.2 \times \frac{\sin(0.2\pi)}{0.2\pi} \\ &= 1 \times 0.935 \\ &= 0.935\ \text{V} \end{aligned}$$
3. **The 1 kHz amplitude.**
   $$2|c_1| = 1.87\ \text{V}$$

**Answer:** the DC level is 1 V, and the 1 kHz component has an amplitude of 1.87 V.
:::
:::

::: example
## Find the complex coefficients $c_0$ and $c_1$ of the full-wave rectified sine $|\sin t|$, whose period is $\pi$.

::: solution
1. **Set up the integral.** With period $\pi$, the fundamental frequency is 2 rad/s, so
   $$c_n = \frac1\pi\int_0^\pi\sin t\,e^{-j2nt}\,dt$$
2. **Evaluate it.**
   $$c_n = -\frac{2}{\pi(4n^2 - 1)}$$
3. **The DC term.**
   $$\begin{aligned} c_0 &= \frac2\pi \\ &= 0.637 \end{aligned}$$
4. **The first harmonic.**
   $$\begin{aligned} c_1 &= -\frac{2}{3\pi} \\ &= -0.212 \end{aligned}$$
5. **What it means.** The DC level is twice a half-wave rectifier's (both halves are kept), and there's no component at the original 1 rad/s at all: the ripple starts at twice the input frequency.

**Answer:** $c_0 = 0.637$ and $c_1 = -0.212$.
:::
:::

::: check
given: n = 1 | 3 | 5
answer: 2/(pi*n)
tolerance: 0.5%

## For the $\pm 1$ square wave, what is $|c_n|$ for $n$ = {n}?

::: right
Right. $\left|\frac{2}{j\pi n}\right| = \frac{2}{\pi n}$ = {answer}; the harmonic's amplitude is twice that.
:::

::: misses
- [4/(pi*n)] That's the amplitude $2|c_n|$. Each complex coefficient carries half.
- [any] Not yet. $c_n = \frac{2}{j\pi n}$ for odd $n$.
:::
:::

::: check
given: A = 5 | 3.3; D = 0.1 | 0.25
answer: A*D

## A pulse train of height {A} V has duty cycle {D}. What is its DC level $c_0$?

::: right
Right. The average, $AD$ = {answer} V.
:::

::: misses
- [A/2] That's for 50% duty.
- [any] Not yet. The average over a period.
:::
:::

::: check
given: A = 5 | 10; D = 0.2 | 0.25; n = 1 | 2
answer: 2*A*D*abs(sin(pi*n*D)/(pi*n*D))
tolerance: 0.5%

## A pulse train of height {A} V and duty {D}: what is the amplitude of harmonic {n}?

::: right
Right. $2|c_n| = 2AD\left|\frac{\sin(\pi nD)}{\pi nD}\right|$ = {answer} V.
:::

::: misses
- [A*D*abs(sin(pi*n*D)/(pi*n*D))] That's $|c_n|$; the amplitude is twice it.
- [any] Not yet. $c_n = AD\,\text{sinc}(nD)$.
:::
:::

::: check
given: D = 0.1 | 0.2 | 0.25
answer: 1/D

## A pulse train has duty cycle {D}. Which harmonic is the first to vanish?

::: right
Right. $\text{sinc}(nD) = 0$ first when $nD = 1$: harmonic {answer}.
:::

::: misses
- [2/D] The first null is at $nD = 1$.
- [any] Not yet. Where is $\sin(\pi nD) = 0$ first?
:::
:::

::: check
given: a = 4 | 2; b = 3 | -2
answer: sqrt(a^2 + b^2)/2
tolerance: 0.5%

## A harmonic is $\given{a}\cos(n\omega_0t) + \given{b}\sin(n\omega_0t)$. What is $|c_n|$?

::: right
Right. $c_n = \frac{a - jb}{2}$, so $|c_n| = \frac{\sqrt{a^2 + b^2}}{2}$ = {answer}.
:::

::: misses
- [sqrt(a^2 + b^2)] That's the amplitude; $c_n$ carries half.
- [(a + b)/2] Combine at right angles: $\sqrt{a^2 + b^2}$.
- [any] Not yet. $c_n = \frac{a_n - jb_n}{2}$.
:::
:::

::: check
kind: choice

## A signal has half-wave symmetry, $x(t + T/2) = -x(t)$. Which harmonics can it contain?

- [x] Only odd harmonics
- [ ] Only even harmonics
- [ ] Only the fundamental
- [ ] All harmonics

::: right
Right. Shifting by half a period flips the sign of odd harmonics and leaves even ones alone, so the even ones must be zero.
:::

::: misses
- [2] Even harmonics are unchanged by a half-period shift, so they can't satisfy $x(t + T/2) = -x(t)$.
- [any] What does a half-period shift do to harmonic $n$?
:::
:::

::: check
kind: parts
given: A = 1 | 10; n = 1 | 2

## The full-wave rectified sine $\given{A}|\sin t|$ has $c_n = -\frac{2A}{\pi(4n^2 - 1)}$.

::: part
answer: 2*A/pi
tolerance: 0.5%

### What is $c_0$, its DC level?

::: misses
- [A/pi] That's the half-wave rectifier's.
- [any] Set $n = 0$.
:::
:::

::: part
answer: 4*A/(pi*(4*n^2 - 1))
tolerance: 0.5%

### What is the amplitude $2|c_n|$ of the harmonic at $2\given{n}$ rad/s?

::: misses
- [2*A/(pi*(4*n^2 - 1))] That's $|c_n|$; a real harmonic's amplitude is twice it.
- [any] $2|c_n|$.
:::
:::
:::

::: check
kind: derivation
vars: d = 0.05..0.95, A = 1..10, n = 1..5

## A pulse train of height $A$ and duty $d$.

::: step
answer: A*d

### What is $c_0$?
:::

::: step
answer: A*sin(pi*n*d)/(pi*n)

### $c_n = \frac{A}{\pi n}\sin(\pi nd)$ up to a phase. Evaluate it.
:::

::: right
Right. A sinc envelope: as the pulses narrow, the harmonics spread out and shrink together.
:::
:::

::: explain
## Why is $c_{-n}$ the complex conjugate of $c_n$ for a real signal?

::: model
A real signal is its own complex conjugate. Conjugating the series $\sum c_ne^{jn\omega_0t}$ gives $\sum c_n^*e^{-jn\omega_0t}$, which is the same series with each coefficient moved from $n$ to $-n$ and conjugated. For the two to be equal, the coefficient at $-n$ must be $c_n^*$. Physically, each real sinusoid is a pair of phasors spinning in opposite directions whose imaginary parts cancel, leaving a real signal.
:::
:::

::: practice

::: check
given: A = 2 | 12; D = 0.5 | 0.3
answer: A*D

## What is the average of a pulse train of height {A} V and duty {D}?

::: misses
- [any] $AD$.
:::
:::

::: check
given: a = 6 | 1; b = 8 | 1
answer: atan(-b/a)*180/pi
tolerance: 0.5%

## A harmonic is $\given{a}\cos + \given{b}\sin$. What is the angle of $c_n$, in degrees?

::: misses
- [atan(b/a)*180/pi] $c_n = \frac{a - jb}{2}$: the imaginary part is $-b$.
- [any] The angle of $a - jb$.
:::
:::

::: check
given: n = 2 | 4 | 6 | 8 | 10 | 12
answer: 0

## What is $c_{\given{n}}$ for the $\pm 1$ square wave?

::: misses
- [any] Even harmonics vanish.
:::
:::
:::
