Differential Equations · Undergraduate

Fourier Series: Functions as Sums of Sines and Cosines

Quick answer

A Fourier series writes a function on −π < x < π, repeated with period 2π, as a sum of sines and cosines. The coefficients come from integrals: aₙ = (1/π)∫ f(x) cos nx dx and bₙ = (1/π)∫ f(x) sin nx dx. They work because different sines and cosines are orthogonal, so their products integrate to zero. Odd functions need only sines and even functions only cosines. The square wave becomes (4/π)(sin x + sin 3x/3 + sin 5x/5 + ⋯), and at a jump the series converges to the midpoint.

What you'll learn

  • Compute Fourier coefficients on (−π, π)
  • Use symmetry to skip the sine or cosine terms
  • Explain the coefficient formulas with orthogonality
  • Find the value a Fourier series converges to at a jump

Building waves from sines and cosines

Musical notes, heat flow and signals are all built from waves. A Fourier series writes a function on −π<x<π-\pi < x < \pi, repeated with period 2π2\pi, as

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

with coefficients

an=1π∫−ππf(x)cos⁡nx dxbn=1π∫−ππf(x)sin⁡nx dxa_n = \frac{1}{\pi}\int_{-\pi}^{\pi} f(x)\cos nx\,dx \qquad b_n = \frac{1}{\pi}\int_{-\pi}^{\pi} f(x)\sin nx\,dx

Symmetry saves work. If ff is odd, every an=0a_n = 0; if ff is even, every bn=0b_n = 0.

Why the coefficient formulas work

Over a full period, the basic waves are orthogonal: for whole numbers mm and nn,

∫−ππsin⁡mxcos⁡nx dx=0,∫−ππsin⁡mxsin⁡nx dx={πm=n0m≠n\int_{-\pi}^{\pi} \sin mx\cos nx\,dx = 0, \qquad \int_{-\pi}^{\pi} \sin mx\sin nx\,dx = \begin{cases} \pi & m = n\\ 0 & m \ne n \end{cases}

and the same for cosines. Multiply the series by sin⁡nx\sin nx and integrate. Every term dies except bnsin⁡nx⋅sin⁡nxb_n\sin nx \cdot \sin nx, which integrates to πbn\pi b_n. Dividing by π\pi gives the formula. It is the same idea as finding a vector’s coordinates in an orthogonal basis with dot products, in an infinite-dimensional space of functions.

Worked examples

Partial sums of the square wave The square wave, −1 on the left half and 1 on the right half of −π to π, drawn as two flat segments. A one-term partial sum, a single sine hump, follows it roughly. A three-term sum is flatter, with small ripples, and closer to the square shape. −3−2−1123−11xy
  • one term
  • three terms
Partial sums of the square wave

Common mistakes

Practice problems

  1. For f(x)=xf(x) = x, find b1b_1, b2b_2 and b3b_3.

    Answer

    22, −1-1, 23\tfrac{2}{3}

    Full solution

    bn=2(−1)n+1nb_n = \tfrac{2(-1)^{n+1}}{n}.

  2. Which coefficients of f(x)=∣x∣f(x) = \lvert x\rvert are zero?

    Answer

    All the bnb_n

    Full solution

    ∣x∣\lvert x\rvert is even, so its series has only cosines.

  3. For the square wave, find b3b_3 and b4b_4.

    Answer

    43π\tfrac{4}{3\pi} and 00

    Full solution

    bn=2nπ(1−cos⁡nπ)b_n = \tfrac{2}{n\pi}(1 - \cos n\pi), which is 00 for even nn.

  4. For f(x)=∣x∣f(x) = \lvert x\rvert, find the constant term a02\tfrac{a_0}{2}.

    Answer

    π2\tfrac{\pi}{2}

    Full solution

    a0=1π∫−ππ∣x∣ dx=1π⋅π2=πa_0 = \tfrac{1}{\pi}\int_{-\pi}^{\pi} \lvert x\rvert\,dx = \tfrac{1}{\pi} \cdot \pi^2 = \pi, and the average value of ∣x∣\lvert x\rvert is π2\tfrac{\pi}{2}.

  5. What is the Fourier series of f(x)=3sin⁡2x+cos⁡xf(x) = 3\sin 2x + \cos x?

    Answer

    Itself: b2=3b_2 = 3, a1=1a_1 = 1, all others 00

    Full solution

    A finite sum of the basic waves is already a Fourier series, and the coefficients are unique.

  6. To what value does the square wave series converge at x=0x = 0?

    Answer

    00

    Full solution

    Every sin⁡(n⋅0)=0\sin(n \cdot 0) = 0, matching the midpoint of the jump from −1-1 to 11.

  7. The series of x2x^2 on (−π,π)(-\pi, \pi) is π23+∑4(−1)nn2cos⁡nx\tfrac{\pi^2}{3} + \sum \tfrac{4(-1)^n}{n^2}\cos nx. Set x=πx = \pi to find ∑1n2\sum \tfrac{1}{n^2}.

    Answer

    π26\tfrac{\pi^2}{6}

    Full solution

    cos⁡nπ=(−1)n\cos n\pi = (-1)^n, so π2=π23+4∑1n2\pi^2 = \tfrac{\pi^2}{3} + 4\sum \tfrac{1}{n^2}, and ∑1n2=2π2/34\sum \tfrac{1}{n^2} = \tfrac{2\pi^2/3}{4}.

  8. A student computes a0=πa_0 = \pi for ∣x∣\lvert x\rvert and writes the constant term as π\pi. What went wrong?

    Answer

    The constant term is a02=π2\tfrac{a_0}{2} = \tfrac{\pi}{2}.

    Full solution

    The constant term must equal the average value of ∣x∣\lvert x\rvert over (−π,π)(-\pi, \pi), which is π2\tfrac{\pi}{2}.

Frequently asked questions

What is a Fourier series?

A representation f(x) = a₀/2 + Σ (aₙ cos nx + bₙ sin nx) of a 2π-periodic function as a sum of sines and cosines.

How are the coefficients found?

aₙ = (1/π)∫ f(x) cos nx dx and bₙ = (1/π)∫ f(x) sin nx dx, both over −π to π. The constant term a₀/2 is the average value of f.

Why do the formulas work?

Over a full period, sin mx cos nx always integrates to 0, and sin mx sin nx and cos mx cos nx integrate to 0 unless m = n. Multiplying by one term and integrating keeps only that term's coefficient.

What happens at a jump?

The series converges to the midpoint of the jump, the average of the left and right limits.

What does symmetry tell you?

An odd function has only sine terms (all aₙ = 0). An even function has only cosine terms (all bₙ = 0).

What to learn next