# Fourier Series

A lot of functions can look really ugly, and be hard to work with.
On the other hand there are some lovely functions that have wonderful properties.
What's amazing though is that some of these beautiful functions that can approximate many
other functions, even ones that look very bad.
Today we'll look at one example of this kind of thing: the Fourier series.
Ok let's start by considering all the functions you can draw on a line between --L to L. So
what do our nice functions look like?
We can make them like this: First draw a dot at 0, and dots at the end
points.
Now connect them like this.
You might recognize this as this sin function.
Then for the next one, put down the original dots and now one in between each of them,
and a swiggle to connect them.
This is also a sin function.
Keep repeating the process, and now we've made an infinite number of nice functions-
but wait, let's make more: take all of our previous ones and shift them over so that
their first peak is now in the middle.
These are all cos functions.
Now we finally have all the nice functions we're going to work with.
You might be wondering what exactly is so nice about these functions.
I won't say too much about that here, besides noting that they're periodic and infinitely
differentiable.
video I'll explain why they're super important in quantum mechanics.
Ok so back to our functions, there are an infinite number of them, but it's obvious
that they are only a tiny fraction of all possible functions.
It only starts to get interesting we start combining them in a special way called a linear
combination.
This is how you make a linear combination.
Pick some of the nice functions.
Now multiply each of these functions by a number.
This has the effect of stretching or compressing each of them.
For the rest of this video, we're only going to consider combining the functions in this
way.
We won't, for example, think about multiplying functions.
Anyway, as you can see from this example, the resulting function isn't one of our nice
ones.
That begs the question, exactly want kind of functions can you make using these linear
combinations?
The amazing result, know as the fourier series, says that actually, you can make a lot of
different functions this way.
Let's see an example to see how this works.
Let's use the function x cubed.
On the interval -Pi to Pi, x cubed looks like this.
We're going to try and approximate it using our nice functions.
The fourier series tells us what coefficients to use in our linear combination.
We start out by plotting the first approximation to it using the squiggles with the biggest
wavelength.
That's ok; we'll go onto linear combinations of two of our functions.
Better, I guess...
Let's do a few more.
This is the 3rd order approximation.
As we get toward the twentieth approximation, it actually looks pretty good!
Ok, so our swiggly functions can approximate smooth curved function like x^3 really well.
Let's give it more of a challenge with a function that isn't even continuous.
You see, by the twentieth approximation, this looks pretty good.
In fact, we can prove that as we go to higher and higher orders, we can make this approximation
as good as we want.
Here are some more examples and you can see in each case that the approximation works
well for them too.
The last one is actually a fractal, one of the nastiest types of functions there are,
and yet the Fourier Series still can approximate it.
I find this completely mind-boggling.
Why should a bunch of squiggly lines give a good approximation to functions that look
nothing like them?
I have no idea.
What's even cooler is that this version of the Fourier series is merely a special case
of an even more powerful one.
Suppose you have a complex valued function on the interval from negative L to L. By that
I mean a function that only takes real numbers between negative L and L as inputs but returns
complex numbers.
The general version of the Fourier series can even approximate those kind of functions.
Here's how.
First we need a new set of nice functions, because our old ones are real valued and that
won't do for this.
This is how we create the new ones: To make the first one, take the two biggest
squiggling functions multiply one by the imaginary number i, and add them together.
You might recognize this as a complex exponential function.
Do the same thing with the next two, and you see this is another exponential with a smaller
wavelength.
And of course, we just repeat this process forever to get the rest.
So these are our new nice functions.
To approximate a function -real or otherwise, with them, we do exactly the same thing as
before, we take linear combinations.
This version of the Fourier series will tell us what coefficients to use.
For real valued functions, the approximation is exactly the same as if we did it with our
original fourier series.
Here's one example of a complex function being approximated.
So that's what the Fourier series is about, approximating functions.
However, we only talked about how to approximate functions on a certain interval.
How to we do it if we want to approximate a function on the entire real line?
That's where the Fourier transform comes in.
If you want to know about that then I'll see you in the next video.