+ All Categories
Home > Documents > NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor...

NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor...

Date post: 19-Jun-2020
Category:
Upload: others
View: 2 times
Download: 0 times
Share this document with a friend
37
NUMERICAL MATHEMATICS & COMPUTING 6th Edition Ward Cheney/David Kincaid c UT Austin Engage Learning: Thomson-Brooks/Cole www.engage.com www.ma.utexas.edu/CNA/NMC6 September 16, 2011 Ward Cheney/David Kincaid c (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/ NUMERICAL MATHEMATICS & COMPUTING 6th Edition September 16, 2011 1 / 13
Transcript
Page 1: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

NUMERICAL MATHEMATICS & COMPUTING6th Edition

Ward Cheney/David Kincaid c©

UT Austin

Engage Learning: Thomson-Brooks/Colewww.engage.com

www.ma.utexas.edu/CNA/NMC6

September 16, 2011

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 1 / 13

Page 2: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

1.2 Review of Taylor Series

ex = 1 + x +x2

2!+

x3

3!+ · · · =

∞∑k=0

xk

k!(|x | <∞)

sin x = x − x3

3!+

x5

5!− · · · =

∞∑k=0

(−1)kx2k+1

(2k + 1)!(|x | <∞)

cos x = 1− x2

2!+

x4

4!− · · · =

∞∑k=0

(−1)kx2k

(2k)!(|x | <∞)

1

1− x= 1 + x + x2 + x3 + · · · =

∞∑k=0

xk (|x | < 1)

ln(1 + x) = x − x2

2+

x3

3− · · · =

∞∑k=1

(−1)k−1xk

k(−1 < x ≤ 1)

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 2 / 13

Page 3: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Example 1

Series are often used to compute good approximate values ofcomplicated functions at specific points.

Example

Approximate ln(1.1) using five terms in Taylor Series.

Take x = 0.1 in the first five terms of the series for ln(1 + x)

ln(1.1) ≈ 0.1− 0.01

2+

0.001

3− 0.0001

4+

0.00001

5= 0.09531 03333 . . .

This value is correct to six decimal places of accuracy!.

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 3 / 13

Page 4: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Example 2

Example

Approximate e8 using Taylor Series.

The result is

e8 = 1 + 8 +64

2+

512

6+

4096

24+

32768

120≈ 570.06666 5

We find e2 = 7.38905 6, e4 = 54.59815 00, e8 = 2980.95798 7.

Many terms are needed to compute e8 with reasonable precision!

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 4 / 13

Page 5: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

RULE OF THUMB

Rule

A Taylor series converges rapidly near the point of expansion and slowly(or not at all) at more remote points.

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 5 / 13

Page 6: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Partial Sums of Taylor Series

A graphical depiction of the phenomenon can be obtained by usingthe Taylor series

sin x = x − x3

6+

x5

120+ · · ·

and some of the partial-sum functions

S1 = x

S3 = x − x3

6

S5 = x − x3

6+

x5

120

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 6 / 13

Page 7: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Figure

Figure: Approximations to sin x

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 7 / 13

Page 8: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Formal Taylor Series of f at the point c

These series are examples of the following general series:

Theorem

f (x) ∼ f (c) + f ′(c)(x − c) +f ′′(c)

2!(x − c)2 +

f ′′′(c)

3!(x − c)3 + · · ·

f (x) ∼∞∑k=0

f (k)(c)

k!(x − c)k

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 8 / 13

Page 9: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Maclaurin series

The special case c = 0

f (x) ∼ f (0) + f ′(0)x +f ′′(0)

2!x2 +

f ′′′(0)

3!x3 + · · ·

f (x) ∼∞∑k=0

f (k)(0)

k!xk

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 9 / 13

Page 10: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Example 3

Example

What is the Taylor series of the function

f (x) = 3x5 − 2x4 + 15x3 + 13x2 − 12x − 5

at the point c = 2?

f (x) = 3x5 − 2x4 + 15x3 + 13x2 − 12x − 5 ⇒ f (2) = 207

f ′(x) = 15x4 − 8x3 + 45x2 + 26x − 12 ⇒ f ′(2) = 396

f ′′(x) = 60x3 − 24x2 + 90x + 26 ⇒ f ′′(2) = 590

f ′′′(x) = 180x2 − 48x + 90 ⇒ f ′′′(2) = 714

f (4)(x) = 360x − 48 ⇒ f (4)(2) = 672

f (5)(x) = 360 ⇒ f (5)(2) = 360

f (k)(x) = 0 ⇒ f (k)(2) = 0

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 10 / 13

Page 11: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Example 3 (cont.)

Therefore, we have

f (x) = 207 + 396(x − 2) + 295(x − 2)2

+ 119(x − 2)3 + 28(x − 2)4 + 3(x − 2)5

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 11 / 13

Page 12: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Maclaurin Series Illustration

We show how well we can approximate a function f (x) at a pointx = a by taking only a few terms of the Maclaurin series.With only the first term, the function is assumed to be a constant:

f (a) ≈ f (0)

With two terms, the slope at 0 is taken into account by way of thestraight line from f (0) to f (a); namely,

f (a) ≈ f (0) + f ′(0)a

With three terms, the curivature due to f ′′(0) comes into play and weobtain a parabolic curve:

f (a) ≈ f (0) + f ′(0)a +1

2f ′′(0)a2

Each additional term improves the accuracy in the approximation forf (a).In Figure 1.3, we show these partial sums in the Maclaurin serieswhen f (x) = ex and x = a = 1.

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 12 / 13

Page 13: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Figure 1.3

0 0.2 0.4 0.6 0.8 1

1

1.2

1.4

1.6

1.8

2

2.2

2.4

2.6

2.8

f0=1 1

f1=1+x

2f2=1+x+x2/2

2.5

f=ex

2.7183

Figure: Approximations to ex

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 13 / 13

Page 14: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Complete Horner’s Algorithm

An application of Horner’s algorithm is that of finding the Taylorexpansion of a polynomial about any point.

Let p(x) be a given polynomial of degree n with coefficients ak .

Suppose that we desire the coefficients ck in the equation

p(x) = anxn + an−1xn−1 + · · ·+ a0

= cn(x − r)n + cn−1(x − r)n−1 + · · ·+ c1(x − r) + c0

Taylor’s Theorem asserts that

ck = p(k)(r)/k!

but we seek a more efficient algorithm.

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 14 / 13

Page 15: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Complete Horner’s Algorithm (cont.)

Notice that p(r) = c0, so this coefficient is obtained by applyingHorner’s algorithm to the polynomial p with the point r .

The algorithm also yields the polynomial

q(x) =p(x)− p(r)

x − r= cn(x − r)n−1 + cn−1(x − r)n−2 + · · ·+ c1

This shows that the second coefficient, c1, can be obtained byapplying Horner’s algorithm to the polynomial q with point r sincec1 = q(r).

This process is repeated until all coefficients ck are found.

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 15 / 13

Page 16: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Complete Horner’s Algorithm (cont.)

The pseudocode for executing it is arranged so that the coefficientsck overwrite the input coefficients ak .

integer n, k , j ; real r ; real array (ai )0:nfor k = 0 to n − 1 do

for j = n − 1 to k doaj ← aj + raj+1

end forend for

This procedure can be used in carrying out Newton’s method forfinding roots of a polynomial, which we discuss later.

Moreover, it can be done in complex arithmetic to handle polynomialswith complex roots or coefficients.

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 16 / 13

Page 17: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Example 4

Example

Using the complete Horner’s algorithm, find the Taylor expansion of thepolynomial

p(x) = x4 − 4x3 + 7x2 − 5x + 2

about the point r = 3.

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 17 / 13

Page 18: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Example 4 (cont.)

The work can be arranged as follows:

1 −4 7 −5 23 ) 3 −3 12 21

