 In this video, we want to find the Fourier series that represents the triangular wave function given by the following formula f of x equals the absolute value of x over pi when x is between negative pi and pi. And then we also define it to be two pi periodic. So as you shift down to pi units, this will just repeat what you saw before. So the graph of f you can see illustrated right here. That from, from negative pi to pi, this is basically just the absolute value function. I did scale it down so that when you hit pi right here, this is actually equal to the y-coordinate of 1. That's not necessary, but that does, that'll make the Fourier series just a little bit cleaner. But it doesn't, it doesn't make much of a difference because after all, changing the function by constant multiple only changes the Fourier series by constant multiple as well. So again, this is mostly just for convenience, but not necessary step here. What happens, and we've talked about this previously in this lecture, that if you take just any function whatsoever, any continuous function, like the absolute value function, you can just carbon copy and repeat it and repeat it and repeat it, and you can make it a periodic function. And that periodic function will have a Fourier series representation that perfectly matches it. You'll notice with this function, there are, because of its symmetry with respect to the y-axis, since the original function was even, there are no jump discontinuities. This function is continuous. Now, sure, its derivative is undefined at the jumps, but its derivative is piecewise continuous. And so by the Fourier convergence theorem, this Fourier series that we're about to compute will be exactly equal to the triangular wave function, sometimes called the sawtooth function, because it looks like the teeth of a saw, like here. And we created a sawtooth function, which is 2 pi periodic. It ranges from negative pi to pi. But I want you to be aware that you could make this work with any period whatsoever. If your function was 2L periodic, be aware that you could find the Fourier coefficients by similar formulas to what we saw before. So for a 2 pi periodic function, the constant in our Fourier series, so just as a reminder, we're looking for the Fourier's representation f of x here is equal to a sub zero plus the sum, where n ranges from one to infinity, we're going to get an cosine of nx plus bn sine of nx, like so. So this is the Fourier series that we're looking for. And so we had formulas previously, how to find the coefficients a0, an, bn. And we did those for 2 pi periodic functions, but be aware if you shift it to any period, like a 2L period, the calculations we did before would modify perfectly. So instead of getting 1 over 2 pi, so the standard formula was 1 over 2 pi times integral from negative pi to pi. Instead what we get is the integral from 1 over 2L, so that the bottom number is the length of the period, you then integrate from negative L to L f of x dx. That's how you get the constant coefficient. In order to grab a sub n, the coefficients of the cosines, normally the formula is 1 over pi times the integral from negative pi to pi of f of x cosine of nx. If you change the period, you're going to get 1 over L, so half of the period, integral from negative L to L, that makes sense, f of x times cosine of, and this is the part that changes the most, you're going to get pi nx over L dx, like so, because you have to change the cosines, so it also is 2L periodic. The pi over L will do exactly that, it changes the period appropriately. And then if you wanted to do it for sine as well, the standard formula is 1 over pi integral from negative pi to pi f of x sine of nx, but if you change the period, you're going to get 1 over L, that makes sense, integrate from negative L to L, f of x, which is already 2L periodic times sine of, you have to make sine become 2L periodic, so you're going to insert this pi over L, and then you get the nx like usual. And so I want you to be aware that these formulas, these general Fourier coefficient formulas can be used to find the Fourier representation of any function that is periodic, whether it's 2 pi periodic or not. Now, in our example here, we are 2 pi periodic, and remember our function, it looks like our functions f of x equals the absolute value of x over pi, and it is 2 pi periodic, so we'll use the simplified formulas in this example here. So as we try to compute, let's keep the formula on the screen here, so as we try to compute the constant term, we have to take 1 over 2 pi, integral from negative pi to pi of f of x here, for which we do exactly that, we're going to get 1 over 2 pi. Now, since our function is the absolute value of x over pi, there's another pi, so I'm just going to bring that out already, so 1 over 2 times pi squared, so we have to integrate, we have to integrate the absolute value of x. Now, the anti-derivative absolute value of x is a little bit more complicated than I want to deal with right now, but by symmetry, the absolute value function, right, it's a symmetric function with respect to the y-axis, so if I just integrate from 0 to pi of the absolute value of x, I can double that. Doubling that will cancel out this 2, as we insert a 2 in there now, that puts the bomb down to 0, but it also has the convenience that if you're only looking at 0 to pi, the absolute value of x is identical to x, and that's a function that's much easier to integrate here. So, using symmetry, this becomes 1 over pi squared times the integral from 0 to pi of f of x, dx there. The anti-derivative x by the power rule, the usual power rule is x squared over 2. We're going to integrate from 0 to pi. If you plug in 0, you're going to get back 0. If you plug in pi, you end up with a pi squared, and so you end up with pi squared over 2 pi squared. The pi squareds cancel out, we end up with 1 half. And this is exactly the reason why we had a divided by pi in the original function. That was just to clean this thing up so that I made this coefficient be a 1 half instead of a 1 over 2 pi or something like that. So, in particular, the constant term for your Fourier coefficients here is going to be 1 half. Now, let's look for the cosine terms utilizing this general formula here. So, we're going to look at, to find a sub n, we're going to look at 1 over pi times integral from negative pi to pi of f of x cosine of n x. Okay? But utilizing some of the same tricks that we did before, I'm going to bring that coefficient of pi outside. So, there's a coefficient of 1 over pi squared there. We're integrating from negative pi to pi of the square root of x, sorry, the absolute value of x. But again, by symmetry, I can integrate from 0 to pi, doubling the whole area. And then the right hand side of the absolute value of x is just x itself. So, then I want to integrate x times cosine of n x. Now, how are we going to find an antiderivative of x times cosine of n x? This is something that seems like we do integration by parts. Where we're going to take u to equal x, so that du becomes dx. We're going to set dv equal to cosine of nx dx. So, then the antiderivative will be 1 over n sine of nx. Like so. So, putting this together, using the integration by parts, we're going to take u times v that shows up here. So, you're going to get x times 1 over n sine of nx. That's this function right here. You'll integrate it, well, you'll evaluate it from 0 to pi. Then we get the, that's just part of the antiderivative. You still have an integral to calculate. We have to take the integral of v du now, for which du is just dx. So, you're going to get 1 over n times sine of nx. That antiderivative doesn't seem so bad, but before I evaluate it, I do want to note here that if you plug in 0 into x, it's going to vanish. Of course, plug it in 0 into sine. Also, we'll vanish. When you plug in pi for x, that's just a pi. But like we saw in the previous video here, if you plug in pi into sine, any multiple of pi when inserted into sine gives you a 0. So, it turns out that this whole thing vanishes. This part of the antiderivative is poof. It's gone. And so therefore, taking that out, we just get 2 over pi squared times negative this thing. I mean, because you're subtracting it. So, we're going to end up with a negative 2 over n pi squared. I'm going to bring the 1 over n outside of this thing. So, we get negative 2 over n pi squared times the integral from 0 to pi of sine of nx dx there. And so then, taking an antiderivative of sine of nx dx, the antiderivative is going to be negative 1 over n cosine of nx. Since there's already a negative there, it cancels out making a positive. We get another 1 over n inside of our coefficient combining with the 1 over n we already have. It's going to give us an n squared. So, we get 2 over n squared pi squared times cosine of nx right here. For which, when we plug in 0, we're going to get a 1. And when we plug in pi, we're going to end up with a negative 1 to the n. We saw this in the previous example as well. So, we get negative 1 to the n minus 1 plus this coefficient 2 over n squared pi squared. Now, depending on your choice of n, this negative 1 to the n, if n is an even number, it's going to be, in that case, you're just going to get a 1. 1 minus 1 is 0. So, it's going to mostly vanish. But if you plug in an odd number for the power of negative 1, you're going to get negative 1. Negative 1 minus 1 gives you a negative 2, which then multiplies by the 2 to give you negative 4. So, when n is an odd number, you're going to get negative 4 over n squared pi squared. And when n is even, you're going to get 0. This was a similar thing we saw when we did the square wave function in the previous video here. If we go through this calculation for b sub n here, you get 1 over pi squared times integral from negative pi to pi of the absolute value of x times sine of nx. I'm actually just going to stop right here. Since absolute value of x is an even function and since sine of nx is an odd function, their product is an odd function. And therefore, the integral of an odd function across the symmetric interval is 0. No anti-derivatives necessary. All of these b n's are 0. Half of the a n's are 0. The odd ones are not. And so, if we put all of this information into play here, we then get the following. The constant term was 1 half. We're then going to subtract 4 over n squared pi squared. But we're only grabbing the odd multiples there. So, I'm going to write this as 2k minus 1 as k ranges from 1 to infinity in this situation here. And then, you're going to get a cosine of that same odd multiple, 2k minus 1x. And so, in an expanded form, this will look like 1 half minus 4 over pi squared sine of x minus 4 over 9 pi squared times sine of 3x minus 4 over 25 pi squared sine of 5x. And if we continue on, you're going to get a minus 4 over 49 pi squared sine of 7x. So, notice here that the multiple of x inside the sine is always, oh, why do I write sines there? Sorry. These should be cosines. Sorry about that typo. These are cosines. It was correct in the above formula. But when I copied it down, I apparently broke the sign. So, it should all be cosines, my mistake. But as you look at the next term here, it would be negative 4 over 49 pi squared cosine of 7x. So, the multiple of x inside the cosine, it will always be a odd integer. And then, the number in the denominators could be that number squared. So, like the next one, you're going to get 4 over 81 pi squared times cosine of 9x, like so. And so, you repeat this over and over and over and over again towards infinity. I'm going to switch over to Desmos.com for a second to show you the graph of these things. And if you want to play around with this graph yourself, you can actually find a link to the graph in the video's description below. So, we see here on the graph our sawtooth function from negative pi to pi. It looks like the absolute value function that's been scaled down by a factor of pi. That's so that the top of the teeth stops at y equals zero. The bottom, of course, is on the x-axis, like so. And so, if we turn on the foyer series approximation, we don't have the whole series. We're starting off with n equals zero right now. Currently, you just see y equals one half. That was the constant term as we increase these things. When you look at just n equals one, man, that is a good approximation. It looks like just a cosine that's been modified, but man, one cosine does pretty good. Notice on this that in the middle, it does really, really good. The part that it struggles is at these non-differentiable cusp, the corners of our sawtooth right there, the sharp points of the saw there. It comes to a point on the graph, but the cosine function is rounded, so it's a little bit harder to fit that. But hey, what if we increase it to n equals two? Boom! It does a lot better approximating the middle part, and it even got better at getting to the points of the teeth there. So, let's look at this a little bit more increase. We're up to n equals three, n equals four, n equals five, and six. So, you notice that each time I increment this thing, it gets a lot tighter right here, and then it's getting closer and closer to that corner. Okay? The gap between them is so small now. You can see seven, eight, nine, ten, eleven, right? For which if I try to zoom out here, if I zoom out to a quite reasonable scale, you can't tell the difference between the sawtooth function and this foyer series approximation. This is just a partial sum. This isn't even the whole thing. We're only at n equals 11 right now. Of course, if you zoom in far enough, you can always see the gap, because there is that gap there. Yikes. But of course, as we start to increase this more, more, more, more, more, you can see that it's approaching that corner. And so, if you take the limit as n goes to infinity, that will actually, they'll finally meet each other, and you'll get a perfect approximation. And so, this gives us the foyer series representation for the sawtooth function. And we can see that it is actually a quite tight match right there. And so, that brings us to the end of our lecture about foyer series. This was an on-core lecture. It was pretty fun. I hope you enjoyed it. If you didn't learn anything about foyer series, or you just like learning about calculus in general, like these videos. Subscribe to the channel to see more videos like this in the future. If you have friends or colleagues who might benefit from these videos, feel free to share them. And of course, if you have any questions whatsoever, feel free to post them in the comments below. And I'll be glad to answer them as soon as I can.