0% found this document useful (0 votes)
27 views11 pages

Numerical Analysis Anzar Lec 07 15102022 035138am

Uploaded by

Aliyyan Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views11 pages

Numerical Analysis Anzar Lec 07 15102022 035138am

Uploaded by

Aliyyan Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Lecture 7

Numerical
Analysis
Chapter 4

Taylor Series

1
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter – 4
Truncation Errors and the Taylor Series
Truncation errors are those that result from using an approximation in place of an
exact mathematical procedure.
For example, in Chap. 1 we approximated the derivative of velocity of a falling
parachutist by a finite-divided-difference equation of the form [Eq. (1.11)]

𝑑𝑣 Δ𝑣 𝑣 𝑡𝑖+1 − 𝑣 𝑡𝑖 ………………………..Eq (1.11)


≅ =
𝑑𝑡 Δ𝑡 𝑡(𝑖+1) − 𝑡𝑖
A truncation error was introduced into the numerical solution because the
difference equation only approximates the true value of the derivative.
In order to gain insight into the properties of such errors, we now turn to a
mathematical formulation that is used widely in numerical methods to express
functions in an approximate fashion— the Taylor series.

2
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
THE TAYLOR SERIES: Taylor’s theorem (Box 4.1) and its associated formula, the
Taylor series, is of great value in the study of numerical methods. In essence, the Taylor
series provides a means to predict a function value at one point in terms of the function
value and its derivatives at another point. In particular, the theorem states that any
smooth function can be approximated as a polynomial. A useful way to gain insight into
the Taylor series is to build it term by term. For example, the first term in the series is:

𝑓(𝑥 𝑖+1 ) ≅ 𝑓(𝑥𝑖 ) (4.2)


This relationship, called the zero-order approximation, indicates that the value of f at the
new point is the same as its value at the old point. This result makes intuitive sense
because if 𝑥𝑖 and 𝑥𝑖+1 are close to each other, it is likely that the new value is probably
similar to the old value. Equation (4.2) provides a perfect estimate if the function being
approximated is, in fact, a constant. However, if the function changes at all over the
interval, additional terms of the Taylor series are required to provide a better estimate.
For example, the first-order approximation is developed by adding another term to yield.
𝑓(𝑥𝑖+1 ) ≅ 𝑓(𝑥𝑖 ) + 𝑓′(𝑥𝑖 )(𝑥𝑖+1 − 𝑥𝑖 ) (4.3)
The additional first-order term consists of a slope 𝑓(𝑥𝑖 ) multiplied by the distance
between 𝑥𝑖 and 𝑥𝑖+1 . Thus, the expression is now in the form of a straight line and is
capable of predicting an increase or decrease of the function between 𝑥𝑖 and 𝑥𝑖+1
3
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Taylor’s Theorem If the function f and its first n+1 derivatives are continuous on an
interval containing a and x, then the value of the function at x is given by
𝑓 ′′ 𝑎
𝑓 𝑥 = 𝑓 𝑎 + 𝑓′(𝑎) 𝑥 − 𝑎 1 + 𝑥−𝑎 2
2!
𝑓3 𝑎 3
+ 𝑥−𝑎 +……….
3!
𝑓𝑛 𝑎 𝑛
+ 𝑥−𝑎 +𝑅𝑛 (B4.1.1)
𝑛!

where the remainder 𝑅𝑛 is defined as

𝑥 𝑥−𝑡 𝑛 (𝑛+1)
𝑅𝑛 = 𝑎
𝑓 𝑡 𝑑𝑡 (𝐵4.1.2)
𝑛!

where t = a dummy variable. Equation (B4.1.1) is called the Taylor series or


Taylor’s formula. If the remainder is omitted, the right side of Eq. (B4.1.1) is
the Taylor polynomial approximation to f(x). In essence, the theorem states
that any smooth function can be approximated as a polynomial.

