Unit 8, lesson 112

Fourier Coefficients and Fourier Series

How to write a periodic function as a sum of sines and cosines, compute its Fourier coefficients for any period, use symmetry to save work and read the coefficients as a spectrum.

  • Theory part 223
  • Practice part 224
  • Fourier Expansions

A chord played on a piano is one wave, yet your ear hears separate notes inside it. Fourier series do the same thing with any periodic function. They split it into a constant plus harmonics, and the orthogonality of sines and cosines tells you exactly how much of each harmonic is present.

Key terms

Fourier series

Definition Let ff be periodic with period 2π2\pi and integrable on [−π,π][-\pi, \pi]. The Fourier series of ff is the trigonometric series

f(x)∼a02+∑n=1∞(ancos⁡(nx)+bnsin⁡(nx)),f(x) \sim \frac{a_0}{2} + \sum_{n=1}^{\infty} \bigl(a_n \cos(nx) + b_n \sin(nx)\bigr),

with the coefficients ana_n and bnb_n defined below. The symbol ∼\sim means the series is attached to ff. Whether and where it converges to f(x)f(x) is a separate question.

In plain words It is a recipe for rebuilding ff from a constant and the harmonics cos⁡(nx)\cos(nx) and sin⁡(nx)\sin(nx), each with its own weight.

Example The square wave equal to −1-1 on (−π,0)(-\pi, 0) and 11 on (0,π)(0, \pi), repeated with period 2π2\pi, has Fourier series

4π(sin⁡x+sin⁡(3x)3+sin⁡(5x)5+⋯ ).\frac{4}{\pi}\left(\sin x + \frac{\sin(3x)}{3} + \frac{\sin(5x)}{5} + \cdots\right).

The coefficients are computed in the next section.

Sine and cosine coefficients

Definition The Fourier coefficients of a 2π2\pi-periodic ff that is integrable on [−π,π][-\pi, \pi] are

an=1π∫−ππf(x)cos⁡(nx) dx(n≥0),bn=1π∫−ππf(x)sin⁡(nx) dx(n≥1).a_n = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \cos(nx) \, dx \quad (n \ge 0), \qquad b_n = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \sin(nx) \, dx \quad (n \ge 1).

These formulas come from orthogonality. If ff equaled a uniformly convergent trigonometric series, multiplying by cos⁡(mx)\cos(mx) and integrating term by term would kill every term except the one with ama_m, leaving

∫−ππf(x)cos⁡(mx) dx=πam\int_{-\pi}^{\pi} f(x) \cos(mx) \, dx = \pi a_m

for m≥1m \ge 1, and 2π2\pi times the constant term for m=0m = 0.

In plain words To find how much of cos⁡(nx)\cos(nx) is in ff, take the inner product of ff with cos⁡(nx)\cos(nx) and divide by π\pi. Same for sine.

Example For the square wave every ana_n is 00, because f(x)cos⁡(nx)f(x)\cos(nx) is odd. For bnb_n,

bn=1π(∫−π0−sin⁡(nx) dx+∫0πsin⁡(nx) dx)=2π⋅1−cos⁡(nπ)n=2(1−(−1)n)nπ.b_n = \frac{1}{\pi}\left(\int_{-\pi}^{0} -\sin(nx) \, dx + \int_{0}^{\pi} \sin(nx) \, dx\right) = \frac{2}{\pi} \cdot \frac{1 - \cos(n\pi)}{n} = \frac{2\bigl(1 - (-1)^n\bigr)}{n\pi}.

So bn=4nπb_n = \frac{4}{n\pi} for odd nn and bn=0b_n = 0 for even nn.

Constant term

Definition The constant term of the Fourier series is

a02=12π∫−ππf(x) dx,\frac{a_0}{2} = \frac{1}{2\pi} \int_{-\pi}^{\pi} f(x) \, dx,

the average value of ff over one period. The factor 12\frac{1}{2} is there so that the single formula for ana_n also covers n=0n = 0.

In plain words The constant term is the level the function oscillates around.

Example For f(x)=x2f(x) = x^2 on [−π,π][-\pi, \pi], extended with period 2π2\pi,

