Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

1

NUMERICAL METHODS
Week-1

SZABIST, Karachi
2

Outline (Numerical Method)


• Taylor polynomials, absolute error, relative error, percent error.
• Solution of the system of Linear Equations: Systems of linear Equations, Gauss Elimination
Method, LU Decomposition, Iterative Methods for Systems of Equations: Gauss-Seidel
Method, Jacobi’s Method.
• Iterative Methods for the Solutions of Non-Linear Equations: Fixed point Method,
Bisection Method, Regula-Falsi Method; Convergence, Newton-Raphson Method, Secant
Method.
• Interpolation: Lagrange Interpolation, Newton’s Divided Difference, Forward Difference and
Backward Difference Interpolations, Taylor Series and Calculation of function.

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

Outline (Numerical Method)


Textbook(s)
• Numerical Methods Using Matlab, 4th Edition, John H. Mathews and Kurtis K. Fink

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

Total 100 marks


4

Numerical Methods
• In mathematics, problems can be solved analytically and
numerically.

• An analytical solution involves framing the problem in a well-


understood form and calculating the exact solution.

• A numerical solution means making guesses at the solution and


testing whether the problem is solved well enough to stop.

• Numerical analysis can solve problems where analytical


solutions are not available.
5

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.

• A Taylor series is a series expansion of a function about a point.


A one-dimensional Taylor series is an expansion of a real
function f(x) about a point x=x0 is given by

( 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

• Many other equations have no analytical solution:

x 9  2 x 2  5  0

x  No analytic solution
xe 

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 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  105
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

• Find the Taylor polynomial of 4th order at x0=3

f ( x)  x 4  10 x 2  6
14

Rounding and Chopping


 Rounding: Replace the number by the nearest machine number.
 Chopping: Throw all extra digits.

 Find the 3-digit Rounding and chopping:


exact  12.3234 exact  0.031964 exact  130.284
Rounding  12.3 Rounding  0.032 Rounding  130
Chopping  12.3 Chopping  0.031 Chopping  130
15

Nested form (Example)


5 x6  x5  3x 4  3x3  x 2  1

(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

A.E  3.833  107


R.E  p  pˆ / p  7.03442 107
19

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!

You might also like