You are on page 1of 261

College of Engineering Pune

Department of Mechanical Engineering

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.

• Case study based learning, Research/Project based learning

Research related activities:


• https://www.linkedin.com/in/abhishek-patange-89884179/
• https://www.scopus.com/authid/detail.uri?authorId=57204179235
• https://scholar.google.co.in/citations?user=u4zim9MAAAAJ&hl=en
• https://www.researchgate.net/profile/Abhishek_Patange
My publications: References:
1. Patange, A. D., Jegadeeshwaran, R., & Dhobale, N. C. (2019, October). Milling cutter
condition monitoring using machine learning approach. In IOP Conference Series:
Materials Science and Engineering (Vol. 624, No. 1, p. 012030). IOP Publishing.
2. Patil, S. S., Pardeshi, S. S., Patange, A. D., & Jegadeeshwaran, R. (2021, July). Deep
Learning Algorithms for Tool Condition Monitoring in Milling: A Review. In Journal
of Physics: Conference Series (Vol. 1969, No. 1, p. 012039). IOP Publishing.
3. Tambake, N. R., Deshmukh, B. B., & Patange, A. D. (2021, July). Data Driven Cutting
Tool Fault Diagnosis System Using Machine Learning Approach: A Review. In Journal
of Physics: Conference Series (Vol. 1969, No. 1, p. 012049). IOP Publishing.
4. Shewale, M. S., Mulik, S. S., Deshmukh, S. P., Patange, A. D., Zambare, H. B., &
Sundare, A. P. (2019). Novel machine health monitoring system. In Proceedings of
the 2nd International Conference on Data Engineering and Communication
Technology (pp. 461-468). Springer, Singapore.
5. Bajaj, N. S., Patange, A. D., Jegadeeshwaran, R., Kulkarni, K. A., Ghatpande, R. S., &
Kapadnis, A. M. (2021). A Bayesian optimized discriminant analysis model for
condition monitoring of face milling cutter using vibration datasets. Journal of
Nondestructive Evaluation, Diagnostics and Prognostics of Engineering
Systems, 5(2), 021002.
My publications: References:
6. Patange, A. D., & Jegadeeshwaran, R. (2021). A machine learning approach for
vibration-based multipoint tool insert health prediction on vertical machining
centre (VMC). Measurement, 173, 108649.
7. Khade, H. S., Patange, A. D., Pardeshi, S. S., & Jegadeeshwaran, R. (2021). Design of
bagged tree ensemble for carbide coated inserts fault diagnosis. Materials Today:
Proceedings, 46(2), 1283-1289.
8. Patange, A. D., & Jegadeeshwaran, R. (2021). Review on tool condition classification
in milling: A machine learning approach. Materials Today: Proceedings, 46(2), 1106-
1115
9. Mulik Sharad, S., Deshmukh Suhas, P., & Patange Abhishek, D. (2017). Review of
vibration monitoring techniques using low cost sensors and microcontrollers. J.
Mechatron. Autom, 4(2).
10. Nalavade, S. P., Patange, A. D., Prabhune, C. L., Mulik, S. S., & Shewale, M. S. (2019).
Development of 12 Channel Temperature Acquisition System for Heat Exchanger
Using MAX6675 and Arduino Interface. In Innovative Design, Analysis and
Development Practices in Aerospace and Automotive Engineering (I-DAD 2018) (pp.
119-125). Springer, Singapore.
My publications: References:
11. Patange, A. D., & Jegadeeshwaran, R. (2020). Application of bayesian family
classifiers for cutting tool inserts health monitoring on CNC milling. International
Journal of Prognostics and Health Management, 11(2), 1-9.
12. Patange AD, Bewoor AK, Deshmukh SP, Mulik SS, Pardeshi SS, Jegadeeshwaran R.
Improving Program Outcome Attainments using Project Based Learning approach
for: UG Course-Mechatronics, Journal of Engineering Education Transformations
33(1);2019:1-13
13. Mulik SS, Patange AD, Jegadeeshwaran R, Pardeshi SS, Rahegaonkar A.
Development and Experimental Assessment of a Fluid Flow Monitoring System
Using Flow Sensor and Arduino Interface. Lecture Notes in Mechanical Engineering.
Springer, Singapore 2021
14. Shewale M.S., Razban A., Deshmukh S.P., Mulik S.S., Patange A.D. (2020)
Characterization and System Identification of XY Flexural Mechanism Using Double
Parallelogram Manipulator for High Precision Scanning. Lecture Notes in Electrical
Engineering, vol 570. Springer, Singapore
15. Apoorva Khairnar, Abhishek Patange, Sujit Pardeshi, and R. Jegadeeshwaran.
Supervision of Carbide Tool Condition by Training of Vibration-based Statistical
Model using Boosted Trees Ensemble [J]. Int J Performability Eng, 2021, 17(2): 229-
240.
Teaching, learning and evaluation..
Teaching Scheme:
• Theory : 2 Hr/week (2 credits)
• Lab: 2 Hr/week (1 credit)
Examination Scheme:
• For theory
❖ T1 (Exam) : 20 Marks
❖ T2 (Research based learning and evaluation) : 20 Marks
❖ End-Semester Exam: 60 Marks
• For Lab
❖ Term work : 50 marks
❖ Practical exam based on MATLAB/Python programming
set and evaluated by external examiner : 50 Marks
Syllabus:
Unit 1 : Numerical Methods I:
• Introduction : Difference between analytical & numerical approach
• Error Approximations: Types of Errors: Absolute, Relative, Algorithmic,
Truncation, Round off Error, Error Propagation, Concept of convergence-
relevance to numerical methods.
• Roots of equations: Bracketing and Open Methods.
• Simultaneous Equations: Gauss-Elimination, with partial pivoting, Gauss-
Seidal, Gauss-Jordan, Gauss-Jacobi, Thomas algorithm for Tri-diagonal Matrix.

