Numerical Methods
Lecture 04
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 1
Roots of Nonlinear Equations
❑ Basic Concepts
– Mathematical models for a wide variety of problems in science and engineering
can be formulated into equations of the form
f(x) = 0
where x and f(x) may be real, complex, or vector quantities. The solution process
often involves finding the values of x that would satisfy the equation. These values
are called the roots of the equation. Since the function f(x) becomes zero at these
values, they are also known as the zeros of the function f(x).
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 2
Roots of Nonlinear Equations
❑ Types of Equations
– Algebraic equations
– Polynomial equations
– Transcendental equations
❑ Linear and Nonlinear Function
– Consider the function y = f(x). f(x) is a linear function, if the dependent
variable y changes in direct proportion to the change in independent variable x.
For example, y = 3x + 5 is a linear function.
– f(x) is said to be nonlinear, if the response of the dependent variable y is not in
direct or exact proportion to the changes in the independent variable x.
For example, y = x2 + 1 is a nonlinear function.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 3
Roots of Nonlinear Equations
❑ Algebraic Equations
– An equation of type y = f(x) is said to be algebraic if it can be expressed in the
form
f n y n + f n −1 y n −1 + .................... + f1 y1 + f 0 = 0
Where f i is an ith order polynomial in x. The above equation can be thought
of as having a general form:
f(x,y) = 0
Some examples are:
3x + 5y - 21 = 0 (linear)
2x + 3xy - 25 = 0 (non-linear)
x3 - xy - 3y3 = 0 (non-linear)
These equations have an infinite number of pairs of values of x and y which satisfy
them.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 4
Roots of Nonlinear Equations
❑ Polynomial Equations
– Polynomial equations are a simple class of algebraic equations that are
represented as follows:
a n x n + a n −1 x n −1 + ........................ + a1 x + a 0 = 0
This is called nth degree polynomial and has n roots. The roots may be:
– real and different
– real and repeated
– complex numbers
Some examples of polynomial equations are:
5x5- x3 + 3x2 = 0
x3 - 4x2 + x + 6 = 0
x2- 4x + 4 = 0
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 5
Roots of Nonlinear Equations
❑ Transcendental Equations
– A non-algebraic equation is called a transcendental equation.
These equations include trigonometric, exponential and logarithmic functions.
Examples of transcendental equation are:
2 sin x - x = 0
ex sin x - 1/2x = 0
log x2 - 1 = 0
x – e1/x = 0
– A transcendental equation may have a finite or an infinite number of real roots
or may not have real root at all.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 6
Roots of Nonlinear Equations
❑ METHODS OF SOLUTION
– There are a number of ways to find the roots of nonlinear equations:
• Direct analytical methods
• Graphical methods
• Trial and error methods
• Iterative methods
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 7
Roots of Nonlinear Equations
❑ Direct Analytical Methods
– In certain cases, roots can be found by using direct analytical methods. For
example, consider a quadratic equation such as
ax2 + bx + c = 0
Solution of this equation is
−b b 2 − 4ac
x =
2a
This gives two roots.
However, there are equations that cannot be solved by analytical methods. For
example, the simple transcendental equation
2 sin x - x = 0
cannot be solved analytically.
– Direct analytical methods for solving non-linear equations do not exist except
for certain simple cases.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 8
Roots of Nonlinear Equations
❑ Graphical Methods
– Graphical methods are useful when we are satisfied with approximate solution
for a problem.
– This method involves plotting the given function and determining the points
where it crosses the x-axis. These points represent approximate values of the
roots of the function.
❑ Trial and Error Methods
– This is another approach to obtain approximate solution.
– This method involves a series of guesses for x, each time evaluating the
function to see whether it is close to zero. The value of x that causes the
function value closer to zero is one of the approximate roots of the equation.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 9
Roots of Nonlinear Equations
❑ Iterative Methods
– Although graphical and trial and error methods provide satisfactory
approximations for many problem situations, they become cumbersome and
time consuming.
– Moreover, the accuracy of the results are inadequate for the requirements of
many engineering and scientific problems.
– An iterative technique usually begins with an approximate value of the root,
known as the initial guess, which is then successively corrected iteration by
iteration. The process of iteration stops when the desired level of accuracy is
obtained.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 10
Roots of Nonlinear Equations
❑ Iterative Methods
– Iterative methods, based on the number of guesses they use, can be grouped
into two categories:
• Bracketing methods
• Open end methods.
❑ Bracketing Methods
– Also known as interpolation methods.
– These methods start with two initial guesses that ‘bracket’ the root and then
systematically reduce the width of the bracket until the solution is reached.
– Two popular methods under this category are:
• Bisection method
• False position method
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 11
Roots of Nonlinear Equations
❑ Open End methods
– Also known as extrapolation methods.
– These methods use a single starting value or two values that do not necessarily
bracket the root.
– Some methods under this category:
• Newton-Raphson method
• Secant method
• Muller’s method
• Fixed-point method
• Bairstow’s method
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 12
Roots of Nonlinear Equations
❑ BISECTION METHOD
– This is one of the simplest and most reliable of iterative methods for the
solution of nonlinear equations.
– This method, also known as binary chopping or half-interval method, relies
on the fact that if f(x) is real and continuous in the interval a < x < b, and f(a)
and f(b) are of opposite signs, that is,
f(a) . f(b) < 0
then there is at least one real root in the interval between a and b.
– Let x1 = a and x2 = b. Let us also define another point x0 to be the midpoint
between a and b. That is,
x1 + x 2
x0 =
2
Now, there exists the following three conditions:
• If f(x0) = 0, we have a root at x0.
• If f(x0) . f(x1) < 0, there is a root between x0 and x1.
• If f(x0) . f(x2) < 0, there is a root between x0 and x2.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 13
•
Roots of Nonlinear Equations
❑ BISECTION METHOD
– Testing the sign of the function at midpoint, we can deduce which part of the interval
contains the root. This is illustrated in the following Fig.
– It shows that since f(x0) and f(x2) are of opposite sign, a root lies between x0 and x2. We
can further divide this subinterval into two halves to locate a new subinterval containing
the root. This process can be repeated until the interval containing the root is as small as
we desire.
Illustration of Bisection Method
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 14
Roots of Nonlinear Equations
❑ Example: Find a root of the equation x2 - 4x - 10 = 0 using bisection method.
Answer:
– Guess two initial values that would bracket a root.
2
a n −1 a
x max = − 2 n − 2
an an
−4 − 10
2
= − 2
1 1
=6
– Therefore, we have both the roots in the interval (-6, 6).
– The table below gives the values of f(x) between -6 and 6 and shows that there
is a root in the interval (-2, -1) and another in (5, 6).
x: -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6
f(x) : 50 35 22 11 2 -5 -10 -13 -14 -13 -10 -5 2
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 15
Roots of Nonlinear Equations
❑ Example: Find a root of the equation x2 - 4x - 10 = 0 using bisection method.
Let us take x1 = -2 and x2 = -1, then
f(x1) = 2 and f(x2) = -5
x1 + x 2 − 2 −1
x0 = = = −1.50
2 2
f(x0) = - 1.75
Since f(x1) . f(x0) < 0, the root must be in the interval (-2, -1.5).
Thus, x1 = -2 and x2 = x0 = -1.5
f(x1) = 2 and f(x2) = - 1.75
x1 + x 2 − 2 − 1.5
x0 = = = −1.75
2 2
f(x0) = 0.0625
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 16
Roots of Nonlinear Equations
❑ Example: Find a root of the equation x2 - 4x - 10 = 0 using bisection method.
Since f(x2) . f(x0) < 0, the root must be in the interval (-1.75, -1.5).
Thus, x1 = x0 = -1.75 and x2 = -1.5
f(x1) = 0.0625 and f(x2) = - 1.75
x1 + x 2 − 1.75 − 1.5
x0 = = = −1.625
2 2
f(x0) = - 0.859
Since f(x1) . f(x0) < 0, the root must be in the interval (-1.75, -1.625).
Thus, x1 = -1.75 and x2 = x0 = -1.625
f(x1) = 0.0625 and f(x2) = - 0.859
x1 + x 2 − 1.75 − 1.625
x0 = = = −1.6875
2 2
f(x0) = - 0.40
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 17
Roots of Nonlinear Equations
❑ Example: Find a root of the equation x2 - 4x - 10 = 0 using bisection method.
Since f(x1) . f(x0) < 0, the root must be in the interval (-1.75, -1.6875).
Thus, x1 = -1.75 and x2 = x0 = -1.6875
f(x1) = 0.0625 and f(x2) = - 0.40
x1 + x 2 − 1.75 − 1.6875
x0 = = = −1.72
2 2
f(x0) = - 0.1616
Since f(x1) . f(x0) < 0, the root must be in the interval (-1.75, -1.72).
Thus, x1 = -1.75 and x2 = x0 = -1.72
f(x1) = 0.0625 and f(x2) = - 0.1616
x1 + x 2 − 1.75 − 1.72
x0 = = = −1.735
2 2
f(x0) = - 0.05
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 18
Roots of Nonlinear Equations
❑ Example: Find a root of the equation x2 - 4x - 10 = 0 using bisection method.
Since f(x1) . f(x0) < 0, the root must be in the interval (-1.75, -1.735).
Thus, x1 = -1.75 and x2 = x0 = -1.735
f(x1) = 0.0625 and f(x2) = - 0.05
x1 + x 2 − 1.75 − 1.735
x0 = = = −1.7425
2 2
f(x0) = 0.0063
Since f(x2) . f(x0) < 0, the root must be in the interval (-1.7425, -1.735).
Approximate root is - 1.7416
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 19
Roots of Nonlinear Equations
❑ Algorithm: Bisection Method
1. Decide initial values for x1 and x2 and stopping criterion, E.
2. Compute f1 = f(x1) and f2 = f(x2)
3. If f1 x f2 > 0, then x1 and x2 do not bracket any root and go to step 7; otherwise continue.
4. Compute x0 = (x1 + x2)/2 and compute f0 = f(x0).
5. If f1 x f0 <0 then
set x2 = x0.
else
set x1 = x0
set f1 = f0.
6. If absolute value of (x2 - x1)/x2 is less than error E, then
root = (x1 + x2)/2
Write the value of root
Go to step 7
else
Go to step 4
7. Stop.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 20
Roots of Nonlinear Equations
❑ Convergence of Bisection Method
– In the bisection method, we choose a midpoint x0 in the interval between x1 and x2.
Depending on the sign of functions f(x0), f(x1), and f(x2), x1 or x2 is set equal to x0 such
that the new interval contains the root. In either case, the interval containing the root is
reduced by a factor of 2. The same procedure is repeated for the new interval. If the
procedure is repeated n times, then the interval containing the root is reduced to the size
x 2 − x1 x
=
2n 2n
– After n iterations, the root must lie within . This means that the error bound at nth
iteration is
x
En =
2n
x En
– Similarly, E n +1 = =
2 n +1 2
– That is, the error decreases linearly with each step by a factor of 0.5. The bisection
method is, therefore, linearly convergent.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 21
Roots of Nonlinear Equations
❑ Bisection Method
– Since the convergence is slow to achieve a high degree of accuracy, a large
number of iterations may be needed. (Disadvantage)
– However, the bisection algorithm is guaranteed to converge. (Advantage)
– In bisection method, the interval between x1 and x2 is divided into two equal
halves, irrespective of location of the root. It may be possible that the root is
closer to one end than the other. (Disadvantage)
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 22
Roots of Nonlinear Equations
❑ False Position Method
– The basic principle of false position method is illustrated in the following figure.
(x2 , f(x2 ) )
f(x)
(x0 , f(x0 ) )
x1
x0 x2 x
(x1 , f(x1 ) )
Fig.: Illustration of false position method
– Suppose the root lines between x1 and x2.
– Let us join the points x1 and x2 by a straight line.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 23
Roots of Nonlinear Equations
❑ False Position Method
– The point of intersection of this line with the x-axis (x0) gives an improved estimate of
the root and is called the false position of the root.
– This point then replaces one of the initial guesses that has a function value of the same
sign as f(x0).
– This process is repeated with the new values of x1 and x2.
– Since this method uses the false position of the root repeatedly, it is called the false
position method.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 24
Roots of Nonlinear Equations
❑ False Position Formula
– We know that equation of the line joining the points (x1, f(x1)) and (x2, f(x2)) is given by
f ( x 2 ) − f ( x1 ) y − f ( x1 )
=
x 2 − x1 x − x1
– Since the line intersects the x-axis at x0, when x = x0, y = 0, we have
f ( x 2 ) − f ( x1 ) 0 − f ( x1 )
=
x 2 − x1 x 0 − x1
f ( x1 )( x 2 − x1 )
x 0 − x1 = −
f ( x 2 ) − f ( x1 )
– Therefore,
f ( x1 )( x 2 − x1 )
x 0 = x1 −
f ( x 2 ) − f ( x1 )
– This equation is known as the false position formula.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 25
Roots of Nonlinear Equations
❑ Example: Use the false position method to find a root of the function
f ( x) = x 2 − x − 2 = 0 in the range 1<x<3
Solution:
Iteration 1:
x1 = 1, x2 = 3,
f(x1) = -2, f(x2) = 4
f ( x1 )( x 2 − x1 ) (−2)(3 − 1) 4
x0 = x1 − = 1− = 1 + = 1.6667
f ( x 2 ) − f ( x1 ) 4 − (−2) 6
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 26
Roots of Nonlinear Equations
❑ Example: Use the false position method to find a root of the function
f ( x) = x 2 − x − 2 = 0 in the range 1<x<3
Solution:
Iteration 2:
f(x0) = f(1.6667) = - 0.8889
Sign is negative. So, the root lies between x0 = 1.6667 and x2 = 3. Thus,
x1 = 1.6667, x2 = 3,
f(x1) = - 0.8889, f(x2) = 4
f ( x1 )( x 2 − x1 )
x 0 = x1 −
f ( x 2 ) − f ( x1 )
( −0.8889)(3 − 1.6667)
= 1.6667 − = 1.909
4 − ( −0.8889)
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 27
Roots of Nonlinear Equations
❑ Example: Use the false position method to find a root of the function
f ( x) = x 2 − x − 2 = 0 in the range 1<x<3
Solution:
Iteration 3:
f(x0) = f(1.909) = - 0.2647
Sign is negative. So, the root lies between x0 = 1.909 and x2 = 3.
Thus,
x1 = 1.909, x2 = 3,
f(x1) = - 0.2647, f(x2) = 4
f ( x1 )( x 2 − x1 )
x 0 = x1 −
f ( x 2 ) − f ( x1 )
( −0.2647)(3 − 1.909)
= 1.909 − = 1.986
4 − ( −0.2647)
After 3rd iteration, the estimated root is: 1.986.
Actual root is 2.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 28
Roots of Nonlinear Equations
❑ Newton-Raphson Method
– Consider the following graph. Let us assume that x1 is an approximate root of
f(x) = 0.
– Now draw a tangent at the curve f(x) at x = x1.
x1, f(x1)
f(x)
x2, f(x2)
f(x1)
α
x3 x2 x1 x
Fig. Newton-Raphson Method
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 29
Roots of Nonlinear Equations
❑ Newton-Raphson Method
– The point of intersection of this tangent with the x-axis gives the second
approximation to the root. Let the point of intersection be x2. The slope of the
tangent is given by
f ( x1 )
tan = = f / ( x1 )
x1 − x 2
where f /(x1) is the slope of f(x) at x = x1.
– Solving for x2 we obtain
f ( x1 )
x 2 = x1 −
f / ( x1 )
This is called the Newton-Raphson formula.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 30
Roots of Nonlinear Equations
❑ Newton-Raphson Method
– The next approximation would be
f ( x2 )
x3 = x 2 −
f / ( x2 )
– In general,
f ( xn )
x n +1 = x n −
f / ( xn )
– This method of successive approximation is called the Newton-Raphson
method. The process will be terminated when the difference between two
successive values is within a prescribed limit.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 31
Roots of Nonlinear Equations
❑ Newton-Raphson Method
Limitations
– Complications will arise if the derivative is zero. In such case, a new initial
value for x must be chosen to continue the procedure.
– If the initial guess is too far away from the required root, the process may
converge to some other root.
– A particular value in the iteration sequence may repeat, resulting in an infinite
loop. This occurs when the tangent to the curve f(x) at x = xi+1 cuts the x-axis
again at x = xi.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 32
Roots of Nonlinear Equations
❑ Newton-Raphson Method
Derivation from Taylor Series Expansion
Assume that xn is an estimate of a root of the function f(x).
Consider a small interval h such that
h = xn+1 - xn - - - - - - ---------------------------------------------- (1)
We can express f(xn+1) using Taylor series expansion as follows:
h2
f ( x n +1 ) = f ( x n ) + f ( x n )h + f ( x n )
/ //
+ .......................
2!
If we neglect the terms containing the second order and higher derivatives, we get,
f ( x n +1 ) = f ( x n ) + f / ( x n ) h
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 33
Roots of Nonlinear Equations
❑ Newton-Raphson Method
Derivation from Taylor Series Expansion
If xn+1 is a root of f(x), then
f ( x n +1 ) = 0 = f ( x n ) + f /
( x n )h
− f ( xn )
h =
f / (xn ) -------------------------------------------------(2)
− f ( xn )
From (1) and (2), = x n +1 − x n
f / (xn )
Therefore, f ( xn )
x n +1 = x n −
f / (xn )
This is the Newton-Raphson formula.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 34
Roots of Nonlinear Equations
❑ Newton-Raphson Algorithm
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 35
Roots of Nonlinear Equations
❑ Example: Find the root of the equation
f(x) = x2 – 3x + 2
in the vicinity of x = 0 using Newton-Raphson method.
Solution:
f(x) = x2 – 3x + 2
f /(x) = 2x – 3
x1 = 0 (First approximation)
f ( x1 ) 2
Therefore, x 2 = x1 − = 0 − = 0.6667
f / ( x1 ) −3
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 36
Roots of Nonlinear Equations
❑ Example: Find the root of the equation
f(x) = x2 – 3x + 2
in the vicinity of x = 0 using Newton-Raphson method.
f ( x2 ) 0.4444
Similarly, x3 = x 2 − = 0.6667 − = 0.9333
/
f ( x2 ) − 1.6667
f ( x3 ) 0.071
x 4 = x3 − = 0.9333 − = 0.9959
/
f ( x3 ) − 1.334
f ( x4 ) 0.0041
x5 = x 4 − = 0.9959 − = 0.9999
/
f ( x4 ) − 1.0082
f ( x5 ) 0.0001
x 6 = x5 − = 0.9999 − = 1.0000
/
f ( x5 ) − 1.0002
f ( x6 ) 0
x7 = x6 − = 1 − = 1.0000
f / ( x6 ) −1
So, Root is 1.0
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 37
Roots of Nonlinear Equations
❑ Secant Method
– Secant method uses two initial estimates but does not require that they must
bracket the root.
– The basic concept is illustrated in the following figure.
Scant line
f(x1) f(x)
f(x)
f(x2)
x3 x2 x1 x
Fig. Scant Method
Consider the points x1 and x2 as starting values. They don’t bracket the root.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 38
Roots of Nonlinear Equations
❑ Secant Method
– Slope of the secant line passing through x1 and x2 is given by
f ( x1 ) f ( x2 )
=
x1 − x3 x 2 − x3
f ( x1 )( x 2 − x3 ) = f ( x 2 )( x1 − x3 )
x3 [ f ( x 2 ) − f ( x1 )] = f ( x 2 ) x1 − f ( x1 ) x 2
f ( x 2 ) x1 − f ( x1 ) x 2
x3 =
f ( x 2 ) − f ( x1 )
– After rearranging,
f ( x 2 )( x 2 − x1 )
x3 = x 2 − -------------------------(1)
f ( x 2 ) − f ( x1 )
– This is known as the secant formula.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 39
Roots of Nonlinear Equations
❑ Secant Method
– The approximate value of the root can be refined by repeating this procedure
by replacing x1 and x2 by x2 and x3 respectively. That is, the next approximate
value is given by,
f ( x3 )( x3 − x 2 )
x 4 = x3 −
f ( x3 ) − f ( x 2 )
– This procedure is continued till the desired level of accuracy is obtained.
– We can express the Secant formula in general form:
f ( xi )( xi − xi −1 )
xi +1 = xi −
f ( xi ) − f ( xi −1 )
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 40
Roots of Nonlinear Equations
❑ Secant Algorithm
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 41
Roots of Nonlinear Equations
❑ Example: Use the Secant method to estimate the root of the equation:
f(x) = x2 - 4x - 10 with the initial estimates of x1 = 4 and x2 = 2.
Answer:
x1 = 4 and x2 = 2
f(x1) = -10 and f(x2) = -14
Now calculate x3:
f ( x 2 )( x 2 − x1 )
x3 = x 2 −
f ( x 2 ) − f ( x1 )
− 14( 2 − 4)
= 2− =9
− 14 − ( −10)
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 42
Roots of Nonlinear Equations
❑ Example: Use the Secant method to estimate the root of the equation:
f(x) = x2 - 4x - 10 with the initial estimates of x1 = 4 and x2 = 2.
For 2nd iteration,
x1 = x2 = 2
x2 = x3 = 9
f(x1) = -14 and f(x2) = 35
f ( x 2 )( x 2 − x1 )
x3 = x 2 −
f ( x 2 ) − f ( x1 )
35(9 − 2)
=9− =4
35 − (−14)
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 43
Roots of Nonlinear Equations
❑ Example: Use the Secant method to estimate the root of the equation:
f(x) = x2 - 4x - 10 with the initial estimates of x1 = 4 and x2 = 2.
For 3rd iteration,
x1 = x2 = 9
x2 = x3 = 4
f(x1) = 35 and f(x2) = -10
f ( x 2 )( x 2 − x1 )
x3 = x 2 −
f ( x 2 ) − f ( x1 )
− 10(4 − 9)
= 4− = 5.1111
− 10 − 35
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 44
Roots of Nonlinear Equations
❑ Example: Use the Secant method to estimate the root of the equation:
f(x) = x2 - 4x - 10 with the initial estimates of x1 = 4 and x2 = 2.
For 4th iteration,
x1 = x2 = 4
x2 = x3 = 5.1111
f(x1) = -10 and f(x2) = -4.3207
f ( x 2 )( x 2 − x1 )
x3 = x 2 −
f ( x 2 ) − f ( x1 )
− 4.3207(5.1111 − 4)
= 5.1111 − = 5.9563
− 4.3207 − (−10)
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 45
Roots of Nonlinear Equations
❑ Example: Use the Secant method to estimate the root of the equation:
f(x) = x2 - 4x - 10 with the initial estimates of x1 = 4 and x2 = 2.
For 5th iteration,
x1 = x2 = 5.1111
x2 = x3 = 5.9563
f(x1) = -4.3207 and f(x2) = 1.6523
f ( x 2 )( x 2 − x1 )
x3 = x 2 −
f ( x 2 ) − f ( x1 )
1.6523(5.9563 − 5.1111)
= 5.9563 − = 5.7225
1.6523 − (−4.3207)
The value can be further refined by continuing the process, if necessary.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 46
Roots of Nonlinear Equations
❑ Secant Method VS Newton-Raphson Method
f ( xn )
Newton formula: x n +1 = x n −
f / ( xn )
Secant formula: f ( x n )( x n − x n −1 )
x n +1 = x n −
f ( x n ) − f ( x n −1 )
– In Newton formula, it needs derivative. There are many functions whose
derivative may be difficult to evaluate. Secant formula needs no derivatives.
– Secant formula needs two initials. Again its convergence rate is slower than
that of Newton formula.
5/27/2023 Md. Golam Moazzam, Dept. of CSE, JU 47