You are on page 1of 17

Numerical

Methods
Lecture-2
[MA-200]
ARISHA ALI
Sources of Error

ARISHA ALI
Measuring Tools Creation of Mathematical Human Error
and Methods Model for problem

Data Error Modelling Error Blunders

Inherit Error

Numerical Method Computer Arithmetic

Truncation Error Round off Error

Numerical Errors

ARISHA ALI 3
Truncation Error
It is an error due to truncating a process involving infinite number of steps to finite numbers of
steps.

For example,
𝑥2 𝑥3 𝑥4 𝑥5
Maclaurine series of 𝑒𝑥 =1+𝑥+ + + + +⋯
2! 3! 4! 5!

We cannot use infinite terms: say we can use only first four terms
𝑥2 𝑥3
Truncate it to 𝑒𝑥 ≈1+𝑥+ +
2! 3!

𝑥2 𝑥3
Truncation error = 𝑒𝑥 − (1 + 𝑥 + + )
2! 3!

𝑥4 𝑥5
= + +⋯
4! 5!

ARISHA ALI 4
Example
Estimate 𝑒 0.5 for different number of terms and calculate relative %
approximation error (Exact value of 𝑒 0.5 up to 5 decimal places is 1.64872)

No of Terms Estimate of 𝒆𝟎.𝟓 Absolute Relative % Absolute Value


Approximation (𝑬𝒂 ) Approximation
1 1 -- -- 0.64872
2 1.5 0.5 33% 0.14872
3 1.625 0.125 7.69% 0.02372
4 1.645832 0.020832 1.27% 0.00289
5 1.64843617 0.00260417 0.16% 0.00028

ARISHA ALI 5
Example
1Τ 2
Given that ‫׬‬0 2
𝑒 𝑥 𝑑𝑥 = 0.544987104184 = 𝑥 , determine the accuracy of
2
approximation obtain by replacing the integrand 𝑓 𝑥 = 𝑒 𝑥 with the truncated
Taylor series
𝑥 4 𝑥 6 𝑥 8
𝑥2
𝑒 = 1 + 𝑥2 + + +
2! 3! 4!
1ൗ 4 6 8
2 𝑥 𝑥 𝑥
=න 1 + 𝑥2 + + + 𝑑𝑥
0 2! 3! 4!
1ൗ
𝑥3 𝑥5 𝑥7 𝑥9 2
= 𝑥+ + + +
3 5(2!) 7(3!) 9(4!) 0
ARISHA ALI 6
Cont…
1 1Τ 3 1Τ 5 1Τ 7 1Τ 9
= + 2 + 2
+ 2
+ 2
2 3 5(2!) 7(3!) 9(4!)

1 1 1 1 1 1 1 1 1
= + ∗ + ∗ + ∗ + ∗
2 8 3 32 10 128 42 512 216
1 1 1 1 1
= + + + +
2 24 320 5376 110592
2109491
=
3870720

𝑥 ∗ = 0.544986720817

ARISHA ALI 7
Cont…
𝐸𝑟𝑟𝑜𝑟 = 𝑥 − 𝑥 ∗
= 0.544987104184 − 0.544986720817
= 0.000000383367
= 3.83367 ∗ 10−7

ARISHA ALI 8
Homework
Complete the following computation
1Τ 2 1Τ 𝑥4 𝑥6
‫׬‬0 4
𝑒 𝑥 𝑑𝑥 ≅ ‫׬‬0 4
1+ 𝑥2 + + 𝑑𝑥
2! 3!

State what type of error is present in this situation. Compare your answer with
true value 0.2553074606

ARISHA ALI 9
Round off Error

ARISHA ALI
Floating Point Number

± 𝑆𝑖𝑔𝑛𝑖𝑓𝑖𝑐𝑎𝑛𝑡 ∗ 𝐵𝑎𝑠𝑒 ±𝐸𝑥𝑝𝑜𝑛𝑒𝑛𝑡


For example
0.00000000005 = 0.5 ∗ 10−10
500000000000 = 5 ∗ 1010

ARISHA ALI 11
Normalization Rules for floating Point
Numbers
▪ The integer part Should be Zero
▪ 0. 𝑑1 𝑑2 𝑑3 … 𝑑𝑛 ∗ 𝐵𝐼𝐸 𝑡ℎ𝑒𝑛 𝑑1 > 0

0.123 ∗ 104
0.0123 ∗ 106
1.23 ∗ 103

ARISHA ALI 12
Representation Techniques
IEEE(Institute of Electrical and Electronic Engineering) 754 floating point
standard
▪ Single Precision (32 bit)

S Exponent (8 bit) Fraction (23 bit)

▪ Double Precision (64 bit)


S Exponent (11 bit) Fraction (52 bit)

ARISHA ALI 13
Chopping Versus Rounding
Chopping Rounding

𝑒 = 2.71828182845 … 𝑒 = 2.71828182845 …
We Need 7 significant digits We Need 7 significant digits
𝑒 = 2.71828182845 … 𝑒 = 2.71828182845 …
After Chopping After Rounding
𝑒 = 2.718281 𝑒 = 2.718282
𝐸𝑟𝑟𝑜𝑟 = 8.2844999 ∗ 10−7 𝐸𝑟𝑟𝑜𝑟 = −1.715499 ∗ 10−7

ARISHA ALI 14
Remarks

▪Rounding is a better choice since the sign of the error can be either positive or
negative leading to smaller total numerical error.
▪Whereas error in chopping is always positive and always adds up.

15
Example
Determine the five-digit normalized decimal form (a) chopping and (b) rounding
values of the irrational number 𝜋.
𝜋 = 3.14159265
Solution:
Written in normalized decimal form
𝜋 = 0.314159265 … ∗ 101
(a) The floating-point form of 𝜋 using five-digit chopping is
𝑓𝑙(𝜋) = 0.31415 ∗ 101 = 3.1415.
ARISHA ALI 16
Cont…
𝜋 = 0.314159265 … ∗ 101
(b) The sixth digit of the decimal expansion of 𝜋 is a 9, so the floating-point
form of 𝜋 using five-digit rounding is
𝑓𝑙 𝜋 = 0.31415 + 0.00001 ∗ 101 = 3.1416.

ARISHA ALI 17

You might also like