Unit 2 : Numerical Methods II:


• Numerical Integration: Trapezoidal rule, Simpson’s 1/3rd Rule, Simpson’s 3/8th
Rule, Gauss Quadrature 2 point and 3 point method. Double Integration using
Trapezoidal rule, Simpson’s 1/3rd Rule
• Ordinary Differential Equations [ODE]: Taylor series method, Euler Method,
Runge-Kutta fourth order, Simultaneous equations using RungeKutta2nd order
method
• Partial Differential Equations [PDE]: Finite Difference methods Introduction to
finite difference method, Simple Laplace method, PDEs- Parabolic explicit
solution, Elliptic-explicit solution
Syllabus:
Unit 3 : Curve fitting and Regression analysis:
• Interpolation: Approximation by Forward, Backward, Central and Divided
Difference Formulae, Interpolation by Newton’s Formulae, Lagrange’s, Spline
Interpolation, Hermite and Stirling Formulae
• Curve fitting: Least square technique- Straight line, Power equation,
Exponential equation and Quadratic equation
• Regression using Machine Learning algorithms: Linear Regression, Logistic
Regression, Polynomial Regression, Support Vector Regression, Regression
trees: Decision tree, random forest, Ridge Regression, Lasso Regression,
Clustering/ K-Means, K-Nearest Neighbor (KNN), Neural Networks
ME: Mechanical Engineering
Section 1: Engineering Mathematics (Minimum 4 questions)
• Linear Algebra: Matrix algebra, systems of linear equations, eigenvalues and eigenvectors.

• 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.

• Probability and Statistics: Definitions of probability, sampling theorems, conditional probability;


mean, median, mode and standard deviation; random variables, binomial, Poisson and normal
distributions.
GATE 2022:

Dates of examination of GATE 2022


• Saturday 5th February 2022
• Sunday 6th February 2022
• Saturday 12th February 2022
• Sunday 13th February 2022

Eligibility Criteria for GATE 2022


GATE 2022:
Official website
https://gate.iitkgp.ac.in/

GATE - Previous Year Question Papers


https://gate.iitkgp.ac.in/old_question_papers.html
Books for CMP:
• Chapra, Cannale, “Numerical Methods for Engineers”, McGraw-
Hill Int.

