1. taylor polynomials taylor polynomialstrenchea/math1070/math1070_1_taylor_polynomials.pdf · >...

34
> 1. Taylor polynomials Taylor polynomials 1 Taylor polynomials 1 The Taylor polynomial 2 Error in Taylor’s polynomial 3 Polynomial evaluation 1. Taylor polynomials Math 1070

Upload: trananh

Post on 20-Jan-2019

252 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials

Taylor polynomials

1 Taylor polynomials1 The Taylor polynomial2 Error in Taylor’s polynomial3 Polynomial evaluation

1. Taylor polynomials Math 1070

Page 2: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.1 The Taylor polynomial

Let f(x) be a given function, for example

ex, sinx, log(x).

The Taylor polynomial mimics the behavior of f(x) near x = a:

T (x) ≈ f(x), for all x ”close” to a.

Example

Find a linear polynomial p1(x) for which{p1(a) = f(a),p′1(a) = f ′(a).

p1 is uniquely given by

p1(x) = f(a) + (x− a)f ′(a).

The graph of y = p1(x) is tangent to that of y = f(x) at x = a.1. Taylor polynomials Math 1070

Page 3: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.1 The Taylor polynomial

Example

Let f(x) = ex, a = 0. Then

p1(x) = 1 + x.

-2.4 -2 -1.6 -1.2 -0.8 -0.4 0 0.4 0.8 1.2 1.6 2 2.4

-1.2

-0.8

-0.4

0.4

0.8

1.2

y=p_1(x)

Figure: Linear Taylor Approximation ex

1. Taylor polynomials Math 1070

Page 4: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.1 The Taylor polynomial

Example

Find a quadratic polynomial p2(x) to approximate f(x) near x = a.

Sincep2(x) = b0 + b1x+ b2x

2

we impose three conditions on p2(x) to determine the coefficients. Tobetter mimic f(x) at x = a we require

p2(a) = f(a)p′2(a) = f ′(a)p′′2(a) = f ′′(a)

p2 is uniquely given by

p2(x) = f(a) + (x− a)f ′(a) +12(x− a)2f ′′(a).

1. Taylor polynomials Math 1070

Page 5: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.1 The Taylor polynomial

Example

Let f(x) = ex, a = 0. Then

p2(x) = 1 + x+12x2.

-1 -0.5 0 0.5 1

-0.25

0.25

0.5

0.75

1

1.25

1.5

y=p_1(x)

y=p_2(x)

y=e^x

Figure: Linear and quadratic Taylor Approximation ex (see eval exp simple.m)

1. Taylor polynomials Math 1070

Page 6: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.1 The Taylor polynomial

Let pn(x) be a polynomial of degree n that mimics the behavior off(x) at x = a. We require

p(j)n (a) = f (j)(a), j = 0, 1, . . . , n

where f (j) the jth derivative of f(x).The Taylor polynomial of degree n for the function f(x) at point a:

pn(x) = f(a) + (x− a)f ′(a) +(x− a)2

2!f ′′(a) + . . .+

(x− a)n

n!f (n)(a)

=n∑j=0

(x− a)j

j!f (j)(a). (3.1)

Recall the notations: f (0)(a) = f(a) and the ”factorial”:

j! ={

1, j = 0j · (j − 1) · · · 2 · 1, j = 1, 2, 3, 4, . . .

1. Taylor polynomials Math 1070

Page 7: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.1 The Taylor polynomial

Example

Let f(x) = ex, a = 0.Since f (j)(x) = ex, f (j)(0) = 1, for all j ≥ 0, then

pn(x) = 1 + x+12!x2 + . . .+

1n!xn =

n∑j=0

xj

j!(3.2)

For a fixed x, the accuracy improves as the degree n increases.

For a fixed degree n, the accuracy improves as x gets close toa = 0.

1. Taylor polynomials Math 1070

Page 8: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.1 The Taylor polynomial

Table. Taylor approximations to ex

x p1(x) p2(x) p3(x) ex

−1.0 0 0.500 0.33333 0.36788

−0.5 0.5 0.625 0.60417 0.60653

−0.1 0.9 0.905 0.90483 0.90484

0 1.0 1.000 1.00000 1.00000

0.1 1.1 1.105 1.10517 1.10517

0.5 1.5 1.625 1.64583 1.64872

1.0 2.0 2.500 2.66667 2.71828

1. Taylor polynomials Math 1070

Page 9: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.1 The Taylor polynomial

Example

Let f(x) = ex, a arbitrary, not necessarily 0.Since f (j)(x) = ex, f (j)(a) = ea, for all j ≥ 0, then

pn(x; a) = ea(

1 + (x− a) +12!

(x− a)2 + . . .+1n!

(x− a)n)

= ean∑j=0

(x− a)j

j!

1. Taylor polynomials Math 1070

Page 10: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.1 The Taylor polynomial

Example

Let f(x) = ln(x), a = 1.

Since f(1) = ln(1) = 0, and

f (j)(x) = (−1)j−1(j − 1)!1xj

f (j)(1) = (−1)j−1(j − 1)!

then the Taylor polynomial is

pn(x) = (x− 1)− 12(x− 1)2 +

13(x− 1)3 − . . .+ (−1)(n−1) 1

n(x− 1)n

=n∑

j=1

(−1)j−1

j(x− 1)j

1. Taylor polynomials Math 1070

Page 11: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.1 The Taylor polynomial

-0.25 0 0.25 0.5 0.75 1 1.25 1.5 1.75 2

-1.5

-1

-0.5

0.5

1

y=ln(x)

y=p_2(x)

y=p_3y=p_1(x)

Figure: Taylor approximations of ln(x) about x = 1 (see plot log.m)

1. Taylor polynomials Math 1070

Page 12: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.2 The error in Taylor’s polynomial

Theorem (Lagrange’s form)

Assume f ∈ Cn[α, β], x ∈ [α, β].The remainder Rn(x) ≡ f(x) − pn(x), or error in approximating

f(x) by pn(x) =n∑j=0

(x− a)j

j!f (j)(a) satisfies

Rn(x) =(x − a)n+1

(n + 1)!f (n+1)(cx), α ≤ x ≤ β (3.3)

where cx is an unknown point between a and x.

[Exercise.] Derive the formal Taylor series for f(x) = ln(1 + x) ata = 0, and determine the range of positive x for which the seriesrepresents the function.

Hint: f(k)(x) = (−1)k−1(k − 1)! 1(1+x)k , f(k)(0) = (−1)k−1(k − 1)!, 0 ≤ x

1+cx≤ 1, if x ∈ [0, 1].

ln(1 + x) =Pn

k=1(−1)k−1 xk

k+

(−1)n

n+1xn+1

(1+cx)n+1

1. Taylor polynomials Math 1070

Page 13: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.2 The error in Taylor’s polynomial

Example

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

Recall that pn(x) =n∑j=0

xj

j!= 1 + x+

12!x2 + . . .+

1n!xn.

The approximation error is

ex − pn(x) =xn+1

(n+ 1)!ec, n ≥ 0 (3.4)

with c ∈ (0, x).[Exercise.] It can be proved that for each fixed x,

limn→∞

Rn(x) = 0, i.e., ex = limn→∞

n∑k=0

xk

k!=

∞∑k=0

xk

k!.

(See the case |x| ≤ 1).

For each fixed n, Rn becomes larger as x moves away from 0.

1. Taylor polynomials Math 1070

Page 14: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.2 The error in Taylor’s polynomial

-1 -0.75 -0.5 -0.25 0 0.25 0.5 0.75 1

0.25

0.5

0.75

y=R_1(x)

y=R_2(x)

y=R_3(x)y=R_3(x)

y=R_1(x)

y=R_2(x)

y=R_4(x)

y=R_4(x)

Figure: Error in Taylor polynomial approx. to ex (see plot exp simple.m)

1. Taylor polynomials Math 1070

Page 15: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.2 The error in Taylor’s polynomial

Example

Let x = 1 in (3.4), so from (3.2):

e ≈ pn(1) = 1 + 1 +12!

+13!

+ · · ·+ 1n!

and from (3.4)

Rn(1) = e− pn(1) =ec

(n+ 1)!, 0 < c < 1

Since e < 3 and e0 ≤ ec ≤ e1 we have

1(n+ 1)!

≤ Rn(1) ≤ e

(n+ 1)!<

3(n+ 1)!

1. Taylor polynomials Math 1070

Page 16: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.2 The error in Taylor’s polynomial

Suppose we want to approximate e by pn(1) with

Rn(1) ≤ 10−9.

We have to take n ≥ 12 to guarantee

3(n+ 1)!

≤ 10−9,

i.e., to have p12 as a sufficiently good approximation to e.

1. Taylor polynomials Math 1070

Page 17: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.2 The error in Taylor’s polynomial

Exercise

Expand√

1 + h in powers of h, then compute√

1.00001.

If f(x) = x12 , then f ′(x) = 1

2x− 1

2 , f ′′(x) = − 14x

− 32 , f ′′′(x) = 3

8x− 5

2 , . . .

√1 + h = 1 +

12h− 1

8h2 +

116h3ε−

52 , 1 < ε < 1 + h, if h > 0.

Let h = 10−5. Then

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

Since 1 < ε < 1 + h, the absolute error does not exceed

116h3ε−

52 <

116

10−52 = 0.00000 00000 00000 0625

and the numerical value is correct to all 15 decimal places shown.

1. Taylor polynomials Math 1070

Page 18: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.2 The error in Taylor’s polynomial

Approximations and remainder formulae

ex = 1 + x+x2

2!+ · · ·+ xn

n!+

xn+1

(n+ 1)!ec (3.5)

sin(x) = x− x3

3!+x5

5!−· · ·+(−1)n−1 x2n−1

(2n−1)!+(−1)n x2n+1

(2n+1)!cos(c) (3.6)

cos(x) = 1− x2

2!+x4

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

(2n)!+(−1)n+1 x2n+2

(2n+2)!cos(c) (3.7)

11− x

= 1 + x+ x2 + · · ·+ xn +xn+1

1− x, x 6= 1 (3.8)

(1 + x)α = 1 +(α1

)x+

(α2

)x2 + · · ·+

(αn

)xn (3.9)

+(

αn+ 1

)xn+1(1 + c)α−n−1, α ∈ R

Recall that c is between 0 and x, and the binomial coefficients are(ακ

)=α(α− 1) · · · (α− κ+ 1)

κ!

1. Taylor polynomials Math 1070

Page 19: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.2 The error in Taylor’s polynomial

Example

Approximate cos(x) for |x| ≤ π4 with an error no greater than 10−5.

Since cos(c) ≤ 1 and

R2n+1(x) ≤x2n+2

(2n+ 2)!≤ 10−5

we must have (π4

)2n+2

(2n+ 2)!≤ 10−5

which is satisfied when n ≥ 3. Hence

cos(x) ≈ 1− x2

2!+x4

4!− x6

6!

1. Taylor polynomials Math 1070

Page 20: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.2 The error in Taylor’s polynomial

Indirect construction of a Taylor polynomial approximation

Remark

From (3.5), by replacing x with −t2, we obtain

e−t2=1− t2 +

t4

2!− t6

3!+ · · ·+ (−1)nx2n

n!+

(−1)(n+1)x2n+2

(n+ 1)!ec,

(3.10)

− t2≤c≤0.

If we attempt to construct the Taylor approximation directly, thederivatives of e−t

2become quickly too complicated.

1. Taylor polynomials Math 1070

Page 21: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.2 The error in Taylor’s polynomial

Indirect construction of a Taylor polynomial approximation

From (3.8) we can easily get:

−∫ t

0

dx

1− x= −

∫ t

0

(1 + x+ x2 + · · ·+ xn

)dx−

∫ t

0

xn+1

1− xdx,

ln(1− t) (3.12)= −

(t+

12t2 + · · ·+ 1

n+ 1tn+1

)− 1

1− c

∫ t

0xn+1dx

ln(1− t) = −(t+

12t2 + · · ·+ 1

n+ 1tn+1

)− 1

1− cttn+2

n+ 2, (3.11)

where ct is a number between 0 and t, −1 ≤ t ≤ 1.

Theorem (Integral Mean Value Theorem)

Let w(x) b a nonnegative integrable function on (a, b), andf ∈ C[a, b]. Then ∃ at least one point c ∈ [a, b] for which∫ b

af(x)w(x)dx = f(c)

∫ b

aw(x)dx (3.12)

1. Taylor polynomials Math 1070

Page 22: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.2 The error in Taylor’s polynomial

Infinite Series

By rearranging the terms in (3.8) we obtain the sum of a infinitegeometric series

1 + x+ x2 + · · ·+ xn =1− xn+1

1− x, x 6= 1. (3.13)

For |x| < 1, letting n→∞ we obtain the infinite geometric series

11− x

= 1 + x+ x2 + x3 + · · · =∞∑j=0

xj , x 6= 1. (3.14)

1. Taylor polynomials Math 1070

Page 23: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.2 The error in Taylor’s polynomial

Infinite Series

Definition

The infinite series∞∑

j=0

cj

is convergent if the partial sums

Sn =n∑

j=0

cj , n ≥ 0

form a convergent sequence, i.e.,

∃S = limn→∞

Sn

and we then write

S =∞∑

j=0

cj

1. Taylor polynomials Math 1070

Page 24: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.2 The error in Taylor’s polynomial

Infinite Series

For the infinite series (3.14)with |x| 6= 1, the partial sums are given by (3.13):

Sn =1− xn+1

1− x

Sn|x|<1−→n→∞

11−x

Sn is divergent when |x| > 1

What happens when |x| = 1?

1. Taylor polynomials Math 1070

Page 25: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.2 The error in Taylor’s polynomial

Infinite Series

Definition

Assume that f(x) has derivatives of any order atx = a. The infinite series

∞∑j=0

(x− a)j

j!f (j)(a)

is called the Taylor series expansion of the function f(x) about thepoint x = a.

The partial sumn∑j=0

(x− a)j

j!f (j)(a)

is simply the Taylor polynomial pn(x).

1. Taylor polynomials Math 1070

Page 26: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.2 The error in Taylor’s polynomial

Infinite Series

If the sequence {pn(x)} has the limit f(x), i.e. the error tends to zeroas n→∞

limn→∞

(f(x)− pn(x)

)= 0

then we can write

f(x) =∞∑j=0

(x− a)j

j!f (j)(a)

1. Taylor polynomials Math 1070

Page 27: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.2 The error in Taylor’s polynomial

Infinite series

Actually, it can be shown that the errors terms in (3.5)-(3.9) and(3.11) tend to 0 as n→∞ for suitable values of x. Hence the Taylorexpansions

ex =∞∑

j=0

xj

j!, −∞ < x <∞

sinx =∞∑

j=0

(−1)jx2j+1

(2j + 1)!, −∞ < x <∞

cosx =∞∑

j=0

(−1)jx2j

(2j)!, −∞ < x <∞ (3.15)

(1 + x)α =∞∑

j=0

(αj

)xj , −1 < x < 1

ln(1− t) = −∞∑

j=0

tj

j, −1 ≤ x < 1

1. Taylor polynomials Math 1070

Page 28: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.2 The error in Taylor’s polynomial

Infinite seriesDefinition

Infinite series of the form ∞∑j=0

aj(x− a)j (3.16)

are called power series.

They can arise from Taylor’s formulae or some other ways. Their convergencecan be examined directly.

Theorem (Comparison criterion)

Assume the series (3.16) converges for some value x0. Then the series (3.16)converges for all x satisfying |x− a| ≤ |x0 − a|.

Theorem (Quotient criterion)

For the series (3.16), assume that the limit

R = limn→∞

∣∣∣∣an+1

an

∣∣∣∣exists. Then for x satisfying |x− a| < 1

R , the series (3.16) converges to alimit S(x). When R = 0, the series (3.16) converges for any x ∈ R.

1. Taylor polynomials Math 1070

Page 29: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.2 The error in Taylor’s polynomial

Infinite series

Example

Consider the power series in (3.15). Letting t = x2, we obtain theseries

∞∑j=0

(−1)jtj

(2j)!(3.17)

Applying the quotient criterion with

aj =(−1)j

(2j)!

we find R = 0, so the series (3.17) converges for any value of t, hencethe series in the formula (3.15) converges for any value of x.

1. Taylor polynomials Math 1070

Page 30: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.3 Polynomial evaluation

Consider the evaluation of the polynomial

p(x) = 3− 4x− 5x2 − 6x3 + 7x4 − 8x5

1 simplest method: compute each term independently, i.e.,

c ∗ xk or c ∗ x ∗ ∗k

yielding1 + 2 + 3 + 4 + 5 = 15 multiplications

2 a more efficient method: compute each power of x using the precedingone:

x3 = x(x2), x4 = x(x3), x5 = x(x4) (3.18)

Since each term takes two multiplications for k > 1, the result will be

1 + 2 + 2 + 2 + 2 = 9 multiplications

3 nested multiplication:

p(x) = 3 + x(−4 + x(−5 + x(−6 + x(7− 8x))))

with only 5 multiplications

1. Taylor polynomials Math 1070

Page 31: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.3 Polynomial evaluation

Consider now the general polynomial of degree n:

p(x) = a0 + a1x+ · · ·+ anxn, an 6= 0

If we use the 2nd method, with the powers of x computed as in(3.18), the number of multiplications in evaluating p(x) is 2n− 1.

For the nested multiplication, we write and evaluate p(x) in theform

p(x) = a0 + x(a1 + x(a2 + · · ·+ x(an−1 + anx) · · · )) (3.19)

using only n multiplications, saving about 50% over the 2ndmethod.

All methods use n additions.

1. Taylor polynomials Math 1070

Page 32: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.3 Polynomial evaluation

Example

Evaluate the Taylor polynomial p5(x) for ln(x) about a = 1.

A general formula is (3.11), with t replaced by −(x− 1), yielding

p5(x) = (x− 1︸ ︷︷ ︸w

)− 12(x− 1)2 +

13(x− 1)3 − 1

4(x− 1)4 +

15(x− 1)5

= w

(1 + w

(−1

2+ w

(13

+ w

(−1

4+

15w

)))).

1. Taylor polynomials Math 1070

Page 33: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.3 Polynomial evaluation

A more formal algorithm than (3.19)

Suppose we want to evaluate p(x) at number z. Let define the sequence ofcoefficients bi as:

bn = an (3.20)

bn−1 = an−1 + zbn (3.21)

bn−2 = an−2 + zbn−1 (3.22)

... (3.23)

b0 = a0 + zb1 (3.24)

Now the nested multiplication is the Horner Method:p(z) = a0 + z(a1 + z(a2 + · · ·+ z(an−1 + an︸︷︷︸

bn

z

︸ ︷︷ ︸bn−1

) · · ·

︸ ︷︷ ︸b2

)

︸ ︷︷ ︸b1

)

︸ ︷︷ ︸b0

1. Taylor polynomials Math 1070

Page 34: 1. Taylor polynomials Taylor polynomialstrenchea/math1070/MATH1070_1_Taylor_polynomials.pdf · > 1. Taylor polynomials > 1.1 The Taylor polynomial Example Find a quadratic polynomial

> 1. Taylor polynomials > 1.3 Polynomial evaluation

Hence

p(z) = b0

With the coefficients from (3.20), define the polynomial

q(x) = b1 + b2x+ b3x2 + · · ·+ bnx

n−1

It can be shown that

p(x) = b0 + (x− z)q(x),

i.e., q(x) is the quotient from dividing p(x) by x− z, and b0 is theremainder.

Remark

This property we will use it later for polynomial rootfinding method toreduce the degree of a polynomial when a root z has been found, sincethen b0 = 0 and p(x) = (x− z)q(x).

1. Taylor polynomials Math 1070