Unit 12, lesson 67

Fourier Series and Orthogonal Expansions

How Fourier coefficients arise as orthogonal projections onto sines and cosines of period 2L, why the partial sums are the best mean-square approximations, and how Parseval's identity accounts for a function's squared size.

  • Video 67
  • Fourier Series

The separated solutions of a boundary problem come one sine or cosine at a time, but an initial temperature profile or the starting shape of a string is rarely a single wave. To use those solutions we need to know how much of each mode a given function contains. This lesson measures functions with an integral inner product, finds each amount by an orthogonal projection, and shows that the resulting partial sums are the best approximations in the mean-square sense, with Parseval’s identity accounting for the whole squared size of the function.

Key terms

Orthogonality of sines and cosines

Definition Fix L>0L > 0. For real functions ff and gg that are piecewise continuous on [−L,L][-L, L], the inner product and the norm are

⟨f,g⟩=∫−LLf(x) g(x) dx,∥f∥=⟨f,f⟩,\begin{gathered} \langle f, g \rangle = \int_{-L}^{L} f(x)\,g(x)\,dx, \\[0.4em] \lVert f \rVert = \sqrt{\langle f, f \rangle}, \end{gathered}

and ff and gg are orthogonal when ⟨f,g⟩=0\langle f, g \rangle = 0. Write cn(x)=cos⁡(nπx/L)c_n(x) = \cos(n\pi x/L) for n≥0n \ge 0, so that c0=1c_0 = 1, and sn(x)=sin⁡(nπx/L)s_n(x) = \sin(n\pi x/L) for n≥1n \ge 1. All of these functions have period 2L2L, and they are mutually orthogonal. For m≠nm \ne n,

⟨cm,cn⟩=⟨sm,sn⟩=0,\langle c_m, c_n \rangle = \langle s_m, s_n \rangle = 0,

and ⟨sm,cn⟩=0\langle s_m, c_n \rangle = 0 for all m≥1m \ge 1 and n≥0n \ge 0. The squared norms are

∥c0∥2=2L,∥cn∥2=∥sn∥2=L\begin{gathered} \lVert c_0 \rVert^2 = 2L, \\[0.4em] \lVert c_n \rVert^2 = \lVert s_n \rVert^2 = L \end{gathered}

for n≥1n \ge 1. For two cosines or two sines, a product-to-sum identity turns the product into cosines with angular frequencies (m−n)π/L(m - n)\pi/L and (m+n)π/L(m + n)\pi/L, and a cosine whose frequency is a nonzero integer multiple of π/L\pi/L integrates to zero over [−L,L][-L, L]. A sine times a cosine is an odd function, so its integral over the symmetric interval is zero. The identities sin⁡2θ=12(1−cos⁡2θ)\sin^2\theta = \tfrac{1}{2}(1 - \cos 2\theta) and cos⁡2θ=12(1+cos⁡2θ)\cos^2\theta = \tfrac{1}{2}(1 + \cos 2\theta) give the squared norm LL.

In plain words Orthogonal here is a statement about an integral, not about graphs meeting at right angles. Over a full period the product of two different modes is positive and negative in amounts that cancel exactly.

Example On [−π,π][-\pi, \pi], where L=πL = \pi, the identity sin⁡xsin⁡2x=12(cos⁡x−cos⁡3x)\sin x \sin 2x = \tfrac{1}{2}(\cos x - \cos 3x) gives

∫−ππsin⁡xsin⁡2x dx=0.\int_{-\pi}^{\pi} \sin x \sin 2x\,dx = 0.

Nothing about the two graphs is perpendicular. At x=0x = 0, for example, they cross with slopes 11 and 22. The orthogonality comes from the integral alone. In the same way sin⁡22x=12(1−cos⁡4x)\sin^2 2x = \tfrac{1}{2}(1 - \cos 4x) gives ∥sin⁡2x∥2=π\lVert \sin 2x \rVert^2 = \pi, which is LL.

Fourier coefficients

Definition The Fourier coefficients of a function ff that is piecewise continuous on [−L,L][-L, L] are

an=1L∫−LLf(x)cos⁡nπxL dxa_n = \frac{1}{L}\int_{-L}^{L} f(x)\cos\frac{n\pi x}{L}\,dx

for n=0,1,2,…n = 0, 1, 2, \dots and