1 −1 4 7 233 6 30

1 2 10 373 15

1 5 253

1 8

The calculation shows that

p(x) = (x − 3)4 + 8(x − 3)3 + 25(x − 3)2 + 37(x − 3) + 23

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 18 / 13

Page 19: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Taylor’s Theorem in Terms of (x − c)

Theorem

Taylor’s Theorem for f (x) If the function f possesses continuousderivatives of orders 0, 1, 2, . . . , (n + 1) in a closed interval I = [a, b], thenfor any c and x in I ,

f (x) =n∑

k=0

f (k)(c)

k!(x − c)k + En+1

where the error term En+1 can be given in the form

En+1 =f (n+1)(ξ)

(n + 1)!(x − c)n+1

Here ξ is a point that lies between c and x and depends on both.

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 19 / 13

Page 20: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Example 5

Example

Derive the Taylor series for ex at c = 0, and prove that it converges to ex

by using Taylor’s Theorem.

If f (x) = ex , then f (k)(x) = ex for k ≥ 0.Therefore, f (k)(c) = f (k)(0) = e0 = 1 for all k .We have

ex =n∑

k=0

xk

k!+

(n + 1)!xn+1

limn→∞

∣∣∣∣ eξ

(n + 1)!xn+1

∣∣∣∣ ≤ limn→∞

es

(n + 1)!sn+1 = 0

if |x | ≤ s.If we take the limit as n→∞ on both sides of ex above.

ex = limn→∞