a02=12π∫−ππx2 dx=12π⋅2π33=π23.\frac{a_0}{2} = \frac{1}{2\pi} \int_{-\pi}^{\pi} x^2 \, dx = \frac{1}{2\pi} \cdot \frac{2\pi^3}{3} = \frac{\pi^2}{3}.

Symmetry

Definition Let ff be 2π2\pi-periodic and integrable on [−π,π][-\pi, \pi].

If ff is even, then bn=0b_n = 0 for all n≥1n \ge 1 and

an=2π∫0πf(x)cos⁡(nx) dx(n≥0),a_n = \frac{2}{\pi} \int_0^{\pi} f(x) \cos(nx) \, dx \qquad (n \ge 0),

so the series has cosines only. If ff is odd, then an=0a_n = 0 for all n≥0n \ge 0 and

bn=2π∫0πf(x)sin⁡(nx) dx(n≥1),b_n = \frac{2}{\pi} \int_0^{\pi} f(x) \sin(nx) \, dx \qquad (n \ge 1),

so the series has sines only.

This follows because an odd function integrates to 00 over [−π,π][-\pi, \pi], and an even one integrates to twice its integral over [0,π][0, \pi].

In plain words Check symmetry first. It can cut the work in half and tells you which coefficients vanish without computing them.

Example The function f(x)=x2f(x) = x^2 is even. Integrating by parts twice,

an=2π∫0πx2cos⁡(nx) dx=4(−1)nn2,n≥1,a_n = \frac{2}{\pi} \int_0^{\pi} x^2 \cos(nx) \, dx = \frac{4(-1)^n}{n^2}, \qquad n \ge 1,

so on [−π,π][-\pi, \pi]

x2∼π23+4∑n=1∞(−1)nn2cos⁡(nx).x^2 \sim \frac{\pi^2}{3} + 4\sum_{n=1}^{\infty} \frac{(-1)^n}{n^2} \cos(nx).

Arbitrary period

Definition If ff has period 2L2L with L>0L > 0 and is integrable on [−L,L][-L, L], its Fourier series is

f(x)∼a02+∑n=1∞(ancos⁡nπxL+bnsin⁡nπxL),f(x) \sim \frac{a_0}{2} + \sum_{n=1}^{\infty} \left(a_n \cos\frac{n\pi x}{L} + b_n \sin\frac{n\pi x}{L}\right),an=1L∫−LLf(x)cos⁡nπxL dx,bn=1L∫−LLf(x)sin⁡nπxL dx.a_n = \frac{1}{L} \int_{-L}^{L} f(x) \cos\frac{n\pi x}{L} \, dx, \qquad b_n = \frac{1}{L} \int_{-L}^{L} f(x) \sin\frac{n\pi x}{L} \, dx.

The symmetry rules hold with the factor 2L\frac{2}{L} and integrals over [0,L][0, L] in place of 2π\frac{2}{\pi} and [0,π][0, \pi].

In plain words Stretch the harmonics so that they fit the period 2L2L, and divide by LL instead of π\pi.

Example Let f(x)=xf(x) = x on (−1,1)(-1, 1) with period 22, so L=1L = 1. It is odd, and

bn=2∫01xsin⁡(nπx) dx=2([−xcos⁡(nπx)nπ]01+∫01cos⁡(nπx)nπ dx)=2(−1)n+1nπ.b_n = 2 \int_0^1 x \sin(n\pi x) \, dx = 2\left(\left[-\frac{x \cos(n\pi x)}{n\pi}\right]_0^1 + \int_0^1 \frac{\cos(n\pi x)}{n\pi} \, dx\right) = \frac{2(-1)^{n+1}}{n\pi}.

So on (−1,1)(-1, 1)

x∼2π(sin⁡(πx)−sin⁡(2πx)2+sin⁡(3πx)3−⋯ ).x \sim \frac{2}{\pi}\left(\sin(\pi x) - \frac{\sin(2\pi x)}{2} + \frac{\sin(3\pi x)}{3} - \cdots\right).

Partial sums

Definition The NNth partial sum of the Fourier series of a 2π2\pi-periodic ff is the trigonometric polynomial

