UNDERGRADUATE COMPUTATIONAL ENGINEERING AND SCIENCE

UCES

"Taylor Polynomials and Higher Order Approximation"

Course:   Methods and Analysis in UCES

Prerequisites:

  1. Math:   Calculus 2
  2. Computing:   Maple
  3. Science:   Physics

Objectives:

  1. Math:   Taylor remainder theorem
  2. Computing:   Higher order algorithms
  3. Science:   Heat diffusion

General Information: In the previous sections in this chapter we have stressed first and second order algorithms. The order of these methods were a consequence of the mean value and extended mean value theorems. The purpose of this lecture is to show how one can extend these concepts to nth order schemes, provided the functions have a sufficient number of continuous derivatives.

Contact Person:   R. E. White, NCSU, white@math.ncsu.edu

Revision Date:   8-3-94

Copyright ©1994, R. E. White. All rights reserved.

Return to Table of Contents


2.8   Taylor Polynomials and Higher Order Approximation

2.8.1.   Introduction.

In previous sections we learned two ways to form polynomial approximation of complicated functions: Lagrange interpolation by requiring P(xi ) = f(xi ) for n+1 points and P(x) an nth degree polynomial, and least squares approximations where there can be many more data points than the degree of the polynomial. The Taylor polynomials will be a third method of function approximation.

We have also made approximations based on the mean value and extended value theorems. The second form of the mean value theorem's conclusion is

f(x) = f(a) + f'(c) (x - a)
for some c between a and x, provided f'(x) is continuous on [a,b]. In this case we can think of f(x) being approximated by a zero order polynomial

P0 (x) = f(a).

The extended mean value theorem concludes

f(x) = f(a) + f'(a) (x - a) + f''(c)(x - a)2 /2

for some c between a and x, provided f''(x) is continuous on [a,b]. Here we view f(x) as being approximated by a first order polynomial

P1(x) = f(a) + f'(a)(x - a).

In order to extend this to a quadratic polynomial, we need to extend the mean value theorems.

The extended mean value result follows in a natural manner from integration by parts and the integral form of the mean value theorem.

In order to extend this, apply integration by parts to the integral in the second line, and again apply the integral form of the mean value theorem.

Thus, for some c between x and a and provided the third derivative is continuous,

f(x) = f(a) + f'(a) (x - a) + f''(a)/2 (x - a)2 + f(3)(c)/6 (x - a)3 .

This gives us a quadratic polynomial approximation of f(x)

P2 (x) = f(a) + f'(a) (x - a) + f''(a)/2 (x - a)2

This process can be continued provided there are a enough continuous derivatives.


2.8.2.   Applied Area.

We will present here and return later in the assessment section three applications of Taylor polynomials to higher order numerical methods of integration, derivatives and numerical solution of differential equations.

Application to Probability. The normal probability distribution involves the exponential function evaluated at a quadratic. The probability that an outcome of an experiment is between a and b is given by

is the standard deviation and µ is the mean. If the mean score of a chemistry exam is 500 and the standard deviation is 100, find the probability that a random student's score is between 450 and 550. This leads to the following integral

We could use a numerical integration method. Also, we can approximate the integrand by a Taylor polynomial and integrate it. What are the errors is such approximations?

Application to Heat Diffusion. Fourier's heat law states that the amount of heat flowing through a surface is proportional to the product of change in time, surface area and the derivative of the temperature. The means the heat coming in and out of small segment of a wire can be approximated by

delta t KAux (x + h) - delta t KAux (x).

In the numerical calculations both derivatives will be approximated by finite differences

delta t KA(ui+1 - ui )/h - delta t KA(ui-1 - ui )/h.

What are the size of the errors when one numerically approximates the derivatives ux and uxx ?

Application to Differential Equations. One advantage of the second order accurate Euler-Trapezoid method for numerical solution of differential equations is increased accuracy with the same mesh size. In order to establish this, we used the extended mean value theorem. This suggests that higher order approximations of the solution might generate better methods. We will be more precise later and will illustrate a fourth order accurate method for Newton's law of cooling.


2.8.3.   Model.