• T Veerarajan, T Rama Chandran, “Theory and Problems in


Numerical Method” Tata McGraw-Hill

• Shastry, “Introductory Methods of Numerical Analysis”, Prentice


Hall Delhi.

• Alex Smola and S.V.N. Vishwanathan, Introduction to Machine


Learning, Cambridge University Press

• Rudolph Russell, Machine Learning: Step-by-Step Guide to


Implement Machine Learning Algorithms with Python, an open
source book.
Course Outcomes:
At the end of the course students will be able to:
1. Use numerical methods in modern scientific computing
2. Determine numerical solutions of nonlinear equations in a
single variable
3. Use numerical interpolation
4. Estimate solution to problems using numerical integration
and differentiation
5. Obtain numerical solution to engineering problems using
programming
6. Apply machine learning algorithms for regression analysis
Introduction to
analytical/exact
approach
A simple mathematical model
• a formulation or equation that expresses the essential
features of a physical system or process in mathematical
terms.

• represented as a functional relationship of the form

Reflects the time and space, reflective of the external


behaviour or along which the system’s influences
state behaviour is properties or acting on
of the system determined composition system
Let’s take one example:
• Newton formulated his second law of motion,

• which states that the time rate of change of momentum of a


body is equal to the resultant force acting on it.

• The mathematical expression, or model, of the second law is the


well-known equation

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)

where a = the dependent variable reflecting the behaviour


F = the forcing function
m = a parameter representing a property of the system

• 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.

• However, other mathematical models of physical phenomena


may be much more complex, and either cannot be solved
exactly or require more sophisticated mathematical
techniques than simple algebra for their solution.

• To illustrate a more complex model of this kind, Newton’s


second law can be used to determine the terminal velocity of
a free-falling body near the earth’s surface.
Continue..
• Our falling body will be a parachutist.

• A model for this case can be derived by expressing the


acceleration as the time rate of change of the velocity (dv/dt)
and substituting it into Eq. (2) to yield

dv / dt = F / m (3)
• where v is velocity (m/s) and t is time (s).

• The net force (+) : the object accelerates


• The net force (-) : the object decelerates
• The net force = 0, the velocity will be constant.
Continue..
• Next, we will express the net force in terms of measurable
variables and parameters.

• For a body falling within the vicinity of the earth, the net
force is composed of two opposing forces:

• the downward pull of gravity FD and


• the upward force of air resistance FU

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)

• where g = the gravitational constant, or the acceleration


due to gravity, which is approximately equal to 9.8 m/s2.
Continue..
• Air resistance can be formulated in a variety of ways. A
simple approach is to assume that it is linearly proportional
to velocity and acts in an upward direction, as in

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,

• Eqs. (3) through (6) can be combined to yield


dv / dt = F / m
where F = mg – cv
dv / dt = ( mg – cv ) / m (7)
or simplifying the right side,

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.

• It is a differential equation because it is written in terms of


the differential rate of change (dv/dt) of the variable that we
are interested in predicting.

• However, in contrast to the solution of Newton’s second law


in Eq. (2), the exact solution of Eq. (8) for the velocity of the
falling parachutist cannot be obtained using simple algebraic
manipulation.

• Rather, more advanced techniques such as those of calculus,


must be applied to obtain an exact or analytical solution.
Continue..
• For example, if the parachutist is initially at rest (v = 0 at t =
0), calculus can be used to solve Eq. (8) for

(9)

• Note that Eq. (9) is cast in the general form of Eq. 1)


• where v(t) = the dependent variable
• t = the independent variable
• c and m = parameters
• g = the forcing function
Example 1: Analytical Solution to the Falling Parachutist Problem

• Problem Statement.

• A parachutist of mass 68.1 kg jumps out of a stationary


hot air balloon.

• Use Eq. (9) to compute velocity prior to opening the chute.

• The drag coefficient is equal to 12.5 kg/s.


Example 1: Analytical Solution to the Falling Parachutist Problem

which can be used to compute


