Complex Variables & Transforms · Unit 2 · Topic 10

Fourier series: any wave from sines and cosines.

Short answer

On \((-\pi, \pi)\), \(f(x) = \dfrac{a_0}{2} + \sum\big(a_n\cos nx + b_n\sin nx\big)\), with \(a_n = \dfrac{1}{\pi}\int_{-\pi}^{\pi} f\cos nx\,dx\) and \(b_n = \dfrac{1}{\pi}\int_{-\pi}^{\pi} f\sin nx\,dx\).

For example, \(x = 2\left(\sin x - \dfrac{\sin 2x}{2} + \dfrac{\sin 3x}{3} - \cdots\right)\) on \((-\pi, \pi)\). Even functions give only cosines, odd functions only sines.

Engineering MathsSemester IIIBSc
01

What a Fourier series is

Before you start: you need integration by parts and the values \(\sin n\pi = 0\), \(\cos n\pi = (-1)^n\) for whole numbers \(n\). Series ideas from convergence of series help.

A Taylor series builds a function out of powers of \(x\). A Fourier series builds a periodic function out of sines and cosines. It works even for functions with corners and jumps, like a square wave, where a Taylor series is useless.

Fourier series on \((-\pi, \pi)\)

\[f(x) = \frac{a_0}{2} + \sum_{n=1}^{\infty}\big(a_n\cos nx + b_n\sin nx\big)\]

Euler's formulas

\[a_0 = \frac{1}{\pi}\int_{-\pi}^{\pi} f(x)\,dx\]

\[a_n = \frac{1}{\pi}\int_{-\pi}^{\pi} f(x)\cos nx\,dx\]

\[b_n = \frac{1}{\pi}\int_{-\pi}^{\pi} f(x)\sin nx\,dx\]

Why do these formulas work? Sines and cosines are orthogonal on \((-\pi, \pi)\): \(\int_{-\pi}^{\pi}\cos mx\cos nx\,dx = 0\) when \(m \ne n\), the same for two sines, and \(\int_{-\pi}^{\pi}\sin mx\cos nx\,dx = 0\) always. Multiply the series by \(\cos nx\) and integrate. Every term dies except \(a_n\cos^2 nx\), whose integral is \(\pi a_n\). That is the formula for \(a_n\).

The constant is written \(\dfrac{a_0}{2}\), not \(a_0\), so that the formula for \(a_0\) is just the \(a_n\) formula with \(n = 0\).

Where the series converges (Dirichlet conditions)

