Professional Documents
Culture Documents
2
Calculating Truncation Error
Example 1:
Find the Taylor expansion of ex about x0 = 0 which use the first two, three,
four and five and evaluate for x = 0.5, respectively.
Answer: Given, x0 = 0, ⸫ h = (x – x0) = x
e x = 1 + x + ( x 2 )
2
x
e = 1 + x + + ( x 3 )
x
2!
2 3
x x
e x = 1 + x + + + ( x 4 )
2! 3!
2 3 4
x x x
e x = 1 + x + + + + ( x 5 )
2! 3! 4! 3
Calculating Truncation Error
e 0.5
= 1.648721.. (True value)
e 0.5
= 1.5 + ( x )
2
( x ) 0.14872..
2
e 0.5
= 1.625 + ( x ) 3
( x ) 0.023721..
3
e 0.5
= 1.64583.. + ( x ) 4
( x ) 0.002887..
4
e 0.5
= 1.64843.. + ( x ) 5
( x ) 0.0002837..
5
4
Calculating Truncation Error
Example 2:
Find the Taylor expansion of ex about x0 = 0.25 which use the first two,
three, four and five and evaluate for x = 0.5, respectively.
Answer: Given, x0 = 0.25, ⸫ h = (x – x0) = (0.5 – 0.25) = 0.25
2!
2 3
h 0.25 h 0.25
e = e + he + e + e + (h 4 )
x 0.25 0.25
2! 3!
2 3 4
h h h
e x = e0.25 + he0.25 + e 0.25 + e0.25 + e0.25 + (h5 )
2! 3! 4!
Calculating Truncation Error
e 0.5
= 1.648721..
e 0.5
= 1.60503..+ (h )
2
(h 2 ) 0.04368...
e 0.5
= 1.64515..+ (h )
3
(h ) 0.00356..
3
e 0.5
= 1.64850..+ (h )
4
(h ) 2.1988..e- 004
4
e 0.5
= 1.64871.. + (h )
5
(h ) 1.0900..e- 005
5
6
Summary from example 1 and 2:
7
Truncation error vs n
h=0.5 h=0.25
0.16
0.14872
0.14
0.12
TRUNCATION ERROR
0.1
0.08
0.06
0.04368
0.04
0.023721
0.02
0.00356 0.002887
0.00021988 0.0002837
0.0000109
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5
NUMBER OF TERMS N
8
More Example
Use Taylor series expansions with n = 0 to 6 to approximate f(x) = cos(x) at
xi+1 = π/3 on the basis of the value of f(x) and its derivatives at xi = π/4. Note
that this means that h = π/3 − π/4 = π/12.
Ans.: f(π/3) = cos(π/3) = 0.5 (True value)
➢Considering result on 1st value only: f(π/3) cos(π/4) = 0.707106781
which represents a percent relative error of
εt = ((|0.5 − 0.707106781|)/0.5)×100% = 41.4213562%
➢Taking 1st 2 values: f(π/3) cos(π/4) – π/12× sin(π/4)
= 0.707106781 – 0.2617993878 × 0.707106781 = 0.521986658625
εt = ((|0.5 − 0.521986658625|)/0.5) × 100% = 4.397331725%
9
Example …
10
Example …
n f(π/3)=0.5(True) % Error
0 0.707106781 41.4213562
1 0.521986659 4.397331725
2 0.497754491 0.4491017457
3 0.499869147 2.62 × 10−2
4 0.500007551 1.51 × 10−3
5 0.500000304 6.08 × 10−5
6 0.499999988 2.44 × 10−6
11
Example …
% ERROR
45
40
35
30
25
20
15
10
0
0 1 2 3 4 5 6
12