SN(x)=a02+∑n=1N(ancos⁡(nx)+bnsin⁡(nx)).S_N(x) = \frac{a_0}{2} + \sum_{n=1}^{N} \bigl(a_n \cos(nx) + b_n \sin(nx)\bigr).

The series converges at xx when SN(x)S_N(x) has a limit as N→∞N \to \infty.

In plain words Keep the first NN harmonics and drop the rest. Watching SNS_N as NN grows shows the series building up the function.

Example For the square wave at x=π2x = \frac{\pi}{2}, where f=1f = 1, the odd sines alternate in sign.

NNSN(π/2)S_N(\pi/2)
111.27321.2732
330.84880.8488
551.10351.1035
770.92160.9216

The values swing above and below 11 and close in on it.

Spectral interpretation

Definition For n≥1n \ge 1 the amplitude of the nnth harmonic is An=an2+bn2A_n = \sqrt{a_n^2 + b_n^2}, and for a suitable phase φn\varphi_n

ancos⁡(nx)+bnsin⁡(nx)=Ancos⁡(nx−φn).a_n \cos(nx) + b_n \sin(nx) = A_n \cos(nx - \varphi_n).

The sequence (An)(A_n) is the amplitude spectrum of ff. For ff that is piecewise continuous on [−π,π][-\pi, \pi], Parseval’s identity holds,

1π∫−ππf(x)2 dx=a022+∑n=1∞(an2+bn2).\frac{1}{\pi} \int_{-\pi}^{\pi} f(x)^2 \, dx = \frac{a_0^2}{2} + \sum_{n=1}^{\infty} \bigl(a_n^2 + b_n^2\bigr).

In plain words The coefficients say how strongly each frequency is present. Parseval says the total energy of ff is the sum of the energies of its harmonics.

Example The square wave has An=4nπA_n = \frac{4}{n\pi} for odd nn and 00 for even nn, so only odd harmonics are present and they fade like 1n\frac{1}{n}. Since f2=1f^2 = 1, Parseval gives

2=16π2(1+19+125+⋯ ),so1+132+152+⋯=π28.2 = \frac{16}{\pi^2}\left(1 + \frac{1}{9} + \frac{1}{25} + \cdots\right), \qquad \text{so} \qquad 1 + \frac{1}{3^2} + \frac{1}{5^2} + \cdots = \frac{\pi^2}{8}.

Check yourself

  1. Find the Fourier series of f(x)=∣x∣f(x) = \lvert x \rvert on [−π,π][-\pi, \pi], extended with period 2π2\pi.
Show the answer

The function is even, so bn=0b_n = 0. The cosine coefficients are

a0=2π∫0πx dx=πa_0 = \frac{2}{\pi}\int_0^{\pi} x \, dx = \pi

and, for n≥1n \ge 1,

an=2π∫0πxcos⁡(nx) dx=2((−1)n−1)πn2,a_n = \frac{2}{\pi}\int_0^{\pi} x \cos(nx) \, dx = \frac{2\bigl((-1)^n - 1\bigr)}{\pi n^2},

which is −4πn2-\frac{4}{\pi n^2} for odd nn and 00 for even nn. So

∣x∣∼π2−4π(cos⁡x+cos⁡(3x)9+cos⁡(5x)25+⋯ ).\lvert x \rvert \sim \frac{\pi}{2} - \frac{4}{\pi}\left(\cos x + \frac{\cos(3x)}{9} + \frac{\cos(5x)}{25} + \cdots\right).
  1. A function with period 44 equals 00 on (−2,0)(-2, 0) and 11 on (0,2)(0, 2). What is the constant term of its Fourier series?
Show the answer

The constant term is the average over one period,

a02=14∫−22f(x) dx=24=12.\frac{a_0}{2} = \frac{1}{4}\int_{-2}^{2} f(x) \, dx = \frac{2}{4} = \frac{1}{2}.
  1. Which coefficients of an odd 2π2\pi-periodic function must be zero, and why?
Show the answer

All ana_n, including a0a_0. The product f(x)cos⁡(nx)f(x)\cos(nx) is odd, so its integral over [−π,π][-\pi, \pi] is 00.

How this lesson connects