bn=1L∫−LLf(x)sin⁡nπxL dxb_n = \frac{1}{L}\int_{-L}^{L} f(x)\sin\frac{n\pi x}{L}\,dx

for n=1,2,3,…n = 1, 2, 3, \dots. In the notation above, an=⟨f,cn⟩/La_n = \langle f, c_n \rangle / L and bn=⟨f,sn⟩/Lb_n = \langle f, s_n \rangle / L. The factor 1/L1/L comes from orthogonality. Suppose f=A0+∑n=1N(Ancn+Bnsn)f = A_0 + \sum_{n=1}^{N}(A_n c_n + B_n s_n) is a finite combination. Taking the inner product with cmc_m for some 1≤m≤N1 \le m \le N removes every term but one and leaves ⟨f,cm⟩=AmL\langle f, c_m \rangle = A_m L, so Am=amA_m = a_m. In the same way Bm=bmB_m = b_m. The constant has the larger squared norm 2L2L, so ⟨f,1⟩=2LA0\langle f, 1 \rangle = 2L A_0 and the constant amplitude is A0=a0/2A_0 = a_0/2. This is why the series below begins with a0/2a_0/2, and why one formula serves every n≥0n \ge 0. Some books call the constant amplitude itself a0a_0 and put 1/(2L)1/(2L) in its formula. Either convention works as long as the coefficient formulas and the series are kept together.

Symmetry saves work. If ff is odd, every ana_n is zero and bnb_n is 2/L2/L times the integral of f(x)sin⁡(nπx/L)f(x)\sin(n\pi x/L) over [0,L][0, L]. If ff is even, every bnb_n is zero and ana_n is 2/L2/L times the integral of f(x)cos⁡(nπx/L)f(x)\cos(n\pi x/L) over [0,L][0, L].

In plain words Each coefficient measures how strongly ff lines up with one mode, divided by the squared length of that mode. A coefficient can be negative, which means that mode enters with its sign reversed.

Example Take the sawtooth, f(x)=xf(x) = x on (−π,π)(-\pi, \pi) repeated with period 2π2\pi, so L=πL = \pi. The function is odd, so an=0a_n = 0 for every n≥0n \ge 0. Integration by parts with u=xu = x and dv=sin⁡nx dxdv = \sin nx\,dx gives a boundary term −πcos⁡(nπ)/n-\pi\cos(n\pi)/n and a remaining integral of cos⁡nx\cos nx over [0,π][0, \pi], which is zero. Since cos⁡nπ=(−1)n\cos n\pi = (-1)^n,

bn=2π∫0πxsin⁡nx dx=2(−1)n+1n.\begin{aligned} b_n &= \frac{2}{\pi}\int_0^{\pi} x\sin nx\,dx \\[0.4em] &= \frac{2(-1)^{n+1}}{n}. \end{aligned}

The first three are b1=2b_1 = 2, b2=−1b_2 = -1 and b3=23b_3 = \tfrac{2}{3}. The signs alternate and the sizes shrink like 1/n1/n.

Fourier series

Definition The Fourier series of a function ff that is piecewise continuous on [−L,L][-L, L] is

f(x)∼a02+∑n=1∞(ancos⁡nπxL+bnsin⁡nπxL),\begin{aligned} f(x) \sim \frac{a_0}{2} &+ \sum_{n=1}^{\infty}\Bigl(a_n \cos\frac{n\pi x}{L} \\ &+ b_n \sin\frac{n\pi x}{L}\Bigr), \end{aligned}

with the coefficients defined above. Its NNth partial sum SNfS_N f keeps the terms with n≤Nn \le N. Every term has period 2L2L, so the series describes the 2L2L-periodic extension of ff, the function on the whole line that repeats the values of ff on (−L,L)(-L, L). The sign ∼\sim only attaches the series to ff. It does not claim that the series converges, or that its sum is f(x)f(x). Where it converges and to what is a separate question, which the next lesson answers for piecewise smooth functions.

In plain words The series is a recipe for rebuilding a periodic function from a constant together with cosines and sines whose angular frequencies are π/L\pi/L, 2π/L2\pi/L, 3π/L3\pi/L and so on.

Example For the sawtooth of the previous section,

x∼∑n=1∞2(−1)n+1nsin⁡nxx \sim \sum_{n=1}^{\infty} \frac{2(-1)^{n+1}}{n}\sin nx

