Unit 8, lesson 114

Fourier Sine and Cosine Series

How a function given only on an interval from 0 to L can be written as a series of sines alone or cosines alone, and how the choice affects the endpoints and the speed of convergence.

  • Theory part 227
  • Practice part 228
  • Fourier Expansions

A guitar string is fixed at both ends and only exists between them. To describe its shape with waves you have a choice to make, because nothing outside the string tells you what the function should be there. Filling in the missing half by mirror symmetry gives a series with only sines or only cosines, and the two choices behave quite differently.

Key terms

Odd and even extensions

Definition Let ff be defined on (0,L)(0, L) with L>0L > 0. The odd extension fof_o is the function with period 2L2L given on (−L,L)(-L, L) by

fo(x)={f(x),0<x<L,0,x=0,−f(−x),−L<x<0,f_o(x) = \begin{cases} f(x), & 0 < x < L, \\ 0, & x = 0, \\ -f(-x), & -L < x < 0, \end{cases}

and fo(±L)=0f_o(\pm L) = 0. If ff is defined on [0,L][0, L], the even extension fef_e is the function with period 2L2L given by fe(x)=f(∣x∣)f_e(x) = f(\lvert x \rvert) for −L≤x≤L-L \le x \le L. This is consistent because fe(−L)=fe(L)=f(L)f_e(-L) = f_e(L) = f(L).

In plain words For the odd extension you copy the graph into the left half turned upside down. For the even extension you copy it as a mirror image. Then you repeat the picture forever in both directions.

Example Take f(x)=xf(x) = x on (0,1)(0, 1). The odd extension is xx on (−1,1)(-1, 1) repeated with period 22, a sawtooth wave that jumps from 11 down to −1-1 at every odd integer. The even extension is ∣x∣\lvert x \rvert on [−1,1][-1, 1] repeated with period 22, a triangle wave with no jumps at all.

Half-range expansions

Definition Let ff be integrable on [0,L][0, L]. A half-range expansion of ff is the Fourier series of either its odd or its even extension. It has period 2L2L, its coefficients are computed only from the values of ff on [0,L][0, L], and it contains only sine terms (odd extension) or only cosine terms (even extension).

Recall that an integrable function with period 2L2L has the Fourier series

a02+∑n=1∞(ancos⁡nπxL+bnsin⁡nπxL),\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),

whose coefficients are

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

In plain words You only know the function on half of a period. You choose how to fill in the other half, and the choice decides which kind of wave appears.

Example The odd extension of ff is odd, so fo(x)cos⁡nπxLf_o(x)\cos\frac{n\pi x}{L} is odd and every ana_n is 00. The product fo(x)sin⁡nπxLf_o(x)\sin\frac{n\pi x}{L} is even, so

bn=1L∫−LLfo(x)sin⁡nπxL dx=2L∫0Lf(x)sin⁡nπxL dx.b_n = \frac{1}{L}\int_{-L}^{L} f_o(x)\sin\frac{n\pi x}{L}\,dx = \frac{2}{L}\int_{0}^{L} f(x)\sin\frac{n\pi x}{L}\,dx.

The same symmetry argument for the even extension kills every bnb_n and doubles the integral over [0,L][0, L] for ana_n.

Sine series

Definition The Fourier sine series of an integrable function ff on [0,L][0, L] is

∑n=1∞bnsin⁡nπxL,bn=2L∫0Lf(x)sin⁡nπxL dx.\sum_{n=1}^{\infty} b_n \sin\frac{n\pi x}{L}, \qquad b_n = \frac{2}{L}\int_{0}^{L} f(x)\sin\frac{n\pi x}{L}\,dx.

It is the Fourier series of the odd extension of ff.

In plain words You build ff from the shapes sin⁡πxL\sin\frac{\pi x}{L}, sin⁡2πxL\sin\frac{2\pi x}{L}, and so on, each of which is zero at both ends of the interval.

Example For f(x)=xf(x) = x on [0,π][0, \pi], integration by parts gives

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

So on (0,π)(0, \pi) the sine series of xx is

x∼2sin⁡x−sin⁡(2x)+23sin⁡(3x)−12sin⁡(4x)+⋯x \sim 2\sin x - \sin(2x) + \frac{2}{3}\sin(3x) - \frac{1}{2}\sin(4x) + \cdots

Cosine series

Definition The Fourier cosine series of an integrable function ff on [0,L][0, L] is

a02+∑n=1∞ancos⁡nπxL,an=2L∫0Lf(x)cos⁡nπxL dx(n≥0).\frac{a_0}{2} + \sum_{n=1}^{\infty} a_n \cos\frac{n\pi x}{L}, \qquad a_n = \frac{2}{L}\int_{0}^{L} f(x)\cos\frac{n\pi x}{L}\,dx \quad (n \ge 0).

It is the Fourier series of the even extension of ff. The constant term a02\frac{a_0}{2} is the average value of ff on [0,L][0, L].

In plain words You build ff from a constant and the shapes cos⁡nπxL\cos\frac{n\pi x}{L}, which all have zero slope at both ends.

Example For f(x)=xf(x) = x on [0,π][0, \pi] the constant term is

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

and for n≥1n \ge 1 integration by parts gives

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

