Now we’re going to take a more complicated expression and approximate it by a polynomial function. The function we’re going to look at is $f(x)=2 \sin x+\frac{\cos 3x}{2}$, but we could choose any function which is well behaved close to where we want to approximate it (there is a much more precise way to phrase this, but for the current discussion, this is enough).

This function looks like:

OK, so how are we going to go about approximating this function? Well, let’s ask about approximating it close to the point $x=2.5$ (this value is arbitrary and we could have asked for any value). What would be the most naive approximation we could make? Well, if we have a function which is a constant, and equal to the original function at $x=2.5$ then that’s a start. At least it matches the value of the function at that point, if nothing else. What is the value of this function at $x=2.5$? Well, it’s about 1.37. So $y=f(2.5)=1.37$ is perhaps the most naive approximation we could make for our function close to $x=2.5$. Let’s see how the two compare:

We will call this the zeroth approximation. Indeed it matches our original function perfectly at $x=2.5$ but apart from that it’s pretty rubbish. Maybe we can do better by approximating our function by a straight line that at least has the same gradient as our function? Well, clearly we want to it to pass through the point $(x,y)=(2.5,f(2.5))$ but now we also want it to have a slope. We are going to try and approximate it by the function:

$y=f(2.5)+c_1(x-2.5)$

for some $c_1$. If we want this to have the same gradient as our original function then we must have that:

$f'(2.5)=\left.\frac{d \left(f(2.5)+c_1(x-2.5)\right)}{dx}\right|_{x=2.5}=c_1$

So in fact we must have:

$y=f(2.5)+f'(2.5)(x-2.5)$

How does this function compare with the original function? Let’s look at them together:

Ah, now maybe we’re getting somewhere! The purple line now has the same value and derivative as our original function at exactly $x=2.5$. It’s looking a bit more like the function close to that point, at least very approximately.

How about if we want to get a bit more accurate. Let’s say that we want to include another power of $x$? We can try and approximate the function by a quadratic, but asking that the value, the first derivative and the second derivative all match with our original function at the value $x=2.5$.

Well we will set up our approximating function as:

$y=c_0+c_1(x-2.5)+c_2(x-2.5)^2$

Matching the value, the first and second derivatives of this function with our original function we will find:

$c_0=f(2.5)$

$c_1=f'(2.5)$

as before. Now let’s take two derivatives of our original function and match it to the second derivative of our approximating function at x=2.5:

$f''(2.5)=2c_2$

so now $c_2=\frac{f''(2.5)}{2}$. If we plug this into our quadratic expression and see how this compares with $f(x)$ we see:

Now the polynomial is exactly the same value, derivative and second derivative as our original function. We could continue this with higher and higher polynomials. If we go up to 14th order ie. $(x-2.5)^{14}$ we get the following approximation, which matches the value, first, second, ….up to fourteenth derivative of our function. As you can see, close to $x=2.5$ it’s a really good approximation now!

Great, so we can see that we can take a pretty arbitrary looking function, and approximate it to good accuracy by a polynomial expression. We still haven’t written this in a general form, but in the next post we will do just that.

 How clear is this post?