Professional Documents
Culture Documents
This teaching material provides an introduction to the numerical methods that are typically
encountered (and used) in engineering, science and mathematics undergraduate courses. It gives
a brief introduction to the learner on basic concepts on error estimation, numerical solutions of
nonlinear equations, methods on system of equations, interpolation, numerical differentiation and
integration and numerical solution of ordinary differential equations.The first chapter is on basic
concepts in error estimation,second chapter about numerical methods to solve nonlinear
equations,such as bisection method,false position method,Newton-Raphson method etc. are
illusterted,in the third chapter numerical methods for system of equations(both direct and
iterative) methods are discussed. In the fourth chapter interpolation (in the case of equally spaced
data, Newton’s forward and back ward difference interpolation and where as in the case of
equally or unequally spaced data points, Newton’s divided difference interpolation method and
the lagrange’s method are presented). In the fifth chapter of this material numerical
differentiation using forward difference and backward difference interpolation formula and
numerical integration techniques, Trapezoidal rule, Simpson’s one-third and three-eight rules are
illustrated and in chapter six numerical solutions of ordinary differential equations are presented,
the methods presented in this chapter are Euler’s Method, Taylor series method of order N and
the Fourth order Runge-Kutta method, all the methods are illustrated with examples.
i
Table of Contents Pages
CHAPTER ONE ........................................................................................................................................... 1
BASIC CONCEPTS ON ERROR ESTIMATION ................................................................................................... 1
1.1 . Introduction ..................................................................................................................................... 1
1.2. Error (1 hour) ......................................................................................................................................... 2
1.3. Sources of Error ................................................................................................................................... 2
1.4. Absolute, Relative and Percentage error (1 hour) .................................................................................. 3
1.5. Error propagation (3 hours).................................................................................................................... 4
CHAPTER TWO .......................................................................................................................................... 1
NUMERICAL SOLUTION OF NON-LINEAR EQUATIONS .................................................................. 1
2.1. Introduction ............................................................................................................................................ 1
2.2. Bisection Method (2hours) .................................................................................................................... 2
2.3. False position method (2 hours) ............................................................................................................. 9
2.4. Fixed-point iteration (1 hour) .......................................................................................................... 14
2.5. Newton-Raphson method (2 hours) ..................................................................................................... 16
2.6. Secantmethod (1 hour) ......................................................................................................................... 20
CHAPTER THREE .................................................................................................................................... 24
SYSTEMS OF LINEAR EQUATIONS ..................................................................................................... 24
3.2. Introduction ................................................................................................................................... 24
3.1. Direct methods to solve a linear system of equations (8 hours)...................................................... 26
3. 2.1. Gaussian elimination (2 hours) ........................................................................................................ 26
3.2.2 Gauss- Jordan elimination (2 hours) .................................................................................................. 29
3.2.3 Solution of a tri-diagonal system (2 hours) ........................................................................................ 30
3.2.4.Thomas method .................................................................................................................................. 31
3.2.5 Lu Decomposition Method (2 hours) ................................................................................................. 32
3.2.6. Crout’s LU decomposition method ................................................................................................... 33
3.3. Iterative methods (4 hours) .................................................................................................................. 37
3.3.1 Jacobi iterative method (2 hours) ....................................................................................................... 39
3.3.2. Gauss-Seidel iterative method (2 hours) ........................................................................................... 43
3.3.3 Newton ‘s method to solve system of nonlinear equations (2 hours) ................................................ 47
CHAPTER 4 ............................................................................................................................................... 54
ii
FINITE DIFFERENCE OPERATORS AND INTERPOLATION ............................................................ 54
4.1. Introduction .......................................................................................................................................... 54
4.2. Finite Differences............................................................................................................................... 55
4.2.1. Forward Differences (1 hour) ......................................................................................................... 55
4.2.2. Backward Differences (1 hour) ......................................................................................................... 57
4.2.3. Central differences (1 hour) .............................................................................................................. 58
4.2.4. Shift Operater(E) (1 hour) ................................................................................................................. 61
4.3. Interpolation with equally spaced data (4 hours) ................................................................................. 63
4.3.1. Newton’s forward difference interpolationFormula (NFDIF) (2 hours) ........................................... 63
4.3.2. Newton’s backward difference interpolation (2 hours) .............................................................. 66
4.4. Interpolation with unequal intervals (4 hours) ..................................................................................... 68
4.4.1. Newton’s divided difference (2 hours) ............................................................................................. 69
4.4.2. Newton’s divided difference Interpolation formula (NDDIF) (2 hours) .................................... 70
4.4.2. Lagrange’s interpolation formula (LIF) (2 hours) ...................................................................... 74
CHAPTER 5 ............................................................................................................................................... 78
NUMERICAL DIFFERNTIATION AND INTEGRATION ..................................................................... 78
5.1. Introduction .......................................................................................................................................... 78
5.2. Numerical differentiation (4 hours) ..................................................................................................... 79
5.3. Numerical Integration (4 hours) ...................................................................................................... 82
5.3.1. Trapezoidal Rule (2 hours) ............................................................................................................... 84
5.3.2. Simpson’s one- third rule (1 hours) .................................................................................................. 85
5.3.3. Simpson’s three-eight rule (1 hours) ........................................................................................... 86
CHAPTER SIX ........................................................................................................................................... 89
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS ....................................... 89
6.1. Introduction .......................................................................................................................................... 89
6.2. Euler’s Method(2hours) ....................................................................................................................... 90
6.3. Modified Euler’s Method (2 hours) ..................................................................................................... 94
6.4. Taylor series Method of order N (2 hours) .......................................................................................... 95
6.5. Runge-Kutta Method (2hours) ............................................................................................................. 98
Reference .................................................................................................................................................. 104
iii
NUMERICAL METHODS
CHAPTER ONE
1.1. Introduction
Numerical methods are methods for solving problems on computers by numerical calculations,
often giving a table of numbers and/or graphical representations or figures. Numerical methods
tend to emphasize the implementation of algorithms. So, we can define Numerical analysis as an
area of mathematics and computer science that deals with crating data, organizing, analizing and
implementing an algorithm to solve mathematical problems. Inshort Numerical analysis is the
study of algorithms that use numerical approximation (as opposed to general symbolic
manipulations) for the problems of mathematical analysis (as distinguished from discrete
mathematics).
The aim of numerical method is therefore to provide systematic methods for solving problems in
a numerical form. The process of solving problems generally involves starting from an initial
data, using high precision digital computers, following the steps in the algorithms and finally
obtaining the results. Most practical problems that have no analytic solutions can usually solved
by numerical methods.
Analytical solution versus numerical solution of a problem: the former is a closed form formula
for a solution and the later is numerical value (usually approximately) for a desired solution.
All numerical methods involve approximations due to either limits in the algorithm or physical
limits in the computer hardware. Errors associated with measurements or calculations can
characterize with reference to accuracy and precision.
Accuracy refers to how closely a computed or measured value agrees with the true value.
Prepared by Abe N 1
NUMERICAL METHODS
Precision refers how close; a measured or computed value agrees with each other after repeated
sampling.
Objective
Define an error.
Identify some common sources of errors.
Determine the magnatiude of the error that occur during numerical computation.
Determine the effect of errors in the independent variables on the dependent variable.
Allowted time to complete this chapter is 5 hours
Activity 1
Given 𝜑(𝑥, 𝑦, 𝑧) = 3𝑥 2 𝑦 + 4𝑧 3 and 𝑥 = 2, 𝑦 = 3 and 𝑧 = 1 with errors
0.02,0.03 and 0.01 respectively, then determine the error in 𝜑.
Often the numerical data and methods used are approximate ones. Hence, the error in a
computed result may caused by the errors in the data, or the errors in the method or both.
Definition1.1: There are a number of ways to describe error in measurements and calculations.
The simplest is the absolute error; this is the difference between the measured or calculated value
and the true value.
Error= true value –approximate value
Prepared by Abe N 2
NUMERICAL METHODS
Absolute, Relative and Percentage errors are methods that help to determine the amount or
magnitude of the error that committed during numerical computation.
|𝑝−𝑝∗|
c. the percentage error(𝐸𝑝 ) is |𝑝|
× 100%provided 𝑝 ≠ 0.
Example1.1: Determine the absolute and relative errors when approximating 𝑝 by 𝑝 ∗ when.
Prepared by Abe N 3
NUMERICAL METHODS
𝐸𝑎 0.1 1
𝐸𝑟 = = = = 0.0333
|𝑝| 3 30
1 10
𝐸𝑝 = 𝐸𝑟 × 100% = × 100% = % = 3.333%
30 3
5 1
Example1.2: Suppose that 𝑥 = 7 and 𝑦 = 3. Use five-digit chopping for calculating
5 1 22
The true value 𝑥 + 𝑦 = 7 + 3 = 21,so
22
Absolute = |21 − 1.0476| = 0.19 × 10−4
0.19×10−4
Relative error= 22 = 0.0018
21
Objective
Suppose that we have a function f (x) that is dependent on a single independent variable x.
Assumethat ∆𝑥 be the absolute error in x. We, therefore, would like to assess the effect of the
error in 𝑥 on the value of the function. That is, we would like to estimate the error in 𝑦 = 𝑓(𝑥).
Prepared by Abe N 4
NUMERICAL METHODS
y y f ( x x )
y f ( x x) f ( x) (1.1)
f ''( x) 2 f '''( x ) 3
f ( x x) f ( x) f '( x)x x x . . .
2! 3!
⟹ ∆𝑦 = 𝑓 ′ (𝑥)∆𝑥
∆𝑦 = |𝑓 ′ (𝑥)|∆𝑥
The foregoing approach can be generalized to functions that are dependent on more than one
independent variable. This is accomplished with a multivariable version of the Taylor series.
That is if 𝜑 = 𝑓(𝑥1 , 𝑥2 , … , 𝑥𝑛 )is a function of several variables and the error in each 𝑥𝑖 be xi ,
then
𝜕𝜑 𝜕𝜑 𝜕𝜑 𝜕𝜑
∆𝜑 = | | ∆𝑥1 + | | ∆𝑥2 + | | ∆𝑥3 + ⋯ + | | ∆𝑥𝑛
𝜕𝑥 𝜕𝑥 𝜕𝑥 𝜕𝑥
Example 1.3: If 𝑓(𝑥) = 7𝑥 3 + 13𝑥 2 + 10 and 𝑥 = 5 with an error 0.002, then determine the
absolute error ∆𝑦.
Solution:
Prepared by Abe N 5
NUMERICAL METHODS
∆𝑦 = |655|(0.002) = 1.31
𝜕𝜑 𝜕 𝜕𝜑
= (12𝑥 2 𝑦𝑧 3 ) = 24𝑥𝑦𝑧 3 ; | = 24𝑥𝑦𝑧 3 |(2,3,1) = 144
𝜕𝑥 𝜕𝑥 𝜕𝑥 (𝑥,𝑦,𝑧)
𝜕𝜑 𝜕 𝜕𝜑
= (12𝑥 2 𝑦𝑧 3 ) = 12𝑥 2 𝑧 3 ; | = 12𝑥 2 𝑧 3 |(2,3,1) = 48
𝜕𝑦 𝜕𝑦 𝜕𝑦 (𝑥,𝑦,𝑧)
𝜕𝜑 𝜕 𝜕𝜑
= (12𝑥 2 𝑦𝑧 3 ) = 48𝑥 2 𝑦𝑧 2 ; | = 48𝑥 2 𝑦𝑧 2 |(2,3,1) = 432
𝜕𝑧 𝜕𝑧 𝜕𝑧 (𝑥,𝑦,𝑧)
𝜕𝜑 𝜕𝜑 𝜕𝜑
∆𝜑 = | | ∆𝑥 + | | ∆𝑦 + | | ∆𝑧 = 144(0.002) + 48(0.003) + 432(0.001)
𝜕𝑥 𝜕𝑥 𝜕𝑥
Therefore, the absolute error in𝜑 is 1. 008.The physical interpretation of the result is, if the
defect in each of the inputs is given as indicated above the defect in the out put is 1.008.
Summary
An error can be difined as the difference between the exact value and the approximate
value.
Absolute, percentage and relaive errors are used to determine the number of errors
occurred during computation.
Propagation error is the effect of the error in the input on the out put.
Prepared by Abe N 6
NUMERICAL METHODS
Review exercise 1
20
1. The three approximations of are given as 3.3, 3 and 3.4.
6
a. Find the absolute, relative and percentage errors for each approximation
b. Which of these is the best approximation?
2. If 𝑓(𝑥) = 𝑥 4 + 3𝑥 2 + 2 and 𝑥 = 1 with error 0.002, then determine ∆𝑦.
𝑦 4 𝑥+𝑥 2 𝑦
3. Given 𝑢(𝑥, 𝑦) = and 𝑥 = 2, 𝑦 = 1 with errors 0.02 and 0.03 respectively. Based on
4𝑥
Prepared by Abe N 1
NUMERICAL METHODS
CHAPTER TWO
2.1. Introduction
The methods used for solving equations numerically divided in to twogroups: Bracketing
methods and open methods. In bracketing methods, an interval that contains the solution is
identified. By definition, the end points of the interval are the upper bound and the lower bound
of the solution. Then by using a numerical scheme, the size of the interval is successively
reduced until the distance between the end points is lessthan the desired accuracy of the solution.
In an open method, an initial estimate (one point) for the solution is assumed. The value of this
initial guess for the solution should be closer to the actual solution. Then, by using a numerical
scheme, better (more accurate) values for the solution are calculated. Bracketing methods are
always converge to the true solution, where as open methods are usually more efficient but
sometimes might not yield the solution.
In this chapter four numerical method for finding a root of equation𝑓(𝑥) = 0 are presented. Two
bracketing methods; the bisection and false postion (regulafalsi) method and three open methods,
Newton-Raphson method, secantmethod and fixed-point iteration methodare illustrated in the
next section.
Objective
Prepared by Abe N 1
NUMERICAL METHODS
Activity 2.1
The bisection method is a bracketing method for finding a numerical solution of an equation of
the form 𝑓(𝑥) = 0 when it is kown that with in a given interval [𝑎, 𝑏], 𝑓 is continuous and the
equation has a solution in this interval. Let 𝑓(𝑥) be a given function, continuous on an interval
[𝑎, 𝑏], such that 𝑓(𝑎)𝑓(𝑏) < 0 .Using intermidate value theorem, it follows that there exists at
least one zero (root) of 𝑓 in (a,b).To simplify our discussion ,we assume that 𝑓 has exactly one
root 𝛼.Such a function is shown in figure 2.1
Prepared by Abe N 2
NUMERICAL METHODS
y
f(x)
(a,f(a))
x0 =( a+b)/2
a x =(a+x )/2 b x
1 0
(b,f(b))
Figure 2.1: The bisection method and the first two approximations to its root 𝛼.
The bisection method is based on repeated halvingof the interval [a, b]to determine a smaller
and smaller interval with in which the root𝛼 must lie. The procuder is carried out by first finding
the midpoint of [𝑎, 𝑏]and at each step, locating the half containing the root. The first step of this
𝑎+𝑏
method is finding the midpoint𝑥0 = of the interval [𝑎, 𝑏]and evaluating 𝑓 at 𝑥0 , if𝑓(𝑥0 ) =
2
0,then 𝑥0 is the required root and we stop,if not compute the product 𝑓(𝑥0 )𝑓(𝑏).If the product
is negative ,then the new interval containing the root 𝛼 is [𝑥0 , 𝑏]otherwise the root is in the
interval [𝑎, 𝑥0 ].The new interval containing the root is bisected again. The process of halving the
new interval containing the root continues until the numerical solution is accurate enough
according to the given condition or tolerance satisfied.
𝑎+𝑏
Step2: Evaluate the mid point𝑥𝑖 = and 𝑓(𝑥𝑖 ).
2
Step 3: If 𝑓(𝑥𝑖 ) = 0, the root is 𝑥𝑖 stop, else If 𝑓(𝑎). 𝑓(𝑥𝑖 ) < 0,then set 𝑏 = 𝑥𝑖 else set
Prepared by Abe N 3
NUMERICAL METHODS
Step 4: Stop the evaluation when the difference between two successive approximation is less
than the given tolerance i.e.|𝑥𝑖+1 − 𝑥𝑖 | <tolerance.
Examples 2.1: Find the root of the equation𝑓(𝑥) = 𝑥 3 − 𝑥 − 1 = 0 lying between 1 and 2
using bisection method.
𝑎+𝑏 1+2
First approximation:𝑥0 = = = 1.5
2 2
⟹ 𝑓(1.5) = (1.5)3 − 1.5 − 1 = 3.375 − 1.5 − 1 = 0.875, which is positive, so the root now
lies between [1,1.5].
1+1.5 2.5
Second iteration:𝑥1 = = = 1.25.
2 2
1.25+1.5
Third iteration:𝑥2 = = 1.375, 𝑓(1.375) = 0.2246 > 0
2
Enter the interval [a, b], maximum iteration and allowed error respectively:
1 2 12 0.0001
Since (𝑎)𝑓(𝑏) < 0 , a root lies between a and b the iterations are:
Table 2.1_________________________________________________________
i a b 𝑥𝑖 𝑓(𝑥𝑖 )|𝑥𝑖+1 − 𝑥𝑖 |
_________________________________________________________
0 1.000000 2.000000 1.500000 0.875000
1 1.000000 1.500000 1.250000 -0.296875 0.250000
Prepared by Abe N 4
NUMERICAL METHODS
Example 2.2: Perform 3 iterations of the bisection method to obtain a root the equation
𝑎+𝑏
First approximation:𝑥1 = = 0.5
2
0.5+1
Second approximation:𝑥2 = = 0.75
2
Prepared by Abe N 5
NUMERICAL METHODS
0.5+0.75
Third approximation:𝑥3 = = 0.625
2
Example2.3: Find the solution of the equation 𝑓(𝑥) = 𝑥 3 + 4𝑥 2 − 10 in [1, 2] using bisection
method with tolerance 0.0003.
Enter the interval [𝑎, 𝑏], maximum iteration and allowed error respectively:
1 2 10 0.003
Since 𝑓(𝑎)𝑓(𝑏) < 0 ,a root lies between a and b, the iterations are:
Table 2.2_________________________________________________________
i a b xi 𝑓(𝑥𝑖 )|𝑥𝑖+1 − 𝑥𝑖 |
__________________________________________________________
0 1.000000 2.000000 1.500000 2.375000
1 1.000000 1.500000 1.250000 -1.796875 0.250000
2 1.250000 1.500000 1.375000 0.162109 0.125000
3 1.250000 1.375000 1.312500 -0.848389 0.062500
4 1.312500 1.375000 1.343750 -0.350983 0.031250
5 1.343750 1.375000 1.359375 -0.096409 0.015625
6 1.359375 1.375000 1.367188 0.032356 0.007813
7 1.359375 1.367188 1.363281 -0.032150 0.003906
8 1.363281 1.367188 1.365234 0.000072 0.001953
__________________________________________________________
The root converges after iteration 8, the root is 𝑥 =1.365234
Example 2.4: Use the bisection method to approximate the solution of the equation
Prepared by Abe N 6
NUMERICAL METHODS
Enter the interval [a, b], maximum iteration and allowed error respectively:
0 1 15 0.0005
Since𝑓 (𝑎) 𝑓 (𝑏) < 0, a root lies between a and b, the iterations are:
Table 2.3__________________________________________________________
i a b 𝑥𝑖 𝑓(𝑥𝑖 ) |𝑥𝑖+1 − 𝑥𝑖 |
__________________________________________________________
0 0.000000 1.000000 0.500000 -12.375000
Example 2.5: Using bisection method to find the real root of the equation
Enter the interval [𝑎, 𝑏],maximum iteration and allowed error respectively:
Prepared by Abe N 7
NUMERICAL METHODS
0 1 16 0.0005
Since 𝑓(𝑎)𝑓(𝑏) < 0 , a root lies between 𝑎and 𝑏, the iterations are:
Table 2.4_________________________________________________________
𝑖a b xi 𝑓(𝑥𝑖 )|𝑥𝑖+1 − 𝑥𝑖 |
_________________________________________________________
0 0.000000 1.000000 0.500000 0.283684
1 0.000000 0.500000 0.250000 -0.366872 0.250000
Theorem2.1: Suppose that 𝑓𝜖𝑐[𝑎, 𝑏] and 𝑓(𝑎)𝑓(𝑏) < 0.The Bisection method generates a
𝑏−𝑎
sequence {𝑝𝑛 }∞
𝑛=1 approximating a zero of 𝑓 with |𝑝𝑛 − 𝑝| ≤ with 𝑛 ≥ 1.
2𝑛
𝑏−𝑎
Proof: For each 𝑛 ≥ 1,we have 𝑏𝑛 − 𝑎𝑛 = 2𝑛−1 and 𝑝 ∈ (𝑎𝑛 , 𝑏𝑛 ) (2.1)
𝑎𝑛 +𝑏𝑛
Since 𝑝𝑛 = 2
for all 𝑛 ≥ 1it follows that
Prepared by Abe N 8
NUMERICAL METHODS
1 𝑏−𝑎 𝑏−𝑎
|𝑝𝑛 − 𝑝| ≤ (𝑏𝑛 − 𝑎𝑛 ) = = (From (2.1))
2 2.2𝑛−1 2𝑛
𝑏−𝑎
⟹ |𝑝𝑛 − 𝑝| ≤ , Thus, the sequence {𝑝𝑛 }∞
𝑛=1 converges to 𝑝 with rate
2𝑛
1 1
of convergence 𝑂(2𝑛) that is 𝑝𝑛 = 𝑝 + 𝑂(2𝑛)
1
𝑝𝑛 → 𝑝as𝑛 → ∞ with 𝑂(2𝑛)
𝑏−𝑎
Solution:|𝑝𝑛 − 𝑝| ≤ 2𝑛
𝑏−𝑎 2−1
= 𝑁 < 10−3
2𝑁 2
3 3
⟹ −𝑁 < − ⟹𝑁> ≈ 9.96 ≈ 10
𝑙𝑜𝑔2 𝑙𝑜𝑔2
Objective
Prepared by Abe N 9
NUMERICAL METHODS
False position method (also known as regulafalsi method) is a bracketing method for finding a
numerical solution of an equation of the form 𝑓(𝑥) = 0 when it is known that with in a given
interval [a, b],𝑓(𝑥) is continuous and the equation has a solution. False position method has the
advantage of being slitly faster than the bisection method.As the bisection method the function
assumed to be continuous over the interval [a, b] and 𝑓(𝑎)𝑓(𝑏) < 0.In this method, the first
estimate of the solution 𝑥0 is selected as appoint of intersection of the 𝑥 axis and the straight line
joining the points (𝑎, 𝑓(𝑎)) and (𝑏, 𝑓(𝑏)) as shown in the figure 2.1.
y
(a,f(a))
x2 x1 x0
a α b x
(b,f(b))
The line passing through (a, f (a)) and (b, f (b)) has slope
𝑓(𝑏)−𝑓(𝑎) 0−𝑓(𝑎)
𝑚= = (2.2)
𝑏−𝑎 𝑥0 −𝑎
Both are the slope of the same line, because the slope of a line is independent of the choice of the
points on the line
Now, solve for 𝑥1 from equation (2.2), to get the first approximation
Prepared by Abe N 10
NUMERICAL METHODS
𝑎𝑓(𝑏)−𝑏𝑓(𝑎)
⟹ 𝑥0 = (2.3)
𝑓(𝑏)−𝑓(𝑎)
Alternatively, for a given interval [a, b], the equation of the straight line that connects point
(𝑎, 𝑓(𝑎)) to point (𝑏, 𝑓(𝑏)) is given by:
𝑓(𝑏)−𝑓(𝑎)
𝑦= (𝑥 − 𝑏) + 𝑓(𝑏) (2.4)
𝑏−𝑎
The point 𝑥1 where the line intersects the 𝑥 axis is determined by substituting 𝑦 = 0 in Eq. (2.4)
and solving the equation for 𝑥1 one can get
𝑎𝑓(𝑏) − 𝑏𝑓(𝑎)
𝑥0 =
𝑓(𝑏) − 𝑓(𝑎)
To find the next approximation, compute 𝑓(𝑥0 ) and check the sign changes, that is if
𝑓(𝑥0 )𝑓(𝑏) < 0 ,then the new interval containing the root is [𝑥1 , 𝑏] and set 𝑎 = 𝑥0 otherwise the
root lies in the interval [𝑎, 𝑥0 ] ,if so set 𝑏 = 𝑥0 .The end points of the second interval are
connected with a straight line ,and the point where this new line crosses the 𝑥 axis is the second
estimate of the solution 𝑥1 .For the third iteration a new sub interval selected and the iteration
continue in the same way until the numerical solution is deemed accurate enough.
𝑎𝑓(𝑏)−𝑏𝑓(𝑎)
Step2: Find the first approximation using the formula 𝑥𝑖 = and evaluate 𝑓(𝑥𝑖 ).
𝑓(𝑏)−𝑓(𝑎)
Step 3: If (𝑥𝑖 ) = 0 , the root is 𝑥𝑖 stop else If 𝑓(𝑎). 𝑓(𝑥𝑖 ) < 0,then set 𝑏 = 𝑥𝑖 else set 𝑎 = 𝑥𝑖 and
go back to step 2.
Step 4: Stop the evaluation when the given condition satisfied or the difference between two
successive approximation is less than the given tolerance i.e.|𝑥𝑖+1 − 𝑥𝑖 | <tolerance.
Examples 2.7: Find the root of the equation𝑥 3 − 𝑥 − 1 = 0 lying between 1 and 2 using false
position method.
Prepared by Abe N 11
NUMERICAL METHODS
Since 𝑓(1) = 13 − 1 − 1 = −1 < 0 and 𝑓(2) = 23 − 2 − 1 = 5 > 0 so at least one root lies in
the interval [1, 2].
𝑎𝑓(𝑏)−𝑏𝑓(𝑎) 5−2(−1) 7
First approximation: 𝑥1 = = = 6 = 1.16667
𝑓(𝑏)−𝑓(𝑎) 5—1
Set 𝑥1 = 𝑎and𝑏 = 2
𝑎𝑓(𝑏)−𝑏𝑓(𝑎)
Second iteration: 𝑥2 = continue the process until you get the desired accuracy.
𝑓(𝑏)−𝑓(𝑎)
1 2 18 0.0001
Since 𝑓(𝑎)𝑓(𝑏) < 0 ,aroot lies between a and b, the iterations are:
Table 2.5_________________________________________________
𝑖a b 𝑥𝑖 𝑓(𝑥𝑖 )
_________________________________________________
1 1.000000 2.000000 1.166667 -0.578704
Prepared by Abe N 12
NUMERICAL METHODS
Example2.8: Find the solution of the equation 𝑓(𝑥) = 𝑥 3 + 4𝑥 2 − 10 in [1, 2] using false
position method with tolerance 0.0001.
1 2 10 0.0003
Since 𝑓(𝑎)𝑓(𝑏) < 0 ,aroot lies between a and b, the iterations are:
Table 2.6_____________________________________________
𝑖a b 𝑥𝑖 𝑓(𝑥𝑖 )
______________________________________________
1 1.000000 2.000000 1.263158 -1.602275
Example 2.9: Use the False position method to approximate the solution of the equation 𝑓(𝑥) =
𝑥 3 − 27𝑥 + 1 = 0 in [0,1] with |𝑥𝑖+1− 𝑥𝑖 | < 0.0005
Prepared by Abe N 13
NUMERICAL METHODS
0 1 8 0.0005
Since 𝑓(𝑎)𝑓(𝑏) < 0 , a root lies between a and b, the iterations are:
Objective
In fixed-point iteration method, first rewrite the equation f ( x) 0 in the form x g ( x ) and
approximate the root using the formula in equation (2.5). The fixed -point iteration method starts
by taking an initial guess 𝑥0 to the root and continue our iteration until we get the desire solution.
Prepared by Abe N 14
NUMERICAL METHODS
If 𝑔(𝑥) and 𝑔′ (𝑥) are continuous on an interval containing the root of the equation x g ( x ) ,
and if |𝑔′ (𝑥)| < 1 for all 𝑥 in the interval , then the sequence 𝑥𝑛+1 = 𝑔(𝑥𝑛 ) with initial guess
interval will converge to the root.
Example2.10:Find a root of 𝑓(𝑥) = −3𝑥 + 𝑒 𝑥 = 0 using fixed point iteration method in the
𝑒𝑥
interval [0,1]with 𝑔(𝑥) = ,continue until|𝑥(𝑖+1) − 𝑥𝑖 | < 0.0005.
3
Table 2.8___________________________
i𝑥𝑖 𝑓(𝑥𝑖 )
______________________________________
0 0.500000 0.148721
1 0.549574 0.083793
2 0.577505 0.049073
3 0.593862 0.029382
4 0.603657 0.017824
5 0.609598 0.010898
6 0.613231 0.006695
7 0.615462 0.004125
8 0.616837 0.002546
9 0.617686 0.001573
10 0.618210 0.000973
11 0.618535 0.000602
_______________________________________
Prepared by Abe N 15
NUMERICAL METHODS
Objective
Let 𝑥0 be an initial approximate root of 𝑓(𝑥) = 0 and 𝑥1 = 𝑥0 + ℎ such that 𝑓(𝑥1 ) = 0 and 𝑓 is
differentiable. Then, using Taylor series expansion 𝑓(𝑥) can be expanded as:
(𝑥 − 𝑥0 )2 (𝑛)
(𝑥 − 𝑥0 )𝑛
𝑓(𝑥) = 𝑓(𝑥0 ) + 𝑓 ′ (𝑥0 )(𝑥 − 𝑥0 ) + 𝑓 ′′ (𝑥0 ) + ⋯ + 𝑓 (𝑥0 )
2! 𝑛!
ℎ2 ℎ𝑛
0= 𝑓(𝑥0 ) + 𝑓 ′ (𝑥0 )ℎ + 𝑓 ′′ (𝑥0 ) 2! + ⋯ + 𝑓 (𝑛) (𝑥0 ) 𝑛!
Now, neglect the second and higher order derivatives and we get
𝑓(𝑥0 )
𝑓(𝑥0 ) + ℎ𝑓 ′ (𝑥0 ) = 0 ⟹ ℎ = −
𝑓 ′ (𝑥0 )
𝑓(𝑥0 ) 𝑓(𝑥0 )
⟹ 𝑥1 − 𝑥0 = − ′
⟹ 𝑥1 = 𝑥0 − ′
𝑓 (𝑥0 ) 𝑓 (𝑥0 )
𝑓(𝑥1 ) 𝑓(𝑥2 )
𝑥2 = 𝑥1 − , 𝑥3 = 𝑥2 −
𝑓 ′ (𝑥1 ) 𝑓 ′ (𝑥2 )
𝑓(𝑥 )
𝑥𝑛+1 = 𝑥𝑛 − 𝑓′ (𝑥𝑛 ) , Provided that 𝑓 ′ (𝑥𝑛 ) ≠ 0 (2.6)
𝑛
The process terminates when two successive values of 𝑥𝑖 are nearly equal with the prescribed
error.
Step 2: For 𝑖 = 0,1,2, …, until the error is smaller than a specified value calculates 𝑥𝑖+1 by using
Eq. (2.6)
Example 2.11: Solve the equation 𝑥 3 − 5𝑥 + 3 = 0 using Newton Raphson method with initial
point 𝑥0 = 0and𝜀 = 0.001.
𝑓(𝑥0 ) 𝑓(0)
𝑥1 = 𝑥0 − ′
=0− ′ = 0.6
𝑓 (𝑥0 ) 𝑓 (0)
𝑓(𝑥1 ) 𝑓(0.6)
𝑥2 = 𝑥1 − = 0.6 − = 0.65510204
𝑓 ′ (𝑥1 ) 𝑓 ′ (0.6)
𝑓(𝑥2 ) 𝑓(0.65510204)
𝑥3 = 𝑥2 − ′
= 0.65510204 − ′ = 0.656619
𝑓 (𝑥2 ) 𝑓 (0.65510204)
𝑓(𝑥3 ) 𝑓(0.656619)
𝑥4 = 𝑥3 − = 0.656619 − = 0.65662
𝑓 ′ (𝑥3 ) 𝑓 ′ (0.656619)
Since,|𝑥4 − 𝑥3 | = 0.000001 < 0.001 = 𝜀, the process terminates and the approximate root is
𝑥4 = 0.65662.
Prepared by Abe N 17
NUMERICAL METHODS
1.5 0.0000005 8
Table 2.9__________________________________________________
𝑖𝑓(𝑥𝑖−1 )𝑓′(𝑥𝑖−1 )𝑥𝑖 𝑓(𝑥𝑖 )
__________________________________________________
1 2.3750000 18.7500000 1.3733333 0.1343455
2 0.1343455 16.6448002 1.3652620 0.0005287
3 0.0005287 16.5139179 1.3652300 -0.0000002
4 -0.0000002 16.5133991 1.3652300 -0.0000002
__________________________________________________
1.5 0.0000005 10
Table 2.11__________________________________________________
𝑖𝑓(𝑥𝑖−1 ) 𝑓′(𝑥𝑖−1 ) 𝑥𝑖 𝑓(𝑥𝑖 )
__________________________________________________
1 0.8750000 5.7500000 1.3478261 0.1006823
2 0.1006823 4.4499059 1.3252004 0.0020585
3 0.0020585 4.2684684 1.3247181 0.0000007
4 0.0000007 4.2646341 1.3247180 0.0000002
__________________________________________________
Example2.14: Find a root of the equation 𝑓(𝑥) = 𝑒 𝑥 + 2−𝑥 + 2𝑐𝑜𝑠𝑥 − 6 using Newton-
Prepared by Abe N 18
NUMERICAL METHODS
0 0.000001 12
Table 2.12__________________________________________________
𝑖𝑓(𝑥𝑖−1 ) 𝑓′(𝑥𝑖−1 )𝑥𝑖 𝑓(𝑥𝑖 )
_________________________________________________
1 -2.0000000 1.6931472 1.1812322 -1.5410681
2 -1.5410681 1.7138977 2.0803921 1.2684095
3 1.2684095 6.4256196 1.8829933 0.2299713
4 0.2299713 4.8577557 1.8356522 0.0258462
5 0.0258462 4.5331569 1.8299507 0.0023270
6 0.0023270 4.4953299 1.8294331 0.0002030
7 0.0002030 4.4919090 1.8293879 0.00001762
8 0.0000176 4.4916105 1.8293840 0.0000015
9 0.0000015 4.4915843 1.8293836 0.0000000
__________________________________________________
Example 2.15: Use the Newton- Raphson method to approximate the solution of the equation
𝑓(𝑥) = 𝑥 3 − 27𝑥 + 1 = 0 in [0,1] with |𝑥𝑖+1− 𝑥𝑖 | < 0.0000005
0.5 0.0000005 6
Table2.13_____________________________________________________
𝑖𝑓(𝑥𝑖−1 ) 𝑓′(𝑥𝑖−1 )𝑥𝑖 𝑓(𝑥𝑖 )
_____________________________________________________
1 -12.3750000 -26.2500000 0.0285714 0.2285948
2 0.2285948 -26.9975510 0.0370387 0.0000067
3 0.0000067 -26.9958839 0.0370389 0.0000000
_____________________________________________________
Prepared by Abe N 19
NUMERICAL METHODS
Objective
Newton Raphson method is very powerful, but the evaluation of the derivatives involved
sometimes may be difficult. This suggests the idea of replacing the derivative 𝑓 ′ (𝑥𝑛 ) in
𝑓(𝑥 )
𝑥𝑖+1 = 𝑥𝑖 − 𝑓′ (𝑥𝑖 ) (2.7)
𝑖
Prepared by Abe N 20
NUMERICAL METHODS
Since 𝑒3 = 0.03134089 < 0.05 = 𝜀, the process terminates and the approximate root of the
equation is 𝑥4 = 5.00057164.
Example2.17: Find a root of the equation 𝑓(𝑥) = 𝑥 3 − 𝑥 − 4 = 0 in the interval [1,2] using
a. Bisection Method.
Enter the interval [a, b], maximum iteration and allowed error respectively.
1 2 15 0.0005
Since 𝑓(𝑎)𝑓(𝑏) < 0 ,a root lies between a and b the iterations are:
Table 2.14_____________________________________________________
𝑖a b 𝑥𝑖 𝑓(𝑥𝑖 ) |𝑥𝑖+1 − 𝑥𝑖 |
_____________________________________________________
0 1.00000 2.00000 1.50000 -2.12500
1 1.50000 2.00000 1.75000 -0.39063 0.25000
2 1.75000 2.00000 1.87500 0.71680 0.12500
3 1.75000 1.87500 1.81250 0.14185 0.06250
4 1.75000 1.81250 1.78125 -0.12961 0.03125
5 1.78125 1.81250 1.79688 0.00480 0.01563
Prepared by Abe N 21
NUMERICAL METHODS
1 2 12 0.0005
Since 𝑓(𝑎)𝑓(𝑏) < 0 ,aroot lies between a and b, the iterations are:
Table 2.16______________________________________________
𝑖a b 𝑥𝑖 𝑓(𝑥𝑖 )
_______________________________________________
1 1.000000 2.000000 1.666667 -1.037037
2 1.666667 2.000000 1.780488 -0.136098
1.5 0.0005 8
Table 2.17_________________________________________________
𝑖𝑓(𝑥𝑖−1 ) 𝑓′(𝑥𝑖−1 ) 𝑥𝑖 𝑓(𝑥𝑖 )
_________________________________________________
1 -2.1250000 5.7500000 1.8695652 0.6650780
2 0.6650780 9.4858227 1.7994524 0.0272268
Prepared by Abe N 22
NUMERICAL METHODS
Summary
Bisection, false position methods are bracketing methods, that is it starts by choosing an
interval [𝑎, 𝑏] contaning a root.
Newton-Raphson and fixed-point iteration methods are commonly known as open
methods. These method starts the iteration by taking an initial guess to the root.
Review exercise 2
1. Using bisection method find a root of the equation 𝑓(𝑥) = 𝑥sin𝑥 − 1 = 0 that lies in
[1,1.5].Compute the first four iterations.
2. Find a root of the equation𝑓(𝑥) = 𝑥 3 − 9𝑥 + 1 = 0 in [2.5,3] by using bisection method
with tolerance 0.005.
3. Find a root of the equation𝑓(𝑥) = 𝑥 3 − 3𝑥 − 5 = 0 in [2,3] by using false position method
with tolerance 0.005.
4. Find the real root of the equation 𝑓(𝑥) = 3𝑥 − cos𝑥 − 1 = 0 using Newton-Raphson
method take 𝑥0 = 0.5,with tolerance 0.00005.
5. Determinethe number of iterationsrequired to solve 𝑓(𝑥) = 𝑥 3 + 𝑥 2 − 10 = 0 with
tolerance of error 10−5in the interval[1,2].
Prepared by Abe N 23
NUMERICAL METHODS
CHAPTER THREE
3.1. Introduction
System of linear equations that have to be solved simultaneously arise in problems that include
several variables that are dependent on each other. Such problems occure not only in engineering
and scince, but also in any discipline such as bussines, statistics, economics, etc. A system of two
or three equations with two or three unknowns can be solved simultinuoesly but solving a system
in this way is practicaliy impossible as the number of equations (unknowns) increase byoned
three.
Objective
Activity 3.1
Prepared by Abe N 24
NUMERICAL METHODS
b 2
.
a m1 a m 2 a m 3 ..a mn bn
xn
x1
The column matrix X x 2 is the matrix of unknown.
xn
Remark: If bi 0, i 1,2,...n then the linear system (3.1) is called Homogenous otherwise, non-
Homogenous
Prepared by Abe N 25
NUMERICAL METHODS
Objective
Objective
Prepared by Abe N 26
NUMERICAL METHODS
2 x3 3 x 2 x3 5
4 x1 14x2 12x3 10
6 x1 x2 5 x3 9
2 3 1 5
Solution: The augmented matrix of the system is 4 14 12 10
6 1 5 9
Applying, elementary row operations on this matrix to change into its echelon form.
2 3 1 5 R R 2 R 2 3 1 5 1 2 3 1 5
4 14 12 10 R R 3 R 0 20 10 0 R3 R3 2 R2 0 20 10 0
2 2 1
3 3_ 1
6 1 5 9 0 10 2 6 0 0 3 6
2 x1 3 x 2 x3 5
20x 2 10x3 0
3 x 3 6
𝑥 + 4𝑦 − 𝑧 = −5;
𝑥 + 𝑦 − 6𝑧 = −12;
3𝑥 − 𝑦 − 𝑧 = 4
We have
𝑥 + 4𝑦 − 𝑧 = −5 ( 𝑖)
𝑥 + 𝑦 − 6𝑧 = −12 ( 𝑖𝑖)
Prepared by Abe N 27
NUMERICAL METHODS
3𝑥 − 𝑦 − 𝑧 = 4 (𝑖𝑖𝑖)
−3𝑦 − 5𝑧 = −7 ( 𝑖𝑣)
−13𝑦 + 2𝑧 = 19 ( 𝑣)
13
Step ІІ: to eliminate𝑦, operate(𝑣) − (𝑖𝑣)
3
71 148
𝑧= (𝑣𝑖)
3 3
148
From(𝑣𝑖)𝑧 = = 2.0845
71
7 5 148 −81
From(𝑖𝑣)𝑦 = 3 − 3 ( 71 ) = = −1.1408
71
Example 3.3: Solve the following system of equations using Gauss-elimination method.
𝑥 + 2𝑦 + 3𝑧 − 𝑢 = 10
2𝑥 − 𝑦 + 2𝑧 + 3𝑦 = 7
3𝑥 + 2𝑦 − 4𝑧 + 3𝑢 = 2
1 2 3 −1 𝑥 10
2 3 −3 −1 𝑦 1
Solution: we have [ ][ ] = [ ]
2 −1 2 3 𝑧 7
3 2 −4 3 𝑢 2
1 2 3 −1 𝑥 −10
0 −1 −9 1 𝑦 −19
[ ][ ] = [ ]
0 −5 −4 5 𝑧 −13
0 −4 −13 6 𝑢 −28
Prepared by Abe N 28
NUMERICAL METHODS
1 2 3 −1 𝑥 10
0 −1 −9 1 𝑦 −19
[ ][ ] = [ ]
0 0 41 0 𝑧 82
0 0 23 2 𝑢 48
23𝑧 + 2𝑢 = 48 i.e, 46 + 2𝑢 = 48 ∴ 𝑢 = 1
𝑥 + 2𝑦 = 3𝑧 − 𝑢 = 10 i.e, 𝑥 + 4 + 6 − 1 = 10 ∴ 𝑥 = 1
Hence 𝑥 = 1, 𝑦 = 2, 𝑧 = 2, 𝑢 = 1
Objective
2 x1 3 x 2 4 x3 19
x1 2 x 2 x3 4
3 x1 x 2 x3 9
Prepared by Abe N 29
NUMERICAL METHODS
2 3 4 19
Solution: The augmented matrix of the system is 1 2 1 4 .
3 1 1 9
2 3 4 19 1 2 1 4 R2 R2 2 R1 1 2 1 4
1 2 1 4 R 1 R2
2 3 4 19 R3 R3 3 R1 0 1 2 11
3 1 1 9 3 1 1 9 0 7 4 3
1 2 1 4 1 2 1 4
0 1 2 11 R
R 2 R2
3
R3 7 R2
0 1 2 11 R3 181 R3
0 7 4 3 0 0 18 80
1 2 1 4 1 0 5 26 R1 R1 5 R3 1 0 0 34 / 9
0 1 2 11 0 1 2
R1 R1 2R2
11 R
R 2 2 R3
2 0 1 0 19 / 9
0 0 1 40 / 9 0 0 1 40 / 9 0 0 1 40 / 9
Objective
Definition 3.2.1: Let 𝐴 = (𝑎𝑖𝑗 )be a square matrix of order n. Then A is called a tri-diagonal
matrix if 𝑎𝑖𝑗 = 0 whenever|𝑖 − 𝑗| > 1.
1 2 0
Example3.4: A= 3 4 5 is a tri-diagonal matrix.
0 6 7
Prepared by Abe N 30
NUMERICAL METHODS
𝐴𝑌 = 𝐷
b1 c 0 0
1
a 2 b c 0
2 2
y d1
0 1
a b c
3 3 3
0
y2 d2
Where 𝐴 = 0 Y D
0 y d n 1
n 1
a n 1 bn 1 cn1 y n dn
0
0 a n bn
And 𝑎𝑖, 𝑏𝑖, 𝑐𝑖 are enters of their respective row and column.
𝑐 𝑐
Step1: take 𝛼1 = 𝑏1 and 𝛼𝑖 = 𝑏 −𝑎 𝑖𝛼 , 𝑖 = 2,3, … , 𝑛 − 1
1 𝑖 𝑖 𝑖−1
𝑑1 𝑑 −𝑎 𝛽
Step2: take 𝛽1 = , 𝛽𝑖 = 𝑏𝑖−𝑎𝑖𝛼𝑖−1 , 𝑖 = 2,3, … , 𝑛
𝑏1 𝑖 𝑖 𝑖−1
This algorithm is known as Thomas algorithm, which is the simplified form of Gauss elimination
Example 3.5: Solve the following tri-diagonal system using Thomas algorithm.
2𝑥1 − 𝑥2 = 1
−𝑥1 + 2𝑥2 − 𝑥3 = 0
−𝑥2 + 2𝑥3 − 𝑥4 = 0
−2𝑥3 + 2𝑥4 = 1
Solution:
Prepared by Abe N 31
NUMERICAL METHODS
2 1 0 0 1 x1
1 2 1 0 0
A ; D ;𝑋 = x 2
0 1 2 1 0 x
3
0 0 2 2
1 x 4
𝑐 1 𝑐2 2 𝑐3 3
Step1:𝛼1 = 𝑏1 = − 2; 𝛼2 = 𝑏 = − 3 and 𝛼3 = 𝑏 = −4
1 2 −𝑎2 𝛼1 3 −𝑎3 𝛼2
𝑑1 1 𝑑 −𝑎 𝛽 1 𝑑3−𝑎3 𝛽2 1 𝑑4−𝑎4 𝛽3
Step2:𝛽1 = = 2;𝛽2 = 𝑏2−𝑎2𝛼1 = 3 and 𝛽3 = 𝑏 = 4;𝛽4 = 𝑏 =3
𝑏1 2 2 1 3 −𝑎3 𝛼2 4 −𝑎4 𝛼3
1 3 10
Step3: take𝛽4 = 𝑥4 = 3 and 𝑥3 = 𝛽3 − 𝛼3 𝑥4 = 4 — 4 (3) = = 2.5
4
1 2 6
𝑥2 = 𝛽2 − 𝛼2 𝑥3 = — (2.5) = = 2;
3 3 3
1 1 3
𝑥1 = 𝛽1 − 𝛼1 𝑥2 = − (− ) (2) = = 1.5
2 2 2
1.5
2
Therefore, the solution is X
2 .5
3
Objective
Prepared by Abe N 32
NUMERICAL METHODS
The LU decomposition method is a method for solving a system of linear equations of the form
𝐴𝑋 = 𝑏.In this method the matrix of coefficient 𝐴 is decomposed (factored) in to a product of
two matrices L and U.
𝐴 = 𝐿𝑈 (3.2)
Where the matrix 𝑳 is lower triangular and 𝑼 is upper triangular matrix. With this
decomposition, the system of equations to be solved has the form:
𝐿𝑈𝑋 = 𝑏 (3.3)
𝑈𝑋 = 𝑌 (3.4)
𝐿𝑌 = 𝑏 (3.5)
Now, the solution 𝑥is obtained in two steps. First Eq. (3.5) is solved for 𝑌.Then the solution 𝑌 is
substituted in Eq. (3.4) and the resulting equation is solved for 𝑋.
Since 𝐿 is a lower triangular matrix, the solution 𝑌 in Eq. (3.5) is obtained by using forward
substitution method. Once𝑌 is known and substituted in Eq. (3.4), the resulting equation is
solved by using back substitution, since 𝑈 is upper triangular matrix.
In crout’s decomposition, the main diagonals of U the upper triangular matrix is 1’s
Prepared by Abe N 33
NUMERICAL METHODS
𝐴𝑋 = 𝐵
𝐴 = 𝐿𝑈 ⟹ 𝐿𝑈𝑋 = 𝐵
Let 𝑈𝑋 = 𝑌 ⇒ 𝐿𝑌 = 𝐵
𝑙11 0 0 𝑦1 𝑏1
𝐿𝑌 = (𝑙21 𝑙22 𝑦
0 ) ( 2 ) = (𝑏2 )
𝑙31 𝑙32 𝑙33 𝑦3 𝑏3
𝑈𝑋 = 𝑌
1 𝑢12 𝑢13 𝑥1 𝑦1
⟹ 𝑈𝑋 = (0 1 𝑥 𝑦
𝑢23 ) ( 2 ) = ( 2 )
0 0 1 𝑥3 𝑦3
First column
First row
Prepared by Abe N 34
NUMERICAL METHODS
𝑎12 𝑎13
𝑙11 𝑢12 = 𝑎12 ⇒ 𝑢12 = ; 𝑙11 𝑢13 = 𝑎13 ⇒ 𝑢13 =
𝑙11 𝑙11
Second column
𝑙21 𝑢12 + 𝑙22 = 𝑎22 ⇒ 𝑙22 = 𝑎22 − 𝑙21 𝑢12 ; 𝑙31 𝑢12 + 𝑙32 = 𝑎32 ⇒ 𝑙32 = 𝑎32 − 𝑙31 𝑢12
Second row
𝑙21 𝑢13
𝑙21 𝑢13 + 𝑙22 𝑢23 = 𝑎23 ⇒ 𝑢23 = 𝑎23 −
𝑙22
Third row
𝑙31 𝑢13 + 𝑙32 𝑢23 + 𝑙33 = 𝑎33 ⇒ 𝑙33 = 𝑎33 − 𝑙31 𝑢13 − 𝑙32 𝑢23
Steps in LU decomposition
Step 1: Express the given system in the form 𝐴𝑋 = 𝐵
Step 2: Put 𝐴 = 𝐿𝑈 where L is lower triangular matrix and U is upper triangular matrix whose
every diagonal element is 1.
Step 3: Find the product LU and by setting 𝐴 = 𝐿𝑈 fined the elements of each.
Note: the method works when 𝑙𝑖𝑖 ≠ 0, ∀𝑖.if this happen rearrange the coefficient matrix 𝐴 so that
𝑙𝑖𝑖 ≠ 0 during decomposition if possible.
Example3.6: Solve the following system of equation using Crout’s decomposition method.
2𝑥1 − 3𝑥2 + 𝑥3 = 5
6𝑥1 + 𝑥2 + 5𝑥3 = 9
Solution:
Prepared by Abe N 35
NUMERICAL METHODS
First column
First row
𝑎12 3
𝑙11 𝑢12 = 𝑎12 ⇒ 𝑢12 = =−
𝑙11 2
𝑎13 1
𝑙11 𝑢13 = 𝑎13 ⇒ 𝑢13 = =
𝑙11 2
Second column
3
𝑙21 𝑢12 + 𝑙22 = 𝑎22 ⇒ 𝑙22 = 𝑎22 − 𝑙21 𝑢12 = 7 − 2 (− ) = 10
2
3
𝑙31 𝑢12 + 𝑙32 = 𝑎32 ⇒ 𝑙32 = 𝑎32 − 𝑙31 𝑢12 = 1 − 6 (− ) = 10
2
Second row
𝑙21 𝑢13 6 − 1 1
𝑙21 𝑢13 + 𝑙22 𝑢23 = 𝑎23 ⇒ 𝑢23 = 𝑎23 − = =
𝑙22 10 2
Third row
1 1
𝑙31 𝑢13 + 𝑙32 𝑢23 + 𝑙33 = 𝑎33 ⇒ 𝑙33 = 𝑎33 − 𝑙31 𝑢13 − 𝑙32 𝑢23 = 5 − 6 ( ) − 10 ( ) = −3
2 2
2 0 0 1 −1.5 0.5
Hence,𝐴 = 𝐿𝑈 = (2 10 0 ) ( 0 1 0.5)
6 10 −3 0 0 1
2 0 0 𝑦1 5
𝐿𝑌 = 𝐵 ⇒ (2 10 0 ) ( 𝑦2 ) = ( 5)
6 10 −3 𝑦3 9
Prepared by Abe N 36
NUMERICAL METHODS
5
⇒ 𝑦1 =
2
2𝑦1 + 10𝑦2 = 5 ⇒ 𝑦2 = 0
5
2
6𝑦1 + 10𝑦2 − 3𝑦3 = 9 ⇒ 𝑦3 = 2.Therefore 𝑌 = (0)
2
3 1 5
𝑥1 − 𝑥2 + 𝑥3 =
2 2 2
1
𝑥2 + 𝑥3 = 0
2
𝑥3 = 2
1
𝑥2 + 2 𝑥3 = 0 ⇒ 𝑥2 = −1Back substitution
0
3 1 5
𝑥1 − 2 𝑥2 + 2 𝑥3 = 2 ⇒ 𝑥1 = 0. Therefore, the solution vector is 𝑋 = (−1)
2
The 𝐿𝑈 decomposition performed by setting the main diagonal elements of the lower triangular
matrix 𝐿 one is known as Doolittle’s method
Objective
Prepared by Abe N 37
NUMERICAL METHODS
A system of linear equations can also be solved by using iterative approach. The process, in
principle is the same as in the fixed-point iteration method for a single none linear equation (in
chapter2).in iterative method the equations are written in an explicit form in which each
unknown in terms of the other unknown. The explicit form for a system of four equations is
illustrated below.
The solution process starts by assuming an initial approximation for the unknowns (first
estimated solution). In the first iteration, the initial value is substituted on the right-hand side of
the equations, and the new values that are calculated for the unknowns are the second estimated
solution. In the second iteration, the second solution is substituted back in the equations to give
new values for the unknowns, which are the third estimated solution. The iteration continues in
the same manner, and when the method does work, the solution that are obtained as successive
iterations converge towards the actual solution. In general, for a system with n equations for the
𝑥𝑖 unknowns are:
Prepared by Abe N 38
NUMERICAL METHODS
1 𝑗=𝑛
𝑥𝑖 = 𝑎 [𝑏𝑖 − (∑𝑗=1 𝑎𝑖𝑗 𝑥𝑗 )] 𝑎𝑖𝑖 ≠ 0, 𝑖 = 1,2, … , 𝑛(3.6)
𝑖𝑖
𝑗≠𝑖
for a system of n equations [a][x] =[b], a sufficient condition for convergence is that in each row
of the matrix of coefficients [a] the absolute value of the diagonal element is greater than the sum
of the absolute values of the off- diagonal elements. i.e.
𝑗=𝑛
This condition is sufficient condition but not necessary for convergence when the iteration
method is used. When the above condition is satisfied, the matrix [a] is classified as diagonally
dominant, and the iteration process converges toward the solution. The solution may converge
even when the condition is not satisfied. In this section we will see Jacobi and Gauss-seidel
iterative methods for solving system of linear equations.
Objective
In the Jacobi method, an initial (first) values is assumed for each of the unknowns𝑿(𝟎) =
(0) (0) (0)
(𝑥1 , 𝑥2 , … , 𝑥𝑛 ).If no information is available regarding the approximate value of the
unknown, the initial value of the unknown can be assumed to be zero. The second estimate of
Prepared by Abe N 39
NUMERICAL METHODS
(1) 1 (0)
𝑥𝑖 = 𝑎 [𝑏𝑖 − ∑𝑛𝑗=1 𝑎𝑖𝑗 𝑥𝑗 ] , 𝑖 = 1,2, … , 𝑛 (3.7)
𝑖𝑖
In general, the (k+1) th estimate of the solution is calculated from (k)th estimate by:
The iteration continues until the difference between two successive iterations in each unknown is
small (less than the given tolerance or error).
5𝑥1 − 𝑥2 + 𝑥3 = 10
2𝑥1 + 4𝑥2 = 12
𝑥1 + 𝑥2 + 5𝑥3 = −1
(0) (0) (0)
Start with initial solution 𝑿(𝟎) = (𝑥1 , 𝑥2 , 𝑥3 ) = (2,3,0)
Solution:
Prepared by Abe N 40
NUMERICAL METHODS
(4) 1 ( ) ( ) 1
Fourth iteration:𝑥1 = 5 [10 + 𝑥23 − 𝑥33 ] = 5 [10 + 1.68 + 1.068] = 2.5496
and so on.
The solution for example 3.7 using the c++ programming are given in table 3.1:
Prepared by Abe N 41
NUMERICAL METHODS
Table 3.1_________________________________________
Iteration x1 x2 x3
_________________________________________
1 2.600000 2.000000 -1.200000
10𝑥1 − 2𝑥2 − 𝑥3 – 𝑥4 = 1 9
−2𝑥1 + 5𝑥2 – 𝑥3 – 𝑥4 = 13
−𝑥1 – 𝑥2 – 𝑥3 + 2 𝑥4 = 15
Prepared by Abe N 42
NUMERICAL METHODS
Objective
Prepared by Abe N 43
NUMERICAL METHODS
In the Gauss-seidel method, initial (first) values are assumed for all the unknowns. In the Gauss-
seidel method, the current values of the unknowns are used to calculating the new value of
nextunknown. In other words, as the new value of an unknown is calculated, it is immediately
used for calculating the next unknown in the same iteration. But in the case of Jacobi the values
of the unknown obtained in a single iteration are used as a complete set for calculating the new
values of the unknowns in the next iteration. The values of the unknowns are not updated in the
middle of a single iteration.
𝑗=𝑖−1 𝑗=𝑛
(𝑘+1) 1 (𝑘+1) (𝑘)
𝑥𝑖 = [𝑏𝑖 − ∑ 𝑎𝑖𝑗 𝑥𝑗 + ∑ 𝑎𝑖𝑗 𝑥𝑗 ] 𝑎𝑖𝑖 ≠ 0, 𝑖 = 2,3, … , 𝑛
𝑎𝑖𝑖
𝑗=1 𝑗=𝑖+1
(𝑘+1)
Notice that the values of the unknowns in the (k+1) iteration 𝑥𝑖 are calculated by using the
(𝑘+1) (k )
values 𝑥𝑗 obtained in the (k+1) iteration for 𝑗 < 𝑖 and using the values x j for𝑗 > 𝑖.The
stopping criterion is the same as that of Jacobi. The Gauss-seidel method is faster than the Jacobi
method and requires less computer memory when programmed.
5𝑥1 − 𝑥2 + 𝑥3 = 10
2𝑥1 + 4𝑥2 = 12
𝑥1 + 𝑥2 + 5𝑥3 = −1
Solution:
(1) 1
(0) (0) 1
First iteration:𝑥1 = [10 + 𝑥2 − 𝑥3 ] = [10 + 3 − 0] = 2.6
5 5
Prepared by Abe N 44
NUMERICAL METHODS
and so on.
Table 3.3________________________________________
Iteration 𝑥1 𝑥2 𝑥3
________________________________________
Prepared by Abe N 45
NUMERICAL METHODS
10𝑥1 − 2𝑥2 − 𝑥3 – 𝑥4 = 1 9
−2𝑥1 + 5𝑥2 – 𝑥3 – 𝑥4 = 13
−𝑥1 – 𝑥2 – 𝑥3 + 2 𝑥4 = 15
10 − 2 − 1 − 1 9
−2 5 − 1 − 1 13
−1 − 1 10 − 2 − 72
−1 − 1 − 1 2 15
Enter the allowed error and maximum iteration:
0.01 20
The solution vectors are:
Table 3.4_______________________________________________________
i𝑥1 𝑥2 𝑥3 𝑥4
___________________________________________________
1 0.900000 2.960000 -6.814000 6.023000
2 1.412900 3.006960 -5.553414 6.933223
Prepared by Abe N 46
NUMERICAL METHODS
Objective
At the end of this subtopic students should be able to solve system of nonlinearequations.
𝑓1 (𝑥, 𝑦) = 0
𝑓2 (𝑥, 𝑦) = 0 (3.8)
𝐹(𝑋) = 0 (3.9)
Similar to Newton’s method for single variable, the solution process starts by choosing an initial
gusses to the roots 𝑋0 = (𝑥0 , 𝑦0 )
Prepared by Abe N 47
NUMERICAL METHODS
If 𝑥1 and 𝑥2 are the true solutions of the system, then the values of 𝑓1 and 𝑓2 at 𝑥1 and 𝑦1 can be
expressed using Taylor series expansion of functions of two variables about the point
𝜕𝑓1 𝜕𝑓1
𝑓1 (𝑥1 , 𝑦1 ) = 𝑓1 (𝑥0 , 𝑦0 ) + (𝑥1 − 𝑥0 ) (𝑋0 ) + (𝑦1 − 𝑦0 ) (𝑋 )
𝜕𝑥 𝜕𝑦 0
𝜕𝑓2 𝜕𝑓2
𝑓2 (𝑥1 , 𝑦1 ) = 𝑓2 (𝑋0 ) + (𝑥1 − 𝑥0 ) (𝑋0 ) + (𝑦1 − 𝑦0 ) (𝑋 )
𝜕𝑥 𝜕𝑦 0
𝜕𝑓1 𝜕𝑓1
⟹ 0 = 𝑓1 (𝑥0 , 𝑦0 ) + ∆𝑥 (𝑋0 ) + ∆𝑦 (𝑋 )
𝜕𝑥 𝜕𝑦 0
𝜕𝑓2 𝜕𝑓2
0 = 𝑓2 (𝑋0 ) + ∆𝑥 (𝑋0 ) + ∆𝑦 (𝑋0 ) (3.10)
𝜕𝑥 𝜕𝑦
Where,∆𝑥 = 𝑥 − 𝑥0 and ∆𝑦 = 𝑦 − 𝑦0
𝜕𝑓1 𝜕𝑓1
(𝑋0 ) (𝑋 )
𝜕𝑥 𝜕𝑦 0 ∆𝑥 −𝑓 (𝑋 )
[ ]=[ 1 0 ]
𝜕𝑓2 𝜕𝑓2 ∆𝑦 −𝑓2 (𝑋0 )
(𝑋0 ) (𝑋0 )
[ 𝜕𝑥 𝜕𝑦 ]
∆𝑥1 = 𝑥1 − 𝑥0 ⟹ 𝑥1 = ∆𝑥1 + 𝑥0
∆𝑦1 = 𝑦1 − 𝑦0 ⟹ 𝑦1 = ∆𝑦1 + 𝑦0
Similarliy we can follow the same procedur for more than two systems of nonlinear equations.
Prepared by Abe N 48
NUMERICAL METHODS
Example3.11: Solve the following system of nonlinear equations using Newton’s method of
solvin system of nonlinear equations with (𝑥0 , 𝑦0 ) = (2.828,2.828).
𝑥2 − 𝑦2 − 4 = 0
𝑥 2 + 𝑦 2 − 16 = 0
𝜕𝑓1 𝜕𝑓1
= 2𝑥; = −2𝑦
𝜕𝑥 𝜕𝑦
𝜕𝑓2 𝜕𝑓2
= 2𝑥; = 2𝑦
𝜕𝑥 𝜕𝑦
𝜕𝑓1 𝜕𝑓1
(𝑋0 ) = (2.828,2.828) = 5.656
𝜕𝑥 𝜕𝑥
𝜕𝑓2 𝜕𝑓2
(𝑋0 ) = (2.828,2.828) = 5.656
𝜕𝑥 𝜕𝑥
𝜕𝑓1 𝜕𝑓1
(𝑋0 ) = (2.828,2.828) = −5.656
𝜕𝑦 𝜕𝑦
𝜕𝑓2 𝜕𝑓2
(𝑋0 ) = (2.828,2.828) = 5.656
𝜕𝑦 𝜕𝑦
First iteration:
Prepared by Abe N 49
NUMERICAL METHODS
Second iteration:
𝜕𝑓1 𝜕𝑓1
(𝑋1 ) = (3.182,2.475) = 6.364
𝜕𝑥 𝜕𝑥
𝜕𝑓2 𝜕𝑓2
(𝑋1 ) = (3.182,2.475) = −4.95
𝜕𝑥 𝜕𝑥
𝜕𝑓1 𝜕𝑓1
(𝑋1 ) = (3.182,2.475) = 6.364
𝜕𝑦 𝜕𝑦
𝜕𝑓2 𝜕𝑓2
(𝑋1 ) = (3.182,2.475) = 4.95
𝜕𝑦 𝜕𝑦
Third iteration:
𝜕𝑓1 𝜕𝑓1
(𝑋2 ) = (3.162,2.449) = 6.324
𝜕𝑥 𝜕𝑥
𝜕𝑓2 𝜕𝑓2
(𝑋2 ) = (3.162,2.449) = 6.324
𝜕𝑥 𝜕𝑥
Prepared by Abe N 50
NUMERICAL METHODS
𝜕𝑓1 𝜕𝑓1
(𝑋2 ) = (3.162,2.449) = −4.898
𝜕𝑦 𝜕𝑦
𝜕𝑓2 𝜕𝑓2
(𝑋2 ) = (3.162,2.449) = 4.898
𝜕𝑦 𝜕𝑦
This method can also used for nonlinear equations of more than two variables in the same way.
Summary
In this chapter we have learnet direct and iterative methods to solve system of linear
equations.
Direct methods are Gauss-elimaniation, Gauss-Jordan elimination, LU decomposition.
Thomas Algorithm helps us to solve tridiagonal system of linear equations.
The coefficent matrix bening diagonally dominant is sufficient condition for the
convergency of Jacobi’s and Gauss-Seidel iterative methods.
Prepared by Abe N 51
NUMERICAL METHODS
Reviwe Exercise 3
2𝑥1 + 𝑥2 + 𝑥3 = 10
𝑥1 + 4𝑥2 + 9𝑥3 = 16
a. 2𝑥1 − 𝑥2 = 3
−𝑥1 + 2𝑥2 − 𝑥3 = −3
−𝑥2 + 2𝑥3 = 1
b. 3𝑥1 + 𝑥2 = 4
2𝑥1 + 5𝑥2 − 𝑥3 = 0
4𝑥2 + 𝑥3 − 𝑥4 = 1
6𝑥3 − 2𝑥4 = −5
3. Find the first two iterations for following system of equations using
a 7𝑥1 − 2𝑥2 + 𝑥3 = 17
𝑥1 − 9𝑥2 + 3𝑥3 − 𝑥4 = 13
2𝑥1 + 10𝑥3 + 𝑥4 = 15
𝑥1 − 𝑥2 + 𝑥3 + 6𝑥4 = 10
b. 3𝑥1 − 𝑥2 + 𝑥3 = 1
Prepared by Abe N 52
NUMERICAL METHODS
c. 3𝑥1 + 𝑥2 + 𝑥3 = 4
−2𝑥1 + 4𝑥2 = 1
Prepared by Abe N 53
NUMERICAL METHODS
CHAPTER 4
4.1. Introduction
Suppose we are given the following values of 𝑦 = 𝑓(𝑥) corrosponging to a set of values of 𝑥:
𝒙 𝒙𝟎 𝒙𝟏 𝒙𝟐 … 𝒙𝒏
𝒚 𝑦0 𝑦1 𝑦2 … 𝑦𝑛
Then the process of finding the value of 𝑦 corresponding to any value of 𝑥 = 𝑥𝑖 between 𝑥0 and
𝑥𝑛 is called interpolation. And the technique of estimating the value of a function out side the
given range is called extrapolation, however, the term interpolation includes extrapolation.
Objective
At the end of this unit, the learner should be able to:
Define forward, backward, centeral and shift operators.
Construct the finite difference tables for a given set of data points.
Find the interpolating polynomial of the given data point using different interpolation
formulas.
Activity 4.1
Given
𝒙 𝟎 𝟏 𝟐 𝟑
𝒚 = 𝒇(𝒙) 1 0 1 10
Based on the given data find 𝑓(𝑥) that thatisfies all the data points.
Prepared by Abe N 54
NUMERICAL METHODS
Objective
At the end of this subtopic the learner should be able to:
Define forward operator.
Construct the forward difference tables for a given set of data points.
Suppose the following data is given such that the values of 𝑥 are eqully spaced throughout the
data, that means the distance between any two consecutives 𝑥 values are constant all over the
data.
𝒙 𝒙𝟎 𝒙𝟏 𝒙𝟐 𝒙𝟑 𝒙𝟒 … 𝒙𝒏
𝒚 𝑦0 𝑦1 𝑦2 𝑦3 𝑦4 … 𝑦𝑛
Prepared by Abe N 55
NUMERICAL METHODS
𝑛
𝑛 𝑛−1 𝑛−1
𝑛!
∆ 𝑓𝑖 = ∆ 𝑓𝑖+1 − ∆ 𝑓𝑖 = ∑(−1)𝑘 𝑓
𝑘! (𝑛 − 𝑘)! 𝑖+𝑛−𝑘
𝑘=0
∆2 𝑦0 = 𝑦2 − 𝑦1 − (𝑦1 − 𝑦0 ) = 𝑦2 − 2𝑦1 + 𝑦0
= 𝑦3 − 𝑦2 − 𝑦2 + 𝑦1 − 𝑦2 + 𝑦1 + 𝑦1 − 𝑦0
= 𝑦3 − 3𝑦2 + 3𝑦1 − 𝑦0
𝒙 𝒙𝟎 𝒙𝟏 𝒙𝟐 𝒙𝟑 𝒙𝟒
𝒚 𝑦0 𝑦1 𝑦2 𝑦3 𝑦4
y
X Y 2 y 3 y 4 y
x0
y0 y0 2 y0 3 y0 4 y0
x1 y1 y1 2 y1 ∆3 𝑦1
x2 y2 y 2 ∆2 𝑦2
x3 y3 ∆𝑦3
𝑥4 𝑦4
Constructing the forward or back ward difference table is important or the first step to use the
interpolation formula, because we read the coefficients that are aviliable in the forward or back
Prepared by Abe N 56
NUMERICAL METHODS
ward difference interpolation formula form the respective difference table. Therefore,
learnersshould be able to construct these difference tables in order to use the respective
interpolation formulas.
Objective
At the end of this subtopic, the learner should be able to:
Define backward difference.
Construct backward difference tables for a given set of data points.
Suppose the following data is given such that the values of 𝑥 are eqully spaced throughout the
data, that means the distance between any two consecutives 𝑥 values are constant all over the
data.
𝒙 𝒙𝟎 𝒙𝟏 𝒙𝟐 𝒙𝟑 𝒙𝟒 … 𝒙𝒏
𝒚 𝑦0 𝑦1 𝑦2 𝑦3 𝑦4 … 𝑦𝑛
∇2 𝑦2 = y2 − y1 − (y1 − y0 ) = y2 − 2y0 + y0
∇3 𝑦3 = ∇(∇2 𝑦3 ) = ∇(∇(𝑦3 − 𝑦2 ))
∇3 𝑦3 = y3 − y2 − y2 + y1 − y2 + y1 + y1 − y0
Prepared by Abe N 57
NUMERICAL METHODS
∇3 𝑦3 = 𝑦3 − 3𝑦2 + 3𝑦1 − 𝑦0
𝑛
𝑛!
𝛻 𝑛 𝑓𝑖 = 𝛻 𝑛−1 𝑓𝑖 − 𝛻 𝑛−1 𝑓𝑖−1 = ∑(−1)𝑘 𝑓
𝑘! (𝑛 − 𝑘)! 𝑖−𝑘
𝑘=0
𝒙 𝒙𝟎 𝒙𝟏 𝒙𝟐 𝒙𝟑 𝒙𝟒
𝒚 𝑦0 𝑦1 𝑦2 𝑦3 𝑦4
y
2 3 4
x y y y
x 0 y 0
x 1 y 1
y 1
y y
2
x 2 y 2 2 2
y y y
2 3
x 3 y 3 3 3 3
y y y y
2 3 4
x 4 y 4 4 4 4 4
In order to construct difference tables, one must frist understand the definiation of backward and
forward differences, once you understand the definition, it will be very simple to construct
difference tables of a given data. The secrete to understand mathematics is understanding the
definition, every thing lies on it.
Objective
At the end of this subtopic, the learner should be able to:
Define centeraldifferece.
Construct centeral difference table for a given set of data points.
Prepared by Abe N 58
NUMERICAL METHODS
Suppose the following data is given such that the values of 𝑥 are eqully spaced throughout the
data, that means the distance between any two consecutives 𝑥 values are constant all over the
data.
𝒙 𝒙𝟎 𝒙𝟏 𝒙𝟐 𝒙𝟑 𝒙𝟒 … 𝒙𝒏
𝒚 𝑦0 𝑦1 𝑦2 𝑦3 𝑦4 … 𝑦𝑛
δ𝑦5 , … , δ𝑦𝑛+1 repectively are known as first order centeral differencesandthe symbol𝛿 is called
2 2
……………
… … … …and so, on
𝛿 2 𝑦1 = 𝛿𝑦3 − 𝛿𝑦1
2 2
𝛿 2 𝑦2 = 𝛿𝑦5 − 𝛿𝑦3
2 2
… … ….
𝛿 2 𝑦𝑛 = 𝛿𝑦𝑛+ 1 − 𝛿𝑦𝑛−1
2 2
Prepared by Abe N 59
NUMERICAL METHODS
Higher order central differences are similarly defined. In general, the 𝑛𝑡ℎ central differences are
given by
𝒙 𝒙𝟎 𝒙𝟏 𝒙𝟐 𝒙𝟑 𝒙𝟒 𝒙𝟓
𝒚 𝑦0 𝑦1 𝑦2 𝑦3 𝑦4 𝑦5
x 0 y 0
y 1
2
x 1 y 1 2y 1
y 3 3y 3
2 2
x 2 y 2 2y 2 4y 2
y 5 y 3
5 5y 5
2 2 2
x 3 y 3 2y 3 4y 3
y 7 y 3
7
2 2
x 4 y 4 2y 4
y 9
2
x 5 y 5
Prepared by Abe N 60
NUMERICAL METHODS
The operator E is called shift operator or displacement or translation operator. It shows the
operation of increasing the argument value 𝑥by its interval of differencing h so that.
𝐸𝑓 (𝑥) = 𝑓(𝑥 + ℎ) 𝑜𝑟𝐸𝑦(𝑥) = 𝑦(𝑥 + ℎ)
Similarly,, 𝐸 2 𝑓(𝑥) = 𝐸𝑓(𝑥 + ℎ) = 𝑓(𝑥 + 2ℎ)
Ingeneral𝐸 𝑛 𝑓(𝑥) = 𝑓(𝑥 + 𝑛ℎ)
And Inverse shift operator (𝐸 −1 ) is defined as
𝐸 −1 𝑓(𝑥) = 𝑓(𝑥 − ℎ)
𝐸 −2 𝑓(𝑥) = 𝑓(𝑥 − 2ℎ)
𝐸 −𝑛 𝑓(𝑥) = 𝑓(𝑥 − 𝑛ℎ)
𝐸 =1+∆
∆𝑓(𝑥) = ∇𝑓(𝑥 + ℎ)
∇𝑓(𝑥) = ∆𝑓(𝑥 − ℎ) = 𝑓(𝑥) − 𝑓(𝑥 − ℎ)
𝑓(𝑥 − ℎ) = 𝑓(𝑥) − ∇𝑓(𝑥) = (1 − ∇)𝑓(𝑥) ⟹ 𝐸 −1 = 1 − ∇
Now, let us consider specific example to demonstrate how to construct the forward and
backward difference tables.
Example 4.1: Construct a forward and backward difference table for the following data.
𝒙 𝟏𝟎 𝟏𝟓 𝟐𝟎 𝟐𝟓 𝟑𝟎 𝟑𝟓
𝒚 15 17 20 21 24 30
Solution:in this specific example,𝑦0 = 15, 𝑦1 = 17, 𝑦2 = 20𝑦3 = 21, 𝑦4 = 24 and 𝑦5 = 30.
∆𝑦0 = 𝑦1 − 𝑦0 = 17 − 15 = 2
∆𝑦1 = 𝑦2 − 𝑦1 = 20 − 17 = 3
Prepared by Abe N 61
NUMERICAL METHODS
∆𝑦2 = 𝑦3 − 𝑦2 = 21 − 20 = 1
∆𝑦3 = 𝑦4 − 𝑦3 = 24 − 21 = 3
∆𝑦4 = 𝑦5 − 𝑦4 = 30 − 24 = 6
All these differences are called first order forward differences because the order of the operator ∆
is one. Second order forward differences are obtained as follow:
x y
2 3 4 5
y y y y y
10 15 2 1 3 7 10
15 17 3 2 4 3
20 20 1 2 1
25 21 3 3
30 24 6
35 30
Using the definition of backward differences, the backward difference table for the above data is
Prepared by Abe N 62
NUMERICAL METHODS
x y
2 3 4 5
y y y y y
10 15
15 17 2
20 20 3 1
25 21 1 2 3
30 24 3 2 4 7
35 30 6 3 1 3 10
Note: The only difference in the forward and backward difference is position.
Objective
At the end of these topic studentsould beable to:
Objective
At the end of these subtopicSudentssould beable to:
Suppose we are given the following data such that the values of 𝑥 are equally spaced with 𝑥𝑖 =
𝑥0 + 𝑖ℎ, for 𝑖 = 0,1,2, … , 𝑛.
Prepared by Abe N 63
NUMERICAL METHODS
𝒙 𝒙𝟎 𝒙𝟏 𝒙𝟐 𝒙𝟑 𝒙𝟒 … 𝒙𝒏
𝒚 𝑦0 𝑦1 𝑦2 𝑦3 𝑦4 … 𝑦𝑛
Our objective is to find a polynomial 𝑓(𝑥) that satisfies the given data, that is
From equation (4.1), we have 𝑓(𝑥0 ) = 𝑦0 and from equation (1.2) we get 𝑓(𝑥0 ) = 𝑎0
From equation (4.1) and (4.2), we have 𝑓(𝑥1 ) = 𝑦1 and 𝑓(𝑥1 ) = 𝑎0 + 𝑎1 (𝑥1 − 𝑥0 ) respectively.
⟹ 𝑦1 = 𝑦0 + 𝑎1 ℎ. (Because 𝑦0 = 𝑎0 )
𝑦1 − 𝑦0 ∆𝑦0 ∆𝑦0
𝑎1 = = =
ℎ ℎ 1! ℎ
𝑦1 −𝑦0
Then,𝑦2 = 𝑎0 + 𝑎1 2ℎ + 𝑎2 2ℎ2 ⟹ 𝑦2 = 𝑦0 + 2ℎ + 𝑎2 2ℎ2
ℎ
2 2
∆2 𝑦0 ∆2 𝑦0
⟹ 𝑎2 2ℎ = ∆ 𝑦0 ⟹ 𝑎2 = =
2ℎ2 2! ℎ2
Prepared by Abe N 64
NUMERICAL METHODS
Following the same procedure, we can obtain the rest of the coefficients as
∆3 𝑦0 ∆4 𝑦0 ∆𝑛 𝑦0
𝑎3 = ,𝑎4 = , … . , 𝑎𝑛 =
3!ℎ3 4!ℎ4 𝑛!ℎ𝑛
∆𝑦0 ∆2 𝑦0 ∆3 𝑦0
𝑓(𝑥) = 𝑦0 + (𝑥 − 𝑥0 ) + (𝑥 − 𝑥0 )(𝑥 − 𝑥1 ) + (𝑥 − 𝑥0 )(𝑥 − 𝑥1 )(𝑥 − 𝑥2 ) + ⋯ +
ℎ 2! ℎ2 3! ℎ3
∆𝑛 𝑦0
(𝑥 − 𝑥0 )(𝑥 − 𝑥1 )(𝑥 − 𝑥2 ) … (𝑥 − 𝑥𝑛−1 ) (4.3)
𝑛!ℎ𝑛
Let 𝑥 = 𝑥0 + 𝑘ℎ ⟹ 𝑥 − 𝑥0 = 𝑘ℎ
∆𝑦0 ∆2 𝑦 ∆3 𝑦
𝑓(𝑥) = 𝑦0 + 𝑘ℎ + (𝑘ℎ)ℎ(𝑘 − 1) + (𝑘ℎ)ℎ(𝑘 − 1)ℎ(𝑘 − 2) + ⋯ +
ℎ 2! ℎ2 3! ℎ3
∆𝑛 𝑦
(𝑘ℎ)ℎ(𝑘 − 1)ℎ(𝑘 − 2) … ℎ(𝑘 − (𝑛 − 1))
𝑛! ℎ𝑛
Δ2 𝑦0 Δ3 𝑦0
𝑓(𝑥) = 𝑦0 + Δ𝑦0 𝑘 + 𝑘(𝑘 − 1) + 𝑘(𝑘 − 1)(𝑘 − 2)
2! 3!
Δ4 𝑦0 Δ𝑛 𝑦0
+ 4!
𝑘(𝑘 − 1)(𝑘 − 2)(𝑘 − 3) + ⋯+ 𝑛!
𝑘(𝑘 − 1)(𝑘 − 2) … (𝑘 − (𝑛 − 1))(4.4)
Prepared by Abe N 65
NUMERICAL METHODS
𝑥−𝑥0
Where 𝑘 = ℎ
𝑥−𝑥0
𝑓(𝑥) = 𝑦(𝑥) = ∑𝑛𝑟=0(𝑘𝑟) ∆𝑟 𝑦0 , Where 𝑘 = ℎ
Objective
At the end of this topicsudentssould beable to:
In order to derive Newton’s backward difference interpolation formula, write the polynomial
𝑓(𝑥) in the following form.
Then by applying the same technique as the forward case, we get the Newton Back ward
difference interpolation formula
∇2 𝑦𝑛 ∇3 𝑦𝑛 ∇4 𝑦𝑛
𝑓(𝑥) = 𝑦𝑛 + ∇𝑦𝑛 𝑘 + 𝑘(𝑘 + 1) + 𝑘(𝑘 + 1)(𝑘 + 2) + 𝑘(𝑘 + 1)(𝑘 + 2)(𝑘 + 3)
2! 3! 4!
∇𝑛 𝑦𝑛
+⋯+ 𝑘(𝑘 + 1)(𝑘 + 2) … (𝑘 + (𝑛 − 1)) (4.5)
𝑛!
𝑥−𝑥𝑛
Where 𝑘 = ℎ
In compact form:
Prepared by Abe N 66
NUMERICAL METHODS
𝑥−𝑥𝑛
𝑓(𝑥) = 𝑦(𝑥) = ∑𝑛𝑟=0(−𝑘
𝑟
) (−1)𝑟 ∇𝑟 𝑦𝑛 , Where 𝑘 = ℎ
𝒙 𝟎 𝟏 𝟐 𝟑 𝟒
𝒚 6 11 66 273 806
Find the interpolating polynomial using NFDIF and evaluate it at𝑥 = 1.5
x y y
2
y
3
y
4
y
0 6 5 50 102 72
1 11 55 152 174
2 66 207 326
3 273 533
4 806
Δ2 𝑦0 Δ3 𝑦0 Δ4 𝑦0
𝑓(𝑥) = 𝑦0 + Δ𝑦0 𝑘 + 𝑘(𝑘 − 1) + 𝑘(𝑘 − 1)(𝑘 − 2) + 𝑘(𝑘 − 1)(𝑘 − 2)(𝑘
2! 3! 4!
𝑥 − 𝑥0 𝑥 − 0
− 3)𝑘 = = =𝑥
ℎ 1
102 72
𝑓(𝑥) = 6 + 5𝑥 + 25𝑥(𝑥 − 1) + 𝑥(𝑥 − 1)(𝑥 − 2) + 𝑥(𝑥 − 1)(𝑥 − 2)(𝑥 − 3)
6 24
= 6 − 4𝑥 + 7𝑥 2 − 𝑥 3 + 3𝑥 4
Example 4.3: Find the interpolating polynomial which takes the following values using NBDIF.
Prepared by Abe N 67
NUMERICAL METHODS
𝒙 𝟎 𝟏 𝟐 𝟑
𝒚 1 0 1 10
x y y
2 3
y y
0 1
1 0 1
2 1 1 2
3 10 9 8 6
∇2 𝑦𝑛 ∇3 𝑦𝑛 𝑥−𝑥𝑛 𝑥−3
𝑓(𝑥) = 𝑦𝑛 + ∇𝑦𝑛 𝑘 + 𝑘(𝑘 + 1) + 𝑘(𝑘 + 1)(𝑘 + 2)and𝑘 = = =𝑥−3
2! 3! ℎ 1
= 10 + 9𝑥 − 27 + 4(𝑥 2 − 5𝑥 + 6) + 𝑥 3 − 6𝑥 2 + 11𝑥 − 6
= 1 − 2𝑥 2 + 𝑥 3
Objective
At the end of these topics sudentssouldbeable to:
To construct NDD table and use it to find the interpolating polynomial of a given data.
Understand the concept how to derive NDDIF and LIF.
Apply NDDIF and LIF to find the interpolating polynomial for a given data.
Prepared by Abe N 68
NUMERICAL METHODS
Objective
At the end of this topicSudentssould beable to:
Let (𝑥0, 𝑦0 ) , (𝑥1, 𝑦1) , (𝑥2, 𝑦2), (𝑥3, 𝑦3),… , ( 𝑥𝑛, 𝑦𝑛 ) be given data points, where the values of 𝑥
may not be necessarly equally spaced.Then the first orderdivided difference for two arguments
𝑥0, 𝑥1 is defined as:
𝑦 −𝑦 𝑦 𝑦
[𝑥0, 𝑥1 ] = 𝑥1 −𝑥0 , [𝑥1, 𝑥2 ] = 𝑥2−𝑥1 , …
1 2 2− 1
2 3 4
x y Dy D y D y D y
x y
x , x
0 0
x , x , x
0 1
x y
x , x x , x , x , x
1 1 0 1 2
x , x , x x x , x x , x
1 2 0 1 2 3
x y
x , x x , x , x , x
2 2 1 2 3 0 1 2 3 4
x , x , x
2 3 1 2 3 4
x y
x , x
3 3 2 3 4
3 4
x y
4 4
Prepared by Abe N 69
NUMERICAL METHODS
Objective
At the end of this subtopicsudentssould beable to:
To construct NDD table and use it to find the interpolating polynomial of a given data.
Understand the concept how to derive NDDIF.
Apply NDDIF to find the interpolating polynomial for a given data.
Let (𝑥0, 𝑦0 ), (𝑥1, 𝑦1) , (𝑥2, 𝑦2 ), (𝑥3, 𝑦3),… , ( 𝑥𝑛, 𝑦𝑛 ) be given data points in which the values of 𝑥
may not be necessarly equally spaced and let 𝑥be a value within the data such that 𝑦 = 𝑓(𝑥).
Then from the definition of divided difference:
𝑦0 −𝑦 𝑦−𝑦
[𝑥, 𝑥0 ] = = 𝑥−𝑥0 .
𝑥0 −𝑥 0
⟹ 𝑦 = 𝑦0 + (𝑥 − 𝑥0 )[𝑥, 𝑥0 ] (4.6)
Prepared by Abe N 70
NUMERICAL METHODS
Example 4.3: Using Newton’s divided difference interpolation formula to find the interpolating
polynomial for the following data.
𝒙 −𝟏 𝟎 𝟏 𝟑
𝒚 2 1 0 −1
2 3
x y Dy D y D y
1 2
1
0 1 0
1
1
24
1
1 0
6
1
2
3 1
1
𝑦 = 2 + (𝑥 + 1)(−1) + (𝑥 + 1)(𝑥)(0) + (𝑥 + 1)(𝑥)(𝑥 − 1)
24
Prepared by Abe N 71
NUMERICAL METHODS
1 2
=2−𝑥−1+ (𝑥 − 1)(𝑥)
24
1 3 1 3
=1−𝑥+ (𝑥 − 𝑥) = (𝑥 − 25𝑥 + 24)
24 24
1
Therefore, 𝑦 = 𝑓(𝑥) = 24 (𝑥 3 − 25𝑥 + 24) is the interpolating polynomial using NDDIF.
Example 4.4: Using Newton’s divided difference interpolation formula find the interpolating
polynomial for the following data and evaluate it at 𝑥 = 1.5and 𝑥 = 8.
𝒙 𝟎 𝟏 𝟐 𝟒 𝟓 𝟔
𝒚 1 14 15 5 6 19
2 3 4 5
x y Dy D y D y D y D y
0 1
13
1 14 6
1 1
2 15 2 0
5 1 0
4 5 2 0
1 1
5 6 6
13
6 19
Prepared by Abe N 72
NUMERICAL METHODS
= 1 + 13𝑥 − 6𝑥 2 + 6𝑥 + 𝑥 3 − 3𝑥 2 + 2𝑥
= 𝑥 3 − 9𝑥 2 + 21𝑥 + 1
Example4.5: construct the divided difference table and find the interpolating polynomial for the
following data points.
𝒙 𝟏 𝟐 𝟑 𝟓 𝟕
𝒚 3 5 9 11 15
2 3 4
x y Dy D y D y D y
1 3
2
2 5 1
1
4
2
1
3 9 1
8
1
1
4
1
5 11
4
2
7 15
1
𝑦(𝑥) = 3 + 2(𝑥 − 1) + (1)(𝑥 − 1)(𝑥 − 2) + (− ) (𝑥 − 1)(𝑥 − 2)(𝑥 − 3)
2
1
+ (𝑥 − 1)(𝑥 − 2)(𝑥 − 3)(𝑥 − 5)
8
Prepared by Abe N 73
NUMERICAL METHODS
1
= (𝑥 4 − 15𝑥 3 + 73𝑥 2 − 11𝑥 + 78)
8
Objective
At the end of this subtopicsudentssould beable to:
If 𝑦 = 𝑓(𝑥) takes the values 𝑦0 , 𝑦1 , … , 𝑦𝑛 corresponding to𝑥0 , 𝑥1 , … , 𝑥𝑛 , then 𝑦(𝑥) is given by:
(𝑥 − 𝑥1 )(𝑥 − 𝑥2 ) … (𝑥 − 𝑥𝑛 ) (𝑥 − 𝑥0 )(𝑥 − 𝑥2 ) … (𝑥 − 𝑥𝑛 )
𝑦(𝑥) = (𝑦0 ) + (𝑦 )
(𝑥0 − 𝑥1 )(𝑥0 − 𝑥2 ) … (𝑥0 − 𝑥𝑛 ) (𝑥1 − 𝑥0 )(𝑥1 − 𝑥2 ) … (𝑥1 − 𝑥𝑛 ) 1
𝑛 𝑛
𝑥 − 𝑥𝑗
𝑓(𝑥) = ∑ 𝑓(𝑥𝑖 ) ∏ ( )
𝑥𝑖 − 𝑥𝑗
𝑖=0 𝑗=0
𝑗≠𝑖
Proof:
Prepared by Abe N 74
NUMERICAL METHODS
𝑦1
⟹ 𝑎1 =
(𝑥1 − 𝑥0 )(𝑥1 − 𝑥1 )(𝑥1 − 𝑥2 ) … (𝑥1 − 𝑥𝑛 )
𝑦𝑛
𝑎𝑛 =
(𝑥𝑛 − 𝑥0 )(𝑥𝑛 − 𝑥1 )(𝑥𝑛 − 𝑥2 ) … (𝑥𝑛 − 𝑥𝑛−1 )
Substituting these values in equation (4.11) one can get equation (4.10).
Example 4.5: Use Lagrange’s interpolation formula (LIF) to find the interpolating polynomial
𝑓(𝑥) of the following data.
𝒙 𝟎 𝟏 𝟐 𝟒
𝒚 8 9 0 48
Solution:
Prepared by Abe N 75
NUMERICAL METHODS
𝒙 -1 0 1 3
𝒚 2 1 0 -1
Then
Solution:(a)
(𝑥 − 𝑥1 )(𝑥 − 𝑥2 ) … (𝑥 − 𝑥𝑛 ) (𝑥 − 𝑥0 )(𝑥 − 𝑥2 ) … (𝑥 − 𝑥𝑛 )
𝑓(𝑥) = (𝑦0 ) + (𝑦 ) + ⋯
(𝑥0 − 𝑥1 )(𝑥0 − 𝑥2 ) … (𝑥0 − 𝑥𝑛 ) (𝑥1 − 𝑥0 )(𝑥1 − 𝑥2 ) … (𝑥1 − 𝑥𝑛 ) 1
𝑥 3 − 4𝑥 2 + 3𝑥 𝑥 3 − 3𝑥 2 − 𝑥 + 3 −𝑥 3 + 𝑥
= + +
−4 3 24
1
= (−6𝑥 3 + 24𝑥 2 − 18𝑥 + 8𝑥 3 − 24𝑥 2 − 8𝑥 + 24 − 𝑥 3 + 𝑥)
24
1 3
= (𝑥 − 25𝑥 + 24)
24
1 1 −3
(b) 𝑓(2) = 24 (28 − 50 + 24) = 24 (−18) = 4
Summary
Different types of difference operators, these are forward difference, backward difference
and centeral difference denoted by ∆, ∇ and𝛿 respectively.
In the case of equally spaced data points Newtonforward difference interpolation formula
and Newton backward differnec interpolation formula where as in the case of un equal
Prepared by Abe N 76
NUMERICAL METHODS
spaced data points we use Newton divided diefference interpolation formula and
Lagrange’s interpolation formula to find the interpolating polynomial for a given data.But
we can also use NDDIF and LIF in the case of equally spaced data.
Review exercise 4
1. Find the interpolating polynomial using NBDIF for the following data.
𝒙 𝟎 𝟏 𝟐 𝟑
𝒚 1 3 7 13
2. Find the interpolating polynomial using NFDIF for the following data
𝒙 𝟑 𝟒 𝟓 𝟔
𝒚 6 24 60 120
3. Use Lagrange’s formula to find the value of y at 𝑥 = 6 for the following data.
𝒙 𝟑 𝟕 𝟗 𝟏𝟎
𝒚 168 120 72 63
4. Given data
𝒙 𝟎 𝟐 𝟑 𝟔
𝒚 648 704 729 792
Prepared by Abe N 77
NUMERICAL METHODS
CHAPTER 5
5.1. Introduction
Why we need numerical differentation and integration?
The integrand can be an analytical function or a set of discrete points (tabulated data). When the
integrand is a mathematical expression for which the antiderivative can be found easily, the
value of the definite integral can be determined analytically. Numerical method is needed when
analytical differentiation and (or integration) is difficult or not possible, and when the integrand
is given as a set of discrete points.
Objective
At the end of this unit the learner would have been able to:
subintervals.
Solve problems using numerical differentiation and integration formulas.
Prepared by Abe N 78
NUMERICAL METHODS
Activity 5.1
If 𝑓(𝑥) is given by the following table, then based on the data
a. Find the first derivative of 𝑓(𝑥)
6
b. Evaluate ∫0 𝑓(𝑥)𝑑𝑥
𝒙 0 1 2 3 4 5 6
𝒚 6.9897 7.4036 7.7815 8.1291 8.4510 8.7506 9.0309
Objective
Δ2 𝑦0 Δ3 𝑦0
𝑦(𝑥) = 𝑦0 + Δ𝑦0 𝑘 + 𝑘(𝑘 − 1) + 𝑘(𝑘 − 1)(𝑘 − 2)
2! 3!
Δ4 𝑦0 Δ𝑛 𝑦0
+ 𝑘(𝑘 − 1)(𝑘 − 2)(𝑘 − 3) + ⋯ + 𝑘(𝑘 − 1)(𝑘 − 2) … (𝑘 − (𝑛 − 1))
4! 𝑛!
𝑥−𝑥0
Where 𝑘 = ℎ
Δ2 𝑦0 2 Δ3 𝑦0 3
𝑦(𝑥) = 𝑦0 + Δ𝑦0 𝑘 + (𝑘 − 𝑘) + (𝑘 − 3𝑘 2 + 2𝑘) +
2! 3!
Δ4 𝑦0 4
(𝑘 − 6𝑘 3 + 11𝑘 2 − 6𝑘) + ⋯
4!
Prepared by Abe N 79
NUMERICAL METHODS
𝑑𝑦 𝑑𝑦 𝑑𝑘 𝑑𝑦 1 1 𝑑𝑦 𝑑𝑘 1
= 𝑑𝑘 𝑑𝑥 = 𝑑𝑘 ℎ = ℎ 𝑑𝑘 (Because𝑑𝑥 = ℎ)
𝑑𝑥
𝑑𝑦 Δ2 𝑦0 Δ3 𝑦0 Δ4 𝑦0
= Δ𝑦0 + (2𝑘 − 1) + (3𝑘 2 − 6𝑘 + 2) + (4𝑘 3 − 18𝑘 2 + 22𝑘 − 6) + ⋯
𝑑𝑘 2! 3! 4!
𝑑𝑦 1 Δ2 𝑦0 Δ3 𝑦0 Δ4 𝑦0
= ℎ[Δ𝑦0 + (2𝑘 − 1) + (3𝑘 2 − 6𝑘 + 2) + (4𝑘 3 − 18𝑘 2 + 22𝑘 − 6) + ⋯] (5.1)
𝑑𝑥 2! 3! 4!
By differentiating Eq. (5.1) with respect to 𝑥,we can obtaine the formula for second order
derivative as follows.
𝑑2 𝑦 𝑑 𝑑𝑦 𝑑𝑘 1 Δ2 𝑦0 Δ3 𝑦0
= 𝑑𝑘 (𝑑𝑘 ) 𝑑𝑥 = ℎ2[Δ𝑦0 + (2𝑘 − 1) + (3𝑘 2 − 6𝑘 + 2)
𝑑𝑥 2 2! 3!
Δ4 𝑦0
+ (4𝑘 3 − 18𝑘 2 + 22𝑘 − 6) + ⋯]
4!
∇2 𝑦𝑛 ∇3 𝑦𝑛 ∇4 𝑦𝑛
𝑓(𝑥) = 𝑦𝑛 + ∇𝑦𝑛 𝑘 + 𝑘(𝑘 + 1) + 𝑘(𝑘 + 1)(𝑘 + 2) + 𝑘(𝑘 + 1)(𝑘 + 2)(𝑘 + 3)
2! 3! 4!
∇𝑛 𝑦𝑛
+⋯+ 𝑘(𝑘 + 1)(𝑘 + 2) … (𝑘 + (𝑛 − 1))
𝑛!
𝑑𝑦 ∇2 𝑦𝑛 ∇3 𝑦𝑛 ∇4 𝑦𝑛
= ∇𝑦𝑛 + (2𝑘 + 1) + (3𝑘 2 + 6𝑘 + 2) + (4𝑘 3 + 18𝑘 2 + 22𝑘 + 6) + ⋯
𝑑𝑘 2! 3! 4!
𝑥 − 𝑥𝑛 𝑑𝑘 1
𝑘= ⟹ =
ℎ 𝑑𝑥 ℎ
𝑑𝑦 𝑑𝑦 𝑑𝑘
Since = 𝑑𝑘 𝑑𝑥 ,we have
𝑑𝑥
𝑑𝑦 1 ∇2 𝑦𝑛 ∇3 𝑦𝑛 ∇4 𝑦𝑛
= [∇𝑦𝑛 + (2𝑘 + 1) + (3𝑘 2 + 6𝑘 + 2) + (4𝑘 3 + 18𝑘 2 + 22𝑘 + 6) + ⋯ ]
𝑑𝑥 ℎ 2! 3! 4!
Prepared by Abe N 80
NUMERICAL METHODS
𝑑2 𝑦 𝑑 𝑑𝑦 𝑑𝑘 1 𝑑 𝑑𝑦 1 𝑑 𝑑𝑦 1 𝑑 𝑑𝑦 𝑑𝑘 1 𝑑 𝑑𝑦 1 𝑑2𝑦
= ( )= ( )= ( )= ( )= 2 ( ) = 2 ( 2)
𝑑𝑥 2 𝑑𝑥 𝑑𝑘 𝑑𝑥 ℎ 𝑑𝑥 𝑑𝑘 ℎ 𝑑𝑘 𝑑𝑥 ℎ 𝑑𝑘 𝑑𝑘 𝑑𝑥 ℎ 𝑑𝑘 𝑑𝑘 ℎ 𝑑𝑘
𝑑2 𝑦 1 ∇4 𝑦𝑛
Hence,𝑑𝑥 2 = ℎ2 [∇2 𝑦𝑛 + ∇3 𝑦𝑛 (𝑘 + 1) + (6𝑘 2 + 18𝑘 + 11) + ⋯ ]
12
Example 5.1: Based on the following data find 𝑓 ′ (0) and 𝑓 ′′ (0)
𝒙 0 1 2 3
𝒚 1 3 9 21
Solution: The forward difference table for the data is given as follows
x y
2 3
y y y
0 1 2 4 2
1 3 6 6
2 9 12
3 21
𝑑𝑦 1 ∆2 𝑦0 ∆3 𝑦0 2
∆4 𝑦0
= [∆𝑦0 + (2𝑘 − 1) + (3𝑘 − 6𝑘 + 2) + (4𝑘 3 − 18𝑘 2 + 22𝑘 − 6) + ⋯ ]
𝑑𝑥 ℎ 2 3! 4!
𝑥−𝑥0 2
And𝑥0 = 0, ℎ = 1, 𝑘 = = 𝑥, but here 𝑥 = 0 ⇒ 𝑓 ′ (0) = 2 + 2(−1) + 3 and
ℎ
′′ (𝑥)
1 2 ∆3 𝑦0 ∆4 𝑦0
𝑓 = 2 [∆ 𝑦0 + (6𝑘 − 6) + (12𝑘 2 − 36𝑘 + 22) + ⋯ ]
ℎ 6 4!
2
⇒ 𝑓 ′′ (0) = 4 + (−6) = 4 − 2 = 2
6
Example 5.2: Based on the folloeing date find 𝑓 ′′ (10) using the back-ward difference derivative
formula.
𝒙 0 2 4 6 8 10
𝒚 6 8 18 36 62 96
Prepared by Abe N 81
NUMERICAL METHODS
Solution:
x y
2 3 4 5
y y y y y
0 6
2 8 2
4 18 10 8
6 36 18 8 0
8 62 26 8 0 0
10 96 34 8 0 0 0
𝑑2𝑦 1 2 3 (𝑘
∇4 𝑦𝑛
= [∇ 𝑦𝑛 + ∇ 𝑦𝑛 + 1) + (6𝑘 2 + 18𝑘 + 11) + ⋯ ]
𝑑𝑥 2 ℎ2 12
1 2 1
𝑓 ′′ (𝑥) = (∇ 𝑦𝑛 + 0) = (8) = 2.
ℎ2 4
Therefore 𝑓 ′′ (10) = 2
Objective
subintervals.
Solve problems using numerical integration rules.
It is well observed that polynomial approximation serves as the basis for a variety of integral
formulas that is why we need to have studied some polynomial approximation techniques. The
main idea is, if𝑃(𝑥) is an approximation to 𝑓(𝑥) then
Prepared by Abe N 82
NUMERICAL METHODS
𝑏 𝑏
∫𝑎 𝑃(𝑥)𝑑𝑥 = ∫𝑎 𝑓(𝑥)𝑑𝑥 (5.2)
The basic procedure of numerical integration is to divide the range of interval of integration into
sub intervals and obtain the integral over each strip of the interval and by composing them one
can found the estimation of the integral over the the entire interval [𝑎, 𝑏]. Thus, if the range or
limits of integration is [𝑎, 𝑏] (actually points in[𝑥0 , 𝑥𝑛 ]), then the interval [𝑥0 , 𝑥𝑛 ] can be
subdivided into 𝑛equal sub interval as𝑥𝑖 = 𝑥0 + 𝑖ℎ,𝑖 = 1,2, … , 𝑛.The derivations of these
formulas are very essential to the learning of numerical integration. While they are interested in
the learning of the topic, it also helps in the understanding of the workings of these formulae
rather than trying to memorize them. The most acceptable way of deriving all these rules listed
above is by using the Newton forward formula or Newton backward formula. However, we shall
restrict our learning to the Newton Forward formula for deriving the integration formula in this
book. The Newton Forward interpolation formula is given by:
Δ2 𝑦0 2 Δ3 𝑦0 3
𝑦(𝑥) = 𝑦0 + Δ𝑦0 𝑘 + (𝑘 − 𝑘) + (𝑘 − 3𝑘 + 2𝑘)
2! 3!
Δ4 𝑦0 𝑥−𝑥0
+ (𝑘 4 − 6𝑘 3 + 11𝑘 2 − 6𝑘) + ⋯ ; Where 𝑘 = (5.3)
4! ℎ
𝑥𝑛
𝑏
Δ2 𝑦0 2 Δ3 𝑦0 3
∫ 𝑓(𝑥)𝑑𝑥 = ∫ (𝑦0 + Δ𝑦0 𝑘 + (𝑘 − 𝑘) + (𝑘 − 3𝑘 2 + 2𝑘) + … ) 𝑑𝑥
𝑎 2! 3!
𝑥0
𝑥 − 𝑥0
𝑘= ⟹ 𝑥 = 𝑥0 + 𝑘ℎ ⟹ 𝑑𝑘ℎ = 𝑑𝑥;
ℎ
𝑛
Δ2 𝑦0 2 Δ3 𝑦0 3
𝐼 = ℎ ∫ (𝑦0 + Δ𝑦0 𝑘 + (𝑘 − 𝑘) + (𝑘 − 3𝑘 2 + 2𝑘) + ⋯ ) 𝑑𝑘
2! 3!
0
𝑛
𝑘 2 Δ2 𝑦0 𝑘 3 𝑘 2 Δ3 𝑦0 𝑘 4
𝐼 = ℎ (𝑦0 𝑘 + Δ𝑦0 + ( − )+ ( − 𝑘 3 + 𝑘 2 ) + ⋯ )|
2 2! 3 2 3! 4 0
Prepared by Abe N 83
NUMERICAL METHODS
𝑛 Δ2 𝑦0 𝑛2 𝑛 Δ3 𝑦0 𝑛3
𝐼 = ℎ𝑛 (𝑦0 + Δ𝑦0 + ( − )+ ( − 𝑛2 + 𝑛) + ⋯ )
2 2! 3 2 3! 4
𝑛 Δ2 𝑦0 2
Δ3 𝑦0 3
𝐼 = ℎ𝑛 (𝑦0 + Δ𝑦0 + (2𝑛 − 3𝑛) + (𝑛 − 4𝑛2 + 4𝑛) + ⋯ )
2 12 24
𝑛 Δ2 𝑦0 Δ3 𝑦0
𝐼 = ℎ𝑛 (𝑦0 + Δ𝑦0 + 𝑛(2𝑛 − 3) + 𝑛(𝑛 − 2)2 + ⋯ )
2 12 24
𝑥1
𝑛 ℎ ℎ
∫ 𝑓(𝑥)𝑑𝑥 = ℎ𝑛 (𝑦0 + Δ𝑦0 ) = (2𝑦0 + Δ𝑦0 ) = (2𝑦0 + 𝑦1 − 𝑦0 )
2 2 2
𝑥0
𝑥1 ℎ
∫𝑥 𝑓(𝑥)𝑑𝑥 = 2 (𝑦0 + 𝑦1 )is the area of the first stipe or trapzim?
0
𝑏 𝑥𝑛 𝑥1 𝑥2 𝑥𝑛
∫ 𝑓(𝑥)𝑑𝑥 = ∫ 𝑓(𝑥)𝑑𝑥 = ∫ 𝑓(𝑥)𝑑𝑥 + ∫ 𝑓(𝑥)𝑑𝑥 + ⋯ + ∫ 𝑓(𝑥)𝑑𝑥
𝑎 𝑥0 𝑥0 𝑥1 𝑥𝑛−1
Prepared by Abe N 84
NUMERICAL METHODS
𝑏
ℎ ℎ ℎ ℎ ℎ
∫ 𝑓(𝑥)𝑑𝑥 = (𝑦0 + 𝑦1 ) + (𝑦1 + 𝑦2 ) + (𝑦2 + 𝑦3 ) … + (𝑦𝑛−2 + 𝑦𝑛−1 ) + (𝑦𝑛−1 + 𝑦𝑛 )
𝑎 2 2 2 2 2
𝑏 ℎ
∫𝑎 𝑓(𝑥)𝑑𝑥 = 2 [𝑦0 + 2(𝑦1 + 𝑦2 + 𝑦3 + ⋯ + 𝑦𝑛−1 ) + 𝑦𝑛 ] (5.4)
By dividing the interval [𝑎, 𝑏] in to 𝑛 = 2𝑚 subintervals and taking two intervals at a time or by
putting 𝑛 = 2 in Newton-Cotes integration formula, for each 𝑖 = 0,1,2, … , 𝑛. that is:
𝑥2
𝑛 Δ2 𝑦0
∫ 𝑓(𝑥)𝑑𝑥 = ℎ𝑛 (𝑦0 + Δ𝑦0 + (2𝑛2 − 3𝑛))
2 12
𝑥0
𝑥2
Δ2 𝑦0 6𝑦0 + 6y1 − 6𝑦0 (𝑦2 − 2𝑦1 + 𝑦0 )
∫ 𝑓(𝑥)𝑑𝑥 = 2ℎ (𝑦0 + Δ𝑦0 + ) = 2ℎ ( + )
6 6 6
𝑥0
𝑥2
𝑦0 + 4y1 + 3𝑦2 ℎ
∫ 𝑓(𝑥)𝑑𝑥 = 2ℎ ( ) = (𝑦0 + 4𝑦1 + 𝑦2 )
6 3
𝑥0
𝑥2 ℎ
∫𝑥 𝑓(𝑥)𝑑𝑥 = 3 (𝑦0 + 4𝑦1 + 𝑦2 )is the area over the interval [𝑥0 , 𝑥2 ]
0
𝑏 𝑥𝑛 𝑥2 𝑥4 𝑥𝑛
∫ 𝑓(𝑥)𝑑𝑥 = ∫ 𝑓(𝑥)𝑑𝑥 = ∫ 𝑓(𝑥)𝑑𝑥 + ∫ 𝑓(𝑥)𝑑𝑥 + ⋯ + ∫ 𝑓(𝑥)𝑑𝑥
𝑎 𝑥0 𝑥0 𝑥2 𝑥𝑛−2
𝑏
ℎ ℎ ℎ
∫ 𝑓(𝑥)𝑑𝑥 = (𝑦0 + 4𝑦1 + 𝑦2 ) + (𝑦2 + 4𝑦3 + 𝑦4 ) + ⋯ + (𝑦𝑛−2 + 4𝑦𝑛−1 + 𝑦𝑛 )
𝑎 3 3 3
Prepared by Abe N 85
NUMERICAL METHODS
𝑏
ℎ
∫ 𝑓(𝑥)𝑑𝑥 = [𝑦 + 4(𝑦1 + 𝑦3 + ⋯ + 𝑦𝑛−1 ) + 2(𝑦2 + 𝑦4 + 𝑦6 + ⋯ ) + 𝑦𝑛 ]
𝑎 3 0
ℎ
⇒ 𝐼 = 3 (𝑦0 + 𝑦𝑛 + 4(𝑦1 + 𝑦3 + 𝑦5 + ⋯ + 𝑦𝑛−1 ) + 2(𝑦2 + 𝑦4 + ⋯ + 𝑦𝑛−2 )) (5.5)
1
Equation (5) is called Simpson’s 3 rule.
1
Notethat: In Simpson’s 3 rulethe number ofsubinterval 𝑁must be even.
By dividing the interval [𝑎, 𝑏] in to 𝑛 = 3𝑚, 𝑚 ∈ 𝑁 subintervals and taking three intervals at a
time and putting 𝑛 = 3 in Newton-Cotes integration formula, for each 𝑖 = 0,1,2, … , 𝑛 and
1
following the same procuder as that of Simpson’s 3one can obtain the following formula:
𝑏 3ℎ
∫𝑎 𝑓(𝑥) 𝑑𝑥 = [𝑦0 + 𝑦𝑛 + 3(𝑦1 + 𝑦2 + 𝑦4 + 𝑦5 + ⋯ + 𝑦𝑛−1 ) + 2(𝑦3 + y6 + … +yn−3 ) ]
8
3
This is known as Composite Simpson’s 8 rule.
𝟑
Note that: In Simpson’s𝟖 rule the number of subintervals must be a multiple of 3.
Example5.3: Given
𝒙 0 0.5 1 1.5 2 2.5 3
𝒇(𝒙) 1 2.028 2.718 3.403 4.113 4.860 5.652
3
Based on the above data Evaluate ∫0 𝑓(𝑥) 𝑑𝑥 by using:
1 3
a. Trapezoidal rule b. Simpson’s 3 rule c. Simpson’s 8 rule
Solution:
3 ℎ
a. ∫0 𝑓(𝑥) 𝑑𝑥 = 2 [𝑦0 + 𝑦𝑛 + 2(𝑦1 + 𝑦2 + ⋯ + 𝑦𝑛−1 )]
Prepared by Abe N 86
NUMERICAL METHODS
0.5
= [1 + 5.652 + 2(2.028 + 2.718 + 3.403 + 4.113 + 4.860)]
2
1 1
= [6.652 + 34.244] = [40.896] = 10.224.
4 4
3 ℎ
b. ∫0 𝑓(𝑥) 𝑑𝑥 = 3 [𝑦0 + 𝑦𝑛 + 4(𝑦1 + 𝑦3 + 𝑦5 … + 𝑦𝑛−1 ) + 2(𝑦2 + y4 + ⋯ yn−2 )]
0.5
= [1 + 5.652 + 4(2.028 + 3.403 + 4.860) + 2(2.718 + 4.113)]
3
1
= [6.652 + 41.164 + 13.662]
4
1
= 4 [61.478] ≈ 10.2463.
3 3ℎ
c. ∫0 𝑓(𝑥) 𝑑𝑥 = [𝑦0 + 𝑦𝑛 + 3(𝑦1 + 𝑦2 + 𝑦4 + 𝑦5 … + 𝑦𝑛−2 + 𝑦𝑛−1 ) + 2(𝑦3 + y6 + ⋯ yn−3 )]
8
3
= [1 + 5.652 + 3(2.028 + 2.718 + 4.113 + 4.86) + 2(3.403)]
16
3
= [6.652 + 3(13.719) + 6.806]
16
3 3
= [6.652 + 41.157 + 6.806] = [54.615] ≈ 10.2403.
16 16
Summary
Numerical differentiation helps us to find rate of changes when the function is given at
desecrate points
Numerical integration is important to find integrals which are difficult to find analytically
or when the integrand is given in tabular form.
The Trapezoidal rule is obtained from Newton cote’s integration formula by taking 𝑛 = 1.
1 3
Simpson’s and rules are obtaind from Newton cote’s general integration formula by
3 8
Prepared by Abe N 87
NUMERICAL METHODS
1
The number of sub interval in Simpson’s3 must be an even number or multiple of two,
3
where as in Simpson’s 8 the number of sub intervals must be multiple of three.
Reviewexercise 5
1. Given
1 3
(i). Trapezoidal rule (ii).Simpson’s3 rule (iii). Simpson’s 8 rule
𝒕(𝒊𝒏𝒔𝒆𝒄𝒐𝒏𝒅) 0 2 4 6 8 10
𝒗(𝒎/𝒔) 4 6 16 34 60 94
3. Compute the first and second derivative at 𝑥 = 51 from the following data
𝒙 50 60 70 80 90
𝒚 19.96 36.65 58.81 77.21 94.61
1 2 3
4. Evaluate the integral of ∫0 𝑒 𝑥 𝑑𝑥 using Simpson 8 with ℎ = 0.1 method.
Prepared by Abe N 88
NUMERICAL METHODS
CHAPTER SIX
6.1. Introduction
Numerical methods for differential equations are of grate importance to engineering, science and
mathematics because of the nature of practical problems. It is help ful to approximate the
solution of differential equations which are imposible to solve using the analytical method. Also,
there are differential equations for which the solutions interms of formulae are too complex so
that one prefers to use a numerical method to approximate the solution of such type of equations.
Objective
Activity 6.1
𝑑𝑦 𝑦 2 −𝑥 2
Given an IVP 𝑑𝑥 = 𝑦 2 +𝑥 2 , 𝑦(0) = 1, then find 𝑦(0.2) and 𝑦(0.4) with ℎ = 0.2.
Prepared by Abe N 89
NUMERICAL METHODS
Definition 6.1: A differential equation (DE) is an equation that involves a dependent variable
and its derivative with respect to one or more independent variables.
Definition6.2: A differential equation that involves only one independent variable is called an
ordinary differential equation (ODE) otherwise it is called a partial differential equation (PDE).
Example 6.1:
a. 𝑦 ′ = −𝑥 is an ODE
b. 𝑢𝑥𝑥 + 𝑢𝑦𝑦 = 0 is PDE
In this chaper we shall be concerned with numerical methods for solving problems of the form
𝑑𝑦
= 𝑓(𝑥, 𝑦), 𝑎 ≤ 𝑥 ≤ 𝑏
𝑑𝑥
Objective
At the end of this subtopic the learner would have been able to:
This method is named after an enormously creative swiss mathematician Leonnered Euler (1707-
1783). He studied under JhonBernolli and became a proffesser of mathematics in St. Petersburg;
Russia. Euler’s method is the simplest method of all numerical methods for solving ordinary
Prepared by Abe N 90
NUMERICAL METHODS
differential equations. Although this methodseldom used, it is realatively easy to analize, and it
will illustrate the centeral ideas involved in the constraction of some more advanced methods.
𝑑𝑦
= 𝑓(𝑥, 𝑦), 𝑦(𝑎) = 𝑦0 , 𝑎 ≤ 𝑥 ≤ 𝑏 (6.1)
𝑑𝑥
To begin the presentation of Euler’s method, let us divide the interval [𝑎, 𝑏] in to 𝑁 equal
intervals and define the mesh points as
𝑏−𝑎
𝑥𝑖 = 𝑥0 + 𝑖ℎ = 𝑎 + 𝑖ℎfor𝑖 = 0,1,2, … , 𝑁 with ℎ = ,ℎ is kown as the step size.
𝑁
Suppose that the exact solution of Eq. (6.1) is 𝑦(𝑥) and has continuous derivative
on[𝑎, 𝑏]applying the Taylor series expansion of 𝑦(𝑥) about the point𝑥 = 𝑥𝑖 , that is
The method is very slow and to obtain more accuracy the value of ℎ should be very small and
naturally it needs more computational time.
Prepared by Abe N 91
NUMERICAL METHODS
Example 6.2: Using Euler’s method solve the IVP 𝑦′ = 𝑦 + 𝑥 2 , 𝑦(0) = 1 , for 0 ≤ 𝑥 ≤ 0.1.
Withℎ = 0.01
𝑦1 = 𝑦0 + 𝑦0′ ℎ = 𝑦0 + ℎ𝑓(𝑥0 , 𝑦0 ) (∵ 𝑦 ′ = 𝑓)
and so on. The complete solution is given below using C++ program.
𝑖 𝑥𝑖 𝑦(𝑥𝑖 )
1 0.01 1.0100000
2 0.02 1.0201010
3 0.03 1.0303060
4 0.04 1.0406181
5 0.05 1.0510403
6 0.06 1.0615757
7 0.07 1.0722274
8 0.08 1.0829986
9 0.09 1.0938926
10 0.10 1.1049125
Prepared by Abe N 92
NUMERICAL METHODS
Withℎ = 0.1
𝑦𝑖+1 = 𝑦𝑖 + ℎ𝑓(𝑥𝑖 , 𝑦𝑖 )
𝑦1 = 𝑦0 + ℎ𝑓(𝑥0 , 𝑦0 )
= 1 + 0.1(12 − 0) = 1.1
𝑦2 = 𝑦1 + ℎ𝑓(𝑥1 , 𝑦1 )
0 1 1 10
ℎ = 0.100000
Prepared by Abe N 93
NUMERICAL METHODS
Objective
At the end of this subtopic the learner would have been able to:
1
If we approximate𝑓(𝑥, 𝑦) by 2 [𝑓(𝑥0 , 𝑦0 ) + 𝑓(𝑥1 , 𝑦1 )] instead of 𝑓(𝑥0 , 𝑦0 ) in the derivation of
ℎ
𝑦1∗ = 𝑦0 + 2 [𝑓(𝑥0 , 𝑦0 ) + 𝑓(𝑥1 , 𝑦1 )] (6.4)
The values of 𝑦1 can be obtained by Euler’s method and the ∗symbol in the super script case
denotes the modified value of 𝑦1 .Proceeding in the same way if we approximate 𝑓(𝑥, 𝑦) by
1
[𝑓(𝑥𝑛 , 𝑦𝑛 ) + 𝑓(𝑥𝑛+1 , 𝑦𝑛+1 )] instaed of 𝑓(𝑥𝑛 , 𝑦𝑛 ),then we have
2
∗ 1
𝑦𝑛+1 = 𝑦𝑛 + 2 [𝑓(𝑥𝑛 , 𝑦𝑛 ) + 𝑓(𝑥𝑛+1 , 𝑦𝑛+1 )] (6.5)
𝑦𝑛+1 = 𝑦𝑛 + ℎ𝑓(𝑥𝑛 , 𝑦𝑛 )
𝑑𝑦
Working rule: If we wish to solve 𝑑𝑥 = 𝑓(𝑥, 𝑦), 𝑦(𝑥0 ) = 𝑦0
Step 1: solve the given equation by Euler’s method to get the solution at 𝑥 = 𝑎.
Step2: substitute the value of 𝑦(𝑥 = 𝑎) obtained in step 1 in to the modified Euler’s formula.
𝑑𝑦
Example 6.5: Solve 𝑑𝑥 = 𝑥 2 + 𝑦, 𝑦(0) = 1 by using modified Euler’s method with ℎ = 0.01.
Prepared by Abe N 94
NUMERICAL METHODS
ℎ 0.01 2
𝑦1∗ = 𝑦0 + [𝑓(𝑥0 , 𝑦0 ) + 𝑓(𝑥1 , 𝑦1 )] = 1 + [0 + 1 + (0.01)2 + 1.01] = 1.01005
2 2
ℎ 0.01
𝑦2∗ = 𝑦1 + [𝑓(𝑥1 , 𝑦1 ) + 𝑓(𝑥2 , 𝑦2 )] = 1.01 + [0.012 + 1.01 + 0.022 + 1.0201010]
2 2
Objective
Euler’s method was derived from the Taylor series using two terms in the series.We can
construct an approximate solution of the IVP using a large number of terms. Assuming that the
solution 𝑦(𝑥)of the IVP has 𝑛 + 1 continuous derivatives and expanding 𝑦(𝑥) about 𝑥0 using
Taylor series expanision we have
𝑦 (𝑛+1) (𝜂)
Where remainder term 𝑅 = (𝑥 − 𝑥0 )𝑛+1 ; for some 𝜂𝜖(𝑥0 , 𝑥𝑛 )
(𝑛+1)!
Evaluating it at 𝑥 = 𝑥𝑖+1
ℎ2 ′′ ℎ3 ′′′ ℎ𝑛 (𝑛)
𝑦(𝑥𝑖+1 ) = 𝑦(𝑥𝑖 ) + 𝑦 ′ (𝑥𝑖 )ℎ + 𝑦 (𝑥𝑖 ) + 𝑦 (𝑥𝑖 ) + ⋯ + 𝑦 (𝑥𝑖 )
2! 3! 𝑛!
Prepared by Abe N 95
NUMERICAL METHODS
We obtain the derivatives using chain rule. Thus, the first few derivatives are:
𝑦 ′ (𝑥) = 𝑓(𝑥, 𝑦)
𝑑𝑓 𝜕𝑓 𝜕𝑓 𝑑𝑦
𝑦 ′′ (𝑥) = = + = 𝑓𝑥 + 𝑓𝑦 𝑓
𝑑𝑥 𝜕𝑥 𝜕𝑦 𝑑𝑥
𝝏 𝝏𝒇 𝝏𝒇 𝒅𝒚 𝝏 𝝏𝒇 𝝏𝒇 𝒅𝒚 𝒅𝒚
𝑦 ′′′ (𝑥) = ( + )+ ( + )
𝝏𝒙 𝝏𝒙 𝝏𝒚 𝒅𝒙 𝝏𝒚 𝝏𝒙 𝝏𝒚 𝒅𝒙 𝒅𝒙
Example 6.5: Using Third order Taylor’s Method approximate the solution of the IVP
𝑑𝑦
= 2𝑥 − 𝑦, 𝑦(0) = −1,0 ≤ 𝑥 ≤ 1 With 𝑁 = 5
𝑑𝑥
𝑦 ′′ = 𝑓 ′ (𝑥, 𝑦) = 2 − 𝑦 ′ = 2(1 − 𝑥) + 𝑦
Prepared by Abe N 96
NUMERICAL METHODS
𝑥2 𝑥3
𝑦(𝑥) = −1 + 𝑥 + −
2 6
Since 𝑁 = 5 ⟹ ℎ = 0.2
(0.2)2 (0.2)3
𝑦(0.2) = 𝑦(𝑥1 ) = −1 + 0.2 + − = −0.7813
2 6
(0.4)2 (0.4)3
𝑦(0.4) = −1 + 0.4 + − = −0.5307
2 6
(0.6)2 (0.6)3
𝑦(0.6) = −1 + 0.6 + − = −0.256
2 6
(0.8)2 (0.8)3
𝑦(0.8) = −1 + 0.8 + − = 0.03467
2 6
1 1
𝑦(1) = −1 + 1 + − = 0.5
2 6
Example 6.6: Obtain the first five nonzero terms in the Taylor’s series solution of the initial
𝑑𝑦
value problem 𝑑𝑥 = 𝑥 2 + 𝑦 2 , 𝑦(0) = 1.And compute 𝑦(0.1)and 𝑦(0.2).
Here 𝑦(0) = 1, 𝑦 ′ = 𝑥 2 + 𝑦 2
𝑦 ′′ = 2𝑥 + 2𝑦𝑦 ′
𝑦 ′′′ = 2 + 2[𝑦𝑦 ′ + (𝑦 ′ )2 ]
𝑦0𝑖𝑣 = 2[1 × 8 + 2 × 1 + 2 × 1 × 2] = 28
4 7
Therefore, 𝑦(𝑥) = 1 + 𝑥 + 𝑥 2 + 3 𝑥 3 + 6 𝑥 4
Prepared by Abe N 97
NUMERICAL METHODS
4 7
𝑦(0.1) = 1 + 0.1 + (0.1)2 + (0.1)3 + (0.1)4 = 1.11145
3 4
4 7
𝑦(0.2) = 1 + 0.2 + (0.2)2 + (0.2)3 + (0.2)4 = 1.25253
3 4
Objective
At the end of this subtopic students should be able to fourth order Runge-Kutta method to
solve an IVP.
Runge-Kutta Method is one of the most widly used method. It is named after two German
mathematicians Carl Runge (1856-1927) and Wilhem Kutta (1867-1944). It is particularly
suitable in cases when the computation of higher order derivatives is difficult, in this case it will
be difficult to apply higher order Taylor series method. But the Runge-Kutta methods aviode this
difficulty since no need of differentiation in the Runge–Kutta method and gives the same
accuracy as that of Taylor series method of the same order. There are different order Runge-
Kutta methods but popular and most commonly used Runge-Kutta method is the fourth order
Runge-Kutta method (4RKM) given by the formula:
1
𝑦𝑖+1 = 𝑦𝑖 + [𝑘1 + 2(𝑘2 + 𝑘3 ) + 𝑘4 ]
6
Where 𝑘1 = ℎ𝑓(𝑥𝑖 , 𝑦𝑖 )
ℎ 𝑘1
𝑘2 = ℎ𝑓 (𝑥𝑖 + , 𝑦𝑖 + )
2 2
ℎ 𝑘2
𝑘3 = ℎ𝑓 (𝑥𝑖 + , 𝑦𝑖 + )
2 2
𝑘4 = ℎ𝑓(𝑥𝑖 + ℎ, 𝑦𝑖 + 𝑘3 )
Prepared by Abe N 98
NUMERICAL METHODS
𝑑𝑦
Example 6.7: Solve = 𝑥𝑦, 𝑦(1) = 2, for 𝑥 = 1.4 using 4RKM with ℎ = 0.2.
𝑑𝑥
𝑑𝑦
Solution: Given 𝑥0 = 1, 𝑦0 = 2, 𝑑𝑥 = 𝑓(𝑥, 𝑦) = 𝑥𝑦, ℎ = 0.2
ℎ 𝑘1 0.2 0.4
𝑘2 = ℎ𝑓 (𝑥0 + , 𝑦0 + ) = 0.2𝑓 (1 + ,2 + ) = 0.2𝑓(1.1,2.2) = 0.484
2 2 2 2
ℎ 𝑘2
𝑘3 = ℎ𝑓 (𝑥0 + , 𝑦0 + ) = 0.2𝑓(1.1,2.242) = 0.4932
2 2
1
𝑦1 = 𝑦0 + (𝑘1 + 2(𝑘2 + 𝑘3 ) + 𝑘4 )
6
1
𝑦1 = 2 + (0.4 + 2(0.484 + 0.4932) + 0,5984) = 2 + 0.4921 = 2.4921
6
1
𝑦2 = 𝑦1 + 6 (𝑘1 + 2(𝑘2 + 𝑘3 ) + 𝑘4 )
ℎ 𝑘1 0.2 0.5981
𝑘2 = ℎ𝑓 (𝑥1 + , 𝑦1 + ) = 0.2𝑓 (1.2 + , 2.4921 + ) = 0.2𝑓(1.3,2.7912)
2 2 2 2
= 0.7257
ℎ 𝑘2 0.7257
𝑘3 = ℎ𝑓 (𝑥1 + , 𝑦1 + ) = 0.2𝑓 (1.3,2.4921 + ) = 0.7423
2 2 2
1
𝑦2 = 2.4921 + (0.5981 + 2(0.7257 + 0.7423) + 0.9056) = 2.4921 + 0.7400 = 3.2321
6
𝑑𝑦
Example 6.8: Solve the IVP 𝑑𝑥 = 𝑥 + 𝑦, 𝑦(0) = 1using fourth order Runge-Kutta method for
Prepared by Abe N 99
NUMERICAL METHODS
ℎ 𝑘1 0.1 0.1
𝑘2 = ℎ𝑓 (𝑥0 + , 𝑦0 + ) = 0.1𝑓 (0 + ,1 + ) = 0.1(0.05 + 1.05) = 0.11
2 2 2 2
ℎ 𝑘2
𝑘3 = ℎ𝑓 (𝑥0 + , 𝑦0 + ) = 0.1(0.05 + 1.055) = 0.1105
2 2
1
𝑦1 = 𝑦0 + (𝑘1 + 2(𝑘2 + 𝑘3 ) + 𝑘4 )
6
1
= 1 + (0.1 + 0.22 + 0.2210 + 0.12105) = 1.11034
6
0 1 0.8 8
Table 6.2____________________________________________________________
𝑖𝑥𝑖 k1 k 2 k 3 k 4 k𝑦𝑖
____________________________________________________________
1 0.10 0.1000 0.1100 0.1105 0.1211 0.1103 1.1103
2 0.20 0.1210 0.1321 0.1326 0.1443 0.1325 1.2428
3 0.30 0.1443 0.1565 0.1571 0.1700 0.1569 1.3997
4 0.40 0.1700 0.1835 0.1841 0.1984 0.1839 1.5836
5 0.50 0.1984 0.2133 0.2140 0.2298 0.2138 1.7974
6 0.60 0.2297 0.2462 0.2471 0.2644 0.2468 2.0442
0 -1 1 10
Table 6.3____________________________________________________________________
𝑖 𝑥𝑖 k1 k 2 k 3 k 4 k𝑦𝑖
____________________________________________________________________________________________
1 0.10 0.100000 0.105000 0.104750 0.109525 0.104837 -0.895163
2 0.20 0.109516 0.114040 0.113814 0.118135 0.113893 -0.781269
𝑑𝑦
Example 6:10: Solve the IVP 𝑑𝑥 = 𝑥 + 2𝑦 , 𝑦(1) = 0 for 1 ≤ 𝑥 ≤ 4withℎ = 0.5 using 4RKM.
Summary
Review exercise 6
𝑑𝑦
1. Solve the IVP 𝑑𝑥 = 𝑦𝑥 2 − 𝑦, 𝑦(0) = 1,0 ≤ 𝑥 ≤ 1, ℎ = 0.25 using Euler’s method.
2. Use Euler’s method to approximate the solution of each of the following IVPs.
𝑑𝑦 1
a. = −5𝑦 + 5𝑥 2 + 2𝑥, 0 ≤ 𝑥 ≤ 1, 𝑦(0) = 3 , ℎ = 0.1.
𝑑𝑥
𝑑𝑦 𝑦 𝑦2
b. = 𝑥 − 𝑥 2 , 1 ≤ 𝑥 ≤ 2, 𝑦(1) = 0, ℎ = 0.2.
𝑑𝑥
𝑑𝑦
c. = −(𝑦 + 1)(𝑦 + 3), 0 ≤ 𝑥 ≤ 2, 𝑦(0) = −2, ℎ = 0.2.
𝑑𝑥
𝑑𝑦
3. Given an IVP = 𝑥 2 + 𝑥 2 𝑦, 1 ≤ 𝑥 ≤ 2,withℎ = 0.2. Solve using
𝑑𝑥
Reference
[1]. Dr.B. sGrawal; Introduction to Numerical methods.
[6]. M.K. Jain, S.R.K. Iyengar, R.K. Jain; Numerical Methods for scientific and engineering
Apendix
Arsi University
Department of Computer Science
Time allowed: 15’
Name_________________________________
ID. No.____________
1. If 𝑓(𝑥) = 𝑥 4 + 3𝑥 2 + 2 and 𝑥 = 1 with error 0.002, then determine ∆𝑦. (2.5 points)
𝑦 4 𝑥+𝑥 2 𝑦
2. Given 𝜔(𝑥, 𝑦) = and 𝑥 = 2, 𝑦 = 3 with errors 0.02 and 0.03 respectively.
4𝑥
Arsi University
Department of Computer Science
Time allowed: 10’
Name_________________________________
ID. No._____________
Dept: ______________________
3. If 𝑓(𝑥) = 2𝑥 4 + 3𝑥 + 5 and 𝑥 = 1 with error 0.002, then determine ∆𝑦. (2.5 pts)
4. Given 𝜔(𝑥, 𝑦) = 21𝑥 3 𝑦 2 and 𝑥 = 2, 𝑦 = 1 with errors 0.1 and 0.2 respectively.
Based on the given determine ∆𝜔. (2.5 pts)
Arsi University
Department of Computer Science
1
Time allowed: 1 2hrs
Name_________________________________
ID. No._____________
Show all the necessary steps clearly and neatly (Use the indicated decimal places
throughout your computation).
Arsi University
Department of Computer Science
1
Time allowed: 1 2hrs
Name_________________________________
ID. No._____________
Dept: Statistics
Show all the necessary steps clearly and neatly (Use the indicated decimal places
throughout your computation).
Arsi University
Department of Computer Science
Time allowed: 1hr
Name____________________________________
ID. No._____________
Dept: Statistics
1. Given data
𝑥 2 4 6 8
𝑦 3 5 33 59
2. Use Newton’s divided difference formula to find the interpolating polynomial 𝑓(𝑥) of
Arsi University
Department of Computer Science
Time allowed: 𝟏hr
Numerical Analysis I
Name_____________________________________
ID. No._____________
Dept: ___________________
1. Given data
𝑥 -2 0 2 4 6 8 10
𝑦 -13 -7 -1 11 35 77 143
2. Use Newton’s divided difference formula to find the interpolating polynomial 𝑓(𝑥) of
Exercise 1
1 1
(1). a. 𝐸𝑎 = 30 , 𝐸𝑟 = 100 , 𝐸𝑝 = 1%
1 1
𝐸𝑎 = , 𝐸𝑟 = , 𝐸 = 10%
3 10 𝑝
2 1
𝐸𝑎 = , 𝐸𝑟 = , 𝐸𝑝 = 20%
3 5
(2).∆𝑦 = 0.002.
(3). ∆𝑢 = 0.05
Exercise 2
(1) .
Hi! Mr. Gada Enter the interval [a, b], maximum iteration and allowed error resp
1 1.54 0.05
Since 𝑓(𝑎)𝑓(𝑏) < 0 ,a root lies between a and b the iterations are:
_____________________________________________________
i a b x[i] f(x[i]) |x[i+1]-x[i]|
______________________________________________________
0 1.00000 1.50000 1.25000 0.18623
Hi! Mr. Gada Enter the interval [a, b], maximum iteration and allowed error resp
2.5 3 16 0.005
___________________________________________________
i a b x[i] f(x[i]) |x[i+1]-x[i]|
_____________________________________________________
0 2.50000 3.00000 2.75000 -2.95313
3).
Hi! Mr. Gada Please Enter a, b, maximum iteration and allowed error:
2 3 15 0.005
_____________________________________________
i a b x[i] f(x[i])
_____________________________________________
1 2.000000 3.000000 2.187500 -1.094971
2 2.187500 3.000000 2.250619 -0.351826
3 2.250619 3.000000 2.270366 -0.108360
4 2.270366 3.000000 2.276397 -0.032937
5 2.276397 3.000000 2.278226 -0.009972
__________________________________________________
The root converges after iteration 5, the root is 2.27822590
4).
Hi! Mr. Gada Please enter xo, allowed error and maximum iteration:
0.5 0.00005 12
________________________________________________
i f(x[i-1]) f'(x[i-1]) x[i] f(x[i])
________________________________________________
1 -0.377583 3.479425 0.608519 0.005060
2 0.005060 3.571653 0.607102 0.000001
3 0.000001 3.570490 0.607102 -0.000000
________________________________________________
The root converges after iteration 3, the root is 0.60710
(5).17
Exercise 3
(1). 𝑥1 = 7, 𝑥2 = −9 , 𝑥3 = 5
(2).𝑥1 = 1, 𝑥2 = −1, 𝑥3 = 0
(3). a.
Hi! Mr. Gada Please enter the elements of the augmented matrix row wise:
7 -2 1 0 17
1 -9 3 -1 13
2 0 10 1 15
1 -1 1 6 10
Hi! Mr. Gada Enter the allowed error and maximum iteration
0.00005 20
___________________________________________________
Iteration x[1] x[2] x[3] x[4]
___________________________________________________
1 3.285714 -1.222222 1.100000 1.833333
x[2]=-0.999995
x[3]=0.999994
x[4]=0.999992
(b).
Hi! Mr. Gada Please enter the elements of the augmented matrix row wise:
3 -1 1 1
3620
3374
Hi! Mr. Gada Enter the allowed error and maximum iteration
0.00005 20
________________________________________
Iteration x[1] x[2] x[3]
_________________________________________
1 1.333333 -1.000000 -1.571429
2 0.523809 -0.142857 0.428571
3 0.142857 -0.404762 0.408163
4 0.062358 -0.207483 0.683674
5 0.036281 -0.259070 0.633625
6 0.035768 -0.229349 0.666910
7 0.034580 -0.240187 0.654392
8 0.035140 -0.235421 0.659546
9 0.035011 -0.237419 0.657263
10 0.035106 -0.236593 0.658175
11 0.035077 -0.236945 0.657780
12 0.035092 -0.236799 0.657943
13 0.035086 -0.236860 0.657874
14 0.035088 -0.236835 0.657903
__________________________________________
Converges after 14 iterations, the roots are:
x[1]=0.035088
x[2]=-0.236835
x[3]=0.657903
(c).
Enter the elements of the augmented matrix row wise:
3114
-2 2 0 1
-1 2 -6 2
Hi! Mr. Gada Enter the allowed error and maximum iteration
0.00005 20
The solution vectors are:
_________________________________________
Iteration x[1] x[2] x[3]
___________________________________________
1 0.333333 2.500000 0.333333
2 0.388889 0.833333 0.444444
3 0.907407 0.888889 -0.120370
4 1.077160 1.407407 -0.188272
5 0.926955 1.577160 -0.043724
6 0.822188 1.426955 0.037894
7 0.845050 1.322188 0.005287
8 0.890842 1.345050 -0.033446
9 0.896132 1.390842 -0.033457
__________________________________________
Converges after 9 iterations, the root is:
x[1]=0.896132
x[2]=1.390842
x[3]=-0.033457
(4).𝑥 = 2, 𝑦 = 1
Exercise 4
Exercise 5
1.
i. The value of the integral using Trapezoidal rule is 10.224
1
ii. The value of the integral using Simpson’s 3is 10.2463
3
iii. The value of the integral using Simpson’s is 10.2403
8
2. i.7m/𝑠 2
ii.323.33m
3. 1.0316,0.2303
4. 1.40178
Exercise 6
_______________________________
_________________________________________________________
i x[i] k[1] k[2] k[3] k[4] k y
_________________________________________________________
1 1.20 0.2000 0.2220 0.2225 0.2499 0.2231 0.2231
2 1.40 0.2500 0.2842 0.2867 0.3320 0.2873 0.5104
3 1.60 0.3321 0.3915 0.3997 0.4857 0.4001 0.9105
4 1.80 0.4858 0.6061 0.6345 0.8374 0.6341 1.5446
5 2.00 0.8371 1.1508 1.2788 1.9943 1.2818 2.8263
________________________________________________________
Arsi University
Department of Statistics
Numerical Method Course syllabus for second year Computer Science students.
Course Information Course title: Numerical Methods for Computer Science Students
Academic Year 2021 Year: II Semester: II Enrollment: Regular Mode of Course delivery: Parallel
Students' Study Workload Gap Tutorial Lab Assessment Home Total study
distribution in hours Lecture Work study
48 32 8 47 135
Course Description The course mainly covers basic concepts in error estimation, solution of non-
linear equations, solutions of system of linear equations, finite differences,
interpolations, numerical differentiation and integration. and Numerical
solution of ODEs.
empirically
understand the roll of finite difference
grasp practical knowledge of polynomial interpolation in numerical differentiation and integration
understand range of iterative methods for solving linear and non-linear equations
translate mathematical algorithms in to computer programming
developed their scientific computation skills
Course Contents:
1 Chapter One: Basic concepts in error Lecturing, Leading, Listening and taking
Estimation discussions, Asking and short notes, asking and
answering questions, preparing answering questions,
1.1. Introduction homework, giving assignment. doing home work.
1.2. Errors
2, 3 Chapter Two: Non-linear equations Lecturing, Leading, discussions, Listening to the lesson,
&4 Asking taking short notes,
2.1. Bisection method asking
and answering questions,
2.2. False position Method Preparing and answering questions
2.3. Newton-Raphson method homework, giving assignments Doing homework and
2.4. Fixed-point Iteration and feedback to the students.
Submitting assignments.
2.5. Secant method
Chapter Three: Solution of System of Lecturing, Leading, discussions, Listening to the lesson,
equations Asking take short notes, asking
and
Equations linear equations and answering questions,
5 Preparing Answering questions,
and 3.1. Direct methods doing homework
6 homework, giving feedbacks to
3.1.1. Gauss Elimination method the students.
3.1.3. LU Decomposition
8 Chapter Four: Difference Operators & Lecturing, Leading, discussions, Listening to the lesson,
Interpolation Asking and answering questions, take short notes, asking
preparing homework, giving and answering
4.1.1. Forward difference operator feedback to home take exam. questions,
4.1.2. Backward difference Operators
11& Chapter Five: Numerical Lecturing, Leading, discussions, Listening to the lesson,
12 Differentiation and Integration Asking and answering questions, take short notes, asking
preparing homework, giving and answering
5.1 Numerical Differentiation feedback to home take exam. questions,
5.2 Numerical Integration (Trapezoidal
and Simpson's Rules)
13& Chapter Six: Numerical solution of Lecturing, Leading, discussions, Listening to the lesson,
14 Ordinary Differential Equations Asking and answering questions, take short notes, asking
preparing homework, giving and answering questions
6.1. Taylor’s series method
The course will be delivered through different ways of instructional methods including gap
lectures, discussions, individual work, group work, assignments, problem solving, presentation
of individual and group works.
Course Requirements/Policies:
All the University policies, and departmental policies regarding academic integrity, including
plagiarism, apply and will be enforced in this course. Specifically: -
Class attendance of at least 90% is required to sit for the final examination,
You are required to do individual assignments, group assignments, and presentation of
assignments,
You are required to collect assignments and submit the assignments due date. No late
assignments submission will be accepted. Copying and getting answers from someone
else will result zero mark.
You should take all tests and assignments as scheduled. If you miss, no makeup class
will be arranged for you unless you reported before and bring sufficient evidence,
Cheating will be strictly forbidden,
You should turn off your mobile phone during session and exam room.
The first thing to learn is discipline! The rest comes after it.
Assessment Types and their results:
Schedule of Assessments
Quizzes, Assignments, and Tests Date Week Percentage (%) Remark
Schedule
Quiz 1 Chapter 1 2 5 Compulsory
Test 1 Chapter 2 3 10 Compulsory
Assignment I Chapter 3 3 10 Compulsory
Quiz 2 Chapter 4 6 5 Compulsory
Test 2 Chapter 4 7 10 Compulsory
Test 3 Chapter 5 9 10 Compulsory
Project I Chapter 11 10 Compulsory
The final grading system of students' result is based on "criteria referenced" system
Students group assignment grading includes written work and classroom presentation of
written workout problems
Textbook: Dr. B. S. Grewal, Numerical Methods in Engineering and science