According to the model, the
parachutist accelerates rapidly. A
velocity of 44.87 m/s is attained after
10 s. Note also that after a sufficiently
long time, a constant velocity, called
the terminal velocity, of 53.39 m/s is
reached. This velocity is constant
because, eventually, the force of
gravity will be in balance with the air
resistance. Thus, the net force is zero
and acceleration has stopped.
Example 1: Analytical Solution to the Falling Parachutist Problem

Velocity increases with time and asymptotically


approaches a terminal velocity.
Continue..
• Equation (9) is called an analytical, or exact, solution
because it exactly satisfies the original differential equation.

• Unfortunately, there are many mathematical models that


cannot be solved exactly.

• In many of these cases, the only alternative is to develop a


numerical solution that approximates the exact solution.
College of Engineering Pune
Department of Mechanical Engineering

Computational Methods & Programming

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)

After a sufficiently long time, a constant velocity,


called the terminal velocity, of 53.39 m/s is reached.
Limitations of exact approach..
• As we studied that, solving the mathematical models using
the exact approach involves the calculus.

• To find out rate of change of velocity w.r.t. time, we applied


the integration to the mathematical model which was
merely consist of fewer factors/parameters.

• But in real-time engineering practice, unfortunately, there


are many mathematical models that cannot be solved
exactly.

• The computation of calculus becomes tedious and time


consuming.
Introduction to
numerical/approximation
approach
A numerical/approximation approach:
• As mentioned previously, numerical methods are those in
which the mathematical problem is reformulated so it can
be solved by arithmetic operations.
Approximated
Velocity Exact / True
response
response
Experimental
response
dv/dt
B
v(ti + 1)

∆𝒗

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???

• Remember that slop is depends on time interval ∆𝒕

• Hence by considering the slope and previous values of v


and t, value of v(ti + 1) can be easily determined

• If you reduce the step size of time, automatically the


accuracy of the response of velocity will increase

• Hence lesser the value of step size, more accurate will be


the velocity at v(ti + 1)
Continue…
• Also remember from calculus that

• Equation (10) represents the reverse process.

(10)

• Equation (10) is called a finite divided difference approximation


of the derivative at time ti .
Continue:

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].

• That is, it provides a means to compute the rate of change or


slope of v.

• Thus, to transform the differential equation into simple


algebraic equation Eq. 10 can be substituted into Eq. 8, we
get
Continue:

• This equation can then be rearranged as our aim is to


calculate velocity at time instance v (ti+1).

• 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:

• If you are given an initial value for velocity at some time ti ,


you can easily compute velocity at a later time ti+1.

• This new value of velocity at ti+1 can in turn be employed to


extend the computation to velocity at ti+2 and so on. Thus,
at any time along the way,

• New value = old value + slope × step size

• Note that this approach is formally called Euler’s method.


Example 2: Numerical Solution to the Falling Parachutist Problem
• Problem Statement. Perform the same computation as in
Example 1 but use Eq. (11) to compute the velocity. Employ a
step size of 2 s for the calculation. Solution. At the start of the
computation (ti = 0), the velocity of the parachutist is zero.

• 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.

• However, because we have employed straight-line segments to


approximate a continuously curving function, there is some discrepancy
between the two results.

• 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′.

3. (G & H batch) Compute the velocity of a free-falling parachutist using


Euler’s method for the case where m = 80 kg and c = 10 kg/s. Perform the
calculation from t = 0 to 20 s with a step size of 1 s. Use an initial condition
that the parachutist has an upward velocity of 20 m/s at t = 0. At t = 10 s,
assume that the chute is instantaneously deployed so that the drag
coefficient jumps to 50 kg/s.
Assignment for the 1st week
5. (E & F batch) A storage tank contains a liquid at depth y where y = 0 when
the tank is half full. Liquid is withdrawn at a constant flow rate Q to meet
demands. The contents are resupplied at a sinusoidal rate 3Q*𝑠𝑖𝑛2 (t).
The above equation can be written for this system as

or, since the surface area A is constant,

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).

• One student should make the power point presentation of a solution.


(He/she shall be excluded from submission of handwritten or typed
scanned copy)

• In addition to that, another one student should deliver the same


