Error Estimation

If the Taylor series for a function $f(x)$ is truncated at the n-th term, what is the difference between $f(x)$ and the value given by the n-th Taylor polynomial? That is, what is the error involved in using the Taylor polynomial to approximate the function?

Suppose you expand f around a, and that f is $n + 1$ times continuously differentiable on an open interval containing a. Taylor's theorem says that if x is another point in this interval, then

$$f(x) = \sum_{k=0}^n \dfrac{f^{(k)}(a)}{k!} (x - a)^k + \dfrac{f^{(n+1)}(c)}{(n + 1)!} (x - a)^{n+1},$$

where c is a number in the open interval between x and a.

$\displaystyle \sum_{k=0}^n
   \dfrac{f^{(k)}(a)}{k!} (x - a)^k$ is the n-th Taylor polynomial at a. The other term on the right is called the Lagrange remainder term:

$$R_n(x;a) = \dfrac{f^{(n+1)}(c)}{(n + 1)!} (x - a)^{n+1}.$$

The appearance of c, a point between x and a, and the fact that it's being plugged into a derivative suggest that there is a connection between this result and the Mean Value Theorem. In fact, for $n = 0$ the result says

$$f(x) = f(a) + f'(c)\cdot (x - a),$$

where c is between x and a. This is the Mean Value Theorem.

On the one hand, this reflects the fact that Taylor's theorem is proved using a generalization of the Mean Value Theorem. On the other hand, this shows that you can regard a Taylor expansion as an extension of the Mean Value Theorem.

There is also an expression for the error which involves an integral. I won't discuss it here.


Example. Compute the Remainder Term $R_3(x;1)$ for $f(x) = \sin 2x$ .

For the third remainder term, I need the fourth derivative:

$$f'(x) = 2\cos 2x, \quad f''(x) = -4\sin 2x, \quad f'''(x) = -8\cos 2x, \quad f^{(4)}(x) = 16\sin 2x.$$

The Remainder Term is

$$R_3(x;1) = \dfrac{16\sin 2c}{4!}(x - 1)^4,$$

where c is a number between x and 1.


Example. Compute the Remainder Term $R_n(x;3)$ for $f(x) = e^{2x}$ .

Since I want the $n^{\rm th}$ Remainder Term, I need to find an expression for the $(n + 1)^{\rm st}$ derivative.

$$f'(x) = 2e^{2x}, \quad f''(x) = 2^2e^{2x}, \quad f'''(x) = 2^3e^{2x}.$$

Clearly, the pattern is

$$f^{(n)}(x) = 2^ne^{2x}, \quad\hbox{so}\quad f^{(n+1)}(x) = 2^{n+1}e^{2x}.$$

The Remainder Term is

$$R_n(x;3) = \dfrac{2^{n+1}e^{2c}}{(n + 1)!}(x - 3)^{n+1},$$

where c is a number between x and 3.


Example. The Maclaurin series for $\ln (1 + x)$ is

$$\ln (1 + x) = x - \dfrac{x^2}{2} + \dfrac{x^3}{3} - \dfrac{x^4}{4} + \cdots.$$

What is the largest error which might result from using the first three terms of the series to approximate $\ln (1 + x)$ , if $0 \le x \le 1$ ?

The remainder term is

$$R_n(x;0) = \dfrac{f^{(n+1)}(c)}{(n + 1)!} x^{n+1},$$

where $0 < c < x$ . Note that since $x \le
   1$ , we have $0 < c < 1$ . I want to estimate the maximum size of $|R_3(x;0)|$ . (I take absolute values, because I only care about the magnitude of the error.)

$f(x) = \ln (1 + x)$ , so $f^{(4)}(x) = \dfrac{-6}{(1 + x)^4}$ . Thus, $f^{(4)}(c) =
   \dfrac{-6}{(1 + c)^4}$ . So

$$|R_3(x;0)| = \dfrac{1}{4!} \left|\dfrac{-6}{(1 + c)^4}\right| |x|^4 \le \dfrac{6}{24}\cdot \dfrac{1}{(1 + c)^4}\cdot 1^4 = \dfrac{1}{4} \cdot \dfrac{1}{(1 + c)^4}.$$

(I used the fact that $|x| \le 1$ .)

How large can $\dfrac{1}{(1 + c)^4}$ be, given that $0 < c < 1$ ? As c goes from 0 to 1, $\dfrac{1}{(1 + c)^4}$ decreases, so it is never larger than it would be if $c = 0$ . In that case, $\dfrac{1}{(1 + c)^4} =
   1$ . Therefore,

$$|R_3(x;0)| \le \dfrac{1}{4}\cdot 1 = \dfrac{1}{4}.$$

The error is no greater than $\dfrac{1}{4}$ .

