Professional Documents
Culture Documents
Welcome!!
A.Y. 2021-22
Semester II
Computational Methods &
Programming
[ME-21009]
Course instructor:
Abhishek D. Patange, Ph.D.
• Assistant Professor, Mechanical Engineering, COEP
• Ph.D. in Application of Machine Learning for condition
monitoring, VIT, Vellore.
• Master’s : Design Engineering, COEP, Pune
• Bachelor's: Mechanical Engineering, COEP, Pune
Area of expertise:
• Mechatronics, Hydraulics & Pneumatics, Numerical Methods, Theory of Machines,
Analysis and Synthesis of Mechanism, Health monitoring & Predictive analytics,
Data acquisition/Instrumentation, The application of machine learning for
Mechanical Engineering.
• Numerical Methods: Numerical solutions of linear and non-linear algebraic equations; integration
by trapezoidal and Simpson’s rules; single and multi-step methods for differential equations
• Calculus: Functions of single variable, limit, continuity and differentiability, mean value theorems,
indeterminate forms; evaluation of definite and improper integrals; double and triple integrals;
partial derivatives, total derivative, Taylor series (in one and two variables), maxima and minima,
Fourier series; gradient, divergence and curl, vector identities, directional derivatives, line, surface
and volume integrals, applications of Gauss, Stokes and Green’s theorems.
• Differential equations: First order equations (linear and nonlinear); higher order linear differential
equations with constant coefficients; Euler-Cauchy equation; initial and boundary value problems;
Laplace transforms; solutions of heat, wave and Laplace's equations.
• Complex variables: Analytic functions; Cauchy-Riemann equations; Cauchy’s integral theorem and
integral formula; Taylor and Laurent series.
F=ma (1)
• F = net force acting on the body (N, or kg m/s2)
• m = mass of the object (kg)
• a = its acceleration (m/s2)
Continue..
• The second law can be recast in the format of generalised
equation by merely dividing both sides by m to give
a=F/m (2)
• Note:
For this simple case there is no independent variable because we are not yet
predicting how acceleration varies in time or space.
Continue..
• Because of its simple algebraic form, the solution of Eq. (1)
can be obtained easily.
dv / dt = F / m (3)
• where v is velocity (m/s) and t is time (s).
• For a body falling within the vicinity of the earth, the net
force is composed of two opposing forces:
F = FD + FU (4)
Continue..
• If the downward force is assigned a positive sign, the
second law can be used to formulate the force due to
gravity, as
FD = mg (5)
FU = −cv (6)
• where c = a proportionality constant called the drag
coefficient (kg/s).
• Thus, the greater the fall velocity, the greater the upward
force due to air resistance.
Continue..
• The net force is the difference between the downward and
upward force. Therefore,
dv / dt = g – (c/ m) * v (8)
Continue..
• Equation (8) is a model that relates the acceleration of a
falling object to the forces acting on it.
(9)
• Problem Statement.
Welcome!!
Session 2
Summary of last session..
A simple mathematical model
F=ma (1)
a=F/m (2)
dv / dt = F / m (3)
F = FD + FU (4)
FD = mg (5)
FU = cv (6)
but F = mg – cv
dv / dt = ( mg – cv ) / m (7)
dv / dt = g – (c/ m) * v (8)
∆𝒗
A
v(ti)
ti ∆𝒕 ti + 1 time
Continue…
• So you might come with the doubt that, why is
approximated response is considered as straight line???
(10)
dv / dt = g – (c/ m) * v (8)
• Notice that the term in brackets is the right-hand side of the
differential equation itself [Eq. 8].
• Hence term v (ti+1) can only be kept on left hand side and
rearranging other terms we get,
(11)
• Thus, the differential equation has been transformed into an
equation that can be used to determine the velocity
algebraically at ti+1 using the slope and previous values of v
and t.
Continue:
• Using the same values from Example 1, Eq. (11) can be used
to compute velocity at ti+1 = 2 s:
Example 2: Numerical Solution to the Falling Parachutist Problem
Example 2: Numerical Solution to the Falling Parachutist Problem
• It can be seen that the numerical method captures the essential features
of the exact solution.
• One way to minimize such discrepancies is to use a smaller step size. For
example, applying Eq. (11) at l-s intervals results in a smaller error, as the
straight-line segments track closer to the true solution.
• However, with the aid of the computer, large numbers of calculations can
be performed easily.
• Thus, you can accurately model the velocity of the falling parachutist
without having to solve the differential equation exactly.
Assignment for the 1st week
1. (A & B batch) Use calculus to solve Eq. (8) for the case where the initial
velocity, v(0) is nonzero.
2. (C & D batch) Rather than the linear relationship of Eq. (6), you might
choose to model the upward force on the parachutist as a second order
relationship,
FU = − c′ * 𝑣 2
where c′ = a second-order drag coefficient (kg/m).
a) Using calculus, obtain the closed-form solution for the case where the
jumper is initially at rest (v = 0 at t = 0).
b) Repeat the numerical calculation in Example 3 with the same initial
condition and parameter values. Use a value of 0.225 kg/m for c′.
Use Euler’s method to solve for the depth y from t = 0 to 10 d with a step size
of 0.5 d. The parameter values are A = 1200 m2 and Q = 500 m3/d. Assume
that the initial condition is y = 0.
Submission mode for submission:
• You can submit either handwritten or typed scanned copy (PDF
compulsory) of your solution by 9th August 2020.
• The name of PDF should be your MIS number (Do not write name or
division).
(1)
can be used to solve
(2)
• The values calculated with Eq. (1) are called the “roots” of Eq. (2).
They represent the values of x that make Eq. (2) equal to zero.
• Although the quadratic formula is handy for solving Eq. (2), there are
many other functions for which the root cannot be determined so
easily.
Continue…
• There were several ways to solve for roots of algebraic and transcendental
equations.
• For some cases, the roots could be obtained by direct methods, as was
done with Eq. (1).
• Although there were equations like this that could be solved directly,
there were many more that could not.
• If not (as is almost always the case), another guess is made, and f (x) is
again evaluated to determine whether the new value provides a better
estimate of the root.
• Such haphazard methods are obviously inefficient and inadequate for the
requirements of engineering practice. Hence systematic strategies are
required to determine the true root.
Continue…
• An example of such a model is the equation, derived from Newton’s
second law, used in previous for the parachutist’s velocity:
(3)
• If the parameters are known, Eq. (3) can be used to predict the
parachutist’s velocity as a function of time.
• Try it.
(4)
• The value of c that makes f (c) = 0 is, therefore, the root of the equation.
This value also represents the drag coefficient that solves the design
problem.
‘Algebraic’ &‘Transcendental’ equations
• By definition, a function given by y = f (x) is algebraic if it can be expressed
in the form
(5)
(6)
• where n = the order of the polynomial and the a’s = constants. Some
specific examples are
(7,8)
‘Algebraic’ &‘Transcendental’ equations
• A transcendental function is one that is non-algebraic.
(9)
(10)
• These methods start with guesses that bracket, or contain, the root and
then systematically reduce the width of the bracket. Two specific methods
are to be studied: bisection and false position.
• Open methods
• This point, which represents the x value for which f (x) = 0, provides a
rough approximation of the root.
(11)
• This is useful for providing rough initial guesses required for graphical
methods.
Bisection method
Step 1: Choose lower x1 and upper x2 guesses for the root such that the
function changes sign over the interval.
This can be checked by ensuring that f (x1)*f(x2) < 0 or
Sign of f(x1) and f(x2) are opposite.
x1
x x3 x2
x1 x3
x x2
F(x3)
f(x1)
X3 = (x1 + x2 )/2
Y = f(x)
f(x2)
x1 x3
x x2
F(x1) F(x3)
X3 = (x1 + x2 )/2
Bisection method
3 2
𝑓 𝑥 = 𝑥 − 𝑥 − 20
Step 1: let’s assume initial guess starting from 0 with the step size of 1.
First guess x = 0 and f(x) = - 20
Second guess x = 1 and f(x) = - 20
Third guess x = 2 and f(x) = - 16
Fourth guess x = 3 and f(x) = - 2
Fifth guess x = 4 and f(x) = 28
Sixth guess x = 5 and f(x) = 80
The sign of function changes between guesses 3 and 4,
hence select x1 = 3 and x2 = 4
OR
Also check whether f (x1)*f(x2) < 0
x = 3 and f(x) = - 2 and x = 4 and f(x) = 28
So f (x1)*f(x2) = - 2*28 = -56 which is < 0
Hence initial guesses are correct.
Step 2: Find out x3 which is nothing but next approximated root bracketing
first two initial guesses.
x3 = (x1 + x2) / 2 i.e. = (3 + 4) /2 = 3.5
Bisection method
3 2
𝑓 𝑥 = 𝑥 − 𝑥 − 20
Step 3: Find f (x3) and check the sign.
x3 = 3.5 hence f(x3) = 10.62 (Positive)
𝑓 𝑥 = cos 𝑥 − 1.3𝑥
The accuracy = 0.01
Initial guesses are not given.
Solution:
Lets start with finding out initial guesses.
Note: whenever the equation contains trigonometric terms, keep the calculator
in RADIAN mode.
Assume initial guess as 0 and find f(x), we get f(x) = 1
Assume initial guess as 0.5 and find f(x), we get f(x) = 0.2275
Assume initial guess as 1 and find f(x), we get f(x) = – 0.7596
Or check the condition f(0.5)*f(1) < 0 or not,
hence 0.2275* – 0.7596 = – 0.1728 < 0
Hence lets assume x1 = 0.5 and x2 = 1
Bisection method
Iteration 1:
x1 = 0.5 and x2 = 1 as f(x1) = 0.2275 and f(x2) = – 0.7596
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.5 + 1)/2 = 0.75
Find f(x3) = cos (0.75) – 1.3*0.75 = – 0.2433 (Negative)
Now compare signs of f(x1), f(x2) and f(x3)
f(x1) = + ve
f(x2) = – ve
f(x3) = – ve
Hence if we check, f(x1)*f(x3) is less than zero and f(x2)*f(x3) is greater
than zero, or remember replace x1 or x2; whose f(x) has same sign as
that of f(x3).
Hence here replace x2 with x3.
x2 = 0.75
Let’s check the accuracy, I x2 – x1 I < accuracy or not
I 0.75 – 0.5 I = 0.25 > 0.01
Hence go for next iteration considering new values of initial guesses as
x1 as it is = 0.5 and x2 = 0.75
Bisection method
Iteration 2:
x1 = 0.5 and x2 = 0.75 as f(x1) = 0.2275 and f(x2) = – 0.2433
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.5 + 0.75)/2 = 0.625
f(x3) = cos (0.625) – 1.3*0.625 = – 1.5368 * 10^ – 3 or – 0.0015368 (Negative)
Now compare signs of f(x1), f(x2) and f(x3)
f(x1) = + ve
f(x2) = – ve
f(x3) = – ve
Hence if we check, f(x1)*f(x3) is less than zero and f(x2)*f(x3) is greater than
zero, or remember replace x1 or x2; whose f(x) has same sign as that of f(x3).
Hence here replace x2 with x3.
x2 = 0.625
Let’s check the accuracy, I x2 – x1 I < accuracy or not
I 0.625 – 0.5 I = 0.125 > 0.01
Hence go for next iteration considering new values of initial guesses as
x1 as it is = 0.5 and x2 = 0.625
Bisection method
Iteration 3:
x1 = 0.5 and x2 = 0.625 as f(x1) = 0.2275 and f(x2) = – 0.0015368
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.5 + 0.625)/2 = 0.5625
f(x3) = cos (0.5625) – 1.3*0.5625 = 0.1146 (Positive)
Now compare signs of f(x1), f(x2) and f(x3)
f(x1) = + ve
f(x2) = – ve
f(x3) = + ve
Hence if we check, f(x1)*f(x3) is greater than zero and f(x2)*f(x3) is less than
zero, or remember replace x1 or x2; whose f(x) has same sign as that of f(x3).
Hence here replace x1 with x3.
x1 = 0.5625
Let’s check the accuracy, I x2 – x1 I < accuracy or not
I 0.625 – 0.5625 I = 0.0625 > 0.01
Hence go for next iteration considering new values of initial guesses as
x1 = 0.5625 and x2 as it is 0.625
Bisection method
Iteration 4:
x1 = 0.5625 and x2 = 0.625 as f(x1) = 0.1146 and f(x2) = – 0.0015368
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.5625 + 0.625)/2 = 0.5937
f(x3) = cos (0.5937) – 1.3* 0.5937 = 0.0570 (Positive)
Now compare signs of f(x1), f(x2) and f(x3)
f(x1) = + ve
f(x2) = – ve
f(x3) = + ve
Hence if we check, f(x1)*f(x3) is greater than zero and f(x2)*f(x3) is less than
zero, or remember replace x1 or x2; whose f(x) has same sign as that of f(x3).
Hence here replace x1 with x3.
x1 = 0.5937
Let’s check the accuracy, I x2 – x1 I < accuracy or not
I 0.625 – 0.5937 I = 0.0313 > 0.01
Hence go for next iteration considering new values of initial guesses as
x1 = 0.5937 and x2 as it is 0.625
Bisection method
Iteration 5:
x1 = 0.5937 and x2 = 0.625 as f(x1) = 0.0570 and f(x2) = – 0.0015368
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.5937 + 0.625)/2 = 0.6093
f(x3) = cos (0.6093) – 1.3* 0.6093 = 0.0278 (Positive)
Now compare signs of f(x1), f(x2) and f(x3)
f(x1) = + ve
f(x2) = – ve
f(x3) = + ve
Hence if we check, f(x1)*f(x3) is greater than zero and f(x2)*f(x3) is less than
zero, or remember replace x1 or x2; whose f(x) has same sign as that of f(x3).
Hence here replace x1 with x3.
x1 = 0.6093
Let’s check the accuracy, I x2 – x1 I < accuracy or not
I 0.625 – 0.6093 I = 0.0157 > 0.01
Hence go for next iteration considering new values of initial guesses as
x1 = 0.6093 and x2 as it is 0.625
Bisection method
Iteration 6:
x1 = 0.6093 and x2 = 0.625 as f(x1) = 0.0278 and f(x2) = – 0.0015368
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.6093 + 0.625)/2 = 0.6171
f(x3) = cos (0.6171) – 1.3* 0.6171= 0.0132 (Positive)
Now compare signs of f(x1), f(x2) and f(x3)
f(x1) = + ve
f(x2) = – ve
f(x3) = + ve
Hence if we check, f(x1)*f(x3) is greater than zero and f(x2)*f(x3) is less than
zero, or remember replace x1 or x2; whose f(x) has same sign as that of f(x3).
Hence here replace x1 with x3.
x1 = 0.6171
Let’s check the accuracy, I x2 – x1 I < accuracy or not
I 0.625 – 0.6171 I = 0.0079 < 0.01
Hence go for next iteration considering new values of initial guesses as
x1 = 0.6171 and x2 as it is 0.625
Bisection method
Iteration 7:
x1 = 0.6171 and x2 = 0.625 as f(x1) = 0.0132 and f(x2) = – 0.0015368
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.6171 + 0.625)/2 = 0.6210
x1
x x2
f(x1)
Regula Falsi method
• An alternative method that exploits this graphical insight is to join f (x1)
and f (x2) by a straight line.
• The intersection of this line with the x axis represents an improved
estimate of the root.
• The fact that the replacement of the curve by a straight line gives a
“false position” of the root is the origin of the name, method of false
position, or in Latin, regula falsi.
• It is also called the linear interpolation method. f(x2)
Y = f(x)
Y = f(x)
x1 x3
x x2
f(x1)
Regula Falsi method
Y = f(x)
f(x2)
x1 x3
x x2
Y = f(x)
f(x3)
f(x1)
Regula Falsi method
Y = f(x) Y = f(x)
f(x2)
x1 x3
x x2
f(x3)
f(x1)
Regula Falsi method
Y = f(x) Y = f(x)
f(x2)
x3
x1
x x2
f(x3)
f(x1)
Regula Falsi method
Y = f(x)
Consider triangle f(x2) x3 x2 f(x2)
and
Triangle f(x1) x3 x1
Observing the similar angles we can
write,
𝑓(𝑥1 ) 𝑓(𝑥2 )
− =
𝑥3 −𝑥1 𝑥2 −𝑥3
Or
x1 x3
𝑓(𝑥1 ) 𝑓(𝑥2 )
= x2
𝑥3 −𝑥1 𝑥3 −𝑥2 x
Cross multiply and get
𝑓 𝑥1 𝑥2 −𝑓(𝑥2 )𝑥1
𝑥3 = Y = f(x)
𝑓(𝑥1 )−𝑓(𝑥2 )
𝑓 𝑥1 𝑥2 𝑓(𝑥2 )𝑥1 f(x3)
𝑥3 = −
𝑓(𝑥1 ) − 𝑓(𝑥2 ) 𝑓(𝑥1 ) − 𝑓(𝑥2 ) f(x1)
Y = f(x)
f(x2)
x1 x3 x3
x2
x
Y = f(x)
Use Bisection method to locate the root of
𝐟 𝐱 = 𝒙𝟏𝟎 − 𝟏
Y = f(x)
f(x2)
x1 x3 x3
x2
x
f(x3)
f(x1) f(x3)
Y = f(x)
College of Engineering Pune
Department of Mechanical Engineering
is available at
https://www.youtube.com/watch?v=qaCDVrnKodA&t=441s
Numerical Methods &
Computer Programming
Session 7
Open methods
(Newton Raphson method)
Open methods:
• Open methods differ from bracketing methods, in that open methods require
only a single starting value or two starting values that do not necessarily bracket
a root. Open methods may diverge as the computation progresses, but when
they do converge, they usually do so much faster than bracketing methods.
1. Newton-Raphson
2. Fixed point iteration or successive approximation
BRACKETING METHODS
OPEN METHODS
Newton-Raphson method:
• It is an open-method, we assume a single initial guess x1 to find the root of
equation.
• So the point at which the tangent intersects the x axis is the new
approximate of root i.e. x2
Newton-Raphson method:
Y = f(x)
f(x1)
Y = f(x)
f(x3)
x5 x4 x2
x x1 x3
f(x4)
f(x2)
Newton-Raphson method:
y1 = f(x1)
Y = f(x)
1st tangent
x x2
𝑑𝑦 x1
𝑠𝑙𝑜𝑝𝑒 𝑜𝑓 𝑙𝑖𝑛𝑒 =
𝑑𝑥
𝑑𝑦 𝑦2 −𝑦1 Y = f(x)
= = 𝑦′
𝑑𝑥 𝑥2 −𝑥1
𝐴𝑝𝑝𝑙𝑦𝑖𝑛𝑔 𝑡ℎ𝑖𝑠 𝑒𝑞𝑢𝑎𝑡𝑖𝑜𝑛 𝑡𝑜 1𝑠𝑡 𝑡𝑎𝑛𝑔𝑒𝑡
0 − 𝑦1
𝑦 ′ = 𝑓 ′ 𝑥1 =
𝑥2 − 𝑥1
′
(𝑥2 −𝑥1 ) × 𝑓 𝑥1 = −𝑦1
−𝑦1 + 𝑥1 × 𝑓 ′ 𝑥1
𝑥2 =
𝑓 ′ 𝑥1
𝑦1 𝑦1
𝑥2 = 𝑥1 − ′ = 𝑥1 − ′
𝑓 𝑥1 𝑦1
Newton-Raphson method:
Newton-Raphson method:
Newton-Raphson method:
Newton-Raphson method:
Newton-Raphson method:
Newton-Raphson method:
Newton-Raphson method:
Newton-Raphson method:
Numerical on Newton Raphson:
Numerical on Newton Raphson:
Numerical on Newton Raphson:
Numerical on Newton Raphson:
Numerical on Newton Raphson:
Numerical on Newton Raphson:
Numerical Methods &
Computer Programming
Session 8
Open methods
(Successive approximation
method)
Successive approximation method:
Successive approximation method:
Successive approximation method:
Successive approximation procedure:
Successive approximation method:
Successive approximation method:
Successive approximation method:
Divergence of successive approximation:
Divergence of successive approximation:
Successive approximation method:
Successive approximation method:
Successive approximation method:
Successive approximation method:
Successive approximation method:
Successive approximation method:
Successive approximation method:
Successive approximation method:
Numerical Methods &
Computer Programming
Session 9
Approximate solutions to
simultaneous equations
Introduction to simultaneous equations
Introduction to simultaneous equations
Introduction to simultaneous equations
Introduction to simultaneous equations
Introduction to simultaneous equations
Introduction to simultaneous equations
Introduction to simultaneous equations
Introduction to simultaneous equations
Introduction to simultaneous equations
Gauss elimination method:
Gauss elimination method:
Gauss elimination method:
Gauss elimination method:
Gauss elimination method:
Gauss elimination method:
Gauss elimination with partial pivoting:
Gauss elimination with partial pivoting:
Gauss elimination with partial pivoting:
Gauss elimination with partial pivoting:
Gauss elimination with partial pivoting:
Gauss elimination with partial pivoting:
Gauss elimination with partial pivoting:
Gauss elimination with partial pivoting:
Thomas algorithm for Tri-diagonal matrix:
Thomas algorithm for Tri-diagonal matrix:
Thomas algorithm for Tri-diagonal matrix:
Thomas algorithm for Tri-diagonal matrix:
Thomas algorithm for Tri-diagonal matrix:
Thomas algorithm for Tri-diagonal matrix:
Thomas algorithm for Tri-diagonal matrix:
Thomas algorithm for Tri-diagonal matrix:
Thomas algorithm for Tri-diagonal matrix:
Thomas algorithm for Tri-diagonal matrix:
Gauss Seidel method:
Gauss Seidel method:
Gauss Seidel method:
Gauss Seidel method:
Gauss Seidel method:
Gauss Seidel method:
Gauss Seidel method:
Gauss Seidel method:
Gauss Seidel method:
Gauss Seidel method:
Gauss Seidel method:
Gauss Seidel method:
Gauss Seidel method:
Gauss Seidel method:
Gauss Seidel method:
Gauss Seidel method:
Jacobi iteration method:
Jacobi iteration method:
Jacobi iteration method:
Jacobi iteration method:
Jacobi iteration method:
College of Engineering Pune
Department of Mechanical Engineering
Welcome!!
Session 4
Bracketing methods for
finding out roots of
equations
Bracketing methods
• Now we will study the methods that exploit the fact that a function
typically changes sign in the vicinity of a root.
• This is useful for providing rough initial guesses required for graphical
methods.
Bisection method
Step 1: Choose lower x1 and upper x2 guesses for the root such that the
function changes sign over the interval.
This can be checked by ensuring that f (x1)*f(x2) < 0 or
Sign of f(x1) and f(x2) are opposite.
x1
x x3 x2
x1 x3
x x2
F(x3)
f(x1)
X3 = (x1 + x2 )/2
Y = f(x)
f(x2)
x1 x3
x x2
F(x1) F(x3)
X3 = (x1 + x2 )/2
Bisection method
3 2
𝑓 𝑥 = 𝑥 − 𝑥 − 20
Step 1: let’s assume initial guess starting from 0 with the step size of 1.
First guess x = 0 and f(x) = - 20
Second guess x = 1 and f(x) = - 20
Third guess x = 2 and f(x) = - 16
Fourth guess x = 3 and f(x) = - 2
Fifth guess x = 4 and f(x) = 28
Sixth guess x = 5 and f(x) = 80
The sign of function changes between guesses 3 and 4,
hence select x1 = 3 and x2 = 4
OR
Also check whether f (x1)*f(x2) < 0
x = 3 and f(x) = - 2 and x = 4 and f(x) = 28
So f (x1)*f(x2) = - 2*28 = -56 which is < 0
Hence initial guesses are correct.
Step 2: Find out x3 which is nothing but next approximated root bracketing
first two initial guesses.
x3 = (x1 + x2) / 2 i.e. = (3 + 4) /2 = 3.5
Bisection method
3 2
𝑓 𝑥 = 𝑥 − 𝑥 − 20
Step 3: Find f (x3) and check the sign.
x3 = 3.5 hence f(x3) = 10.62 (Positive)
Welcome!!
Session 5
Some more numerical on
Bisection method
Bisection method
Determine the root of equation cos x – 1.3 x = 0 using bisection method
with the accuracy of 0.01.
Given:
𝑓 𝑥 = cos 𝑥 − 1.3𝑥
The accuracy = 0.01
Initial guesses are not given.
Solution:
Lets start with finding out initial guesses.
Note: whenever the equation contains trigonometric terms, keep the calculator
in RADIAN mode.
Assume initial guess as 0 and find f(x), we get f(x) = 1
Assume initial guess as 0.5 and find f(x), we get f(x) = 0.2275
Assume initial guess as 1 and find f(x), we get f(x) = – 0.7596
Or check the condition f(0.5)*f(1) < 0 or not,
hence 0.2275* – 0.7596 = – 0.1728 < 0
Hence lets assume x1 = 0.5 and x2 = 1
Bisection method
Iteration 1:
x1 = 0.5 and x2 = 1 as f(x1) = 0.2275 and f(x2) = – 0.7596
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.5 + 1)/2 = 0.75
Find f(x3) = cos (0.75) – 1.3*0.75 = – 0.2433 (Negative)
Now compare signs of f(x1), f(x2) and f(x3)
f(x1) = + ve
f(x2) = – ve
f(x3) = – ve
Hence if we check, f(x1)*f(x3) is less than zero and f(x2)*f(x3) is greater
than zero, or remember replace x1 or x2; whose f(x) has same sign as
that of f(x3).
Hence here replace x2 with x3.
x2 = 0.75
Let’s check the accuracy, I x2 – x1 I < accuracy or not
I 0.75 – 0.5 I = 0.25 > 0.01
Hence go for next iteration considering new values of initial guesses as
x1 as it is = 0.5 and x2 = 0.75
Bisection method
Iteration 2:
x1 = 0.5 and x2 = 0.75 as f(x1) = 0.2275 and f(x2) = – 0.2433
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.5 + 0.75)/2 = 0.625
f(x3) = cos (0.625) – 1.3*0.625 = – 1.5368 * 10^ – 3 or – 0.0015368 (Negative)
Now compare signs of f(x1), f(x2) and f(x3)
f(x1) = + ve
f(x2) = – ve
f(x3) = – ve
Hence if we check, f(x1)*f(x3) is less than zero and f(x2)*f(x3) is greater than
zero, or remember replace x1 or x2; whose f(x) has same sign as that of f(x3).
Hence here replace x2 with x3.
x2 = 0.625
Let’s check the accuracy, I x2 – x1 I < accuracy or not
I 0.625 – 0.5 I = 0.125 > 0.01
Hence go for next iteration considering new values of initial guesses as
x1 as it is = 0.5 and x2 = 0.625
Bisection method
Iteration 3:
x1 = 0.5 and x2 = 0.625 as f(x1) = 0.2275 and f(x2) = – 0.0015368
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.5 + 0.625)/2 = 0.5625
f(x3) = cos (0.5625) – 1.3*0.5625 = 0.1146 (Positive)
Now compare signs of f(x1), f(x2) and f(x3)
f(x1) = + ve
f(x2) = – ve
f(x3) = + ve
Hence if we check, f(x1)*f(x3) is greater than zero and f(x2)*f(x3) is less than
zero, or remember replace x1 or x2; whose f(x) has same sign as that of f(x3).
Hence here replace x1 with x3.
x1 = 0.5625
Let’s check the accuracy, I x2 – x1 I < accuracy or not
I 0.625 – 0.5625 I = 0.0625 > 0.01
Hence go for next iteration considering new values of initial guesses as
x1 = 0.5625 and x2 as it is 0.625
Bisection method
Iteration 4:
x1 = 0.5625 and x2 = 0.625 as f(x1) = 0.1146 and f(x2) = – 0.0015368
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.5625 + 0.625)/2 = 0.5937
f(x3) = cos (0.5937) – 1.3* 0.5937 = 0.0570 (Positive)
Now compare signs of f(x1), f(x2) and f(x3)
f(x1) = + ve
f(x2) = – ve
f(x3) = + ve
Hence if we check, f(x1)*f(x3) is greater than zero and f(x2)*f(x3) is less than
zero, or remember replace x1 or x2; whose f(x) has same sign as that of f(x3).
Hence here replace x1 with x3.
x1 = 0.5937
Let’s check the accuracy, I x2 – x1 I < accuracy or not
I 0.625 – 0.5937 I = 0.0313 > 0.01
Hence go for next iteration considering new values of initial guesses as
x1 = 0.5937 and x2 as it is 0.625
Bisection method
Iteration 5:
x1 = 0.5937 and x2 = 0.625 as f(x1) = 0.0570 and f(x2) = – 0.0015368
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.5937 + 0.625)/2 = 0.6093
f(x3) = cos (0.6093) – 1.3* 0.6093 = 0.0278 (Positive)
Now compare signs of f(x1), f(x2) and f(x3)
f(x1) = + ve
f(x2) = – ve
f(x3) = + ve
Hence if we check, f(x1)*f(x3) is greater than zero and f(x2)*f(x3) is less than
zero, or remember replace x1 or x2; whose f(x) has same sign as that of f(x3).
Hence here replace x1 with x3.
x1 = 0.6093
Let’s check the accuracy, I x2 – x1 I < accuracy or not
I 0.625 – 0.6093 I = 0.0157 > 0.01
Hence go for next iteration considering new values of initial guesses as
x1 = 0.6093 and x2 as it is 0.625
Bisection method
Iteration 6:
x1 = 0.6093 and x2 = 0.625 as f(x1) = 0.0278 and f(x2) = – 0.0015368
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.6093 + 0.625)/2 = 0.6171
f(x3) = cos (0.6171) – 1.3* 0.6171= 0.0132 (Positive)
Now compare signs of f(x1), f(x2) and f(x3)
f(x1) = + ve
f(x2) = – ve
f(x3) = + ve
Hence if we check, f(x1)*f(x3) is greater than zero and f(x2)*f(x3) is less than
zero, or remember replace x1 or x2; whose f(x) has same sign as that of f(x3).
Hence here replace x1 with x3.
x1 = 0.6171
Let’s check the accuracy, I x2 – x1 I < accuracy or not
I 0.625 – 0.6171 I = 0.0079 < 0.01
Hence go for next iteration considering new values of initial guesses as
x1 = 0.6171 and x2 as it is 0.625
Bisection method
Iteration 7:
x1 = 0.6171 and x2 = 0.625 as f(x1) = 0.0132 and f(x2) = – 0.0015368
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.6171 + 0.625)/2 = 0.6210
Welcome!!
Session 6
Regula Falsi method
(False position method)
Regula Falsi method
• Although bisection is a perfectly valid technique for determining roots, its
approach is relatively inefficient for some cases.
• False position is an alternative based on a graphical insight.
• A shortcoming of the bisection method is that, in dividing the interval from
x1 to x2 into equal halves, no account is taken of the magnitudes of f (x1)
and f (x2).
• For example, if f (x1) is much closer to zero than f (x2), it is likely that the
root is closer to x1 than to x2 (see the figure). f(x2)
Y = f(x)
Y = f(x)
x1
x x2
f(x1)
Regula Falsi method
• An alternative method that exploits this graphical insight is to join f (x1)
and f (x2) by a straight line.
• The intersection of this line with the x axis represents an improved
estimate of the root.
• The fact that the replacement of the curve by a straight line gives a
“false position” of the root is the origin of the name, method of false
position, or in Latin, regula falsi.
• It is also called the linear interpolation method. f(x2)
Y = f(x)
Y = f(x)
x1 x3
x x2
f(x1)
Regula Falsi method
Y = f(x)
f(x2)
x1 x3
x x2
Y = f(x)
f(x3)
f(x1)
Regula Falsi method
Y = f(x) Y = f(x)
f(x2)
x1 x3
x x2
f(x3)
f(x1)
Regula Falsi method
Y = f(x) Y = f(x)
f(x2)
x3
x1
x x2
f(x3)
f(x1)
Regula Falsi method
Y = f(x)
Consider triangle f(x2) x3 x2 f(x2)
and
Triangle f(x1) x3 x1
Observing the similar angles we can
write,
𝑓(𝑥1 ) 𝑓(𝑥2 )
− =
𝑥3 −𝑥1 𝑥2 −𝑥3
Or
x1 x3
𝑓(𝑥1 ) 𝑓(𝑥2 )
= x2
𝑥3 −𝑥1 𝑥3 −𝑥2 x
Cross multiply and get
𝑓 𝑥1 𝑥2 −𝑓(𝑥2 )𝑥1
𝑥3 = Y = f(x)
𝑓(𝑥1 )−𝑓(𝑥2 )
𝑓 𝑥1 𝑥2 𝑓(𝑥2 )𝑥1 f(x3)
𝑥3 = −
𝑓(𝑥1 ) − 𝑓(𝑥2 ) 𝑓(𝑥1 ) − 𝑓(𝑥2 ) f(x1)
Y = f(x)
f(x2)
x1 x3 x3
x2
x
Y = f(x)
Use Bisection method to locate the root of
𝐟 𝐱 = 𝒙𝟏𝟎 − 𝟏
Y = f(x)
f(x2)
x1 x3 x3
x2
x
f(x3)
f(x1) f(x3)
Y = f(x)
College of Engineering Pune
Department of Mechanical Engineering
Welcome!!
Session 7
Open methods
(Newton Raphson method)
Open methods:
• Open methods differ from bracketing methods, in that open methods require
only a single starting value or two starting values that do not necessarily bracket
a root. Open methods may diverge as the computation progresses, but when
they do converge, they usually do so much faster than bracketing methods.
1. Newton-Raphson
2. Fixed point iteration or successive approximation
BRACKETING METHODS
OPEN METHODS
Newton-Raphson method:
• It is an open-method, we assume a single initial guess x1 to find the root of
equation.
• So the point at which the tangent intersects the x axis is the new
approximate of root i.e. x2
Newton-Raphson method:
Y = f(x)
f(x1)
Y = f(x)
f(x3)
x5 x4 x2
x x1 x3
f(x4)
f(x2)
Newton-Raphson method:
y1 = f(x1)
Y = f(x)
1st tangent
x x2
𝑑𝑦 x1
𝑠𝑙𝑜𝑝𝑒 𝑜𝑓 𝑙𝑖𝑛𝑒 =
𝑑𝑥
𝑑𝑦 𝑦2 −𝑦1 Y = f(x)
= = 𝑦′
𝑑𝑥 𝑥2 −𝑥1
𝐴𝑝𝑝𝑙𝑦𝑖𝑛𝑔 𝑡ℎ𝑖𝑠 𝑒𝑞𝑢𝑎𝑡𝑖𝑜𝑛 𝑡𝑜 1𝑠𝑡 𝑡𝑎𝑛𝑔𝑒𝑡
0 − 𝑦1
𝑦 ′ = 𝑓 ′ 𝑥1 =
𝑥2 − 𝑥1
′
(𝑥2 −𝑥1 ) × 𝑓 𝑥1 = −𝑦1
−𝑦1 + 𝑥1 × 𝑓 ′ 𝑥1
𝑥2 =
𝑓 ′ 𝑥1
𝑦1 𝑦1
𝑥2 = 𝑥1 − ′ = 𝑥1 − ′
𝑓 𝑥1 𝑦1
Newton-Raphson method:
Newton-Raphson method:
Newton-Raphson method:
Newton-Raphson method:
Newton-Raphson method:
Newton-Raphson method:
Newton-Raphson method:
Newton-Raphson method:
Numerical on Newton Raphson:
Numerical on Newton Raphson:
Numerical on Newton Raphson:
Numerical on Newton Raphson:
Numerical on Newton Raphson:
Numerical on Newton Raphson:
College of Engineering Pune
Department of Mechanical Engineering
Welcome!!
Session 8
Open methods
(Successive approximation
method)
Successive approximation method:
Successive approximation method:
Successive approximation method:
Successive approximation procedure:
Successive approximation method:
Successive approximation method:
Successive approximation method:
Divergence of successive approximation:
Divergence of successive approximation:
Successive approximation method:
Successive approximation method:
Successive approximation method:
Successive approximation method:
Successive approximation method:
Successive approximation method:
Successive approximation method:
Successive approximation method: