EEE 3604 : Numerical Analysis Sessional
Experiment- 04
Analysis of Numerical Methods for
Identifying Multiple Roots in Nonlinear
Equations
Sanjid-E-Elahi
Department of Electrical and Electronic Engineering
Dhaka University of Engineering & Technology (DUET)
Secant Method
When the derivative function, 𝒇′(𝒙), is unavailable or prohibitively costly
to evaluate, an alternative to Newton’s method is required. The preferred
alternative is the secant method.
In this method, we proceed like the Regula Falsi method, i.e., we
approximate our curve 𝑓(𝑥) with the chord joining two points on the curve.
The only difference is that we don’t check the intermediate value property for
the next two approximation points.
A secant to a curve is the straight line which passes through two points on the
curve. The procedure is applied repetitively to convergence. Two initial
approximations, 𝑥1 and 𝑥2 , which are not required to bracket the root, are
required to initiate the secant method.
EEE 3604 : Numerical Analysis Ex-04: Open Method-2 © Department of EEE, DUET 2
Secant Method
Consider the graph of 𝑓(𝑥) in Figure. Start
with two initial points 𝑥1 and 𝑥2 , locate the
points (𝑥1 , 𝑓(𝑥1 )) and (𝑥2 , 𝑓(𝑥2 )) on the
curve, and draw the secant line connecting
them
𝑓(𝑥) − 𝑓(𝑥2 ) 𝑥 − 𝑥2
=
𝑓 𝑥2 − 𝑓(𝑥1 ) 𝑥2 − 𝑥1
Now to find x intercept we put
𝑓 𝑥 = 0 𝑎𝑡 𝑥 = 𝑥3
𝒙𝟐 − 𝒙𝟏
𝒙𝟑 = 𝒙𝟐 − 𝒇(𝒙𝟐 )
𝒇 𝒙𝟐 − 𝒇 𝒙𝟏
EEE 3604 : Numerical Analysis Ex-04: Open Method-2 © Department of EEE, DUET 3
Secant Method
Next, use 𝑥2 and 𝑥3 to define a secant line and let the x-intercept of this line
be 𝑥4 . Continue the process until the sequence {x𝑛 } converges to the root. In
general, two consecutive elements x𝑛 and x𝑛+1 generated by secant method
are related via
Comparing with Newton’s method, we see that 𝑓′(𝑥𝑛 ) in is essentially
approximated by, and replaced with, the difference quotient
The iterations stop when two consecutive elements
are sufficiently close to one another, that is,
EEE 3604 : Numerical Analysis Ex-04: Open Method-2 © Department of EEE, DUET 4
Example
EEE 3604 : Numerical Analysis Ex-04: Open Method-2 © Department of EEE, DUET 5
Example (Contd.)
EEE 3604 : Numerical Analysis Ex-04: Open Method-2 © Department of EEE, DUET 6
MATLAB Example Secant Method
Find the first positive root of 𝑥 cos 𝑥 = −1 using Newton’s method
with ε = 10-4 and maximum 20 iterations. Take initial points x1 = 1
and x2 = 1.5.
Advantages and Disadvantages of Secant
Method (Self Study)
EEE 3604 : Numerical Analysis Ex-04: Open Method-2 © Department of EEE, DUET 7
Equations with Several Roots
All the bracketing and open methods presented upto now are
capable of finding one root of f(x) = 0 at a time.
The built-in MATLAB function built-in function fzero can be utilized
to find several real roots of an equation in a given interval.
A simple representation of its syntax is
where function is the name of the function being evaluated, and x0
is the initial guess.
EEE 3604 : Numerical Analysis Ex-04: Open Method-2 © Department of EEE, DUET 8
MATLAB function built-in function fzero
Two guesses that bracket the root can be passed as a vector:
where x0 and x1 are guesses that bracket a sign change.
The fzero function works as follows. If a single initial guess is passed, it first
performs a search to identify a sign change, in that the search starts at the
single initial guess and then takes increasingly bigger steps in both the
positive and negative directions until a sign change is detected.
Thereafter, the fast methods (secant and inverse quadratic interpolation) are
used unless an unacceptable result occurs (e.g., the root estimate falls
outside the bracket). If an unacceptable result happens, bisection is
implemented until an acceptable root is obtained with one of the fast
methods. As might be expected, bisection typically dominates at first but as
the root is approached, the technique shifts to the faster methods.
EEE 3604 : Numerical Analysis Ex-04: Open Method-2 © Department of EEE, DUET 9
Example
EEE 3604 : Numerical Analysis Ex-04: Open Method-2 © Department of EEE, DUET 10
MATLAB function built-in function fzero
A more complete representation of the fzero syntax can be written
as
The optimset function has the syntax
EEE 3604 : Numerical Analysis Ex-04: Open Method-2 © Department of EEE, DUET 11
MATLAB function built-in function fzero
EEE 3604 : Numerical Analysis Ex-04: Open Method-2 © Department of EEE, DUET 12
Example
EEE 3604 : Numerical Analysis Ex-04: Open Method-2 © Department of EEE, DUET 13
Example
EEE 3604 : Numerical Analysis Ex-04: Open Method-2 © Department of EEE, DUET 14
MATLAB Example Several Roots using fzero
Find all roots of 𝑥 sin 𝑥 = 0 in [−10,10]
EEE 3604 : Numerical Analysis Ex-04: Open Method-2 © Department of EEE, DUET 15
Points of Discontinuity Mistaken for Roots
If a function is not continuous, fzero may return values that are
points of discontinuity rather than roots. In general, it can be difficult
to find all roots of any arbitrary nonlinear function unless we have
knowledge of the behavior of the function, and an approximate
location of all desired roots.
Example : Points of Discontinuity
Find the roots of tan x = tanh x in [-2,2].
EEE 3604 : Numerical Analysis Ex-04: Open Method-2 © Department of EEE, DUET 16
Report-1
Figure shows a circuit with a resistor, an
inductor, and a capacitor in parallel.
Kirchhoff’s rules can be used to express
the impedance of the system as
where Z = impedance (Ω), and ω is the
angular frequency. Find the ω that
results in an impedance of 100 Ω using
the secant and fzero method with initial
guesses of 1 and 1000 for the following
parameters: R = 225 Ω, C = 0.6 × 10−6 F,
and L = 0.5 H.
EEE 3604 : Numerical Analysis Ex-04: Open Method-2 © Department of EEE, DUET 17
Report-2
For the circuit shown in Fig.,
𝑰𝟎 𝜔
1. Find its transfer function H 𝜔 = 𝑰𝒔 𝜔
Hint
2. Determine all the poles of H 𝜔 using
fzero. Assume an interval -5 to 0.
EEE 3604 : Numerical Analysis Ex-04: Open Method-2 © Department of EEE, DUET 18
Reference Books
EEE 3604 : Numerical Analysis Ex-04: Open Method-2 © Department of EEE, DUET 19
THANK YOU!!
EEE 3604 : Numerical Analysis Ex-04: Open Method-2 © Department of EEE, DUET 20