4
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
𝑓(𝑥𝑖+1 ) ≅ 𝑓(𝑥𝑖 ) + 𝑓′(𝑥𝑖 )(𝑥𝑖+1 − 𝑥𝑖 ) (4.3)
Although Eq. (4.3) can predict a change, it is exact only for a straight-line, or linear, trend.
Therefore, a second-order term is added to the series to capture some of the curvature that
the function might exhibit:
𝑓′′(𝑥𝑖 )
𝑓(𝑥𝑖+1 ) ≅ 𝑓(𝑥𝑖 ) + 𝑓′(𝑥𝑖 )(𝑥𝑖+1 − 𝑥𝑖 ) + (𝑥𝑖+1 − 𝑥𝑖 )2 (4.4)
2!
In a similar manner, additional terms can be included to develop the complete Taylor
series expansion:
𝑓′′(𝑥𝑖 )
𝑓(𝑥𝑖+1 ) = 𝑓(𝑥𝑖 ) + 𝑓′(𝑥𝑖 )(𝑥𝑖+1 − 𝑥𝑖 ) + (𝑥𝑖+1 − 𝑥𝑖 )2 +
2!
𝑓(3) (𝑥𝑖 ) 𝑓(𝑛) (𝑥𝑖 )
(𝑥𝑖+1 − 𝑥𝑖 )3 + ∙∙∙∙∙∙ + (𝑥𝑖+1 − 𝑥𝑖 )𝑛 + Rn (4.5)
3! 𝑛!
Note that because Eq. (4.5) is an infinite series, an equal sign replaces the
approximate sign that was used in Eqs. (4.2) through (4.4). A remainder term is
included to account for all terms from n +1 to infinity:
𝑓 (𝑛+1) ) (ξ )
Rn = (𝑥𝑖+1 − 𝑥𝑖 )𝑛+1 (4.6)
𝑛+1 !
Here, ξ is a value of x that lies somewhere between xi and xi+1
5
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
It is often convenient to simplify the Taylor series by defining a step size
h = (𝑥𝑖+1 − 𝑥𝑖 ) and expressing Eq. (4.5) as

𝑓′′(𝑥𝑖 ) 2 𝑓(3) (𝑥𝑖 ) 3 𝑓(𝑛) (𝑥𝑖 )


𝑓(𝑥𝑖+1 ) = 𝑓(𝑥𝑖 ) + 𝑓′(𝑥𝑖 )ℎ + ℎ + ℎ + ∙∙∙ + ℎ𝑛 +𝑅𝑛 (4.7)
2! 3! 𝑛!

𝑓 (𝑛+1) ) (ξ )
𝑅𝑛 = ℎ𝑛+1 (4.8)
𝑛+1 !

6
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
𝑓′′(𝑥𝑖 ) 2 𝑓(3) (𝑥𝑖 ) 3 𝑓(𝑛) (𝑥𝑖 )
𝑓(𝑥𝑖+1 ) = 𝑓(𝑥𝑖 ) + 𝑓′(𝑥𝑖 )ℎ + ℎ + ℎ + ∙∙∙ + ℎ𝑛 +𝑅𝑛 (4.7)
2! 3! 𝑛!

EXAMPLE 4.1: Taylor Series Approximation of a Polynomial


Problem Statement.
Use zero- through fourth-order Taylor series expansions to approximate the function
𝑓 𝑥 = −0.1𝑥 4 − 0.15𝑥 3 − 0.5𝑥 2 − 0.25𝑥 + 1.2
from 𝑥𝑖 = 0 with h = 1. That is, predict the function’s value at 𝑥𝑖+1 = 1.
Solution: Because we are dealing with a known function, we can compute values for 𝑓 𝑥
between 0 and 1.
The results (Fig. 4.1) indicate that the function starts at 𝑓 0 = 1.2 and then curves down to
𝑓 1 = 0.2, Thus, the true value that we are trying to predict is 0.2.
The Taylor series approximation with zero order (𝑛 = 0) is [Eq. (49.2)]

𝑓(𝑥𝑖+1 ) ≈ 1.2 at x=0; zero order (n=0)

7
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
𝑓′′(𝑥𝑖 ) 2 𝑓(3) (𝑥𝑖 ) 3 𝑓(𝑛) (𝑥𝑖 )
𝑓(𝑥𝑖+1 ) = 𝑓(𝑥𝑖 ) + 𝑓′(𝑥𝑖 )ℎ + ℎ + ℎ + ∙∙∙ + ℎ𝑛 +𝑅𝑛 (4.7)
2! 3! 𝑛!

𝑓 𝑥 = −0.1𝑥 4 − 0.15𝑥 3 − 0.5𝑥 2 − 0.25𝑥 + 1.2


from 𝑥𝑖 = 0 with h = 1. That is, predict the function’s value at 𝑥𝑖+1 = 1.
Solution: Because we are dealing with a known function, we can compute values for 𝑓 𝑥
between 0 and 1.
1st we calculate derivatives up to 4 order at 𝑥𝑖 =0;

𝑓 𝑥 = −0.1𝑥 4 − 0.15𝑥 3 − 0.5𝑥 2 − 0.25𝑥 + 1.2


