yego.me
💡 Stop wasting time. Read Youtube instead of watch. Download Chrome Extension

Finding Fourier coefficients for square wave


6m read
·Nov 11, 2024

So this could very well be an exciting video because we started with this idea of a 4A series that we could take a periodic function and represent it as an infinite sum of weighted cosines and sines. We use that idea to say, well, can we find formulas for those coefficients? We were able to do that using the powers of calculus. Now we can actually apply it for this particular square wave.

I picked a square wave that has a period of 2 pi, and that's where actually a lot of these 2 pi came out from. That's also why we started here at cosine T and sine T. They both have a frequency of 1 over 2 pi, which is the frequency of our original square wave. 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. We will generalize in the future.

Now, let's actually evaluate a sub z, a sub n, and b sub n for this particular square wave. The key to realize is that our square wave between 0 and pi—because we're going to keep taking the definite integral from 0 to 2 pi—between 0 and pi, our function is equal to three, and from pi to 2 pi, our function is equal to zero.

So all of these definite integrals—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 three, and F of T between pi and 2 pi—well, it's going to be equal to zero.

That's actually the case for these other situations, that F of T is going to be zero from pi to 2 pi, and zero times anything is going to be zero. So the definite integrals over the second part of the interval are always going to be zero. It boils down to this. 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, so if you evaluate this, the anti-derivative of three would be 3T evaluated from 0 to pi.

It would 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. This is going to be equal to three halves. That makes a lot of sense because a sub z, we said, you could view that as the average value of the function over that interval. 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. Now let's figure out the general a sub n, where n is not equal to zero. So a sub n, well, we are just going to take—it’s going to be 1 over pi, 1 over pi times the definite integral. I could go from 0 to 2 pi, but instead, I'm just going to cut to the chase. I'm going to go just from 0 to pi, because the integral from pi to 2 pi is just going to be zero. The function is equal to zero; it's going to be zero times cosine, which is just going to be zero.

For this particular square wave, I can just worry about from 0 to pi. From 0 to pi, F of T is three, so it's going to be three times cosine of nT dT. 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.

We could take that three and bring it out front, so just putting the three out here. We know that the derivative of sine of nT is n cosine of nT, so let's multiply the inside and the outside. We could also divide by n, but we could put that outside; it 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 anti-derivative of this business is going to be sine of nT evaluated from 0 to pi.

This is going to be equal to 3 over n pi times sine of n pi. Well, that's going to be zero for any n minus sine of 0. Well, that's going to 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 n's for any n not equal to zero is going to be zero.

So actually, we're not going to have any of these cosines show up in the 4A 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 n's. So our b sub n's 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. 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, from 0 to pi dT.

Now the value of the function from 0 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. So it's going to be three times sine of nT. Let's see, how can I reconstruct this so it's easy to take the anti-derivative?

Well, this is going to be—if we take that three out front, it's going to be 3 over pi, and then you have your definite integral from 0 to pi of sine of nT dT. 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, but let's also divide by negative n, just like that. If you have n divided by n, we haven't changed the value; that's just one.

This is going to be equal to negative 3 over n pi times— we're going to take the anti-derivative here—so this is going to be sine of nT evaluated from 0 to pi. So what is this? This is going to be equal to negative 3 over n pi times cosine of n pi minus cosine of 0.

Cosine of 0 is just going to be one for any n. 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 even, this is going to be positive one. If n is odd, this is going to be negative one.

So it depends. Actually, let's just write that out. So b sub n is equal to—let's write those two cases. So if n is even, 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 if n is even, it 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 one. You're going to have 1 minus 1, which is zero, so the whole thing is going to evaluate to zero.

And if n is odd, cosine of pi, cosine of 3 pi, cosine of 5 pi, well, those are going to evaluate to positive one; then it's going to be negative one. If n is odd, 1 minus 1 is negative 2, and so this is all going to be negative 2 times negative 3 over n pi, which is going to be 6 over n pi.

So there you have it. We have been able to figure out our 4A expansion; it is going to be our square wave. We definitely deserve a drum roll; this is many videos in the making.

F of T is going to be equal to a sub z we figured out in this video, which is equal to three halves. So it’s 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 n's; we figure that out—all of the a sub n's are going to be zero. And then the only b sub n's we have is when n is odd. When n is odd, we're going to have b sub one, so that's going to be 6 over 1 pi, 6 over 1 pi sine of 1T, so sine of T plus—now we're not going to have a b sub 2, we're going to have a b sub 3—so 6 over 3 pi times sine of 3T.

Of course, this is the same thing as 2 over pi sine of 3T. Plus now, we're not going to have a b sub 4, we're going to have a b sub 5, so that's going to be 6 over 5 pi sine of 5T.

I actually 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 sine of 5T, and we're just going to go on and on and on.

And there you have it; we have our 4A expansion. In the next video, we're actually going to visualize this.

More Articles

View All
Jessica Livingston on Cofounder Disputes and Making Something People Want
All right, so now we’re going to move on to another monster: co-founder disputes. I think people underestimate how critical founder relationships are to the success of a startup. Unfortunately, I’ve seen more founder breakups than I care to even count, an…
What To Focus On To Make $1 Million Dollars in 90 days | Grant Cardone
If you had 90 days, 90 days to make a million dollars, start with nothing. You started with nothing, and you can’t use your name, Kevin O’Leary. What would you focus on? Wow, well, that’s a tough one, Grant. Like, that’s a real tough one. Does it make se…
Functions of money | Financial sector | AP Macroeconomics | Khan Academy
Hello everyone, Grant here. So I’d like to talk to you today about the various functions of money. Functions of money now. Money, of course, is something that we all use every day, and we kind of have a general feel for what it is. But it’s interesting t…
We Are All Related
Hey, Vsauce, Michael here, and you guys are my family. Scientifically speaking, geneticists tell us that every single person on earth is, at the least, 50th cousins with everybody else on earth. It kind of has to be that way. Think of it like this—you ha…
Huge Whip Spiders Wear Nail Polish for Science | Expedition Raw
You want me to catch this one? We’re looking for wig spiders tonight because they have a remarkable navigational ability. Yeah, yeah, yeah, you got them. They come back each night faithfully to the same little refuge site and this large tree that you’ve …
10 Tips to Avoid Bad Stock Market Mistakes
[Music] Hey guys, welcome back to the channel. In this video, we’re talking 10 quick tips to help you avoid bad investments. These are essentially just tips that I kind of wish I heard, you know, five, six years ago, which someone had told me that I’ve ju…