1 Approximations and Errors

advertisement
1
Approximations and Errors
1.1 Taylor series.
1.1.1
Taylor series and their error.
Mathematical approximations are necessary because on most computers the only built-in operations are
addition, subtraction, multiplication, and division. In order to do other mathematical operations, such as
evaluating functions like sin x or ex, solving algebraic or differential equations, or doing definite integrals, one
must approximate these operations with a finite number of built-in operations. The error in this type of
approximation is called a truncation error. In this section we look at approximating functions using a Taylor
series. In chapter 4 we consider other methods of approximating functions.
The Taylor series approximation of a function y = f(x) is
f(x)  p(x)
where
p(x) = a0 + a1x + a2x2 + a3x3 +
 + anxn
is the polynomial where the coefficient an of xn is
an =
f
(n)
(0)
n!
the nth derivative of f(x) evaluated at x = 0 and divided by n!. Thus
p(x) = f(0) + f '(0) x +
f ''(0) x2
f
+
2!
(3)
(0) x3
f
+  +
3!
(n)
(0) xn
n!
and f(x) is approximated by
(1)
f(x)  f(0) + f '(0) x +
f ''(0) x2
f
+
2!
(3)
(0) x3
f
+  +
3!
(n)
(0) xn
n!
This is called the nth degree Taylor series approximation of f(x) at x = 0. For each n we get a different
approximation.
Example 1. Apply (1) to f(x) = ex. In this case f
(n)
(x) = ex for all n and f
becomes
(2)
ex  1 + x +
x2
x3
xn
+
+  +
2!
3!
n!
The error in the approximation (1) is
1.1.1 - 1
(n)
(0) = 1 for all n. Therefore (1)
(3)
R = f(x) - [ f(0) + f '(0) x +
f ''(0) x2
f
+
2!
(3)
(0) x3
f
+  +
3!
(n)
(0) xn
]
n!
R = Rn(x) is sometimes called the remainder and it depends on x and n. It turns out that the error is
approximately a constant times xn+1. Thus the error is small when x is small, but increases rapidly with x. More
precisely one has the following Proposition.
Proposition 1. If f(x) has n+1 continuous derivatives then
x
(4)
f
R = 

(n+1)
(t)(x-t)n
dt
n!
=
f
() xn+1
(n+1)!
(n+1)
0
where  is between 0 and x.
The proof of Proposition 1 is given at the end of this section. Since the number  in (4) is usually not known, we
are usually content with an estimate of the error.
Example 2. Apply Proposition 1 to f(x) = ex. In this case (3) and (4) become
(5)
R = ex - [ 1 + x +
x2
x3
xn
e xn+1
+
+  +
] =
2!
3!
n!
(n+1)!
Example 3. Use (3) with n = 3 to approximate e-0.5. Then use (5) to find an upper bound for the error in this
approximation. Solution. Putting x = - 0.5 and n = 3 in (3) and (5) we get
0.52 0.53
e-0.5  1 - 0.5 +
= 1 - 0.5 + 0.125 - 0.0208… = 0.60416...
2!
3!
e (- 0.5)4
(0.5)4
The error is R =
where  is between 0 and – 0.5. So 0  e  1 and 0  R 
= 0.0026...
4!
4!
Often one wants to use (1) to approximate f(x) for x in some interval of the form -  x  . To find an upper
bound for the error in this approximation we find K such that
(6)
|f
for | x |  .
(x) |  K
(n+1)
Then
(7)
| R(x) | 
K n+1
(n+1)!
for | x |  ..
Example 4. If we use (3) with n = 3 to approximate ex for | x |  ½, what is an upper bound for the error in this
approximation?
Puttin n = 3 into (3) and (5) gives
(8)
ex  1 + x +
(9)
R =
x2
x3
+
2!
3!
e x4
4!
1.1.1 - 2
where  lies between 0 and x. Since | x |  ½ one has |  |  ½. So | R | 
e1/2(½)4
= 0.00429.. for | x |  ½.
4!
Sometimes one wants to know how small an interval of the form | x |   one must restrict x to in order that the
error will be less than a given amount.
Example 5. Consider the approximation (8). Let’s find  so that | R |  10-4 for | x |  .
Arguing as in Example 4 one has | R | 
e4
for | x |  . So we need to find  so that 4e  2.4  10-3. One
4!
possibility is to take  as the solution of the equation 4e = 2.4  10-3. This is a nonlinear equation for  that
one can solve (approximately) using the methods of Chapter 2. Calculators and mathematical software have
these equation solving methods built-in and if we use one of them we get  = 0.210021. Another approach is to
start with an upper bound for the solution of the equation, e.g. from Example 4 we see that  is less than 1/2 . So
e is less than e0.5 which is less than 2. We solve the equation 24 = 2.4  10-3. Its solution is  = 0.18… So
 = 0.18 is an answer to the question, although it is not as sharp as the one obtained by solving the equation