n∑k=0

xk

k!=∞∑k=0

xk

k!

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 20 / 13

Page 21: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Example 6

Example

Derive the formal Taylor series for f (x) = ln(1 + x) at c = 0, anddetermine the range of positive x for which the series represents thefunction.

We need f (k)(x) and f (k)(0) for k ≥ 1.

f (x) = ln(1 + x) ⇒ f (0) = 0

f ′(x) = (1 + x)−1 ⇒ f ′(0) = 1

f ′′(x) = −(1 + x)−2 ⇒ f ′′(0) = −1

f ′′′(x) = 2(1 + x)−3 ⇒ f ′′′(0) = 2

f (4)(x) = −6(1 + x)−4 ⇒ f (4)(0) = −6

... ⇒...

f (k)(x) = (−1)k−1(k − 1)!(1 + x)−k⇒ f (k)(0) = (−1)k−1(k − 1)!

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 21 / 13

Page 22: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Example 6 (con.t)

Hence by Taylor’s Theorem, we obtain

ln(1 + x) =n∑

k=1

(−1)k−1(k − 1)!

k!xk +

(−1)nn!(1 + ξ)−n−1

(n + 1)!xn+1

=n∑

k=1

(−1)k−1xk

k+

(−1)n

n + 1

(1 + ξ

)−n−1xn+1

For the infinite series to represent ln(1 + x), it is necessary andsufficient that the error term converge to zero as n→∞.

Hence, the series represents ln(1 + x) if 0 ≤ x ≤ 1, but not if x > 1.

The series also represents ln(1 + x) for −1 < x < 0, but not ifx ≤ −1.

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 22 / 13

Page 23: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Mean-Value Theorem

The special case n = 0 in Taylor’s Theorem is known as theMean-Value Theorem.

Theorem

Mean-Value Theorem If f is a continuous function on the closed interval[a, b] and possesses a derivative at each point of the open interval (a, b),then

f (b) = f (a) + (b − a)f ′(ξ)

for some ξ in (a, b).

For some ξ ∈ (a, b)

f ′(ξ) =f (b)− f (a)

b − a

The approximation of derivatives is discussed more fully later.

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 23 / 13

Page 24: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Taylor’s Theorem in Terms of h

Other forms of Taylor’s Theorem are often useful. These can be obtainedby changing the variables.

Corollary

If the function f possesses continuous derivatives of order0, 1, 2, . . . , (n + 1) in a closed interval I = [a, b], then for any x in I ,

f (x + h) =n∑

k=0

f (k)(x)

k!hk + En+1

where h is any value such that x + h is in I and where

En+1 =f (n+1)(ξ)

(n + 1)!hn+1

for some ξ between x and x + h.

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 24 / 13

Page 25: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Taylor’s Theorem in Terms of h (cont.)

The error term En+1 depends on h:

As h converges to zero, En+1 converges to zero with essentially thesame rapidity with which hn+1 converges to zero.

To express this qualitative fact, we write

En+1 = O(hn+1)

as h→ 0.

This is called big O notation, and it is shorthand for the inequality

|En+1| ≤ C |h|n+1

where C is a constant.

Roughly speaking, En+1 = O(hn+1) means that the behavior of En+1

is similar to the much simpler expression hn+1.

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 25 / 13

Page 26: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Taylor’s Theorem in Terms of h (cont.)

For example, we can write out the cases n = 0, 1, 2 as follows:

f (x + h) = f (x) + f ′(ξ1)h

= f (x) +O(h)

f (x + h) = f (x) + f ′(x)h +1

2!f ′′(ξ2)h2

= f (x) + f ′(x)h +O(h2)

f (x + h) = f (x) + f ′(x)h +1

2!f ′′(x)h2 +

1

3!f ′′′(ξ3)h3

= f (x) + f ′(x)h +1

2!f ′′(x)h2 +O(h3)

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 26 / 13

Page 27: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Example 7

Example

Expand√

1 + h in powers of h. Then compute√

1.00001 and√

0.99999.

Let f (x) = x1/2.

Then f ′(x) =1

2x−1/2, f ′′(x) = −1

4x−3/2, f ′′′(x) =

3

8x−5/2, and so

on.

Now let x = 1 and take n = 2 for illustration

√1 + h = 1 +

1

2h − 1

8h2 +

1

16h3ξ−5/2

Let h = 10−5

√1.00001 ≈ 1 + 0.5× 10−5 − 0.125× 10−10 = 1.00000 49999 87500

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 27 / 13

Page 28: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Example 7 (cont.)

By substituting −h for h in the series, we obtain

√1− h = 1− 1

2h − 1

8h2 − 1

16h3ξ−5/2

Hence, we have