𝑓 0 = −0.1 0 4 − 0.15 0 3 − 0.5 0 2 − 0.25 0 + 1.2 = 1.2
3 2
𝑓′ 0 = −0.4 0 − 0.45 0 − 1.0 0 − 0.25 = − 0.25 𝑓 0 = 1.2
𝑓′′ 0 = −1.2 0 2 − 0.9 0 1 − 1.0= − 1.0 𝑓′ 0 = − 0.25
𝑓 3 0 = −2.4 0 1 − 0.9 = − 0.9 𝑓′′ 0 = − 1.0
𝑓 4 0 = −2.4 = −2.4 𝑓3 0 = − 0.9
𝑓 5 0 = 𝑐𝑎𝑛 𝑛𝑜𝑡 𝑒𝑣𝑎𝑙𝑢𝑎𝑡𝑒𝑑. So stop the estimation here. 𝑓4 0 = −2.4

8
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
𝑓′′(𝑥𝑖 ) 2 𝑓(3) (𝑥𝑖 ) 3 𝑓(𝑛) (𝑥𝑖 )
𝑓(𝑥𝑖+1 ) = 𝑓(𝑥𝑖 ) + 𝑓′(𝑥𝑖 )ℎ + ℎ + ℎ + ∙∙∙ + ℎ𝑛 +𝑅𝑛 (4.7)
2! 3! 𝑛!

Because we are dealing with a known function, we compute values for 𝑓 𝑥


between 0 and 1

𝐸𝑡 = 𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒 − 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛 (3.2)


zero order approximation (n=0) at 𝑥𝑖+1 = 1; from Eq 𝑓 0 = 1.2
(4.7)
𝑓(𝑥 ) = 𝑓(𝑥 ) = 1.2 𝑓′ 0 = − 0.25
𝑖+1 𝑖
𝑓′′ 0 = − 1.0
𝐸𝑡 = 𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒 − 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛 (3.2)
𝑓3 0 = − 0.9
𝐸𝑡 = 0.2 − 1.2 = -1.0
𝑓4 0 = −2.4
1st order approximation (n=1) at 𝑥𝑖+1 = 1;
𝑓(𝑥𝑖+1 ) = 𝑓(𝑥𝑖 )) + 𝑓′(𝑥𝑖 )ℎ = 1.2 + −0.25 1 = 0.95
𝐸𝑡 = 𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒 − 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛 (3.2)
𝐸𝑡 = 0.2 − 0.95 = - 0.75
9
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
𝑓′′(𝑥𝑖 ) 2 𝑓(3) (𝑥𝑖 ) 3 𝑓(𝑛) (𝑥𝑖 )
𝑓(𝑥𝑖+1 ) = 𝑓(𝑥𝑖 ) + 𝑓′(𝑥𝑖 )ℎ + ℎ + ℎ + ∙∙∙ + ℎ𝑛 +𝑅𝑛 (4.7)
2! 3! 𝑛!
2nd order approximation (n=2) at 𝑥𝑖+1 = 1; 𝑓 0 = 1.2
𝑓′′(𝑥𝑖 ) 2 −1
𝑓(𝑥𝑖+1 ) = 𝑓(𝑥𝑖 ) + 𝑓′(𝑥𝑖 )ℎ + ℎ = 0.95+ (1)2 = 0.45 𝑓′ 0 = − 0.25
2! 2!
𝐸𝑡 = 𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒 − 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛 𝑓′′ 0 = − 1.0
𝑓3 0 = − 0.9
𝐸𝑡 = 0.2 − 0.45 = - 0.25
𝑓4 0 = −2.4
3rd order approximation (n=3) at 𝑥𝑖+1 = 1;
𝑓′′(𝑥𝑖 ) 2 𝑓(3) (𝑥𝑖 ) 3 −0.9
𝑓(𝑥𝑖+1 ) = 𝑓(𝑥𝑖 ) + 𝑓′(𝑥𝑖 )ℎ + ℎ + ℎ = 0.45+ (1)3 = 0.3
2! 3! 3!
𝐸𝑡 = 𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒 − 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛
Et = 0.2– 0.3 = − 0.1
4th order approximation (n=4) at 𝑥𝑖+1 = 1;
𝑓′′(𝑥𝑖 ) 2 𝑓 (3) (𝑥𝑖 ) 3 𝑓(4) (𝑥𝑖 ) 4
𝑓(𝑥𝑖+1 ) = 𝑓(𝑥𝑖 )) + 𝑓′(𝑥𝑖 )ℎ + ℎ + ℎ + ℎ
2! 3! 4!
−2.4
= 0.3 + (1)4 = 0.3 - 0.1 = 0.2
4!
𝐸𝑡 = 𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒 − 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛
Et = 0.2– 0.2 = 0.0
10
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
= 𝟏. 𝟐

= 𝟎. 𝟗𝟓

= 0.45

= 0.3

= 0.2

11
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

You might also like