If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content
Current time:0:00Total duration:10:40

Finding Fourier coefficients for square wave

Video transcript

- [Voiceover] So this could very well be an exciting video because we start with this idea of a Fourier series that we could take a periodic function and represent it as an infinite sum of weighted cosines and sines and we use that idea to say, "Well can we find formulas "for those coefficients?" And we were able to do that using the powers of calculus. And now we can actually apply it for this particular square wave. And I picked a square wave that has a period of two pi and that's where, actually, a lot of these two pis came out from, and that's also why we started here at cosine t and sine of t. They both have a frequency of one over two pi, which is the frequency of our original square wave. And then the other terms have frequencies that are multiples of that. If we had a different period then all of that would change. But I picked this period to just make the math a little bit simpler and we will generalize in the future. But now, let's actually evaluate a-sub-zero, a-sub-n, and b-sub-n for this particular square wave. So, they key to realize is that our square wave between zero and pi, 'cause we're gonna keep taking the definite integral from zero to two pi, from zero to two pi, from zero to two pi. The key realization here is from zero to pi our function is equal to three, and from pi to two pi, our function is equal to zero. So all of these definite integrals. So this definite integral, for example, is going to be the same thing as, and I'll do it once and then we'll see that trend. This is the same thing as one over two pi times the definite integral from zero to pi of f-of-t dt plus the integral from pi to two pi of f-of-t dt. Now f-of-t, between zero and pi, we just said it's equal to three. And f-of-t between pi and two pi, well it's going to be equal to zero. And that's actually the case for these other situations. That f-of-t's gonna be zero from pi to two pi and zero times anything is gonna be zero, so the integrals, the definite integrals over this, the second part of the interval, are always going to be zero. And so it boils down to this. And so what's the definite integral from zero to pi of three dt? Well this is going to be equal to one over two pi times, so if you evaluate this, the anti-derivative of three, it'd be three t, evaluated from zero to pi, and so it'd be three pi minus three times zero which is just three pi. So it's equal to three pi over the two pi that we had already, over the two pi, and so this is going to be equal to three halves. Three halves. And that makes a lot of sense because a-sub-zero we said you could view that as the average value of the function over that interval. And the average value of that function is indeed, if it's three half the time, and zero the other half of the time, well then the average is going to be one and a half, or three halves. So that is our a-sub-zero. So now let's figure out the general a-sub-n where n is not equal zero. So, a-sub-n, well we are just gonna take, it's gonna be one over pi, one over pi, the definite integral, I could go from zero to two pi, but instead I'm just gonna cut to the chase. I'm gonna go just from zero to pi 'cause the integral from pi to two pi is just gonna be zero 'cause the function's equal to zero. It's gonna be zero times cosine nt; it's just gonna be zero. So for this particular square wave, I can just worry about from zero to pi. From zero to pi, f-of-t is three. So it's gonna be three cosine-nt. Three, let me do that color, three cosine-of-nt, cosine-nt dt. Now what is this going to be equal to? Well we can do a few things. We could take our three and bring it out front. So let me do that. So we could take that three and bring it out front. So, just putting the three out here. So take that three, put it out front. And we know that the derivative of sine-of-nt is n cosine-of-nt. So let's multiple the inside and the out, or let's multiple the inside by n, and then we could also divide by n but we could put that outside. They would, it'd be, n divided by n, we haven't changed the value. And so this is going to be equal to three over n pi, that's just what we had out here, times, well the anti-derivative of this business is going to be sine-of-nt, sine-of-nt. And we're gonna evaluate from zero to pi. So this is going to be equal to three over n pi times sine-of-n pi, well that's gonna be zero for any n, minus sine-of-zero times n. Well that's gonna be zero for any n. So all of this is just going to be zero. So a-sub-n is going to be equal to zero. The coefficient on any, for any, of a-sub-ns for any n not equal zero, it's going to be zero. So actually we're not gonna have any of these cosines show up in the Fourier expansion. Let's think about our b-sub-n. When you look at the shape of the square wave, it actually makes a lot of sense. But let's now tackle our b-sub-ns. So our b-sub-ns, get a little space here. So b-sub-n. Same thing, we could just worry about the interval from zero to pi because from pi to two pi our f-of-t is going to be equal to zero. So this is going to be equal to one over pi times the definite integral, once again I'm only gonna worry about from zero to pi, zero to pi dt. Now the value of the function from zero to pi is three, we've seen that before, I could put it here, but just to get a little bit simpler, let's just stick it right over here. Just gonna be three, actually I don't wanna skip too many steps. It's gonna be three times sine-of-nt. Three sine-of-nt. Now let's see. How can I reconstruct this so it's easy to take the anti-derivative? Well this is going to be, we take that three out front, it's gonna be three over pi. And then you have your definite integral from zero to pi of sine-of, we'll do that same color, sine-of-nt. Sine-of-nt dt. And we know the derivative of cosine-nt is negative n sine-of-nt, so let's throw a negative n in here. So negative n. Let's also divide by negative n. Just like that. If you have negative n divided by negative n, we haven't changed the value. That's just one. And so this is going to be equal to negative three over n pi times, we're going to take the anti-derivative here, so this is gonna be cosine-of-nt evaluated from zero zero to pi. And so, what is this? This is going to be equal to, this is equal to negative three over n pi. Cosine-of-zero n, that's gonna be one for any n, minus cosine-of Oh sorry. Why did I start at zero? It's gonna be cosine-of-n pi, cosine-of-n pi minus cosine-of-n times zero. So minus cosine-of-zero, cosine-of-zero is just gonna be one for any n. And so there you have it. We have a general And you might say, "Well, cosine-of-n pi, "is that positive one, or is that negative one?" Well, it depends. If n is, if n is even, this is going to be positive one. If n is odd, this is going to be negative one. So it depends. And actually let's just write that out. So b-sub-n, b-sub-n is equal to, let's write those two cases. So if n is if n is even, and, another one, if n is odd. So if n is even, you're gonna have negative three over n pi times Actually let me just do it over here so we have the space. So what would this thing evaluate to if n is even? So this n, if it's even it'd be like cosine-of-two pi, cosine-of-four pi, cosine-of-six pi. Well in that situation, this is going to evaluate to one. You're gonna have one minus one, which is zero, so the whole thing is gonna evaluate to zero. And if n is odd, cosine-of-pi, cosine-of-three pi, cosine-of-five pi, well those are gonna evaluate to negative one. Then it's gonna be negative one if n is odd. Negative one minus one is negative two, and so this is all gonna be negative two. Negative two times negative three over n pi is going to be six. Six over n pi. So there you have it. We have been able to figure out our Fourier expansion. It is going to be, our square wave, and we definitely deserve a drumroll, this is many videos in the making, f-of-t is going to be equal to a-sub-zero, we figured out in this video is equal to three halves. So it's gonna be three halves. Let me write this. Well I'm just write it all in yellow. So three halves. Now we don't have any a-sub-ns. We figured that out. All of the a-sub-ns are going to be zero. And then the b, the only b-sub-ns we have is when n is odd. When n is odd. So, we're gonna have b-sub-one. So that's gonna be six over one pi. Six over one pi. Sine-of-one times t. So sine-of-t. Plus, now we're not gonna have a b-sub-two, we're gonna have a b-sub-three. So six over three pi times sine-of-three t, and of course this is the same thing as, this is the same thing as two over pi times sine of three t, plus, now we're not gonna have a b-sub-four, we're gonna have a b-sub-five. So that's going to be six over five pi. Actually I liked writing, it's nicer to actually not simplify here because you can see the pattern. So it's gonna be plus six over five pi times sine-of-five t. And we're just gonna go on and on and on. And there you have it. We have our Fourier expansion. In the next video, we're actually going to visualize this.