The two versions of the mean value theorem gave error estimates for constant and linear polynomial approximations that satisfied P0 (a) = f(a), and P1 (a) = f(a) and P1(1) (a) = f(1)(a), respectively. In the introduction we established a quadratic polynomial approximation. The Taylor polynomials are an extension of this to polynomials of degree n that satisfy Pn(i) (a) = f(i) (a) where i ranges from 0 to n and (i) indicates the ith derivative.

Definition. The nth degree Taylor polynomial is

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

Example. Let f(x) = ex and a = 0.

P1 (x) = 1 + x, P2 (x) = 1 + x + x2/2, P3(x) = 1 + x + x2/2 + x3/6.

Also inspection of the graphs indicates that the approximations get better as the degree increases. These give reasonable approximation of f(x) provided x is "near" a = 0. If we are interested in the approximation for larger, say x near 10, then we should choose a = 10:

P1 (x) = e10 + e10 (x - 10), P2 (x) = e10 + e10 (x - 10) + e10 /2 (x - 10)2 and
P3 (x) = e10 + e10 (x - 10) + e10 /2 (x - 10)2 + e10 /6 (x - 10)3.

Figure: exp(x), 1, 1 + x, 1 + x + x2 /2

Example. Let f(x) = cos(x) and a = 0. It is easy to see that

P0 (x) = 1, P1 (x) = 1, P2 (x) = 1 - (1/2) x2, P3 (x) = 1 - (1/2) x2 and
P4 (x) = 1 - (1/2) x2 + (1/24) x4.

Figure: cos(x), 1, 1 - x2 /2, 1 - x2 /2 + x4 /24

The following very important theorem will allow us to estimate the errors as a function of n and a. It can be viewed as an extension of the mean value theorems.

Taylor Polynomial Error Theorem. If f(i)(x) for i=0,1,...,n+1 are continuous [a,b], then for each x in [a,b] there is some c between a and x such that

Error = f(x) - Pn (x) = f(n+1) (c)/(n+1)! (x - a)n+1.

Moreover, if Mn+1 = max |f(n+1) (x)| where x is in [a,b], then

|Error| Mn+1 /(n+1)! |x - a|n+1.

Proof. This proof is similar to the extended mean value theorem and uses the integral form of the mean value theorem. As in the extended mean value theorem continue to do the integration by aparts to obtain

By the integral form of the mean value theorem there is some c between a and x such that

Example. Estimate the error for the third degree Taylor polynomial approximation of ex on [0,1]. So, n = 3 and choose a = 0 so that P3(x) = 1 + x + x2/2 + x3/6 . f(3+1)(c) = ec and on [0,1] it is bounded by e1 = M3+1. Thus, for x in [0,1]

|Error| M3+1/(3+1)! |x - 0|3+1 < 3/24 |x|4 < 1/8.

If x is in the interval [0,.5], then the error would be bounded by (1/8)(1/16).

In the above we were given n and asked to estimate the error. Often the error tolerance is given, and one must find n so that the error is less than this tolerance. Find n so that the error for the above approximation will be less than 10-6 .

|Error| Mn+1/(n+1)! |x - a|n+1

e1/(n+1)! |x|n+1

< 3/(n+1)! < 10-6.

Thus, we need to choose n so that 3 106 < (n+1)! By trial computations n = 9 works.


2.8.4.   Method.

The evaluation of Taylor polynomials is straightforward. The following algorithm attempts to avoid any extra calculations. In most cases, it is the evaluation of the derivatives that is most costly. The reader should consider some of the Maple procedures for doing derivatives. Also the coefficients are computed and stored. There are other types of approximations which have the form of quotients of polynomials, and they vary according to the interval the variable is in.

Taylor Polynomial Algorithm.


	choose n, a and x
	sumtp = f(a)
	ifac = 1
	xi = 1
	for i = 1, n
		ifac = ifac*i
		xi = xi*(x - a)
		ai = f(i)(a)/ifac
		sumtp = sumtp + ai*xi
	endloop.


2.8.5.   Implementation.

Maple has some very nice symbolic procedures than can significantly reduce the amount of paper work in dealing with Taylor series. Below we illustrate the Maple procedures series, int, convert and evalf.

