## Friday, June 24, 2011

### 7.1 – Taylor Polynomial

A power series is an expression of a function as a sum of infinite polynomials. Every differentiable function f(x) can somehow be approximated by a series of polynomials, such that f(x) = a + b(x-x0) + c(x-x0)2 + d(x-x0)3 + e(x-x0)4 + … + f(x-x0)n

When x is close to x0, and where a f are constants. If you remembered the Binomial Expansion for real numbers, the function (1+x)r can be represented by the series

Compare the Binomial Series above with the formula for f(x). You see that it is just a special case of the above function, such that x0 is zero, and the constants are defined in a special relation.

Our question is this: Since we could represent the above bracketed polynomial function as an infinite series of polynomials, so is it possible that we represent other functions, like sin x, ln x, ex or anything else? If it is doable, how do we determine the constants a, b, c and so on as in the function f(x) above?

Before we get into our topic Taylor polynomials, let me introduce to you Taylor’s Theorem with Remainder. The theorem states that if a certain function f(x) is (n+1)-times differentiable, then

Let me explain this a little. The term a is used when we measure the f(x) close to it. For example, when a = 0, we substitute it into the series, and the new expression will be  definitely quite accurate for estimating values x which are close to a (of course, for certain functions, the value x is accurate for whatever value a. We’ll discuss this in the later section). This means, we vary a to approximate the different values of the same function.

Then, the term f’(a), f’’(a) are the 1st and 2nd derivatives of the function f(x). Note that the term f(n)(x), the ‘n’ has a bracket, to tell us that it is not the ‘nth power of f’, but the nth derivative of f. The entire series is what we called as Taylor series. All those terms between the equal sign and the Rn are called as the Taylor polynomial, and sometimes we denote this whole chunk of polynomial as pn(x). Writing the whole equation in another form, we have

Now, the term Rn(x) is what we call as the remainder term. Since the Taylor series is an infinite series, we won’t possibly write down all the terms of the series. So sometimes we just set our limits, for example, we want the series corrected till the 6th order. So in this case, we see that Rn(x) is the difference between f(x) and the sum of its first 6 polynomials.

The remainder term, could also be written as

I’ll try to give you an illustration to make you understand how this Taylor Series thingy work. By the way, we are not required to prove the formula for Taylor series. For an example, take the function

Using Taylor’s Theorem, we find the Taylor series expanded at x = 0 (which means, a = 0) for this function. By the way, there is a special name for the Taylor series expanded at x = 0, which is named Maclaurin Series. We find f’(x), f’’(x) and so on, substituting them into the formula, we get
f(x) = x + x2 + x3 + x4 + …

Notice that this function could be expanded by binomial expansion, which is faster. Now look at the graph below.

Notice that the blue line sketches the exact graph of the function f(x). As I said earlier, the Taylor series is only an estimation. This means that, the more Taylor polynomial terms we keep, the more accurate the Taylor series estimates the function f(x). Look and see that the graph of degree 1, and degree 2 are actually quite far off from representing f(x), but is quite accurate for values of x near 0. As the degree of polynomial increases, the graph of the Taylor series will eventually be the same as the actual function f(x).

So now, we want to learn how to find the series for some functions that we know of. Let’s try ex. Since there can be an infinite amount of Taylor series expanded at any a, we shall focus on deriving the Maclaurin series of functions.

Recalling the formula,

We find that ex will still be itself after infinite derivatives, and e0 = 1. So plugging in what we have to, we get the Maclaurin series

Try finding the Maclaurin expansion for other functions, ln (1 - x), sinh x, and any other functions you can think of. Note that not all Maclaurin series of functions could have such beautiful series. Some might end up with non-ordered coefficients.

Below is a list of common Maclaurin expansions:

I want you to note a few things:
1. There is no Maclaurin expansion for ln x, because ln 0 is not defined.
2. Notice that the Maclaurin expansion similarities for trigonometric and hyperbolic functions. Here you are able to proof the hyperbolic-trigonometric identities, which relates both the functions.
3. Some expansions are either odd or even. In other cases, there might be missing a power as well, so it is normal for a function not to have all the powers of x.

REMAINDER ESTIMATION THEOREM

If a function f(x) can be differentiated n + 1 times on an interval I containing a & if M is an upper bound for fn+1(x) on I, i.e., | f(n+1)(x) | ≤ M,

then

Ignore the alien language first. Continuing from the previous part, the remainder of the series is actually quite significant. When you use a Taylor series to estimate something, you are interested in knowing the error you estimate, or the difference between your estimate and the actual value. If you remembered from the previous section, the remainder is given by the formula

The formula gives the exact error when f(x) is approximated by the nth Taylor sum. The problem is that it is too difficult to evaluate it this way, so we are going to find an overestimate of the remainder instead. We look at the magnitude of the (n + 1)th derivative of f(t) as t varies between a and x, and overestimate that by a single number M (known as upper bound, as stated above). So here, we are saying that the remainder is definitely smaller or equal to the upper bound, and thus the formula above,

This information is important, as we will use it to
1. Estimate the error between the function and the series
2. Approximate a function to n decimal places

I understand that this might be hard for you to catch, so I will give you 2 examples here.

EXAMPLE 1 (ESTIMATE ERROR)
Find the Taylor series of the function ln x expanded at x = 1, to get a cubic approximation, and estimate the error for ln 2.

Have I taught you how to find a Taylor series for a function?
We first list the function in terms of what we are looking for. In this case, since it is expanded at x = 1, so the terms are powers of (x – 1). It will be in terms of x or (x + 5) if it is expanded at x = 0 and x = –5 respectively, so
ln x = a + b(x-1) + c(x-1)2 + d(x-1)3

Now, we need to find the constants a, b, c and d. You can find all of them by substituting x=1, and by differentiating the left and right side of the function. Which means,

which gives you

and then

To go on, we need to use the formula above. To find M, we need to first find f(n+1)(x), which is –6x-4. Remember the part above which says | f(n+1)(x) | ≤ M, we find that the maximum value of –6x-4 is 6 if we use values 1 ≤ x ≤ 2 (interval I containing a), so we have

Thus, ln 2 = 5/6 within ± 1/4.

EXAMPLE 2 (Approximating decimal places)
Use an nth Maclaurin polynomial for ex to approximate e to 5 decimal places accuracy. Find n.

(Note that if you are finding f(n+1)(x) = cosn x or sinn x, then M ≤ 1 instead. Useful information.) Now, the different thing here compared to the previous example is that we don’t know n, so we can’t substitute n for any value (in fact, we are looking for n!). But we do have another piece of information, which is, to 5 decimal places. We take that decimal place, give it a ± 50%, and now the we know that the remainder must be smaller than 0.000005. So we have

By trial and error, we find that n = 9, then the equation holds. Therefore,

To summarize things up, this is what your checklist when you are dealing with such related questions:

STEP 1: Write down the series f(x), f(c) (the function substituted with the value you want),
STEP 2: Find the interval [a, x] (a is what the series is expanded at, and c is within this limit)..
STEP 3: Find M (the upper bound), which is f(n+1)(x) ≤ [something]
STEP 4: Write down the equation
|Rn (x)| ≤ [the equation above]
STEP 5:
If required, write down
[the equation above] ≤ [amount of decimal points ± 50%]
STEP 6:
Continue on the estimation.

So now you know the mystery of how calculators calculate your cos x, sin x and all those weird functions. They all make use of Taylor series.

#### 1 comment:

1. Great thoughts you got there, believe I may possibly try just some of it throughout my daily life.

Function Point Estimation Training