presentation and capture the video. (He/she shall be excluded from
submission of handwritten or typed scanned copy)

• The link for submission is shared to your CR.


Thank you!
Numerical Methods &
Computer Programming
Session 3
Revisit to
roots of equation
Roots of equations
• The quadratic formula

(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.

• Thus, we can define the root of an equation as the value of x that


makes f (x) = 0. For this reason, roots are sometimes called the zeros
of the equation.

• 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.

• For example, even an apparently simple function such as 𝑓(𝑥) = 𝑒 −𝑥 − 𝑥


cannot be solved analytically.

• In such instances, the only alternative is an approximate solution


technique.

• One method to obtain an approximate solution is to plot the function and


determine where it crosses the x axis. This point, which represents the x
value for which f (x) = 0, is the root ‘Graphical techniques’.
Continue…
• Although graphical methods are useful for obtaining rough estimates of
roots, they are limited because of their lack of precision.

• An alternative approach is to use trial and error.

• This “technique” consists of guessing a value of x and evaluating whether


f (x) is zero.

• 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.

• The process is repeated until a guess is obtained that results in an f (x)


that is close to zero.

• 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)

• where velocity v = the dependent variable, time t = the independent


variable, the gravitational constant g = the forcing function, and the drag
coefficient c and mass m = parameters.

• If the parameters are known, Eq. (3) can be used to predict the
parachutist’s velocity as a function of time.

• Such computations can be performed directly because v is expressed


explicitly as a function of time.

• That is, it is isolated on one side of the equal sign.


Continue…
• However, suppose we had to determine the drag coefficient for a
parachutist of a given mass to attain a prescribed velocity in a set time
period.

• Although Eq. (3) provides a mathematical representation of the


interrelationship among the model variables and parameters, it cannot be
solved explicitly for the drag coefficient.

• Try it.

• There is no way to rearrange the equation so that c is isolated on one side


of the equal sign. In such cases, c is said to be implicit.

• This represents a real dilemma, because many engineering design


problems involve specifying the properties or composition of a system (as
represented by its parameters) to ensure that it performs in a desired
manner (as represented by its variables).

• Thus, these problems often require the determination of implicit


parameters.
Continue…
• The solution to the dilemma is provided by numerical methods for roots
of equations.

• To solve the problem using numerical methods, it is conventional to re-


express Eq. (3).

• This is done by subtracting the dependent variable v from both sides of


the equation to give

(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)

• where fi = an ith-order polynomial in x. Polynomials are a simple class of


algebraic functions that are represented generally by