√0.99999 ≈ 0.99999 49999 87500

Both numerical values are correct to all 15 decimal places shown.

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 28 / 13

Page 29: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Alternating Series

Principle

If the magnitudes of the terms in an alternating series convergemonotonically to zero, then the error in truncating the series is no largerthan the magnitude of the first omitted term.

This theorem applies only to alternating series!

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 29 / 13

Page 30: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Alternating Series Theorem

Theorem

If a1 ≥ a2 ≥ · · · ≥ an ≥ · · · 0 for all n and limn→∞ an = 0, then thealternating series

a1 − a2 + a3 − a4 + · · ·

converges; that is,

∞∑k=1

(−1)k−1ak = limn→∞

n∑k=1

(−1)k−1ak = limn→∞

Sn = S

where S is its sum and Sn is the nth partial sum. Moreover, for all n,

|S − Sn| ≤ an+1

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 30 / 13

Page 31: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Example 8

Example

If the sine series is to be used in computing sin 1 with an error less than1

2× 10−6, how many terms are needed?

We have

sin 1 = 1− 1

3!+

1

5!− 1

7!+ · · ·

If we stop at 1/(2n − 1)!, the error does not exceed the firstneglected term, which is 1/(2n + 1)!.

Thus, we should select n so that

1

(2n + 1)!<

1

2× 10−6

We obtain log(2n + 1)! > log 2 + 6 = 6.3.

With a calculator, we find that log 10! ≈ 6.6.

Hence, if n ≥ 5, the error is acceptable.

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 31 / 13

Page 32: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Example 9

Example

If the logarithmic series is to be used for computing ln 2 with an error of

less than1

2× 10−6, how many terms are required?

To compute ln 2, we take x = 1 in the series

S = ln 2 ≈ 1− 1

2+

1

3− 1

4+ · · ·+ (−1)n−1

n= Sn

By the Alternating Series Theorem, the error involved when the seriesis truncated with n terms is

|S − Sn| ≤1

n + 1<

1

2× 10−6

Hence, more than two million terms would be needed!

We conclude that this method of computing ln 2 is not practical!

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 32 / 13

Page 33: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Example 10

Example

It is known thatπ4

90= 1−4 + 2−4 + 3−4 + · · ·

How many terms should we take to compute π4/90 with an error of at

most1

2× 10−6?

A naive approach is to take

1−4 + 2−4 + 3−4 + · · ·+ n−4

n is chosen so that the next term, (n + 1)−4, is less that1

2× 10−6.

This value of n is 37.

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 33 / 13

Page 34: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Example 10 (cont.)

But this is an erroneous answer because the partial sumS37 =

∑37k=1 k−4 differs from π4/90 by approximately 6× 10−6.

What we should do is to select n so that all the omitted terms add up

to less than1

2× 10−6

∞∑k=n+1

k−4 <1

2× 10−6

By a technique familiar from calculus, we have

∞∑k=n+1

k−4 <

∫ ∞n

x−4 dx =x−3

−3

∣∣∣∣∞n

=1

3n3

Thus, it suffices to select n so that

(3n3)−1 <1

2× 10−6 ⇒ n ≥ 88

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 34 / 13

Page 35: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Figure

Figure: Illustrating Example 10

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 35 / 13

Page 36: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Summary 1.2

The Taylor series expansion about c for f (x) is

f (x) =n∑

k=0

f (k)(c)

k!(x − c)k + En+1

with error term

En+1 =f (n+1)(ξ)

(n + 1)!(x − c)n+1

A more useful form for us is the Taylor series expansion for f (x + h)

f (x + h) =n∑

k=0

f (k)(x)

k!hk + En+1

with error term

En+1 =f (n+1)(ξ)

(n + 1)!hn+1 = O(hn+1)

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 36 / 13

Page 37: NUMERICAL MATHEMATICS & COMPUTING 6th Edition · Example 2 Example Approximate e8 using Taylor Series. The result is e8 = 1 + 8 + 64 2 + 512 6 + 4096 24 + 32768 120 ˇ570:066665 We

Summary 1.2 (cont.)

An alternating series

S =∞∑k=1

(−1)k−1ak

converges when the terms ak converge downward to zero.

Furthermore, the partial sums

Sn =n∑

k=1

(−1)k−1ak

differ from S by an amount that is bounded by

|S − Sn| ≤ an+1

Ward Cheney/David Kincaid c© (UT Austin[10pt] Engage Learning: Thomson-Brooks/Cole www.engage.com[10pt] www.ma.utexas.edu/CNA/NMC6)NUMERICAL MATHEMATICS & COMPUTING 6th EditionSeptember 16, 2011 37 / 13


Recommended