4e = 2.4  10-3.
Yet another problem is to find n so that | R | is less than a given amount for x in a given interval. Let’s suppose
the interval is of the form | x |  .
Example 6. Consider the approximation (3). Let’s find n so that | R | is less than 10-3 in the interval | x |  ½.
Arguing as in Example 3 one has | R | 
e½(1/2)n+1
e½(1/2)n+1
for | x |  ½ . So we need to find n so that
 10-3.
(n+1)!
(n+1)!
This is a nonlinear inequality for n that is hard to solve analytically. One way to obtain a solution is to make a
guess at a value of n and check if it works. Based on the outcome we either increase or decrease our guess and
try again. We repeat this until we find the smallest one for which the inequality holds. From Example 4 we
e½(1/2)5
know that n = 3 doesn't work. If we try n = 4 then
= 0.0004… < 0.001, so n = 4 works.
5!
Equation (1) and Proposition 1 generalize to the nth degree Taylor series approximation of f(x) centered at x = xo.
f(x) = f(xo) + f '(xo) (x - xo) +
f ''(xo) (x - xo)2  f
+
+
2!
(n)
( xo) (x - xo)n
f
+
n!
(n+1)
() (x - xo)n+1
(n+1)!
where  is a number between xo and x This formula is in most calculus books.
Section 1.9.1 has some illustrations of using mathematical software when making Taylor series approximations.
Proof of Proposition 1. First consider the case n = 0 in which case (4) becomes
x
f(x) – f(0) =
'
'

 f (t) dt = f () x
0
1.1.1 - 3
The first equality is just the fundamental theorem of calculus and the equality f(x) – f(0) = f '() x follows from
x
the mean value theorem for derivatives. To prove the left inequality in (4) for n = 1 we integrate 
 f '(t) dt by
0
'
''
parts letting u = f (t) and dv = dt. Then du = f (t)dt and for v we can take v = - (x-t). Therefore
x
x
f(x) – f(0) = - f '(t)(x-t) |t = 0 +
x
 f ''(t)(x-t) dt

= f '(0)x +
0
 f ''(t)(x-t) dt

0
So
x
f(x) – [ f(0) + f '(0)x ] =
''

 f (t)(x-t) dt
0
which is the left equality in (4) for n = 1. Integrating by parts again gives
x
f ''(0) x2
f(x) – [ f(0) + f '(0)x +
] =
2!
2
 f (3)(t)(x-t) dt
2!

0
which is the left equality in (4) for n = 2. Integrating by parts n – 2 more times gives the left inequaltiy in (4) for
general n. The right inequality in (4) follows from the integral mean value theorem. (See the following.) //
Integral Mean Value Theorem. Suppose f(x) and g(x) are continuous for a  x  b and g(x) is of one sign
b
b
between a and b. Then there is a number  between a and b such that 
 f(x)g(x) dx = f() 
 g(x) dx.
a
a
Problems. You may use mathematical software to help with the calculations.
1
a.
Find the 8th degree Taylor series approximation to f(x) = tan x centered at xo = 0.
b.
Use this to estimate the value of tan(0.1). Estimate the error in this approximation.
2
c.
Estimate the truncation error in part a as x varies over the interval | x |  0.2.
d.
For the approximation in part a, find  so that | R |  10-4 for | x |  .
e.
If in part a we take the terms up to order n, find n so that | R |  10-3 for | x |  0.2.
Answers. (a) tan x  x + x3/3 + 2x5/15 + 17x7/315. (b) tan(0.1)  0.100335. The error is less than
2.8  10-11. (c) 2.4  10-8. (d) 0.42. (e) 3.
a.
Find the 2nd degree Taylor series approximation to f(x) = x centered at xo = 1.
b.
Use this to estimate the value of 1.5 and find an upper bound for the truncation error.
c.
Find an upper bound for the truncation error in the approximation that you found in part a as x
varies over the interval 1  x  1.5.
d.
For the approximation in part a, find  so that | R |  10-4 for 1  x  1 + .
e.
If in part a we take the terms up to order n, find n so that | R |  10-3 for 0.8  x  1.2.
1.1.1 - 4
Download