(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.

• These include trigonometric, exponential, logarithmic, and other, less


familiar, functions. Examples are

(9)

(10)

• Roots of equations may be either real or complex.

• Although there are cases where complex roots of non-polynomials are of


interest, such situations are less common than for polynomials.
‘Algebraic’ &‘Transcendental’ equations
• As a consequence, the standard methods for locating roots typically fall
into two somewhat related but primarily distinct problem areas:

1. The determination of the real roots of algebraic and transcendental


equations.

These techniques are usually designed to determine the value of a


single real root on the basis of foreknowledge of its approximate
location.

2. The determination of all real and complex roots of polynomials.

These methods are specifically designed for polynomials.

They systematically determine all the roots of the polynomial rather


than determining a single real root given an approximate location.
‘Algebraic’ &‘Transcendental’ equations
• Bracketing methods

• 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

• These methods also involve systematic trial-and-error iterations but do not


require that the initial guesses bracket the root.

• These methods are usually more computationally efficient than bracketing


methods but that they do not always work. Three specific methods are to
be studied: One-point iteration, Newton-Raphson, and secant methods.
Graphical methods:
• A simple method for obtaining an estimate of the root of the equation
f (x) = 0 is to make a plot of the function and observe where it crosses
the x axis.

• This point, which represents the x value for which f (x) = 0, provides a
rough approximation of the root.

• Graphical techniques are of limited practical value because they are


not precise.

• However, graphical methods can be utilized to obtain rough estimates


of roots.

• These estimates can be employed as starting guesses for numerical


methods.

• Aside from providing rough estimates of the root, graphical


interpretations are important tools for understanding the properties of
the functions and anticipating the pitfalls of the numerical methods.
Types of roots
• For example, Fig. shows a number of ways in
which roots can occur (or be absent) in an
interval prescribed by a lower bound xl and an
upper bound xu.

• Figure b depicts the case where a single root is


bracketed by negative and positive values of f (x).

• However, Fig. d, where f (xl) and f (xu) are also on


opposite sides of the x axis, shows three roots
occurring within the interval.

• In general, if f (xl) and f (xu) have opposite signs,


there are an odd number of roots in the interval.

• As indicated by Fig. a and c, if f (xl) and f (xu) have


the same sign, there are either no roots or an
even number of roots between the values.
Types of roots
• Although these generalizations are
usually true, there are cases where they
do not hold.

• For example, functions that are tangential


to the x axis (Fig. a) and discontinuous
functions (Fig. b) can violate these
principles.

• An example of a function that is


tangential to the axis is the cubic
equation f(x) = (x − 2)(x − 2)(x − 4).

• Notice that x = 2 makes two terms in this


polynomial equal to zero.

• Mathematically, x = 2 is called a multiple


root.
The Graphical Approach
Problem Statement
• Use the graphical approach to determine the drag coefficient c needed
for a parachutist of mass m = 68.1 kg to have a velocity of 40 m/s after
free-falling for time t = 10 s. Note: The acceleration due to gravity is 9.8
m/s2

(11)

• Various values of c can be substituted into the right-hand side of this


equation to compute f(c)
Continue…

• These points are plotted in Fig. The resulting curve


No
crosses the c axis between 12 and 16. Visual
inspection of the plot provides a rough estimate of
the root of 14.75. The validity of the graphical
estimate can be checked by substituting it into Eq.
(11) to yield
Image
• which is close to zero.
Continue…
• It can also be checked by substituting it into Eq. (4) along with the
parameter values from this example to give

• which is very close to the desired fall velocity of 40 m/s.


Numerical Methods &
Computer Programming
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.

• These techniques are called bracketing methods because two initial


guesses for the root are required.

• As the name implies, these guesses must “bracket,” or be on either side


of, the root.

• The particular methods described herein employ different strategies to


systematically reduce the width of the bracket and, hence, home in on the
correct answer.

• To initiates to such methods, we have already discussed the graphical


methods for depicting functions and their roots.

• 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.

Step 2: The first approximate root estimation is to be done by considering


the midpoint of x1 and x2 Y = f(x)
f(x2)
Y = f(x)
F(x3)

x1

x x3 x2

f(x1) X3 = (x1 + x2 )/2


Y = f(x)
f(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)

Hence we have to replace x2 with x3

Therefore new initial guesses are:


x1 = 3 as it is and x2 = 3.5
Find new x3 between x1 = 3 and x2 = 3.5
X3 = (3 + 3.5) / 2 = 3.25

Find f (x3) and check the sign.


x3 = 3.25 hence f(x3) = 3.76 (Positive)

Hence again replace x2 with x3


Therefore new initial guesses are:
x1 = 3 as it is and x2 = 3.25
Find new x3 between x1 = 3 and x2 = 3.25
X3 = (3 + 3.25) / 2 = 3.125
Bisection method
3 2
𝑓 𝑥 = 𝑥 − 𝑥 − 20
Step 3: Find f (x3) and check the sign.
x3 = 3.125 hence f(x3) = 0.75 (Positive)

Hence we have to replace x2 with x3

Therefore new initial guesses are:


x1 = 3 as it is and x2 = 3.125
Find new x3 between x1 = 3 and x2 = 3.125
X3 = (3 + 3.125) / 2 = 3.06

Find f (x3) and check the sign.


x3 = 3.06 hence f(x3) = -0.71 (negative)

Hence again replace x1 with x3


Therefore new initial guesses are:
x1 = 3.06 and x2 = as it is 3.125
Find new x3 between x1 = 3.06 and x2 = 3.125
X3 = (3.06 + 3.125) / 2 = 3.09
Bisection method
3 2
𝑓 𝑥 = 𝑥 − 𝑥 − 20
Step 3: Find f (x3) and check the sign.
x3 = 3.09 hence f(x3) = -0.04 (Negative)

Hence we have to replace x1 with x3

Therefore new initial guesses are:


x1 = 3.09 and x2 = as it is 3.125
Find new x3 between x1 = 3.09 and x2 = 3.125
X3 = (3.09 + 3.125) / 2 = 3.10

Find f (x3) and check the sign.


x3 = 3.10 hence f(x3) = 0.18 (Positive)

Hence again replace x2 with x3


Therefore new initial guesses are:
x1 = 3.09 as it is and x2 = 3.10
Find new x3 between x1 = 3.09 and x2 = 3.10
X3 = (3.09 + 3.10) / 2 = 3.095
Bisection method
3 2
𝑓 𝑥 = 𝑥 − 𝑥 − 20
Step 3: Find f (x3) and check the sign.
x3 = 3.095 hence f(x3) = 0.06 (Positive)

Which is almost near to zero. Hence we can stop.


Numerical Methods &
Computer Programming
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

Hence root of equation is 0.6210

Iteration 1 x1 F(x1) x2 F(x2) x3 F(x3) Accuracy


1 0.5 0.2275 1 -0.7596 0.75 -0.2433 0.25
2 0.5 0.2275 0.75 -0.2433 0.625 – 0.0015368 0.125
3 0.5 0.2275 0.625 – 0.0015368 0.5625 0.1146 0.0625
4 0.5625 0.1146 0.625 – 0.0015368 0.5937 0.0570 0.0313
5 0.5937 0.0570 0.625 – 0.0015368 0.6093 0.0278 0.0157
6 0.6093 0.0278 0.625 – 0.0015368 0.6171 0.0132 0.0079
7 0.6171 0.0132 0.625 – 0.0015368 0.6210 0.0059
Numerical Methods &
Computer Programming
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)