on (−π,π)(-\pi, \pi), a series that begins 2sin⁡x−sin⁡2x+23sin⁡3x2\sin x - \sin 2x + \tfrac{2}{3}\sin 3x. At x=π/2x = \pi/2 the even terms vanish and the odd terms give 2(1−13+15−⋯ )2(1 - \tfrac{1}{3} + \tfrac{1}{5} - \cdots). That is twice Leibniz’s series for π/4\pi/4, so the sum is π/2\pi/2, the value of the sawtooth there. At x=πx = \pi every term is zero, while the sawtooth jumps there from π\pi down to −π-\pi.

Orthogonal projection

Definition Let TNT_N be the set of trigonometric polynomials of degree at most NN with period 2L2L, the functions

T=A0+∑n=1N(Ancn+Bnsn)T = A_0 + \sum_{n=1}^{N}\bigl(A_n c_n + B_n s_n\bigr)

with real constants AnA_n and BnB_n. The orthogonal projection of a piecewise continuous ff onto TNT_N is the function PfPf in TNT_N for which the residual f−Pff - Pf is orthogonal to every element of TNT_N, or equivalently to 11 and to cnc_n and sns_n for 1≤n≤N1 \le n \le N. It is unique. If two members of TNT_N had this property, their difference would lie in TNT_N and be orthogonal to itself, so it would have norm zero, and the only trigonometric polynomial with norm zero is the zero function. Because the basis is orthogonal, the projection is found one direction at a time. The amplitude of each basis function φ\varphi is ⟨f,φ⟩/∥φ∥2\langle f, \varphi \rangle / \lVert \varphi \rVert^2, which is a0/2a_0/2 for the constant, ana_n for cnc_n and bnb_n for sns_n. Hence

Pf=SNf,Pf = S_N f,

the NNth partial sum of the Fourier series. The spaces are nested, TN⊆TN+1T_N \subseteq T_{N+1}, so a projection with more modes keeps all the old amplitudes and adds new ones.

In plain words Dropping a perpendicular from a point to a plane gives the nearest point of the plane, and the leftover piece has no component along the plane. Here the plane is the span of the first few modes, and the Fourier partial sum is the foot of the perpendicular.

Example For the sawtooth and N=1N = 1, the projection is S1f(x)=2sin⁡xS_1 f(x) = 2\sin x, since a0=a1=0a_0 = a_1 = 0. The residual r(x)=x−2sin⁡xr(x) = x - 2\sin x is odd, so it is orthogonal to 11 and to cos⁡x\cos x, and

⟨r,sin⁡x⟩=∫−ππxsin⁡x dx−2∫−ππsin⁡2x dx=2π−2π=0.\begin{aligned} \langle r, \sin x \rangle &= \int_{-\pi}^{\pi} x\sin x\,dx \\ &\quad - 2\int_{-\pi}^{\pi} \sin^2 x\,dx \\[0.4em] &= 2\pi - 2\pi = 0. \end{aligned}

Best mean-square approximation

Definition Let ff be piecewise continuous on [−L,L][-L, L] and let N≥0N \ge 0. The mean-square error of a trigonometric polynomial TT in TNT_N is

E(T)=∫−LL(f−T)2 dx,E(T) = \int_{-L}^{L}\bigl(f - T\bigr)^2\,dx,

which is ∥f−T∥2\lVert f - T \rVert^2. The partial sum SNfS_N f is the best mean-square approximation of ff in TNT_N, meaning E(T)>E(SNf)E(T) > E(S_N f) for every other TT in TNT_N. The reason is the Pythagorean theorem. The residual f−SNff - S_N f is orthogonal to SNf−TS_N f - T, which lies in TNT_N, so

E(T)=E(SNf)+∥SNf−T∥2,\begin{aligned} E(T) &= E(S_N f) \\ &\quad + \lVert S_N f - T \rVert^2, \end{aligned}

and the last term is positive unless T=SNfT = S_N f. The smallest error is

E(SNf)=∥f∥2−L QN,QN=a022+∑n=1N(an2+bn2).\begin{gathered} E(S_N f) = \lVert f \rVert^2 - L\,Q_N, \\[0.4em] Q_N = \frac{a_0^2}{2} + \sum_{n=1}^{N}\bigl(a_n^2 + b_n^2\bigr). \end{gathered}