If \(f\) and \(f'\) are piecewise continuous, with finitely many finite jumps, the series converges to \(f(x)\) wherever \(f\) is continuous. At a jump it converges to the average \(\tfrac{1}{2}\big[f(x^-) + f(x^+)\big]\). At the ends \(\pm\pi\) it converges to \(\tfrac{1}{2}\big[f(-\pi^+) + f(\pi^-)\big]\), because the series repeats with period \(2\pi\).

02

Other intervals, even and odd functions

IntervalTermsCoefficients
\((0, 2\pi)\)\(\cos nx\), \(\sin nx\)same formulas, limits \(0\) to \(2\pi\)
\((-l, l)\)\(\cos\dfrac{n\pi x}{l}\), \(\sin\dfrac{n\pi x}{l}\)\(a_n = \dfrac{1}{l}\displaystyle\int_{-l}^{l} f(x)\cos\dfrac{n\pi x}{l}\,dx\)
\((0, 2l)\)\(\cos\dfrac{n\pi x}{l}\), \(\sin\dfrac{n\pi x}{l}\)factor \(\dfrac{1}{l}\), limits \(0\) to \(2l\)

On \((-l, l)\) the \(b_n\) formula has \(\sin\dfrac{n\pi x}{l}\) in place of the cosine. Put \(l = \pi\) and you are back to the first box.

Even and odd functions on \((-l, l)\)

\(f\) even, \(f(-x) = f(x)\): cosine series

\(b_n = 0\) and \(a_n = \dfrac{2}{l}\displaystyle\int_0^l f(x)\cos\dfrac{n\pi x}{l}\,dx\)

\(f\) odd, \(f(-x) = -f(x)\): sine series

\(a_0 = a_n = 0\) and \(b_n = \dfrac{2}{l}\displaystyle\int_0^l f(x)\sin\dfrac{n\pi x}{l}\,dx\)

Half-range series

Sometimes \(f\) is given only on \((0, l)\). You may extend it to \((-l, l)\) as you like. Extend it as an even function and you get the half-range cosine series, using the even-function formula above. Extend it as an odd function and you get the half-range sine series, using the odd-function formula. Both converge to \(f\) on \((0, l)\).

Parseval's identity on \((-\pi, \pi)\)

\[\frac{1}{\pi}\int_{-\pi}^{\pi}\big[f(x)\big]^2\,dx = \frac{a_0^2}{2} + \sum_{n=1}^{\infty}\left(a_n^2 + b_n^2\right)\]

Method

  1. Check for even or odd. It can halve the work.
  2. Find \(a_0\) separately. The \(a_n\) formula often has \(n\) in a denominator and fails at \(n = 0\).
  3. Find \(a_n\) and \(b_n\) by parts, then simplify with \(\sin n\pi = 0\) and \(\cos n\pi = (-1)^n\).
  4. Write the series with the first few terms shown.
  5. For a sum of numbers, put a convenient \(x\) (a point of continuity, or use the jump average), or apply Parseval.
03

Solved examples

Example 1: f(x) = x on (−π, π)

Easy

Find the Fourier series of \(f(x) = x\) on \((-\pi, \pi)\), and deduce the value of \(1 - \tfrac{1}{3} + \tfrac{1}{5} - \cdots\).

  1. \(x\) is odd, so \(a_0 = a_n = 0\) and \(b_n = \dfrac{2}{\pi}\displaystyle\int_0^\pi x\sin nx\,dx\).
  2. By parts: \(\displaystyle\int_0^\pi x\sin nx\,dx = \Big[-\frac{x\cos nx}{n} + \frac{\sin nx}{n^2}\Big]_0^\pi = -\frac{\pi(-1)^n}{n}\).
  3. So \(b_n = \dfrac{2(-1)^{n+1}}{n}\) and \[x = 2\left(\sin x - \frac{\sin 2x}{2} + \frac{\sin 3x}{3} - \cdots\right)\]
  4. Put \(x = \dfrac{\pi}{2}\): \(\sin\dfrac{n\pi}{2}\) is \(1, 0, -1, 0, \dots\), so \(\dfrac{\pi}{2} = 2\left(1 - \dfrac{1}{3} + \dfrac{1}{5} - \cdots\right)\).

Answer\(x = 2\displaystyle\sum_{n=1}^\infty \frac{(-1)^{n+1}}{n}\sin nx\), and \(1 - \dfrac{1}{3} + \dfrac{1}{5} - \cdots = \dfrac{\pi}{4}\)

Example 2: f(x) = x² and the sum of 1/n²

Medium

Find the Fourier series of \(f(x) = x^2\) on \((-\pi, \pi)\). Hence show \(\displaystyle\sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}\).

  1. \(x^2\) is even, so \(b_n = 0\). \(a_0 = \dfrac{2}{\pi}\displaystyle\int_0^\pi x^2\,dx = \dfrac{2\pi^2}{3}\).
  2. \[\int_0^\pi x^2\cos nx\,dx = \Big[\frac{x^2\sin nx}{n} + \frac{2x\cos nx}{n^2} - \frac{2\sin nx}{n^3}\Big]_0^\pi = \frac{2\pi(-1)^n}{n^2}\]
  3. So \(a_n = \dfrac{2}{\pi}\cdot\dfrac{2\pi(-1)^n}{n^2} = \dfrac{4(-1)^n}{n^2}\), and \[x^2 = \frac{\pi^2}{3} + 4\sum_{n=1}^\infty \frac{(-1)^n}{n^2}\cos nx\]
  4. Put \(x = \pi\). The function is continuous there (\(x^2\) has the same value at \(\pm\pi\)) and \(\cos n\pi = (-1)^n\), so \(\pi^2 = \dfrac{\pi^2}{3} + 4\displaystyle\sum \frac{1}{n^2}\).

Answer\(x^2 = \dfrac{\pi^2}{3} + 4\displaystyle\sum_{n=1}^\infty \frac{(-1)^n\cos nx}{n^2}\), and \(\displaystyle\sum \frac{1}{n^2} = \frac{\pi^2}{6}\)

Example 3: f(x) = |x| and the odd squares

Medium