Add and subtract x2 on RHS


𝑓 𝑥1 𝑥2 𝑓(𝑥2 )𝑥1 𝑓 𝑥2 (𝑥1 − 𝑥2 )
𝑥3 = 𝑥2 + − 𝑥2 − Cross multiply 𝑥3 = 𝑥2 −
𝑓(𝑥1 ) − 𝑓(𝑥2 ) 𝑓(𝑥1 ) − 𝑓(𝑥2 ) 𝑓(𝑥1 ) − 𝑓(𝑥2 )
Use false position method to locate the root of
𝐟 𝐱 = 𝒙𝟏𝟎 − 𝟏

Y = f(x)

f(x2)

x1 x3 x3
x2
x

f(x1) f(x3) f(x3) f(x3)

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

Numerical Methods &


Computer Programming
Tutorial 2
Roots of equation
Bracketing methods in MATLAB
Tutorial 2
Roots of equation
Bracketing methods in MATLAB

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.

• The value of x1 can be substituted in equation y = f(x) and y1 can be found.

• The value of first approximate of root is found by drawing a tangent at point


y1 whose coordinates are x1 and y1.

• 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

Computational Methods & Programming

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.

• These techniques are called bracketing methods because two initial


guesses for the root are required.

• As the name implies, these guesses must “bracket,” or be on either side


of, the root.

• The particular methods described herein employ different strategies to


systematically reduce the width of the bracket and, hence, home in on the
correct answer.

• To initiates to such methods, we have already discussed the graphical


methods for depicting functions and their roots.

• 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.

Step 2: The first approximate root estimation is to be done by considering


the midpoint of x1 and x2 Y = f(x)
f(x2)
Y = f(x)
F(x3)

x1

x x3 x2

f(x1) X3 = (x1 + x2 )/2


Y = f(x)
f(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)

Hence we have to replace x2 with x3

Therefore new initial guesses are:


x1 = 3 as it is and x2 = 3.5
Find new x3 between x1 = 3 and x2 = 3.5
X3 = (3 + 3.5) / 2 = 3.25

Find f (x3) and check the sign.


x3 = 3.25 hence f(x3) = 3.76 (Positive)

Hence again replace x2 with x3