Since an error is never negative, this gives Bessel’s inequality QN≤∥f∥2/LQ_N \le \lVert f \rVert^2 / L for every NN. Because TN⊆TN+1T_N \subseteq T_{N+1}, the smallest error can only decrease as NN grows. All of this concerns the integral of the squared error. It does not say that SNfS_N f makes the largest pointwise error as small as possible.

In plain words With the same modes available, no other choice of amplitudes gives a smaller total squared error. Moving any amplitude away from its Fourier value adds a positive amount to the error.

Example Approximate f(x)=xf(x) = x on [−π,π][-\pi, \pi] by csin⁡xc\sin x. Over this interval the integrals of x2x^2, xsin⁡xx\sin x and sin⁡2x\sin^2 x are 2π3/32\pi^3/3, 2π2\pi and π\pi, so expanding the square gives

E(c)=2π33−4πc+πc2=2π33−4π+π(c−2)2.\begin{aligned} E(c) &= \frac{2\pi^3}{3} - 4\pi c + \pi c^2 \\[0.4em] &= \frac{2\pi^3}{3} - 4\pi \\ &\quad + \pi(c - 2)^2. \end{aligned}

The minimum is at c=2c = 2, which is exactly b1b_1, and the smallest error is 2π3/3−4π≈8.102\pi^3/3 - 4\pi \approx 8.10, about 3939 percent of ∥f∥2≈20.67\lVert f \rVert^2 \approx 20.67. The largest pointwise error tells a different story. At x=±πx = \pm\pi the approximation 2sin⁡x2\sin x is 00 while ∣x∣=π\lvert x \rvert = \pi, so the largest gap on [−π,π][-\pi, \pi] is still π\pi, just as it was for c=0c = 0.

Parseval’s identity

Definition If ff is piecewise continuous on [−L,L][-L, L], then

1L∫−LLf(x)2 dx=a022+∑n=1∞(an2+bn2).\begin{aligned} &\frac{1}{L}\int_{-L}^{L} f(x)^2\,dx \\[0.4em] &\quad = \frac{a_0^2}{2} + \sum_{n=1}^{\infty}\bigl(a_n^2 + b_n^2\bigr). \end{aligned}

The same holds for every square-integrable ff, with the integral taken in the Lebesgue sense. By the formula for the smallest error, the identity is equivalent to E(SNf)→0E(S_N f) \to 0 as N→∞N \to \infty, so the partial sums converge to ff in the mean-square sense. It expresses the completeness of the sines and cosines. Bessel’s inequality becomes an equality in the limit, and a piecewise continuous function whose Fourier coefficients are all zero vanishes at every point where it is continuous. The identity says nothing about single points. Changing ff at finitely many points changes no integral, so it changes no coefficient and neither side of the identity, and mean-square convergence alone does not decide the sum of the series at any particular point.

In plain words The total squared size of the function is shared out among the modes, with nothing missing once every mode is counted. A partial sum accounts for part of it, and the part it misses is its mean-square error divided by LL.

Example For the sawtooth on [−π,π][-\pi, \pi] the left side is 1π⋅2π33=2π23\frac{1}{\pi}\cdot\frac{2\pi^3}{3} = \frac{2\pi^2}{3}, and the only nonzero coefficients have bn2=4/n2b_n^2 = 4/n^2. Parseval’s identity gives

4∑n=1∞1n2=2π23,∑n=1∞1n2=π26.\begin{gathered} 4\sum_{n=1}^{\infty}\frac{1}{n^2} = \frac{2\pi^2}{3}, \\[0.4em] \sum_{n=1}^{\infty}\frac{1}{n^2} = \frac{\pi^2}{6}. \end{gathered}

With one mode the coefficients account for b12=4b_1^2 = 4 out of 2π2/3≈6.582\pi^2/3 \approx 6.58. The missing 2π2/3−4≈2.582\pi^2/3 - 4 \approx 2.58 is the error E(S1f)≈8.10E(S_1 f) \approx 8.10 from the previous section divided by L=πL = \pi.

Check yourself

  1. Find the Fourier coefficients on [−π,π][-\pi, \pi] of f(x)=3+2cos⁡x−sin⁡4xf(x) = 3 + 2\cos x - \sin 4x, and check Parseval’s identity for this function.
Show the answer

