Ryerson Crest Ryerson Header

MTH 207 Lab Lesson 19

Taylor Series


Up to Main Lab Page Next Lesson - Integration Previous Lesson - Approximating Functions

Taylor Series

[See section 10.10 of Stewart]

We can generalise the idea of constant, linear and quadratic approximations, the result is a Talylor series.

In general, given a function f, we want a polynomial, p, whose derivatives are the same as the derivatives of f for every order, at some point a.
Since p is a polynomial (possibly of infinite degree) it must look like:


p(x) = c0 + c1 (x - a) + c2 (x - a)2 + c3 (x - a)3 + . . . + cn (x - a)n + . . .

Power Series

A word of warning is in order here. p(x) is no longer strictly speaking a polynomial, this is because a polynomial must have finite degree. Rather we should now refer to p(x) as a formal power series, or power series for short. The general theory of formal power series is beyond the scope of this course (see Stewart Chapter 10), however a few comments are in order.

The problem with Formal Power Series is that we can't guarentee convergence of the series for a given value of x.

For example, taking a = 0, and cn = 1 for each n, we get the series


q(x) = 1 + x + x2 + x3 + . . . + xn + . . .

This series will not converge for any value of x above 1. On the other hand it is not difficult to see that q(x) will converge to a definite value for any value of | x | < 1. ( q(x) is a geometric series and so q(x) = lim n -> infinity (1 - xn)/(1 - x) which converges for | x | < 1. )

If a power series converges for every value of x within R of a, i.e. | x - a | < R => p(x) converges, then R is called the Radius of Convergence of the series. Thus q above has a radius of convergence of R = 1.
If a power series converges for every real number we say that the radius of convergence is infinite, and write R = infinity.

Taylor Series

To get our approximation we require the derivatives of all orders of the power series p(x) to be equal to those of our given function f.
Thus setting p(a) = f (a), p '(a) = f '(a), p ''(a) = f ''(a), . . . , p (n)(a) = f (n)(a), . . . we get:
p(a) = c0 = f (a)
p'(a) = c1 = f '(a)
p ''(a) = 2 × c2 = f ''(a)
p '''(a) = 3 × 2 × c3 = f '''(a)
.
.
.
p(n)(a) = n! cn = f (n)(a)

Where f (n)(x) represents the nth derivative, and n! is n factorial, n! = n (n - 1) (n - 2) (n - 3) . . . 3 × 2 × 1.

Putting this together we get Taylor's Theorem.

Taylor's Theorem Given a function f (x) and some point a where f is defined, then


f (x) = f (a) + f '(a)/1! (x - a) + f ''(a)/2! (x - a)2 + f '''(a)/3! (x - a)3 + . . . + f (n)/n! (x - a)n + . . .

whenever | x - a | < R, where R is the radius of convergence of the power series on the right hand side.

Note that in this case we have equality between the function and the power series. The power series on the right hand side is called the Taylor Series for f at a.

Example

Consider the function f (x) = ex. We will construct the Taylor series for f at a.

f '(x) = ex, so f (n)(x) = ex for every n. Thus f (n)(0) = e0 = 1. So the Taylor Series for ex is


ex = 1 + (x - a) + 1/2! (x - a)2 + 1/3! (x - a)3 + . . . + 1/n! (x - a)n + . . .

Taylor Polynomials

Of course in practice it is impossible to explicitly calculate an infinite series, thus we may approximate f by calculating only the first n terms, for some n.

Thus the Taylor polynomial of degree n of f about a is given by


f (x) ~ Tn(x) = f (a) + f '(a)/1! (x - a) + f ''(a)/2! (x - a)2 + f '''(a)/3! (x - a)3 + . . . + f (n)/n! (x - a)n

Note that taking only the first term gives the constant approximation, the first two terms the linear approximation and the first three terms the quadratic approximation.

Consider the following procedure for calculating the n term Taylor series of a function g(x), Tn(x), about some point a.
> Taylor := proc(g, x::algebraic, n::integer, a::algebraic)
> local s, i;
> s := 0;
> for i from 0 to n do
> s := s + (D@@i)(g)(a)*(x - a)^i/i!;
> od;
> RETURN(s);
> end;

We can now get Maple to find the first ten terms of the Taylor polynomial for exp about zero:
> f := x->exp(x);
> Taylor(f, x, 10, 0);

We can also check the accuracy as n increases.
> for i from 1 to 15 do
> [evalf(f(2)), evalf(Taylor(f,2,i,0))];
> od;

  1. Find Taylor polynomials for the following functions at the given value of a. In each case evaluate your answer at a a + 1, check this value against the value reported by Maple for various values of n.
    1. sin(x), a = 0.
    2. 1/(1 - x), a = 0. (Use .5 for evaluation)
    3. ln(x), a = 1.
    4. sqrt(x) a = 1.
    5. tan(x), a = 0.

Error Analysis

The error in the approximation by Taylor polynomial Tn(x) is given by Taylor's Formula.

Taylor's Formula If f is n + 1 times differentiable on an interval I that conatins a, then for every x in I there is a number z between x and a such that


f (x) = Tn(x) + Rn(x)
where Rn(x) = f (n + 1)(z)/(n + 1)! (x - a)n + 1.

Rn(x) is called the remainder term.

Note that though the remainder term looks superficialy like the n + 1th term in the Taylor series, the derivative f (n + 1)(z) is evaluated at some point z. The only thing we now about z is that it lies between x and a.

The usual trick is to bound f (n + 1)(x) on I.
i.e. f (n + 1)(x) < M on I
=> Rn(x) < M/(n + 1)! (x - a)n + 1.

A much more practical rule of thumb is to stop iterating once the difference between successive approximations becomes small enough.
i.e. | Tn + 1(x) - Tn(x) | < stop value.

The difference between successive approximations is exactly equal to the next term in the Taylor series.


Up to Main Lab Page Next Lesson - Integration Previous Lesson - Approximating Functions Top of this Lesson


Maintained by: P. Danziger, March 1998