Fourier series solutions V - Computing some Fourier series

It is a good idea to see computations of some Fourier series of functions that aren't built from sines and cosines. To that end, we consider two simple examples: 1) a "square wave"; and 2) a "triangular wave".

Example: A square wave


Consider the piecewise-defined function f(t) is periodic with period 1, and which on [0,1) is defined by

f(t)={1, if 0≤t<12−1, if 12≤t<1

In other words, this function alternates between the values of 1 and −1 over intervals of length 12. Although this function is discontinuous (where it "jumps" between the values of 1 and −1), if we suggestively connect the values across those jumps with vertical lines we get the following visualization of the graph of f:

squareWave.png600

Based on this image, it's reasonable to call this graph a "rectangular wave", but for some reason the descriptor "square wave" is more popular.

In any case, let's compute the complex Fourier series associated to this function f. We first compute

f^(0)=∫01f(t)dt=∫0121dt+∫121−1dt=0.

For n≠0 we compute

f^(n)=∫01f(t)e−2πintdt=∫012e−2πintdt−∫121e−2πintdt=−12πin(e−πin−1)+12πin(e−2πin−e−πin)=1πin(1−e−πin)=1πin(1−(−1)n)={0, if n even2πin, if n odd

Note that we computed the integrals using u-substitutions, and simplified some expressions using the facts that e2πik=1 whenever k is an integer, while eπik is 1 when k is even and −1 when k is odd; i.e., eπik=(−1)k.

It follows that that Fourier series associated to our function f is

∑n=−∞∞f^(n)e2πint=∑n odd2πine2πint=⋯−2πi⋅3e−6πit−2πie−2πit+2πie2πit+2πi⋅3e6πit+⋯

If we group together the term at index n with the term at index −n and use the identity e2πint−e−2πint=2isin⁡(2πnt), we can rewrite the above series in the sines-and-cosines form as

∑n odd2πine2πint=∑odd n>04nπsin⁡(2πnt)

Some Fourier approximations

Let's truncate our Fourier series after various amounts of terms and see how well the corresponding finite Fourier series approximates our function f. If we only use the first term, the finite Fourier series we obtain is

S1(t)=4πsin⁡(2πt),

whose graph is

squareWave1.png600

If we truncate instead at N=9 (i.e., include all terms with n≤9), the finite Fourier series we obtain is

S9(t)=4πsin⁡(2πt)+43πsin⁡(6πt)+45πsin⁡(10πt)+47πsin⁡(14πt)+49πsin⁡(18πt),

whose graph is

squareWave9.png600

Finally, if we truncate our series at N=99, the graph of the corresponding finite Fourier series we obtain is

squareWave99.png600

Although our "Fourier approximations" appear to be converging quickly to the original square wave, you might notice those weird little "peaks" at the corners of each wave. There's something a little surprising going on here, but we'll hold off on investigating further until after our next example.

Example: A triangular wave


Now f(t) denote the "triangle wave" function, which is periodic with period 1 and is defined on [0,1) by

f(t)={t,0≤t<121−t,12≤t<1

As you can see from the graph, it seems reasonable to call this function a "triangle wave":

triangleWave.png600

We first compute

f^(0)=∫01f(t)dt=∫01/2tdt+∫1/21(1−t)dt=14.

For n≠0, we have

f^(n)=∫01f(t)e−2πintdt=∫01/2te−2πintdt+∫1/21(1−t)e−2πintdt.

To compute these, we make the substitution u=−2πint (so du=−2πindt) and use integration by parts, obtaining

f^(n)=−14πn2∫0−πinueudu−12πin∫−πin−2πineudu+14π2n2∫−πin−2πinueudu=−14π2n2[ueu−eu]0−πin+i2πn[eu]−πin−2πin+14π2n2[ueu−eu]−πin−2πin=−14π2n2(−πine−πin−e−πin+1)+i2πn(e−2πin−e−πin)+14π2n2(−2πine−2πin−e−2πin+πine−πin+e−πin)

To simplify this mess, recall that e−2πin=1 for all n, and that e−πin=(e−πi)n=(−1)n. So when n is even, the above expression simplifies to

f^(n)=−14π2n2(−πin−1+1)+i2πn(1−1)+14π2n2(−2πin−1+πin+1)=0.

When n is odd, the expression instead simplifies to

f^(n)=−14π2n2(πin+1+1)+i2πn(1+1)+14π2n2(−2πin−1−πin−1)=−1π2n2.

We've shown that the Fourier series for f(t) is

∑n=−∞∞f^(n)e2πint=14−1π2∑odd n1n2e2πint=14−1π2∑odd n>0(1n2e2πint+1(−n)2e2πi(−n)t)=14−1π2∑odd n>01n2(e2πint+e−2πint)=14−2π2∑odd n>01n2cos⁡(2πnt).

Some Fourier approximations

As with the square wave, we can get a sense for how quickly our Fourier series is converging to the original function by looking at some Fourier approximations with increasingly larger N values (i.e., more and more terms included). Here are the graphs of those approximations when N=1,9 and 99, this time with the original graph overlaid for visual comparison:

triangleWave1.png600

triangleWave9.png600

triangleWave99.png600

Suggested next notes


Fourier series solutions VI - Inner product spaces