Therefore new initial guesses are:
x1 = 3 as it is and x2 = 3.25
Find new x3 between x1 = 3 and x2 = 3.25
X3 = (3 + 3.25) / 2 = 3.125
Bisection method
3 2
𝑓 𝑥 = 𝑥 − 𝑥 − 20
Step 3: Find f (x3) and check the sign.
x3 = 3.125 hence f(x3) = 0.75 (Positive)

Hence we have to replace x2 with x3

Therefore new initial guesses are:


x1 = 3 as it is and x2 = 3.125
Find new x3 between x1 = 3 and x2 = 3.125
X3 = (3 + 3.125) / 2 = 3.06

Find f (x3) and check the sign.


x3 = 3.06 hence f(x3) = -0.71 (negative)

Hence again replace x1 with x3


Therefore new initial guesses are:
x1 = 3.06 and x2 = as it is 3.125
Find new x3 between x1 = 3.06 and x2 = 3.125
X3 = (3.06 + 3.125) / 2 = 3.09
Bisection method
3 2
𝑓 𝑥 = 𝑥 − 𝑥 − 20
Step 3: Find f (x3) and check the sign.
x3 = 3.09 hence f(x3) = -0.04 (Negative)

Hence we have to replace x1 with x3

Therefore new initial guesses are:


x1 = 3.09 and x2 = as it is 3.125
Find new x3 between x1 = 3.09 and x2 = 3.125
X3 = (3.09 + 3.125) / 2 = 3.10

Find f (x3) and check the sign.


x3 = 3.10 hence f(x3) = 0.18 (Positive)

Hence again replace x2 with x3


Therefore new initial guesses are:
x1 = 3.09 as it is and x2 = 3.10
Find new x3 between x1 = 3.09 and x2 = 3.10
X3 = (3.09 + 3.10) / 2 = 3.095
Bisection method
3 2
𝑓 𝑥 = 𝑥 − 𝑥 − 20
Step 3: Find f (x3) and check the sign.
x3 = 3.095 hence f(x3) = 0.06 (Positive)

Which is almost near to zero. Hence we can stop.


College of Engineering Pune
Department of Mechanical Engineering

Computational Methods & Programming

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

Hence root of equation is 0.6210

Iteration 1 x1 F(x1) x2 F(x2) x3 F(x3) Accuracy


1 0.5 0.2275 1 -0.7596 0.75 -0.2433 0.25
2 0.5 0.2275 0.75 -0.2433 0.625 – 0.0015368 0.125
3 0.5 0.2275 0.625 – 0.0015368 0.5625 0.1146 0.0625
4 0.5625 0.1146 0.625 – 0.0015368 0.5937 0.0570 0.0313
5 0.5937 0.0570 0.625 – 0.0015368 0.6093 0.0278 0.0157
6 0.6093 0.0278 0.625 – 0.0015368 0.6171 0.0132 0.0079
7 0.6171 0.0132 0.625 – 0.0015368 0.6210 0.0059
College of Engineering Pune
Department of Mechanical Engineering

Computational Methods & Programming

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)

Add and subtract x2 on RHS


𝑓 𝑥1 𝑥2 𝑓(𝑥2 )𝑥1 𝑓 𝑥2 (𝑥1 − 𝑥2 )
𝑥3 = 𝑥2 + − 𝑥2 − Cross multiply 𝑥3 = 𝑥2 −
𝑓(𝑥1 ) − 𝑓(𝑥2 ) 𝑓(𝑥1 ) − 𝑓(𝑥2 ) 𝑓(𝑥1 ) − 𝑓(𝑥2 )
Use false position method to locate the root of
𝐟 𝐱 = 𝒙𝟏𝟎 − 𝟏

Y = f(x)

f(x2)

x1 x3 x3
x2
x

f(x1) f(x3) f(x3) f(x3)

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

Computational Methods & Programming

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.

• The value of x1 can be substituted in equation y = f(x) and y1 can be found.

• The value of first approximate of root is found by drawing a tangent at point


y1 whose coordinates are x1 and y1.

• 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

Computational Methods & Programming

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:

You might also like