which is −4πn2-\frac{4}{\pi n^2} for odd nn and 00 for even nn. So the cosine series of xx on [0,π][0, \pi] is

x∼π2−4π(cos⁡x+cos⁡3x9+cos⁡5x25+⋯ ).x \sim \frac{\pi}{2} - \frac{4}{\pi}\left(\cos x + \frac{\cos 3x}{9} + \frac{\cos 5x}{25} + \cdots\right).

Endpoint behavior

Definition Let ff be piecewise smooth on [0,L][0, L], meaning ff and f′f' are piecewise continuous there. Then for 0<x<L0 < x < L both half-range series converge to

f(x+)+f(x−)2,\frac{f(x^+) + f(x^-)}{2},

which is f(x)f(x) wherever ff is continuous. At the ends the sine series converges to 00 at both x=0x = 0 and x=Lx = L, whatever the values of ff there, while the cosine series converges to f(0+)f(0^+) at x=0x = 0 and to f(L−)f(L^-) at x=Lx = L.

In plain words Every sine term vanishes at the ends, so the sine series is stuck at 00 there. The even extension has no jump at the ends, so the cosine series lands on the true end values.

Example For f(x)=xf(x) = x on [0,π][0, \pi], the sine series at x=πx = \pi is ∑bnsin⁡(nπ)=0\sum b_n \sin(n\pi) = 0, the average of the jump from π\pi to −π-\pi in the sawtooth. The cosine series at x=0x = 0 is

π2−4π∑k=1∞1(2k−1)2=π2−4π⋅π28=0=f(0).\frac{\pi}{2} - \frac{4}{\pi}\sum_{k=1}^{\infty}\frac{1}{(2k-1)^2} = \frac{\pi}{2} - \frac{4}{\pi}\cdot\frac{\pi^2}{8} = 0 = f(0).

The second step uses the known sum

∑k=1∞1(2k−1)2=π28.\sum_{k=1}^{\infty}\frac{1}{(2k-1)^2} = \frac{\pi^2}{8}.

Approximating periodic signals

Definition For an integrable function ff with period 2L2L, the partial sum

SN(x)=a02+∑n=1N(ancos⁡nπxL+bnsin⁡nπxL)S_N(x) = \frac{a_0}{2} + \sum_{n=1}^{N}\left(a_n\cos\frac{n\pi x}{L} + b_n\sin\frac{n\pi x}{L}\right)

is an approximation built from finitely many frequencies. If ff is continuous on R\mathbb{R} and f′f' is piecewise continuous, then ∑(∣an∣+∣bn∣)\sum (\lvert a_n \rvert + \lvert b_n \rvert) converges and SN→fS_N \to f uniformly on R\mathbb{R}. If ff has a jump, SNS_N cannot converge uniformly near it, and the overshoot of the Gibbs phenomenon persists. For a half-range expansion this means the cosine series of a continuous piecewise smooth ff always converges uniformly on [0,L][0, L], while the sine series does so only when also f(0)=f(L)=0f(0) = f(L) = 0.

In plain words A signal with no jumps is captured well by a handful of frequencies. A jump forces you to keep many terms and still leaves a ripple next to the jump.

Example For f(x)=xf(x) = x on [0,π][0, \pi], the sine coefficients shrink like 2n\frac{2}{n} and the cosine coefficients like 4πn2\frac{4}{\pi n^2}. The largest error of the cosine partial sum on [0,π][0, \pi] occurs at the ends.

Terms up to n=Nn = NLargest error of cosine sum on [0,π][0, \pi]
550.1050.105
20200.0320.032
1001000.00640.0064

The sine partial sums equal 00 at x=πx = \pi while f(π)=πf(\pi) = \pi, and they are continuous, so their largest error on (0,π)(0, \pi) comes arbitrarily close to π\pi for every NN.

Check yourself

  1. Find the sine series of f(x)=1f(x) = 1 on (0,π)(0, \pi).
Show the answer

The coefficients are

bn=2π∫0πsin⁡(nx) dx=2π⋅1−(−1)nn,b_n = \frac{2}{\pi}\int_0^{\pi}\sin(nx)\,dx = \frac{2}{\pi}\cdot\frac{1 - (-1)^n}{n},

which is 4πn\frac{4}{\pi n} for odd nn and 00 for even nn. So on (0,π)(0, \pi)

1∼4π(sin⁡x+sin⁡3x3+sin⁡5x5+⋯ ).1 \sim \frac{4}{\pi}\left(\sin x + \frac{\sin 3x}{3} + \frac{\sin 5x}{5} + \cdots\right).
  1. What is the cosine series of f(x)=1f(x) = 1 on [0,π][0, \pi]?
Show the answer

Just the constant 11. The even extension is the constant function 11, so a0=2a_0 = 2 and an=0a_n = 0 for n≥1n \ge 1.

  1. To what value does the sine series of f(x)=x2f(x) = x^2 on [0,2][0, 2] converge at x=2x = 2? What about the cosine series?
Show the answer

The sine series converges to 00 at x=2x = 2, since every term sin⁡(nπ)\sin(n\pi) is 00. The cosine series converges to f(2)=4f(2) = 4, because the even extension is continuous there.

How this lesson connects

It also uses even and odd extension.