In this post, I want to have a look at a really neat part of calculus, Taylor series. It’s essentially a process you can use to approximate some graph, e.g. ex, using a polynomial – the idea is, the higher order the polynomial, the more accurate the approximation gets.
Let’s dive in! (This gets a bit tricky)
How does it work? First, some terminology – the first order approximation is a linear approximation (so ax+b), second order is quadratic (ax2 + bx + c), and so on. So let’s start with a first order approximation of, say, ex.
The first thing to do is to decide at what point we want to approximate it – so let’s pick x=0, as it’s simple. Obviously, the easiest way to approximate the function at x=0 is to make sure it takes the same value as ex there, so the graphs intersect at that point. e0=1, so our approximation must pass through (0,1). So our first order approximation looks like ax+1. Let’s choose a random value of a (e.g. 2), and see how it looks.
The slope is obviously not very accurate, but how do we find a better gradient for our first order approximation? Well, gradients are essentially derivatives – so what if we make the derivative of our first order approximation equal to the derivative of ex?
(ex)’ = ex, e0=1
So the derivative of ex at x=0 is 1. This means we want the gradient of our approximation to also be 1, so our approximation is x+1. Let’s try that out:
This is, as it turns out, the best first order approximation for this function. The next step is to make a second order approximation, ax2 + bx + c. We start the same way:
e0=a(0)2 + b(0) + c, so c=1
Then we make their derivatives equal, so they are generally heading in the same direction:
e0=2a(0) + b, b=1
Then the natural next step is to make their second derivatives equal:
And in general, to approximate some function f(x) around x=0, the nth order approximation pn(x) has to fit these rules:
f(0) = pn(0)
f'(0) = pn‘(0)
f”(0) = pn”(0)
f(n)(0) = pn(n)(0)
So all the derivatives match up. If you think about it, this makes sense – not only are the functions equal at 0, but they are also heading in the same direction, and the rate of change of direction is the same, and so on down the line – this isn’t a rigorous explanation of why this works, but for a lot of graphs, the further you go down this line, the closer the approximation gets.
Is this a Taylor series?
No, not yet. There are a few more steps that make this a Taylor series. First of all, what we’ve found are the Maclaurin Polynomials, the series of polynomials that give better and better approximations of our function. If we take this polynomial to infinity, we get the Maclaurin Series, which is no longer an approximation, at least in the case of ex; for some functions at least, it is exactly that function. For other functions, it is exact over a small range (for example, hyperbolas), while for still other functions it is only exact at the point x=0. Take this graph,e-1/x2.
Trying to find the Maclaurin series, you will quickly find that it tells you all the gradients of this function at 0 are 0, so the best you will get is the line y=0. To remedy this, you can approximate the function at a point other than 0. This generalised series, where you take an approximation at x=a towards infinite accuracy, is the Taylor Series. This is the general formula:
Taylor series =
It isn’t necessary to understand this, but it’s the fully fleshed out formula.
What’s the outcome of this?
If you can’t be bothered trying to follow that mess of an explanation, the ultimate result you need to understand is that for some nice functions, e.g. exponentials, and some trig functions, there is a way of representing them as a polynomial of infinite order. For example, 1/1-x = 1 + x + x2 + x3 + x4 + … and so on.
What is this good for?
Taylor Series have one big advantage – they take functions that are sometimes hard to work with, like exponentials or trig functions, and turn them into polynomials, which are often much more convenient. How are they more convenient? Well, let’s try differentiating ex. We can try from first principles:
but this doesn’t really get us anwhere. However, when we turn it into an infinite polynomial:
If we differentiate this term by term:
We end up with in the same place we started. We can do similar manipulations to show the derivative of sin(x) is cos(x), and the derivative of cos(x) is -sin(x).
Is that all?
Not quite. Let’s look at a slight variation of ex, eix, where . Then the expansion looks like this:
But we know that we can replace the powers of i, because , so:
If we split this into the terms that have i, and the terms that don’t:
Don’t these two new infinite series look familiar? As it happens, they are the Taylor expansions of cos(x) and sin(x), so:
This formula is called Euler’s formula. Now, if we substitute in π as x:
This little relationship is Euler’s identity, and is considered to be one of the most beautiful and fundamental connections in mathematics.