The function already lies in T4T_4, so its projection onto T4T_4 is itself and its Fourier series is the function itself. The constant term 33 equals a0/2a_0/2, so a0=6a_0 = 6, not 33. The formula agrees, since 1π∫−ππf(x) dx=1π⋅3⋅2π=6\frac{1}{\pi}\int_{-\pi}^{\pi} f(x)\,dx = \frac{1}{\pi}\cdot 3 \cdot 2\pi = 6. The other nonzero coefficients are a1=2a_1 = 2 and b4=−1b_4 = -1, and all the rest are zero. The right side of Parseval’s identity is 362+4+1=23\frac{36}{2} + 4 + 1 = 23. On the left, the cross terms of the square integrate to zero by orthogonality, so

1π∫−ππf(x)2 dx=18π+4π+ππ=23.\begin{aligned} &\frac{1}{\pi}\int_{-\pi}^{\pi} f(x)^2\,dx \\[0.4em] &\quad = \frac{18\pi + 4\pi + \pi}{\pi} = 23. \end{aligned}
  1. Find the Fourier series of f(x)=∣x∣f(x) = \lvert x \rvert on [−π,π][-\pi, \pi]. Then find its best mean-square approximation of the form A0+A1cos⁡x+B1sin⁡xA_0 + A_1\cos x + B_1\sin x and the smallest mean-square error.
Show the answer

The function is even, so every bnb_n is zero, and a0=2π∫0πx dx=πa_0 = \frac{2}{\pi}\int_0^{\pi} x\,dx = \pi. For n≥1n \ge 1, integration by parts gives a boundary term xsin⁡(nx)/nx\sin(nx)/n that vanishes at both ends, and then

an=2π∫0πxcos⁡nx dx=2((−1)n−1)πn2.\begin{aligned} a_n &= \frac{2}{\pi}\int_0^{\pi} x\cos nx\,dx \\[0.4em] &= \frac{2\bigl((-1)^n - 1\bigr)}{\pi n^2}. \end{aligned}

This is −4/(πn2)-4/(\pi n^2) for odd nn and 00 for even nn, so

∣x∣∼π2−4π∑n oddcos⁡nxn2.\lvert x \rvert \sim \frac{\pi}{2} - \frac{4}{\pi}\sum_{n\ \text{odd}}\frac{\cos nx}{n^2}.

The best approximation is the projection S1f(x)=π2−4πcos⁡xS_1 f(x) = \frac{\pi}{2} - \frac{4}{\pi}\cos x, so A0=π/2A_0 = \pi/2, A1=−4/πA_1 = -4/\pi and B1=0B_1 = 0. With ∥f∥2=2π3/3\lVert f \rVert^2 = 2\pi^3/3, the smallest error is

E=2π33−π(π22+16π2)=π36−16π≈0.0748.\begin{aligned} E &= \frac{2\pi^3}{3} - \pi\Bigl(\frac{\pi^2}{2} + \frac{16}{\pi^2}\Bigr) \\[0.4em] &= \frac{\pi^3}{6} - \frac{16}{\pi} \approx 0.0748. \end{aligned}
  1. Use Parseval’s identity for ∣x∣\lvert x \rvert on [−π,π][-\pi, \pi] to find the sum of 1/n41/n^4 over the odd nn. What goes wrong if the constant term is entered as a02a_0^2 instead of a02/2a_0^2/2?
Show the answer

The left side is 1π∫−ππx2 dx=2π23\frac{1}{\pi}\int_{-\pi}^{\pi} x^2\,dx = \frac{2\pi^2}{3}. On the right, a02/2=π2/2a_0^2/2 = \pi^2/2 and an2=16/(π2n4)a_n^2 = 16/(\pi^2 n^4) for odd nn, so

16π2∑n odd1n4=2π23−π22=π26,\begin{aligned} \frac{16}{\pi^2}\sum_{n\ \text{odd}}\frac{1}{n^4} &= \frac{2\pi^2}{3} - \frac{\pi^2}{2} \\[0.4em] &= \frac{\pi^2}{6}, \end{aligned}

and the sum is π4/96≈1.0147\pi^4/96 \approx 1.0147. With a02=π2a_0^2 = \pi^2 in place of a02/2a_0^2/2, the sum of the squares an2a_n^2 would have to equal 2π2/3−π2=−π2/32\pi^2/3 - \pi^2 = -\pi^2/3, which is impossible for a sum of squares. The factor 12\tfrac{1}{2} is there because the constant function has squared norm 2L2L, twice that of every sine and cosine.

How this lesson connects