Guides / Series
Fourier series: integrate against each sine and cosine, halve the constant term, and let symmetry do half the work
Short answer
Period 2π: f(x) ~ a0/2 + Σ (an cos nx + bn sin nx), with an = (1/π)∫ f(x) cos nx dx and bn = (1/π)∫ f(x) sin nx dx over [−π, π]. Period 2L: use cos(nπx/L) and sin(nπx/L), and 1/L in front. Symmetry: even f has bn = 0, odd f has an = 0. Useful: cos nπ = (−1)n and sin nπ = 0. At a jump the series gives the average of the two sides.
Why it works
On [−π, π], the integral of cos mx cos nx is 0 unless m = n, when it is π, and the same holds for the sines; a sine times a cosine always integrates to 0. So multiply the series by cos nx and integrate: every term but one vanishes, and what is left is π an. That is the coefficient formula. It works the way a dot product with a unit vector picks out one coordinate.
The same formula with n = 0 gives a0 as twice the average of f, because cos 0 = 1 integrates to 2π, not π. Writing the constant term as a0/2 lets one formula serve every n. On an even function, f(x) sin nx is odd and integrates to 0, so only cosines survive; on an odd function only sines do.
Example 1: a step and its value at the jump
Find the series of f(x) = 0 on (−π, 0) and f(x) = 1 on (0, π), repeated with period 2π.
- a0 = (1/π)∫0π 1 dx = 1f is 0 on the left half, so only (0, π) counts.
- an = (1/π)∫0π cos nx dx = 0sin nx/n is 0 at both ends.
- bn = (1 − cos nπ)/(nπ)From ∫0π sin nx dx = (1 − cos nπ)/n.
- bn = 2/(nπ), n oddcos nπ = −1 for odd n and +1 for even n, so the even terms are 0.
- f ~ 1/2 + (2/π)(sin xThe constant is a0/2 = 1/2, the average of f …
- + sin 3x/3 + sin 5x/5 + ⋯)… plus the odd sines.
- At x = 0 the series is 1/2Every sine is 0 there, so it lands halfway between the left value 0 and the right value 1. At x = π/2, where f = 1, it gives 1 − 1/3 + 1/5 − ⋯ = π/4.
Example 2: an even function, |sin x|
Find the series of f(x) = |sin x|, the output of a full-wave rectifier.
- bn = 0|sin x| is even, so only cosines appear.
- an = (2/π)∫0π sin x cos nx dxFor an even function, twice the integral over (0, π), where |sin x| = sin x.
- a0 = 4/π∫0π sin x dx = 2.
- an = −4/(π(n2 − 1)), n evenFrom the product-to-sum identity. For odd n the integral is 0.
- a2 = −4/(3π)Then a4 = −4/(15π) and a6 = −4/(35π).
- f ~ 2/π − (4/π)Σ ck cos 2kxThe sum runs over k = 1, 2, 3, …, with n = 2k.
- ck = 1/(4k2 − 1)The constant is a0/2 = 2/π ≈ 0.637, the average of |sin x|. Check at x = 0: Σ 1/(4k2 − 1) = 1/2, so the series gives 0.
Example 3: a period other than 2π
Find the series of f(x) = 1 − x2 on [−1, 1], repeated with period 2.
- L = 1The period is 2L = 2. Use cos(nπx) and 1/L = 1 in front.
- bn = 0f is even.
- a0 = ∫−11 (1 − x2) dx = 4/3So the constant term is 2/3.
- an = 4(−1)n+1/(n2π2)Integrate (1 − x2)cos(nπx) by parts twice. a1 = 4/π2.
- Check at x = 02/3 + (4/π2)(1 − 1/4 + 1/9 − ⋯). The alternating sum is π2/12, so the series gives 2/3 + 1/3 = 1 = f(0).
Example 4: Parseval's identity
Use the series of Example 1 to find 1 + 1/32 + 1/52 + ⋯.
- (1/π)∫ f2 dxParseval: this equals a02/2 + Σ (an2 + bn2).
- (1/π)∫0π 1 dx = 1f2 = f, which is 1 on half the period.
- a02/2 = 1/2With a0 = 1. Leaving this term out is a common slip.
- Σ bn2 = (4/π2)Σ 1/n2Over odd n, from bn = 2/(nπ).
- 1 = 1/2 + (4/π2)Σ 1/n2Put the pieces together.
- Σ 1/n2 = π2/8Over odd n. Check: the even terms add to (1/4)(π2/6), and π2/8 + π2/24 = π2/6.
Common mistakes, and the exact line they happen on
1. Writing a0 instead of a0/2
The constant term of Example 2.
- a0 = 4/πRight so far.
- f ~ 4/π − ⋯This is the mistake. The constant term is a0/2 = 2/π. With 4/π ≈ 1.27, the series says the average of |sin x| is larger than its maximum, 1. The constant term is always the average of f over a period: check it first.
2. Treating cos nπ as 0
The sine coefficients of Example 1.
- bn = (1 − cos nπ)/(nπ)Right so far.
- bn = 1/(nπ)This is the mistake. cos nπ is (−1)n, never 0; sin nπ is the one that is 0. The right coefficients are 2/(nπ) for odd n and 0 for even n. f − 1/2 is odd and also symmetric about x = π/2, which rules out the even sines.
3. Dividing by π when the period is 2L
The constant term of Example 3.
- ∫−11 (1 − x2) dx = 4/3Right so far.
- a0 = (1/π)(4/3)This is the mistake. The factor in front is 1/L, and L = 1 here. Dividing by π makes the constant term 2/(3π) ≈ 0.212, but f runs from 0 to 1 and averages 2/3. The 1/π only belongs when the period is 2π.
Practice
Which coefficients of f(x) = x3 on [−π, π] are zero?
Show answer
All the an, including a0: x3 is odd.
What is the constant term of the series of f(x) = x2 + 1 on [−π, π]?
Show answer
The average of f: π2/3 + 1.
Read off the coefficients of f(x) = 2 cos x + sin 3x.
Show answer
a1 = 2, b3 = 1, and every other coefficient is 0. A sum of sines and cosines is already its own Fourier series.
f is −1 on (−π, 0) and 2 on (0, π). What does its series give at x = 0?
Show answer
The average of the two sides, (−1 + 2)/2 = 1/2.
For a function of period 6, which cosines appear, and what factor goes in front of the coefficient integrals?
Show answer
L = 3, so cos(nπx/3), with 1/3 in front of integrals over [−3, 3].