I can check this by plotting the difference between the $3^{\rm rd}$ degree Taylor polynomial and $\ln (1 + x)$ . The graph below shows $\ln (1 + x) - p_3(x)$ :

$$\hbox{\epsfysize=1.75in \epsffile{tayerr1.eps}}$$

From the picture, it looks as though the maximum error is around 0.15 (in absolute value). The estimated error was pretty conservative.


Example. Calvin wants to impress Phoebe Small by using the MacLaurin series for $e^{2x}$ to approximate $\displaystyle \int_0^{0.5} x e^{2x}\,dx$ to within 0.0001. How many terms of the series should he use?

The Maclaurin series for $e^{2x}$ is

$$e^{2x} = \sum_{n=0}^{\infty} \dfrac{2^n x^n}{n!}.$$

(Substitute $u = 2x$ in the standard series for $e^u$ .) I want to know how many terms of the series to use to approximate the integral.

Since $f(x) = e^{2x}$ , $f'(x) = 2
   e^{2x}$ , $f''(x) = 2^2 e^{2x}$ , and in general, $f^n(x) = 2^n e^{2x}$ . Therefore,

$$R_n(x) = \dfrac{1}{(n + 1)!} f^{(n+1)}(c) (x - a)^{n+1} = \dfrac{1}{(n + 1)!} \cdot 2^n \cdot e^{2c} \cdot x^{n+1}.$$

In the integral, x goes from 0 to 0.5, and c is a number between 0 (the expansion point) and x. Therefore, I know that c is a number between 0 and 0.5. Taking the worst possible case, the largest $e^{2c}$ could be is $e^{2\cdot0.5} = e$ . Replace $e^{2c}$ with e to obtain

$$R_n(x) \le \dfrac{1}{(n + 1)!} \cdot 2^n \cdot e \cdot x^{n+1}.$$

Insert this into the integral (remembering to multiply by x):

$$\hbox{error} \le \int_0^{0.5} \dfrac{1}{(n + 1)!} \cdot 2^n \cdot e \cdot x^{n+2}\,dx = \dfrac{1}{(n + 1)!} 2^{n+1} \cdot e \cdot \dfrac{1}{n + 3} \cdot (0.5)^{n+3}.$$

I want the smallest value of n for which this ugly mess is less than 0.0001. The easiest way to do this is by trial: Plug in successive values of n until you discover that $n =
   6$ is the smallest value that works.


Example. (a) Compute $R_3(x;0)$ for $f(x) = \dfrac{1}{2 + x}$ , and express $f(x)$ using $p_3(x)$ and the remainder term.

Since I want $R_3(x;0)$ , I need the fourth derivative:

$$f'(x) = \dfrac{-1}{(2 + x)^2}, \quad f''(x) = \dfrac{2}{(2 + x)^3}, \quad f'''(x) = \dfrac{-6}{(x + x)^4}, \quad f^{(4)}(x) = \dfrac{24}{(2 + x)^5}.$$

Thus,

$$R_3(x;0) = \dfrac{24}{(2 + c)^5}\cdot \dfrac{1}{4!}x^4 = \dfrac{x^4}{(2 + c)^5}.$$

Now

$$\dfrac{1}{2 + x} = \dfrac{1}{2}\cdot \dfrac{1}{1 - \left(-\dfrac{x}{2}\right)} = \dfrac{1}{2}\cdot\left(1 - \dfrac{x}{2} + \dfrac{x^2}{4} - \dfrac{x^3}{8} + \cdots\right).$$

Therefore,

$$\dfrac{1}{2 + x} = \dfrac{1}{2}\cdot\left(1 - \dfrac{x}{2} + \dfrac{x^2}{4} - \dfrac{x^3}{8}\right) + \dfrac{x^4}{(2 + c)^5},$$

where c is between x and 0.

(b) Use $R_3(x;0)$ to approximate the largest error that occurs in using $p_3(x)$ to approximate $\dfrac{1}{2 + x}$ for $0 \le x \le 1$ .

Since $0 \le x \le 1$ and c is between 0 and x, it follows that $0 \le c \le 1$ . On this interval, $\dfrac{1}{(2 + c)^5}$ decreases, so it attains its largest value at $c = 0$ . For $c = 0$ , $\dfrac{1}{(2 + c)^5} = \dfrac{1}{32}$ . Thus,

$$|R_3(x;0)| = \dfrac{|x|^4}{(2 + c)^5} \le \dfrac{1^4}{32} = \dfrac{1}{32}.$$

The error is no greater than $\dfrac{1}{32}$ .


Send comments about this page to: bikenaga@marauder.millersville.edu.

Last updated: December 2, 2005

Bruce Ikenaga's Home Page

Math Department Home Page

Millersville University Home Page

Copyright 2005 by Bruce Ikenaga