Lecture Notes 1
Lecture Notes 1
Lecture Notes 1
Introduction
1 x2 b 1 a2 b2
I1 e (e e )
2 a
2
b
x2
I2 e
a
dx
• Significant figures
• Whenever we employ a number in a computation, we
must have assurance that it can be used with confidence
• It is 48 km/h or 49km/h?
• Chopping
• Π= 3.1415926535897932384626433832795….
• If the π is represented 5 significant digits
• Π=3.1415
• Example
1
Calculate the derivative of f ( x ) 2
with 3& 4 digit aritmetics at x 1.22
(3 2 x )
4x
f ( x)
(3 2 x 2 ) 2
3 Digits Arithmetic's
4*1.22 4.88 4.88 4.88
f (1.22) 2 2
2
2
12, 200
(3 2*(1.22) ) (3 2*1.49) (3 2.98) 0.0004
4 Digits Arithmetic's
• ACCURACY
• Accuracy refers to how closely a computed or measured
value agrees with the true value.
• PRECISION
• Precision refers to how closely individual computed or
measured values agree with each other.
• TRUE ERROR
• 1. TRUNCATION ERROR
• This error results from the discrepancy introduced by the
fact that the numerical method employs approximation to
represent exact mathematical operations and quantities
f n (a)
f ( x) ( x a) n
n 0 n!
( x a) ( x a)2 ( x a )3 ( x a)n
f ( x) f (a ) f (a) f (a) f (a) n
...... f (a ) Rn
1! 2! 3! n!
n 1 ( x a ) n 1
Rn f (a ).
( n 1)!
• True value =
f (0.5) e0.5 1.6487
• Approximate values:
• n=2
x
f ap ( x) 1 f ap (0.5) 1 0.5 1.5
1!
• Relative True error
n=input('enter n');
Outputs
x=input('enter x');
enter n=4
eax=0; enter x=0.5
ex=exp(x); n eax error
disp(['n eax error']) 1.0000 1.6487 0.3935
for i=1:n; 2.0000 1.6487 0.0902
k=i-1;
eax=eax+(x^k)/factorial(k); 3.0000 1.6487 0.0144
error=abs((ex-eax)/ex); 4.0000 1.6487 0.0018
disp([i eax error])
end