Professional Documents
Culture Documents
Numerical Methods: Week-1
Numerical Methods: Week-1
NUMERICAL METHODS
Week-1
SZABIST, Karachi
2
Midterm
• Numerical Differentiation
• Numerical Integration: Rectangular, Trapezoidal and Simpson’s Rules, Error analysis.
• Evaluation of Eigen values by Iteration: Power Method, Eigenvectors.
• Solution of 1st and 2nd Order Ordinary Differential Equations: Euler Method, Heun’s
Method, Runge-Kutta Method.
• Taylor Series Method, Predictor-Corrector Method.
3
Reference Book(s)
• Applied Numerical Analysis by Curtis F.Gerald and Patrick O.Wheatley, Addison Wesley,
Latest Edition.
• Numerical Methods for Engineers by Steven C. Chapra and Raymond P. Canale , McGraw-
Hill Science, Latest Edition.
Midterm 20 marks
Quiz 20 marks
Assignment 10 marks
Final 50 marks
Numerical Methods
• In mathematics, problems can be solved analytically and
numerically.
Taylor Series
• In calculus, Taylor's theorem gives an approximation of a n-
times differentiable function around a given point by a nth
order Taylor polynomial.
( x x0 ) 2 ( x x0 ) n n
f ( x) f ( x0 ) ( x x0 ) f '( x0 ) f ''( x0 ) .... f ( x0 ) ...
2! n!
6
Taylor Series
f(x)=cos(x)
7
Error Analysis
• Absolute Error
The absolute error is the magnitude of the difference between the
exact value and the approximation.
A.E exact value approximate value x xˆ
• Relative Error
The relative error is the absolute error divided by the magnitude of
the exact value.
exact value approximate value x xˆ
R.E
exact value x
• Percentage Error
The percent error is the relative error expressed in terms of per 100.
P.E R.E 100%
8
Analytical vs Numerical
• Some simple equations can be solved analytically:
x2 4x 3 0
4 4 2 4(1)(3)
Analytic solution roots
2(1)
x 1 and x 3
x 9 2 x 2 5 0
x No analytic solution
xe
9
Remark
In this course, all angles are assumed to be in radian
unless you are told otherwise.
10
Example-1(i)
If f ( x) sin( x), about x0 0 then find P1(x), P3(x),P5(x)
f ( x0 ) sin( x0 ) 0 f ( x0 ) cos( x0 ) 1
f ( x0 ) sin( x0 ) 0
4 f 5 ( x0 ) cos( x0 ) 1
P1 ( x) 0 ( x 0) 1 x
x3 x3
P3 ( x) x 0 (1) x
3! 3!
x3 ( x 0)5 x3 x5
P5 ( x) x 0 x
3! 5! 3! 5!
try it yourself f ( x ) cos( x), about x0 0
11
Example-1(ii)
Find the A.E and R.E at x=0.1
P1 (0.1) x 0.1
0.00017
A.E 0.09983 0.1 0.00017 R.E 0.0017
0.09983
x3
P3 (0.1) x 0.09984
3!
0.00001
A.E 0.09983 0.09984 0.00001 R.E 1.0017 105
0.09983
x3 x5
P5 ( x) x 0.09983
3! 5!
A.E and R.E , Do it yourself
12
Example-2
Find the Taylor polynomial of 2nd and 3rd order at x0=1
f ( x) x3 x
f ( x0 ) x03 x0 2 f ( x0 ) 3 x0 2 1 4
f ( x0 ) 6 x0 6 f ( x0 ) 6
( x 1) 2
P2 ( x) 2 ( x 1)4 6
2!
P2 ( x) 2 4( x 1) 3( x 1) 2
P3 ( x) 2 4( x 1) 3( x 1) 2 ( x 1)3
13
Practice Problem
• Find the Taylor polynomial of 3rd order at x0=1
f ( x) x 3 2 x 2 2 x
f ( x) x 4 10 x 2 6
14
(5 x 4 x 3 3 x 2 3 x 1) x 2 1
((5 x 3 x 2 3 x 3) x 1) x 2 1
(((5 x 2 x 3) x 3) x 1) x 2 1
((((5 x 1) x 3) x 3) x 1) x 2 1
16
Example-3
Use 3-digit chopping to compute the following approximation. Also
compute A.E and R.E. Exact value is given as e 2.7182818
5 5
1
b) S 2
1
a ) S1
n 0 n ! n 0 (5 n)!
1 1 1 1 1 1
S1
0! 1! 2! 3! 4! 5!
S1 1 1 0.5 0.166 0.041 0.008
S1 2.70
A.E 2.7182818 2.70 R.E 0.0182818 / e
0.0182818 6.7254 10 3
part (b), Do it yourself
17
Example-4
If f ( x) e x , about x0 0 , find the Taylor series
f ( x0 ) e x0 1 f ( x0 ) e x0 1
f ( x0 ) e x0 1 f ( x0 ) e x0 1
f 4 ( x0 ) e x0 1 f 5 ( x0 ) e x0 1
2 3 4 5
x x x x
e x 1 x ....
2! 3! 4! 5!
18
Example-5
Practice Problem
• Find absolute and relative errors
1/4
e dx 0.2553074606 p
x2
4 6
x x
P( x) 1 x 2 , pˆ ?
2! 3!