Numerical Methods Course Overview
Numerical Methods Course Overview
2016 E.C
CHAPTER ONE
The chapter gives the use of Numerical methods and introduces the fundamental concepts of
Numerical methods such as Relative error, absolute error, approximate error, round off error and
truncation error. Also it introduces about significant digits, Taylor’s theorem etc.
Objective
Introduction
Mathematical models are an integral part in solving engineering problems. Many times, these
mathematical models are derived from engineering and science principles, while at other times
the models may be obtained from experimental data.
Mathematical models generally result in need of using mathematical procedures that
include but are not limited to
(A) differentiation,
(B) nonlinear equations,
(C) simultaneous linear equations,
(D) curve fitting by interpolation or regression,
(E) integration, and
(F) differential equations.
These mathematical procedures may be suitable to be solved exactly as you must have
experienced in the series of calculus or applied mathematics courses you have taken, but in most
cases, the procedures need to be solved approximately using numerical methods. Numerical or
Computational methods is a subject concerned with developing methods for computing, usually
approximately, the solution of mathematical expressions which can’t be solved analytically.
Truncation error:
Truncation error is defined as the error caused by truncating a mathematical procedure. For
example, the Maclaurin series for e x is given as
x2 x3
ex 1 x ....................
2! 3!
This series has an infinite number of terms but when using this series to calculate e x , only a
finite number of terms can be used. For example, if one uses three terms to calculate e x , then
x2
ex 1 x .
2!
the truncation error for such an approximation is
Significant Figures
The significant figures (sig figs) of a number are the digits from the first nonzero digit on the
left to either last digit (zero or non) on the right if there is a decimal, or last nonzero digit of a
number if there is no decimal.
• 2300 or 2.3×103 has 2 sig figs
• 2300. or 2.300×103 has 4 sig figs
• 2300.0 or 2.3000×103 has 5 sig figs
• 23,040 or 2.304×104 has 4 sig figs
• 0.035 or 3.5×10-2 has 2 sig figs
• 0.03500 or 3.500×10-2 has 4 sig figs
Taylor Series:
From Maclaurin series, we have
x2 x4 x6
cos( x) 1 (1)
2! 4! 6!
x3 x5 x7
sin( x) x (2)
3! 5! 7!
x 2 x3
ex 1 x (3)
2! 3!
All the above expressions are actually a special case of Taylor series called the Maclaurin series.
Why are these applications of Taylor’s theorem important for numerical methods? Expressions
such as given in Equations (1), (2) and (3) give you a way to find the approximate values of these
functions by using the basic arithmetic operations of addition, subtraction, division, and
multiplication.
Questions
2. Chapra, S.C and Canale, R.P., Numerical methods for engineers, McGraw – Hill
international edition, 6th edition, 2010.
CHAPTER TWO
This chapter discusses about various methods such as Bisection method, False position method,
Secant method, Newton- Raphson method their advantages and drawbacks for solving non linear
equations.
Learning objectives
After completing this course the students will be able to:
Explain Bisection method and apply to solve engineering problems (K, L3)
Derive False position method Apply False position method to
solve engineering problems (K, L3)
Derive Secant method and apply to solve engineering problems (K, L3)
Derive Newton- Raphson method and apply to solve engineering problems (K, L3)
Introduction
Most of Engineering Problems are complex and difficult to solve analytically. If the modelling
equation is linear and quadratic equation it is possible to solve analytical and using the general
formula of quadratic equation. But if our modelling equation is Non-linear equation we have no
general formula to solve our modelling problem. There are two common numerical method two
solve non-linear equation the first one is closed – domain (Bracketing) the other one is Open
domain method.
Since the root is bracketed between two points, x and xu , one can find the mid-point,
xm between x and xu . This gives us two new intervals
1. x and xm , and
2. xm and xu .
Introduction
In chapter 03.03, the bisection method was described as one of the simple bracketing methods
for solving a nonlinear equation of the general form
f ( x) 0 (1)
f x
f xU
Exact root
xL
O xr xU x
f xL
The above nonlinear equation can be stated as finding the value of xsuch that Equation (1) is
satisfied. In the bisection method, we identify proper values of x L (lower bound value) and xU
(upper bound value) for the current bracket, such that
f ( xL ) f ( xU ) 0 . (2)
The next predicted/improved root xm can be computed as the midpoint between x L and xU as
x L xU
xm (3)
2
False-Position Method
Based on two similar triangles, shown in Figure 1, one gets
0 f ( x L ) 0 f ( xU )
(4)
xm x L xm xU
The above equation can be solved to obtain the next predicted root xm as
xU f x L x L f xU
xm (5)
f x L f xU
The above equation, through simple algebraic manipulations, can also be expressed as
f xU
x m xU (6)
f x L f xU
x L xU
or
f x L
xm x L
f xU f x L
xU x L
Introduction
Methods such as the bisection method and the false position method of finding roots of a
nonlinear equation f ( x) 0 require bracketing of the root by two guesses. Such methods are
called bracketing methods. These methods are always convergent since they are based on
reducing the interval between the two guesses so as to zero in on the root of the equation.
In the Newton-Raphson method, the root is not bracketed. In fact, only one initial guess
of the root is needed to get the iterative process started to find the root of an equation. The
method hence falls in the category of open methods. Convergence in open methods is not
guaranteed but if the method does converge, it does so much faster than the bracketing methods.
Derivation
The Newton-Raphson method is based on the principle that if the initial guess of the root of
f ( x) 0 is at xi , then if one draws the tangent to the curve at f ( xi ) , the point xi 1 where the
tangent crosses the x -axis is an improved estimate of the root (Figure 1).
f xi 0
f xi = tan θ =
xi xi 1
which gives
f xi
xi 1 = xi (1)
f xi
Equation (1) is called the Newton-Raphson formula for solving nonlinear equations of the form
f x 0 . So starting with an initial guess, xi , one can find the next guess, xi 1 , by using
Equation (1). One can repeat this process until one finds the root within a desirable tolerance.
f ( xi )
xi 1 = xi (1)
f ( xi )
One of the drawbacks of the Newton-Raphson method is that you have to evaluate the derivative
of the function. With availability of MATLAB etc, this process has become more convenient.
However, it still can be a laborious process, and even intractable if the function is derived as part
of a numerical scheme. To overcome these drawbacks, the derivative of the function, f (x) is
approximated as
f ( xi ) f ( xi 1 )
f ( xi ) (2)
xi xi 1
f ( xi )( xi xi 1 )
xi 1 xi (3)
f ( xi ) f ( xi 1 )
The above equation is called the secant method. This method now requires two initial guesses,
but unlike the bisection method, the two initial guesses do not need to bracket the root of the
equation. The secant method is an open method and may or may not converge. However, when
secant method converges, it will typically converge faster than the bisection method. However,
since the derivative is approximated as given by Equation (2), it typically converges slower than
the Newton-Raphson method.
The secant method can also be derived from geometry,as shown in Figure 1. Taking two initial
guesses, xi 1 and xi , one draws a straight line between f ( xi ) and f ( xi 1 ) passing through the x -
axis at xi 1 . ABE and DCE are similar triangles.
Hence
AB DC
AE DE
f ( xi ) f ( xi 1 )
xi xi 1 xi 1 xi 1
f ( xi )( xi xi 1 )
xi 1 xi
f ( xi ) f ( xi 1 )
Questions
Question 1: Derive the Bisection method, False position method, Secant method, Newton-
Raphson methods.
Question 2: Bisection method and Newton - Raphson methods advantages and drawbacks for
solving non linear equations.
Question 3: Find the roots of the equation x 3 0.165x 2 3.993 104 0
by using the following methods?
i) Bisection method ii) False position method
iii) Secant method iv) Newton - Raphson method
Question 4: Find the root of equation x + sinx -1 = 0 using Newton - Raphson method.
Question 5: Find the real root of equation ex – 4x2 = 0 using Bisection method.
References
1. M.K. Jain, S.R.K Iyengar and R.K Jain “ Numerical Methods for Scientific and
engineering computation” Sixth edition, New age international publishers. P.P: 18 - 50.
2. Chapra, S.C and Canale, R.P., Numerical methods for engineers, McGraw – Hill
international edition, 6th edition, 2010.
CHAPTER THREE
The chapter gives formation of matrices from linear equations and discusses about solution of
different matrices. Various methods such as Gauss elimination, Gauss – Seidel method and LU
Decomposition methods are applied to solve engineering problems.
Learning objectives
Introduction
……………………………………
…………………………………….
AX C , where A is called the coefficient matrix, C is called the right hand side vector and
X is called the solution vector.
Sometimes AX C systems of equations are written in the augmented form. That is
[A][X]= [B]
. .
. .
. .
a 21 a a
a 21 x1 a12 x2 ... 21 a1n xn 21 b1
a11 a11 a11
Now, this equation can be subtracted from the second equation to give
a a a
a 22 21 a12 x 2 ... a 2 n 21 a1n x n b2 21 b1
a11 a11 a11
or
x2 ... a2 n xn b2
a22
where
This procedure of eliminating x1 , is now repeated for the third equation to the n th equation to
reduce the set of equations as
x2 a23
a22 x3 ... a2 n xn b2
x2 a33
a32 x3 ... a3 n xn b3
. . .
. . .
This is the end of the first step of forward elimination. Now for the second step of forward
elimination, we start with the second equation as the pivot equation and a22 as the pivot element.
(the pivot
So, to eliminate x 2 in the third equation, one divides the second equation by a22
. This is the same as multiplying the second equation by
element) and then multiply it by a32
/ a22
a32 and subtracting it from the third equation. This makes the coefficient of x 2 zero in the
third equation. The same procedure is now repeated for the fourth equation till the n th equation
to give
x2 a23
a22 x3 ... a2 n xn b2
. . .
. . .
The next steps of forward elimination are conducted by using the third equation as a pivot
equation and so on. That is, there will be a total of n 1 steps of forward elimination. At the
end of n 1 steps of forward elimination, we get a set of equations that look like
x2 a23
a22 x3 ... a2 n xn b2
. . .
. . .
n 1
ann xn bnn 1
Back Substitution:
Now the equations are solved starting from the last equation as it has only one unknown.
bn( n 1)
xn ( n 1)
a nn
Then the second last equation, that is the (n 1) th equation, has two unknowns: x n and xn 1 , but
x n is already known. This reduces the (n 1) th equation also to one unknown. Back
substitution hence can be represented for all equations by the formula
j i 1
xi for i n 1, n 2,,1
aiii 1
and
bn( n 1)
xn ( n 1)
a nn
In certain cases, such as when a system of equations is large, iterative methods of solving
equations are more advantageous. Elimination methods, such as Gaussian elimination, are prone
to large round-off errors for a large set of equations. Iterative methods, such as the Gauss-Seidel
method, give the user control of the round-off error. Also, if the physics of the problem are well
known, initial guesses needed in iterative methods can be made more judiciously leading to
faster convergence.
What is the algorithm for the Gauss-Seidel method? Given a general set of n equations and n
unknowns, we have
. . .
. . .
If the diagonal elements are non-zero, each equation is rewritten for the corresponding unknown,
that is, the first equation is rewritten with x1 on the left hand side, the second equation is
rewritten with x 2 on the left hand side and so on as follows.
c2 a21 x1 a23 x3 a2 n xn
x2
a22
cn 1 an 1,1 x1 an 1, 2 x2 an 1,n 2 xn 2 an 1,n xn
xn 1
an 1,n 1
cn an1 x1 an 2 x2 an ,n 1 xn 1
xn
ann
.
.
n
c n 1 a
j 1
n 1, j xj
j n 1
x n 1
a n 1,n 1
Now to find xi ’s, one assumes an initial guess for the xi ’s and then uses the rewritten equations
to calculate the new estimates. Remember, one always uses the most recent estimates to
calculate the next estimates, xi . At the end of each iteration, one calculates the absolute relative
approximate error for each xi as
x inew x iold
a 100
i
x inew
where xinew is the recently obtained value of xi , and xiold is the previous value of xi .
When the absolute relative approximate error for each xi is less than the pre-specified
tolerance, the iterations are stopped.
It is possible to show that any square matrix A can be expressed as a product of a lower
triangular matrix L and an upper triangular matrix U:
A= LU
The process of computing L and U for a given A is known as LU decomposition or LU
factorization. LU decomposition is not unique (the combinations of L and U for a prescribed A
are endless), unless certain constraints are placed on L or U.
After decomposing A, it is easy to solve the equations Ax =B. We first rewrite the equations as
LUx = B. Upon using the notation Ux = D, the equations become
LD = B
which can be solved for D by forward substitution. Then
Ux = D
will yield x by the back substitution process.
The advantage of LU decomposition over the Gauss elimination method is that once A is
decomposed, we can solve Ax = B for as many constant vectors B as we please. The cost of each
additional solution is relatively small, since the forward and back substitution operations are
much less time consuming than the decomposition process.
Questions
Question1: Write the formation of matrices from the system of linear eqautions?
Question2: Explain the step by step procedure involved Gauss elimination method and
Gauss – Seidel methods.
Question3: Solve the following system of linear equations by using Gauss elimination
Method and LU Decomposition methods
4x – 2y + z = 15, -3x –y + 4z = 8 and x – y + 3z = 13
Question4: Solve by Gauss – Siedel method, the following system of equations
20x + y -2z = 17, 3x + 20y – z = -18, 2x -3y + 20 z = 25
References:
1. M.K. Jain, S.R.K Iyengar and R.K Jain “Numerical Methods for Scientific and
engineering computation” Sixth edition, New age international publishers. P.P: 104 -
152.
2. Chapra, S.C and Canale, R.P., Numerical methods for engineers, McGraw – Hill
international edition, 6th edition, 2010.
CHAPTER FOUR
CURVE FITTING
This chapter deals with Lagrange and Newton’s divided difference interpolation methods to
solve curve fitting problems and least squares method to fit regression linear and polynomial
models.
Objectives
y a0 a1 x ............... a n x n (1)
through the data, where a0 , a1 ,........., an are n 1 real constants. Since n 1 values of y are
given at n 1 values of x , one can write n 1 equations. Then the n 1 constants,
a0 , a1 ,........., an can be found by solving the n 1 simultaneous linear equations. To find the
value of y at a given value of x , simply substitute the value of x in Equation 1.
Given ( x0 , y0 ) and ( x1 , y1 ), fit a linear interpolant through the data. Noting y f (x) and
y1 f ( x1 ) , assume the linear interpolant f1 ( x) is given by (Figure 2)
f1 ( x) b0 b1 ( x x0 )
Since at x x0 ,
f1 ( x0 ) f ( x0 ) b0 b1 ( x0 x0 ) b0
and at x x1 ,
f1 ( x1 ) f ( x1 ) b0 b1 ( x1 x0 )
f ( x0 ) b1 ( x1 x0 )
giving
f ( x1 ) f ( x0 )
b1
x1 x0
So
b0 f ( x0 )
f ( x1 ) f ( x0 )
b1
x1 x0
f ( x1 ) f ( x0 )
f 1 ( x) f ( x0 ) ( x x0 )
x1 x0
x1 , y1
f1 x
x0 , y0
x
Quadratic Interpolation
Given ( x0 , y0 ), ( x1 , y1 ), and ( x 2 , y 2 ), fit a quadratic interpolant through the data. Noting y f (x),
y0 f ( x0 ), y1 f ( x1 ), and y 2 f ( x 2 ), assume the quadratic interpolant f 2 ( x) is given by
f 2 ( x) b0 b1 ( x x0 ) b2 ( x x0 )( x x1 )
At x x0 ,
f 2 ( x0 ) f ( x0 ) b0 b1 ( x0 x0 ) b2 ( x0 x0 )( x0 x1 )
b0
b0 f ( x0 )
At x x1
f 2 ( x1 ) f ( x1 ) b0 b1 ( x1 x0 ) b2 ( x1 x0 )( x1 x1 )
giving
f ( x1 ) f ( x0 )
b1
x1 x0
At x x2
f 2 ( x2 ) f ( x2 ) b0 b1 ( x2 x0 ) b2 ( x2 x0 )( x2 x1 )
f ( x1 ) f ( x0 )
f ( x 2 ) f ( x0 ) ( x2 x0 ) b2 ( x2 x0 )( x2 x1 )
x1 x0
Giving
f ( x 2 ) f ( x1 ) f ( x1 ) f ( x0 )
x 2 x1 x1 x0
b2
x 2 x0
f 2 ( x) b0 b1 ( x x0 ) b2 ( x x0 )( x x1 )
f ( x2 ) f ( x1 ) f ( x1 ) f ( x0 )
f ( x1 ) f ( x0 ) x2 x1 x1 x0
f ( x0 ) ( x x0 ) ( x x0 )( x x1 )
x1 x0 x2 x0
x1 , y1
x2 , y 2
f 2 x
x0 , y0
x
f 2 ( x) b0 b1 ( x x0 ) b2 ( x x0 )( x x1 )
where
b0 f ( x0 )
f ( x1 ) f ( x0 )
b1
x1 x0
f ( x 2 ) f ( x1 ) f ( x1 ) f ( x0 )
x 2 x1 x1 x0
b2
x 2 x0
Note that b0 , b1 , and b2 are finite divided differences. b0 , b1 , and b2 are the first, second, and third
finite divided differences, respectively. We denote the first divided difference by
f [ x0 ] f ( x0 )
f ( x1 ) f ( x0 )
f [ x1 , x0 ]
x1 x0
f [ x2 , x1 ] f [ x1 , x0 ]
f [ x2 , x1 , x0 ]
x 2 x0
f ( x 2 ) f ( x1 ) f ( x1 ) f ( x0 )
x 2 x1 x1 x0
x 2 x0
Rewriting,
f 2 ( x) f [ x0 ] f [ x1 , x0 ]( x x0 ) f [ x2 , x1 , x0 ]( x x0 )( x x1 )
This leads us to writing the general form of the Newton’s divided difference polynomial for n 1 data
points, x0 , y0 , x1 , y1 ,......,xn1 , yn1 , xn , yn , as
where
b0 f [ x0 ]
b1 f [ x1 , x0 ]
b2 f [ x2 , x1 , x0 ]
bn f [ xn , xn1 ,....,x0 ]
bm f [ xm ,........,x0 ]
f [ xm ,........,x1 ] f [ xm 1 ,........,x0 ]
xm x0
From the above definition, it can be seen that the divided differences are calculated recursively.
f 3 ( x) f [ x0 ] f [ x1 , x0 ]( x x0 ) f [ x 2 , x1 , x0 ]( x x0 )( x x1 )
f [ x3 , x 2 , x1 , x0 ]( x x0 )( x x1 )( x x 2 )
b0
b1
b2
x0 f x0
f x1 , x0
b3
x1 f x1 f x2 , x1 , x0
x2 f x2 f x3 , x2 , x1
f x3 , x2
x3 f x3
Linear Regression
Linear regression is the most popular regression model. In this model, we wish to predict
response to n data points ( x1 , y1 ), ( x2 , y2 ),......,( xn , yn ) by a regression model given by
y a0 a1 x (1)
A measure of goodness of fit, that is, how well a0 a1 x predicts the response variable y
is the magnitude of the residual i at each of the n data points.
Ei yi (a0 a1 xi ) (2)
Ideally, if all the residuals i are zero, one may have found an equation in which all the
points lie on the model. Thus, minimization of the residual is an objective of obtaining
regression coefficients.
The most popular method to minimize the residual is the least squares methods, where
the estimates of the constants of the models are chosen such that the sum of the squared residuals
n
E
2
is minimized, that is minimize i .
i 1
Why minimize the sum of the square of the residuals? Why not, for instance, minimize the
sum of the residual errors or the sum of the absolute values of the residuals? Alternatively,
constants of the model can be chosen such that the average residual is zero without making
individual residuals small. Will any of these criteria yield unbiased parameters with the smallest
variance? All of these questions will be answered below.
To explain this data by a straight line regression model,
y a0 a1 x (3)
n n 2
S r Ei yi a0 a1 xi
2
(9)
i 1 i 1
S r n
2 yi a0 a1 xi 1 0 (10)
a0 i 1
S r n
2 yi a0 a1 xi xi 0 (11)
a1 i 1
giving
n n n
yi a0 a1 xi 0 (12)
i 1 i 1 i 1
n n n
y i x i a 0 x i a1 x i2 0 (13)
i 1 i 1 i 1
n
Noting that a
i 1
0 a 0 a 0 . . . a 0 na0
n n
na0 a1 xi y i (14)
i 1 i 1
n n n
a 0 x i a1 x i2 x i y i (15)
i 1 i 1 i 1
( xn , yn )
y
xi , yi
Ei yi a0 a1 xi
x2 , y 2
x3 , y3
y a0 a1 x
x1 , y1
x
Figure 4.4 Linear regression of y vs. x data showing residuals and square of residual at a
typical point, xi .
xi2 y i xi xi y i
i 1 i 1 i 1 i 1
a0 2
(17)
n
n
n x i2 x i
i 1 i 1
Redefining
_ x
i 1
i
x (20)
n
_ y
i 1
i
y (21)
n
we can rewrite
_ _
a 0 y a1 x
Questions
Question 2: Find a polynomial P(x) that interpolates the points {(-1,2), (0,3), (2,-1), (5,1)} using
the Lagrange method. Hence find out P(2.5).
Question 3:Derive linear and quadratic interpolation equations by using Newton’s divided
difference method?
Question 4: Using Newton’s divided differences, find the cubic polynomial for the following
data.
x: 0 1 2 3
y: 1 2 1 10
Question 5: Fit the curve of the form y = a + bx by the method of least squares from the
following data.
x 0 5 10 15 20 25
y 12 15 17 22 24 30
References:
1. M.K. Jain, S.R.K Iyengar and R.K Jain “Numerical Methods for Scientific and
engineering computation” Sixth edition, New age international publishers. P.P: 210 -
290.
2. Chapra, S.C and Canale, R.P., Numerical methods for engineers, McGraw – Hill
international edition, 6th edition, 2010.
CHAPTER FIVE
NUMERICAL DIFFERENTIATION
5.1) Introduction
In the case of differentiation, we first write the interpolating formula on the interval (x0,xn) and
differentiate the polynomial term by term to get an approximated polynomial to the derivative of
the function. When the tabular points are equidistant, we can use the finite divided differences
such as Central, backward and forward differences formula.
Questions
Question 1: Given the evenly spaced data points find first and second derivatives?
References
1. M.K. Jain, S.R.K Iyengar and R.K Jain “Numerical Methods for Scientific and
engineering computation” Sixth edition, New age international publishers. P.P: 348 -
370.
2. Chapra, S.C and Canale, R.P., Numerical methods for engineers, McGraw – Hill
international edition, 6th edition, 2010.
CHAPTER SIX
NUMERICAL INTEGRATION
The chapter deals with Trapezoidal rule, Simpson’s 1/3rd & 3/8th rules and Gauss quadrature
rules - single and multi segmental rules to solve numerical integration problems.
Objectives
After completing this course the students will be able to:
to yield
where h=(b-a)/3. This equation is called Simpson’s 3/8 rule since h is multiplied by 3/8.
Questions
Question 2: Derive Single segment and multi segment Simpson’s 1/3rd rule?
Question 3: Evaluate ∫ dx/(1 + x2) with Trapezoidal rule from limits 0 to 1 with h = 1/6
Question 4: Evaluate ∫ dx/x with Simpson’s 1/3 rd rule from limits 0 to 1 with h =1/4.
Question 5: Evaluate ∫ eSinx with Simpson’s 3/8 th rule from limits 0 to π/2.
References
3. M.K. Jain, S.R.K Iyengar and R.K Jain “Numerical Methods for Scientific and
engineering computation” Sixth edition, New age international publishers. P.P: 348 -
370.
4. Chapra, S.C and Canale, R.P., Numerical methods for engineers, McGraw – Hill
international edition, 6th edition, 2010.
CHAPTER SEVEN
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS
These chapter deals with Euler’s method, Modified Euler’s method, Runge – Kutta 4th order
method and Finite difference method to solve ordinary differential equations.
Learning objectives
Questions
References
i. M.K. Jain, S.R.K Iyengar and R.K Jain “Numerical Methods for Scientific and
engineering computation” Sixth edition, New age international publishers. P.P:
425 - 585.
ii. Chapra, S.C and Canale, R.P., Numerical methods for engineers, McGraw – Hill
international edition, 6th edition, 2010.