Find the Fourier series of \(f(x) = |x|\) on \((-\pi, \pi)\) and deduce \(\dfrac{1}{1^2} + \dfrac{1}{3^2} + \dfrac{1}{5^2} + \cdots\).

  1. \(|x|\) is even. \(a_0 = \dfrac{2}{\pi}\displaystyle\int_0^\pi x\,dx = \pi\).
  2. \(a_n = \dfrac{2}{\pi}\Big[\dfrac{x\sin nx}{n} + \dfrac{\cos nx}{n^2}\Big]_0^\pi = \dfrac{2}{\pi}\cdot\dfrac{(-1)^n - 1}{n^2}\).
  3. This is \(0\) for even \(n\) and \(-\dfrac{4}{\pi n^2}\) for odd \(n\). So \[|x| = \frac{\pi}{2} - \frac{4}{\pi}\left(\cos x + \frac{\cos 3x}{3^2} + \frac{\cos 5x}{5^2} + \cdots\right)\]
  4. Put \(x = 0\): \(0 = \dfrac{\pi}{2} - \dfrac{4}{\pi}\left(1 + \dfrac{1}{3^2} + \dfrac{1}{5^2} + \cdots\right)\).

Answer\(1 + \dfrac{1}{3^2} + \dfrac{1}{5^2} + \cdots = \dfrac{\pi^2}{8}\)

Example 4: A square wave

Medium

Find the Fourier series of \(f(x) = -1\) for \(-\pi < x < 0\) and \(f(x) = 1\) for \(0 < x < \pi\).

  1. \(f\) is odd, so only \(b_n\) survive: \(b_n = \dfrac{2}{\pi}\displaystyle\int_0^\pi \sin nx\,dx = \dfrac{2}{\pi}\cdot\dfrac{1 - (-1)^n}{n}\).
  2. That is \(\dfrac{4}{n\pi}\) for odd \(n\) and \(0\) for even \(n\).
  3. At the jump \(x = 0\) every term is \(0\), which matches the average of \(-1\) and \(1\).

Answer\(f(x) = \dfrac{4}{\pi}\left(\sin x + \dfrac{\sin 3x}{3} + \dfrac{\sin 5x}{5} + \cdots\right)\)

Example 5: The interval (0, 2π)

Exam level

Find the Fourier series of \(f(x) = x^2\) on \((0, 2\pi)\) and use it to find \(\displaystyle\sum \frac{1}{n^2}\).

  1. No symmetry here. \(a_0 = \dfrac{1}{\pi}\displaystyle\int_0^{2\pi} x^2\,dx = \dfrac{8\pi^2}{3}\).
  2. \(a_n = \dfrac{1}{\pi}\Big[\dfrac{x^2\sin nx}{n} + \dfrac{2x\cos nx}{n^2} - \dfrac{2\sin nx}{n^3}\Big]_0^{2\pi} = \dfrac{1}{\pi}\cdot\dfrac{4\pi}{n^2} = \dfrac{4}{n^2}\).
  3. \(b_n = \dfrac{1}{\pi}\Big[-\dfrac{x^2\cos nx}{n} + \dfrac{2x\sin nx}{n^2} + \dfrac{2\cos nx}{n^3}\Big]_0^{2\pi} = \dfrac{1}{\pi}\cdot\left(-\dfrac{4\pi^2}{n}\right) = -\dfrac{4\pi}{n}\).
  4. So \[x^2 = \frac{4\pi^2}{3} + \sum_{n=1}^\infty\left(\frac{4}{n^2}\cos nx - \frac{4\pi}{n}\sin nx\right)\]
  5. At \(x = 0\) the periodic extension jumps from \(4\pi^2\) to \(0\), so the series gives the average \(2\pi^2\): \(2\pi^2 = \dfrac{4\pi^2}{3} + 4\displaystyle\sum \frac{1}{n^2}\).

Answer\(\displaystyle\sum \frac{1}{n^2} = \frac{\pi^2}{6}\), the same as Example 2

Example 6: Half-range cosine series on (0, 2)

Medium

