Visualizing the Fourier expansion of a square wave

Learn this with friends

ScienceElectrical engineering3:305 check-ins

About this video

Builds a Fourier series for a square wave with period 2pi. The coefficients are found by evaluating integrals: a0 equals 3/2, all cosine coefficients a_n are zero, and the sine coefficients b_n are zero for even n and 6/(n pi) for odd n. Adding the odd sine terms one by one shows the partial sums converging visually toward the square wave.

You'll be able to

  • explain why a periodic square wave can be written as a weighted sum of sines and cosines.
  • identify which Fourier coefficients vanish for this square wave and explain why, using symmetry and phase.
  • predict how adding more odd sine terms changes the partial sum of the series.

Key words

Fourier series
An infinite sum of weighted sines and cosines that represents a periodic function.
Period
The length of one full cycle of a periodic function, here 2pi for the square wave.
Fourier coefficients
The weights a0, a_n and b_n that multiply the constant term, cosine terms and sine terms.
Partial sum
The Fourier series truncated after a finite number of terms, used to approximate the function.
Odd harmonic
A sine term whose frequency is an odd multiple of the base frequency, such as sin 3t or sin 5t.
Transcript

- [Voiceover] So we started with a square wave that had a period of two pi, then we said, hmm, can we represent it as an infinite series of weighted sines and cosines, and then working from that idea, we were actually able to find expressions for the coefficients, for a sub zero and a sub n when n does not equal zero, and the b sub ns.

And evaluating it for this particular square wave, we were able to get that a sub n is going to be equal, or a sub zero is going to be 3/2, that a sub n is going to be equal to zero for any n other than zero, and that b sub n is going to be equal to zero if n is even and six over n pi if n is odd.

So one way to think about it, you're gonna get your a sub zero, you're not gonna have any of the cosine terms, and you're only going to have the odd sine terms. And if you think about it just visually, if you look at the square wave, it makes sense that you're gonna have the sines and not the cosines because a sine function is gonna look something like this.

So a sine function is gonna look something like this, while a cosine function looks something like, let me make it a little bit neater, a cosine function would look something like that. And so a cosine and multiples of cosine of two x, cosine of three x, is gonna be out of phase, while the sine of x, or I should say cosine of ts and the sines of ts, sine two t, sine three t, is gonna be more in phase with the way this function just happened to be.

So it made sense that our a sub ns were all zero for n not equaling zero. And so based on what we found for our a sub zero, and our a sub ns, and our b sub ns, we could expand out this actual, we did in the previous video, what is this Fourier series actually look like?

So 3/2 plus six over pi sine of t plus six over three pi sine of three t plus six over five pi sine of five t, and so on and so forth. And so a lot of you might be curious what does this actually look like. And so I actually just, you can type these things into Google and it will just graph it for you.

And so this right over here is just the first two terms. This is 3/2 plus six over pi sine of t. And notice it's starting to look right because our square wave looks something like, it goes, it looks something like this. So it's gonna go like that and then it's gonna go down to zero and then it's gonna go up, looks something like that.

It doesn't have the pis and the two pis marked off between these because it's gonna look something like that. So even just the two terms, it's kind of a decent approximation for even two terms, but then as soon as you get to three terms, if you add the six over three pi sine of three t to the first two terms.

So if you look at these first three terms, now it's looking a lot more like a square wave. And then if you add the next term, well, it looks like even more like a square wave, and then if you add to that what we already wrote down here, if you were to add to that six over seven pi times sine of seven t, it looks even more like a square wave.

So this is pretty neat. You can visually see that we were actually able to do it. And it all kind of just fell out from the mathematics.

Video © Khan Academy, used under CC BY-NC-SA. Watch on Khan Academy. Puzzicle is not affiliated with Khan Academy.