Maple Procedures for Taylor Polynomials.


        > p6:=series(exp(-x*x/2),x=0,6);
		
        
        > p8:=series(exp(-x*x/2),x=0,8);
		
        
        > I8:=int(p8,x);
		
        
        > Ip8:=convert(I8,polynom);
		
        
        > evalf(subs(x=.5,Ip8)) - evalf(subs(x=0,Ip8));
		
        


2.8.6.   Assessment.

We now return to the three applied problems and show how the Taylor polynomials can be used to develop higher order numerical schemes.

Higher Order Numerical Integration. Consider the probability integral

Let P3 (x) be the Taylor polynomial for ex with a = 0. Now consider P3 (-1/2 z2 ). This is really just the sixth degree Taylor polynomial for the above integrand. The error term has the form (max | ex |) |x|4 /24 where x = -1/2 z2 and x is in the interval [-1/8,0].

Error < 1 (1/8)4 /24.

The error in the integration is estimated by

So, the integration error is small and we can have confidence in the approximate answer of

Higher Order Numerical Derivatives. The second order derivative has a second order accurate finite difference approximation provided the fourth order derivative in continuous. More precisely, we can show for M4 = max |f(4) (x) | and x in [a,b]

Apply the error theorem with n = 4, a replaced by x and x replaced by x + h and x - h

f(x + h) = f(x) + f(1) (x)h + f(2) (x)h2 /2 + f(3) (x)h3 /6 + f(4) (c)h4 /24 and
f(x - h) = f(x) - f(1) (x)h + f(2) (x)h2 /2 - f(3) (x)h3 /6 + f(4) (c)h4 /24.

Add these two equations and divide by h2 to get

Higher Order Numerical Solution Differential Equations. Consider the differential equation ut = f(t,u). We wish to have a higher order approximation scheme, and so, we apply the fourth order Taylor polynomial approximation to u(t + h) and a = t.

u(t + h) = u(t) + ut (t) h + utt (t) h2 /2 + uttt (t) h3 /6 + utttt (t) h4 /24 + u(5) (C) h5 /120.

Since u is a solution of the differential equation, one can compute the higher order derivatives by using the chain rule

utt = ft (t,u(t))*1 + fu (t,u(t)) ut = ft (t,u(t))*1 + fu (t,u(t)) f(t,u(t)).

If f(t,u) is complicated, then these calculations will become costly. However, for simpler cases it is very powerful.

Consider the Newton's law of cooling where f(t,u) = c(usur - u). Then the nth derivative of u has the form (-c)n-1f. The above Taylor polynomial is

u(t + h) = u(t) + f(u(t)) h + (-c)1 f(u(t)) h2 /2 + (-c)2 f(u(t)) h3 /6

+ (-c)3 f(u(t)) h4 /24 + (-c)4 f(C) h5 /120.

This suggests the following algorithm

uk+1 = uk + f(uk ) h - cf(uk) h2 /2 + c2 f(uk ) h3 /6 - c3 f(uk ) h4 /24.

Since the error in Taylor's theorem is of order 5, the discretization error might have an error of order 4. This is the case provided the solution has 5 continuous derivatives.

Table: Discretization Errors: Euler Order One and Taylor Order Four
K (h = 50/K) Euler Error = E E/h Tay. Error = TE TE/(h4 )
10 (5.000) 1.9710 .3942 1.7951 10-5 .2873 10-7
20 (2.500) 0.9664 .3866 0.1084 10-5 .2775 10-7
40 (1.250) 0.4786 .3829 0.0066 10-5 .2703 10-7
80 (0.625) 0.2382 .3811 0.0004 10-5 .2621 10-7


2.8.7.   Homework.

  1. Use Maple to graph higher order approximations of ex and cos(x).

  2. Consider (1 + x2 )1/2 on [-1,1]. Find P3 (x) and estimate the error.

  3. Consider the roof problem where the integrand has the form (1 + cos2(8x))1/2 . Use problem two to approximate the integral.

  4. Verify the error estimates for the numerical derivatives of f(x) = xex .

  5. Approximate the integral of 1/(1 + x3 ) from x = 0 to x = 1 to within 10-6 .

  6. Find a numerical derivative and an error estimate for the third order derivative.

  7. Consider the radiative cooling problem ut = .6941(1 - (u/273)4 ) and u(0) = 973. Use the fourth order Taylor polynomial to generated a higher order method. Observe the order of convergence and the stability constraint on h.