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

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 2pi and that's where actually a lot of these two pies came out from and that's also why we started here at cosine T and sine of T they both have a frequency of 1 over 2 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 0 a sub N and B sub n for this particular square wave so the key to realize is that our square wave between 0 and pi because we're going to keep taking the DEF integral from 0 to 2pi from 0 to 2pi from 0 to 2pi the key realization here is from 0 to pi our function is equal to 3 and from PI to 2 pi our function is equal to 0 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 1 over 2 pi times the definite integral from 0 to PI of F of T DT plus the integral from PI to 2 pi of F of T DT now F of T between 0 and pi we just said it's equal to 3 and F of T between PI and 2 pi well it's going to be equal to 0 and that's actually the case for for these other situations so that f of T is going to be 0 from PI to 2 pi and 0 times anything is going to be 0 so the integrals the definite integrals over this the second part of the interval are always going to be 0 and so it boils down to this and so what's the definite integral from 0 to PI of 3 DT well this is going to be equal to 1 over 2 pi times times so if you evaluate this the antiderivative 3 would be 3 T evaluated from from 0 to PI and so it'd be 3 pi minus 3 times 0 which is just 3 pi so it's equal to 3 PI over the 2 pi that we had already over the 2 pi and so this is going to be equal to 3 halves 3 halves and that makes a lot of sense because a sub 0 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 3 half the time and 0 the other half of the time well then the average is going to be one and a half or 3 halves so that is our a sub 0 so now let's figure out the general a sub n where n is not equal 0 so a sub n well we are just going to take it's going to be 1 over pi 1 over pi the definite integral I could go from 0 to 2 pi but instead I'm just going to cut to the taste I'm going to go just from 0 to PI because the integral from PI to 2 pi is just going to be 0 because the function is equal to 0 it's going to be zero times cosine and T is going to be 0 so for this particular square wave if I can just worry about from 0 to PI from 0 to PI f of T is 3 so it's going to be 3 cosine NT 3 let me do in that color 3 cosine of n T cosine NT DT now what is this going to be equal to well we can do a few things we could take our 3 and bring it out front so let me do that so we could take that 3 and bring it out front so just putting the 3 out here so take that 3 put it out front and we know that site the derivative of sine of NT is n cosine of NT so let's multiply the inside and the out or let's multiply the inside by N and then we could also divide by n but we could put that outside they would be n divided by n we haven't changed the value and so this is going to be equal to 3 over N pi that's just what we had out here times well the antiderivative of this business is going to be sine of NT sine of n T and we're going to 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 going to be zero for any n minus sine of zero times n well that's going to be zero for any n so all 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 n s for any n not equal to zero it's going to be zero so actually we're not we're not going to 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 ends get a little space here so B sub n same thing we could take the we could just worry about the interval from zero to pi because from PI to 2 pi our f of T is going to be equal to zero so this is going to be equal to 1 over pi times the definite integral once again I'm only going to worry about from 0 to PI 0 to PI D T now the value of the function from 0 to PI is 3 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 so it's going to be 3 actually I don't want to skip too many steps it's going to be 3 times sine of NT 3 sine of n T and let's see how can i reconstruct this so it's easy to take the antiderivative well this is going to be if we take that 3 out front it's going to be 3 over PI and then you have your definite integral from 0 to PI of sine of mu do that same color sine of NT sine of n T 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 and let's also divide by a negative end just like that if you have negative n divided by negative and we haven't chain 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 antiderivative here so this is going to be cosine of n T evaluated from 0 0 to PI and so what is this this is going to be equal to this is equal to negative 3 over n PI cosine of 0 n that's going to be 1 for any n minus cosine of oh sorry and why did I start at 0 it's going to be cosine of n PI cosine of n PI minus cosine of n times 0 so minus cosine of 0 cosine of 0 is just going to be 1 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 1 or is that negative 1 well it depends if n is if n is even this is going to be positive 1 if n is odd this is going to be negative 1 so it depends actually let's 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 going to have negative 3 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 would be like cosine of 2 pi cosine of 4 pi cosine of 6 pi well in that situation this is going to evaluate to 1 you're going to have 1 minus 1 which is 0 so the whole thing is going to evaluate to 0 and if n is odd cosine of pi cosine of 3 PI cosine of 5pi well those are going to evaluate to negative 1 then it's going to be negative 1 if n is odd negative 1 minus 1 is negative 2 and so this is all going to be negative 2 negative 2 times negative 3 over n pi is going to be 6 6 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 then we definitely deserve a drumroll this is many videos in the making f of T is going to be equal to a sub 0 we figure it out in this video is equal to three halves this is going to be three halves let me write this well let me just write it all in yellow so three halves now we don't have any a sub ends we figure that out all of the a sub ends are going to be 0 and then the B the only B sub ends we have is when n is odd when n is odd so we're going to have B sub 1 so that's going to be 6 over 1 pi 6 over 1 pi sine of 1 times T so 2 sine of T plus now we're not going to have a B sub 2 we're gonna have a B sub 3 so 6 over 3 pi times sine of 3t and of course this is the same thing as this is the same thing as 2 over pi times sine of 3t plus now we are not going to have a b sub 4 we're gonna have a b sub 5 so that's going to be 6 over 5 pi/6 actually I liked I liked writing it it's nicer to actually not simplify here because you can see the pattern so it's going to be plus 6 over 5 pi times sine of 5t and we're just going to 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