Find the half-range cosine series of \(f(x) = x\) on \((0, 2)\).

  1. Here \(l = 2\). \(a_0 = \dfrac{2}{2}\displaystyle\int_0^2 x\,dx = 2\).
  2. \[a_n = \int_0^2 x\cos\frac{n\pi x}{2}\,dx = \Big[\frac{2x}{n\pi}\sin\frac{n\pi x}{2} + \frac{4}{n^2\pi^2}\cos\frac{n\pi x}{2}\Big]_0^2\]
  3. That is \(\dfrac{4\big((-1)^n - 1\big)}{n^2\pi^2}\): \(-\dfrac{8}{n^2\pi^2}\) for odd \(n\), \(0\) for even \(n\).

Answer\(x = 1 - \dfrac{8}{\pi^2}\displaystyle\sum_{n\ \text{odd}}\frac{1}{n^2}\cos\frac{n\pi x}{2}\)

Example 7: Half-range sine series

Exam level

Find the half-range sine series of \(f(x) = x(\pi - x)\) on \((0, \pi)\) and deduce \(1 - \dfrac{1}{3^3} + \dfrac{1}{5^3} - \cdots\).

  1. \(b_n = \dfrac{2}{\pi}\displaystyle\int_0^\pi (\pi x - x^2)\sin nx\,dx\). Use repeated parts with \(u = \pi x - x^2\), \(u' = \pi - 2x\), \(u'' = -2\).
  2. \[\int_0^\pi u\sin nx\,dx = \Big[-\frac{u\cos nx}{n} + \frac{u'\sin nx}{n^2} - \frac{2\cos nx}{n^3}\Big]_0^\pi = \frac{2\big(1 - (-1)^n\big)}{n^3}\]
  3. So \(b_n = \dfrac{8}{\pi n^3}\) for odd \(n\) and \(0\) for even \(n\): \[x(\pi - x) = \frac{8}{\pi}\left(\sin x + \frac{\sin 3x}{3^3} + \frac{\sin 5x}{5^3} + \cdots\right)\]
  4. Put \(x = \dfrac{\pi}{2}\): \(\dfrac{\pi^2}{4} = \dfrac{8}{\pi}\left(1 - \dfrac{1}{3^3} + \dfrac{1}{5^3} - \cdots\right)\).

Answer\(1 - \dfrac{1}{3^3} + \dfrac{1}{5^3} - \cdots = \dfrac{\pi^3}{32}\)

Example 8: Parseval's identity

Exam level

Use Parseval's identity with the series of \(x^2\) from Example 2 to find \(\displaystyle\sum_{n=1}^\infty \frac{1}{n^4}\).

  1. Left side: \(\dfrac{1}{\pi}\displaystyle\int_{-\pi}^{\pi} x^4\,dx = \dfrac{2\pi^4}{5}\).
  2. Right side: \(\dfrac{a_0^2}{2} = \dfrac{1}{2}\left(\dfrac{2\pi^2}{3}\right)^2 = \dfrac{2\pi^4}{9}\), and \(\displaystyle\sum a_n^2 = 16\sum \frac{1}{n^4}\).
  3. So \(16\displaystyle\sum \frac{1}{n^4} = \frac{2\pi^4}{5} - \frac{2\pi^4}{9} = \frac{8\pi^4}{45}\).

Answer\(\displaystyle\sum_{n=1}^\infty \frac{1}{n^4} = \frac{\pi^4}{90}\)

Vipul Sir's tip

For integrals like \(\int x^2\cos nx\,dx\), use the repeated-parts rule: \(\int uv\,dx = uv_1 - u'v_2 + u''v_3 - \cdots\), where \(v_1, v_2, v_3\) are successive integrals of \(v\). Write the three columns side by side and the whole calculation fits on two lines. Then put the limits in and kill every \(\sin n\pi\) before you do anything else.

04

Common mistakes

1. Using \(a_0\) instead of \(\dfrac{a_0}{2}\)

For \(x^2\) on \((-\pi, \pi)\), \(a_0 = \dfrac{2\pi^2}{3}\) and the constant term is \(\dfrac{\pi^2}{3}\). Writing \(\dfrac{2\pi^2}{3}\) as the constant shifts the whole graph up. (Some books define \(a_0\) with \(\dfrac{1}{2\pi}\) and write it without the half. Either works; don't mix them.)

2. Getting the formula for \(a_0\) from the \(a_n\) answer

For \(|x|\), \(a_n = \dfrac{2\big((-1)^n - 1\big)}{\pi n^2}\) and putting \(n = 0\) means dividing by zero. Always integrate separately for \(a_0\); here it is \(\pi\).

3. Using \(f\) at a jump

At \(x = 0\) the square-wave series gives \(0\), not \(1\) or \(-1\). At a discontinuity the series gives the average of the two one-sided values. Use this when you put in a point to sum a series.

05

Practice questions

Try each one on paper before you open the answer.

Q1For \(f(x) = x^3\) on \((-\pi, \pi)\), which coefficients are zero?

\(x^3\) is odd, so \(a_0 = 0\) and every \(a_n = 0\). Only the sine terms remain.

Q2Write down the Fourier series of \(f(x) = x + x^2\) on \((-\pi, \pi)\).

Add Examples 1 and 2: \[\frac{\pi^2}{3} + \sum_{n=1}^\infty\left(\frac{4(-1)^n}{n^2}\cos nx + \frac{2(-1)^{n+1}}{n}\sin nx\right)\]

Q3Find the half-range sine series of \(f(x) = 1\) on \((0, l)\).

\(b_n = \dfrac{2}{l}\displaystyle\int_0^l \sin\frac{n\pi x}{l}\,dx = \frac{2\big(1 - (-1)^n\big)}{n\pi}\).

So \(1 = \dfrac{4}{\pi}\left(\sin\dfrac{\pi x}{l} + \dfrac{1}{3}\sin\dfrac{3\pi x}{l} + \cdots\right)\).

Q4What value does the Fourier series of \(f(x) = x\) on \((-\pi, \pi)\) take at \(x = \pi\)?

\(0\). The periodic extension jumps from \(\pi\) to \(-\pi\) there, and the average is \(0\). Every \(\sin n\pi\) is \(0\) too.

Q5Find the Fourier series of \(f(x) = x^2\) on \((-1, 1)\).

Even, with \(l = 1\): \(a_0 = 2\displaystyle\int_0^1 x^2\,dx = \frac{2}{3}\) and \(a_n = 2\displaystyle\int_0^1 x^2\cos n\pi x\,dx = \frac{4(-1)^n}{n^2\pi^2}\).

\(x^2 = \dfrac{1}{3} + \dfrac{4}{\pi^2}\displaystyle\sum_{n=1}^\infty \frac{(-1)^n}{n^2}\cos n\pi x\).

Q6Find the half-range cosine series of \(f(x) = \pi - x\) on \((0, \pi)\).

\(a_0 = \dfrac{2}{\pi}\displaystyle\int_0^\pi (\pi - x)\,dx = \pi\) and \(a_n = \dfrac{2\big(1 - (-1)^n\big)}{\pi n^2}\), which is \(\dfrac{4}{\pi n^2}\) for odd \(n\).

\(\pi - x = \dfrac{\pi}{2} + \dfrac{4}{\pi}\left(\cos x + \dfrac{\cos 3x}{3^2} + \cdots\right)\).

Stuck on a question?

Bring it to a free demo class and work through it with Vipul Sir. Book on WhatsApp.

06

Frequently asked questions

What is a Fourier series?

A way of writing a periodic function as a constant plus a sum of sines and cosines, \(\dfrac{a_0}{2} + \sum(a_n\cos nx + b_n\sin nx)\), with the coefficients given by Euler's formulas.

Why is the constant term a0/2?

So that one formula, \(a_n = \dfrac{1}{\pi}\int_{-\pi}^{\pi} f(x)\cos nx\,dx\), also gives \(a_0\) when \(n = 0\). The constant term itself is the average value of \(f\) over one period.

What does a Fourier series converge to at a discontinuity?

The average of the left and right limits, \(\tfrac{1}{2}\big[f(x^-) + f(x^+)\big]\). At points where \(f\) is continuous it converges to \(f(x)\).

When do I use a half-range series?

When the function is given only on \((0, l)\). The question tells you which one: a cosine series uses the even extension, a sine series the odd extension.

Related lessons

← All 12 Complex Variables & Transforms topics
Vipul Sir
Written by Vipul Sir

Vipul Sir has taught mathematics for over 15 years to HSC, CBSE, ICSE, IGCSE/IB, Diploma, Engineering and BSc students at VVS Classes in Goregaon and Vile Parle, Mumbai. He teaches every class himself, concepts first and exam technique second.

Complex Variables and Transforms

Get Complex Variables & Transforms right, with Vipul Sir beside you.

Concept-first classes in small batches in Goregaon and Vile Parle, or online. Your first class is free.

WhatsApp↗