Nonlinear Equations & Bisection Method
Nonlinear Equations & Bisection Method
3.1 Introduction
Many physical and engineering problems can be governed by nonlinear equation f (x)=0.
These equations involve circular function, hyperbolic function, exponential and other
transcendental functions, and their combinations. The solution (values of x) of the
nonlinear equation f (x)=0 is challenging. In fact, most equations cannot be solved
analytically and so we have to solve them numerically. In this chapter, we shall consider
some of the important approximate methods in finding the roots of the equations in one
variable.
Rewrite the equation f (x)=0 as f 1 ( x)=f 2 (x) . At the point of intersection x=x 1 (say) of
the graphs
y=f 1 (x ) and y=f 2 (x )
that is
f 1 ( x1 )=f 2 (x 1)
and hence, x=x 1is a root of the equation.
Thus, the number of intersections of the two graphs will be the number of real roots.
Example 3.1
(a) Find the number of real roots of x 3 +4 x−3=0 by graphical method.
(b) Find the number of complex roots, if any.
(c) Use MATLAB function “roots” to find all the roots including complex roots.
( a ) x 3 +4 x−3=0
3
⟹ x =3−4 x
3
f 1 ( x )=x
f 2 ( x )=3−4 x
1
Fall 2024-2025
¿ 3−1=2.
(c) >> p= [1 0 4 -3] % entry of cubic polynomial
p = 1 0 4 -3
>> Roots = roots(p)
Roots =
-0.3368 + 2.0833i
-0.3368 - 2.0833i
0.6736 + 0.0000i
Example 3.2: Find the number of real roots of sin x−x +1=0 by graphical method.
sin x−x +1=0
⟹ sin x=x−1
f 1 ( x )=sin x
f 2 ( x )=x−1
Example 3.3: Find the number of real roots of 1−x−cos 3 x=0 by graphical method.
1−x−cos 3 x=0
1−x=cos 3 x
f 1 ( x )=1−x
f 2 ( x )=cos 3 x
To locate the roots of f (x)=0, first study the graph of y=f (x ) as shown below. If we
can find two values of x, one for which f (x) is positive, and one for which f (x) is
negative, then the curve must have crossed the x-axis and so must have passed through a
root of the equation f (x)=0.
2
Fall 2024-2025
Example 3.4 The equation ( x−1 ) e x =x has two real roots. For each root, find an interval
where it lies.
Consider the values of function f ( x )= ( x −1 ) e x −x for different values of x:
x f(x)
-2 1.59
-1 0.26
0 -1
1 -1
2 5.39
From the above table, we see that f (−1 ) f ( 0 )=−0.26 <0, a root lies in (−1 , 0 ) ,
and f ( 1 ) f ( 2 ) =−5.39<0, a root lies in (1 , 2)
3
Fall 2024-2025
• Errors can be managed. Increasing the number of iterations in the bisection method
always results in a more accurate root.
• Doesn't demand complicated calculations. There are no complicated calculations
required when using the bisection method. To use the bisection method, we only
need to take the average of two values.
• Error bound is guaranteed. There is a guaranteed error bound in this technique, and it
reduces with each repetition. Each cycle reduces the error bound by 12 per cent.
• The bisection method is simple and straightforward to program on a computer.
• In the case of several roots, the bisection procedure is quick.
𝑓(𝑥) = 𝑥².
• Some equations' roots cannot be found. Because there are no bracketing values, like
Example 3.5 For the given equation x 3−4 x+ 3=0 , a real root lies in between the
interval [−3 ,−2]. Find the minimum number of iterations required to find the root up to
the accuracy of three decimal points.
4
Fall 2024-2025
or, n ≥ 9.96 ≈ 10
MATLAB Code:
function [a,b,c]=bisectionMethod()
a=1;b=2;tol=0.01;
while abs((b-a))>tol
c=(a+b)/2;
if f(a)*f(c)<0
b=c;
else
a=c;
end
end
end
function f=f(x)
f=x*x-3;
end
Example 3.7 Given the equation x e x =1. Use the bisection method THREE
times in the interval [0 ,1] to get a new smaller interval, giving your answer
up to 3 d.p.
5
Fall 2024-2025
There are different iterative methods in finding the roots of an equation. To compare the
methods, order of convergence is used.
Let ε n be the error in the nth iteration for a root of f (x)=0, then:
ε n=|x n−α|
If
lim ε n−1
n →∞
R
=A (const)
εn
then the order of convergence of the sequence {x n } is R.
In special case,
If R=1, the convergence is called linear.
If R=2, the convergence is called quadratic.
If 1< R<2, the convergence is superlinear.
In Secant method two values of x near the root is used and the root is approximated by
the x-intercept of the secant line (chord) joining the two points. The straight line through
f (x 2 )−f (x1 )
the two points (x 1 , f (x 1)) and(x 2 , f (x 2)) is y−f (x 2 )= ( x−x 2)
x 2−x 1
On the x-axis y=0 and let x=x 3, then
f (x 2)−f (x 1 ) y
−f (x 2)=
x 2−x 1
(x 3−x 2 ) ( x1 , f ( x1 ))
(x 2−x 1)
Solving for x 3, x 3=x 2− f ( x 2) .
f ( x 2 )−f ( x 1)
2 ( x , f ( x ))
2
The estimated value will be closer to the root than either of the O x3 x x x
two initial points. We continue the process to get better 2 1
approximation of the root by using the last two computed Fig.4.3 The Secant Method
points using the iteration formula,
6
Fall 2024-2025
(x n+1−x n )
x n+2=x n +1− f ( x n+1) , n ≥ 1.
f (x n +1)−f (x n )
Here it is not necessary that the interval [ xn +1 , x n ] should contain the root i.e.
f (x n+1 )f (x n)< 0. In selecting, x 1 and x 2 care should be taken so that x 2 is closer to the
root than x 1 to get rapid convergence. This can be achieved by selecting x 1 and x 2 such
that |f ( x 2)|<|f ( x1 )|
If the initial values x 0 and x 1 are close enough to the root, the secant method iterates x n
and converges to a root of function f . The order of convergence is given by φ , where
1+ √ 5
φ= ≈ 1.618. Which is the golden ratio.
2
The convergence is particularly superliner, but not quadratic. This solution is only valid
under certain technical requirements, such as f being two times continuously
differentiable and the root being simple in the question (i.e., having multiplicity 1).
There is no certainty that the secant method will converge if the beginning values are not
close enough to the root. For instance, if the function f is differentiable on the interval
[ x0 , x 1] , and there is a point on the interval where f ' =0, the algorithm may not converge.
7
Fall 2024-2025
1. Compute two iterations for the function 𝑓(x )=x 3 – 5 x +1 using the secant method, in which
Related problems of Secant Method:
the real roots of the equation f ( x )=0 lies in the interval (0 , 1).
2. Compute the root of the equation x 2 e−x/ 2=1 in the interval [0 ,2 ] using the secant method.
The root should be correct to three decimal places.
y
( x0 , f ( x0 )) 8
O x2 x1 x0 x
Fall 2024-2025
Applications
• This method is used to find a minimum or maximum of a function.
• The method also finds application in finding multiplicative inverses of numbers and
power series.
• It is used in solving transcendental equations, obtaining zeros of special functions
such as Bessel functions.
• The method is used for the numerical verification for solutions of non-linear
equations.
9
Fall 2024-2025
break;
end
xi=xn;
end
Example 3.9: Find the root of the equation √ x+ x2=7 using Newton-Raphson method.
Start at x=3 and carry out the first three iterations. Also, write MATLAB syntax for finding the
root in the interval [2.5, 3.5] using MATLAB function “fzero”.
f ( x )= √ x + x −7
2
Solution: i.
' 1
f ( x )= +2x
2 √x
Newton-Raphson iterative formula for double root is
f (x n )
x n+1=x n −
f ' (x n )
n xn f (x n) f ' (x n)
0 3 3.7321 6.2887
1 2.4065 0.3428 5.1354
2 2.3398 0.0043 5.0065
3 2.3389 0.0000007 5.0048
Sol =
2.3389
If the starting value is reasonably close to the root, the number of iterations needed will
be less and calculation time will be saved. Use specified starting value, if stated.
Otherwise, first find an interval in which a root lies and then choose as a starting value,
x 0, either
(i) one of the endpoints of the interval where the magnitudes of the value of the
function is small, or
(ii) guess an internal point of the interval closer to the root.
Equal (repeated) roots are known as multiple roots. If the root of f (x)=0 is a repeated
root, then we may write
f (x)=¿
10
Fall 2024-2025
For a multiple root the order of convergence of the Newton-Raphson formula is linear.
The order can be increased by the modified formula,
f (x n)
x n+1=x n −m ' , n=0 ,1 , 2 ,3 , ⋅⋅⋅
f (x n )
where m is the multiplicity of the root.
The order of convergence of the above is two as that of the simple root.
When the multiplicity of the root is not known in advance, we may proceed as follows;
The function
f (x)
u(x )= '
f (x )
has a simple root regardless of the multiplicity of the root of f (x)=0.
When the Newton-Raphson method is applied to the simple root of u(x )=0 , we have
u(x n)
x n+1=x n − '
u (x n )
or
'
f (x n) f ( xn ) .
x n+1=x n −
¿¿
Example 3.10 The equation 686 x 3−735 x 2+ 125=0 has a double root near x=0.5 .
Compute the iterative results using modified Newton-Raphson formula.
Here we may take
3 2
f ( x )=686 x −735 x +125
and
' 2
f ( x )=2058 x −1470 x .
Newton-Raphson iterative formula for double root is
f (x n)
x n+1=x n −2
f ' (x n)
3 2
2(686 xn −735 xn +125)
¿ xn + 2
2058 x n−1470 x n
n xn f (x n) f ' (x n)
0 0.5 27 -220.5
1 0.7449 0.70855 46.93183
2 0.7147 0.00013 0.609353
11
Fall 2024-2025
A fixed point of a function g(x ) is a real number such that α =g(α ). This means is a
root of the equation x=g(x ). To find a root of the equation f (x)=0 by an iterative
method, first rearrange the equation into a form x=g(x ). The function g(x ) is called the
iteration function. Note that there is no unique form x=g(x ) into which the equation can
be rearranged.
An iteration formula is then x n+1=g (x n), n=0 ,1 , 2 ,3 , ⋅⋅⋅
If x 0 is an approximation close to a root of f (x)=0 and x n+1=g ( x n) is an iterative
formula used to find the root of the equation near x0, then
(i) if |g (x 0 )|<1, the sequence x 1 , x 2 , x 3 , x 4 , ⋅⋅⋅ will converge to the root. In particular,
'
(a)if −1< g' (x 0 )< 0, the sequence will oscillate and converge to the root
(b)if 0< g ' (x 0 )<1, the sequence will converge to the root without oscillating.
(ii) if |g (x 0 )|≥ 1, the sequence x 1 , x 2 , x 3 , x 4 , ⋅⋅⋅ will diverge.
'
1
Example 3.11: The equation x 2−5 x 3 +1=0 has a root near x=2. Using following
iteration formulae, perform few iterations and comment on the results.
√ −1
1 2 3
(a) x = 5 x 3 −1
n+1 n
(b) x n+1=
125
( 1+ x n )
The calculation using the three iteration formulae are as follows:
√
1 ' 5x
The iteration function in (a) is g (x )= 5 x −1 and g (x )= ,
√
3 a 1
a
3
6 5 x −1
x =2 '
with 0 , ga (2)=0.228.
So |g'a (2)|< 1and the sequence will converge to the root as shown in the above table.
−1
( 1+ x 2 ) and g'b (x )= −6 x ( 1+ x 2 )
3 2
The iteration function in (b) is gb (x )=
125 125
=2 '
with 0 , gb ( 2 )=−12
x
Since |gb (2)|> 1, larger than 1 so the sequence is not convergent to the root.
'
Example 3.12 : Given that f ( x )=cos x−0.8 x 2. [Ref. Page# 89 Ex- 3.12]
a. i. Find the number of real roots of the equation f (x)=0.
ii. For each root, find an interval where it lies.
b. i. Show that the equation f (x)=0 has a root in [0 ,1] .
12
Fall 2024-2025
[Link] Bisection method twice to find the new smaller interval where the root
lies.
c. Apply Secant method twice to find the root to 2 d.p in the last interval
obtained by using Bisection method.
d. i. Write down an iteration formula based on Newton-Raphson method.
ii. Perform three iterations starting with the value x 0=0.5 and write the root to 2
d.p.
iii. Write down MATLAB commands to execute the iteration four times.
x n+1=
f (x)=0
√ cos x n
0.8
and (b) x n+1=cos−1( 0.8 x 2 ) can be used to estimate the root of
i. State with reason whether the iterative formulas will converge to the root near
x 0=0 .9.
ii. If the iterative formula converges to the root do the iteration two times to
estimate the root to 3 decimal places
iii. Write down MATLAB commands to execute the iterations five times.
13
Fall 2024-2025
c. Let us use starting values for Secant method as x 1=0.875 and x 2=1.0
n xn f (x n)
1 0.875 0.0285
2 1.0 -0.2597
3 0.887 0.00145
4
4 0.888 0.00013
0
x
Root to 2 d.p. is 4 =0.89 .
d. i. We have
2
f (x)=cos x−0.8 x
'
f ( x )=−sin x−1.6 x .
Newton-Raphson iterative formula is
f ( xn )
x n+1=x n − ' .
f (x n)
ii. Using the starting value x 0=0.5 from (c), we may proceed as follows:
n xn f (x n) '
f ( xn )
0 0.5 0.6776 −1.2794
1 1.0296 -0.3329 −2.50445
2 0.8967 -0.0190 −2.2159
3 0.8881 -0.0001 −2.1968
The root to 2 d.p. is 0.89.
iii. f=@(x) cos(x)-0.8*x^2;
fd=@(x) -sin(x)-1.6*x;
x(1)=0.5;
for n=1:4
x(n+1)=x(n)-f(x(n))/fd(x(n));
end
Output: >> Solution = x
0.5000 1.0296 0.8967 0.8881 0.8881
√
g ( x )=
cos x √ 5
0.8
= √ cos x
2
− √5 sin x
g' ( x ) =
4 √cos x
'
and g ( 0.9 )=0.7044
The iterative formula will converge to the root near 0 since |g ' (0.9)|=0.7044 <1
(b) In this case the iterative function g(x ) is given by
−1 2
g ( x )=cos (0.8 x )
14
Fall 2024-2025
' −1.6 x
g (x )=
√ 1−0.8 x 2
and g' ( 0.9 )=−1.8906
The iterative formula will not converge to the root near 0 since |g ' (0.9)|=−1.8906> 1.
Exercise 3
1. Given the following polynomial equations and an interval.
a. x 3−5 x+ 1=0 ; [ 2 ,3 ] , c. x 4 −2 x−5=0 ; [ 0 , 2 ] ,
b. x 3 + x 2−2 x−5=0 ; [ 1 ,2 ] , d. x 4 + x 2−80=0 ; [ 2.90 ,2.92 ] .
i. Find the number of real roots of the equation by graphical method. Find also
the number of complex roots, if any.
ii. Apply bisection method two times in the given interval to find the new
smaller interval of this root.
iii. Apply secant method to estimate the root correct to 2 d.p. in the last interval
acquired by using bisection method.
iv. Write down an iteration formula based on Newton-Raphson method.
v. Perform one iteration starting using the above formula (iv.) with a suitable
value in the given interval to estimate the root to 2 d.p.
vi. Write down MATLAB codes to execute the iteration four times.
vii. Write MATLAB commands “roots” to find all the roots including complex
roots.
2. Given the following nonlinear equations.
a. 2 sin() x
2
−x 2 +1=0 ,
i. sin−1 x + x 2−1=0.
15
Fall 2024-2025
d. x¿ l. x−2−x =0
x 2
e. 2 e −x −7=0 , m. sin ( x )−e x =0
2
f. x + ln x−2=0. n. 2 x cos ( 2 x )−( x−2 )2=0
g. ln ( x )−2 x +7=0 , o. 2 x+3 cos ( x )−e x =0
h. cosh ( x )−x 2=0 ,
i. For each function, find a suitable interval for which the root lies.
ii. Use the bisection method two times to find the new smaller interval in one
of the intervals obtained in(ii).
iii. Use secant method in the interval obtained in (iii) to find the root of the
equation correct to 2 decimal places.
iv. Write an iterative formula based on Newton-Raphson method and iterate 2
times with a suitable value.
v. Write MATLAB codes to execute the iterative formula five times in part (v).
vi. Use MATLAB builtin function “fzero” to find all the roots of each equation
using an interval or a guess value.
3.
4.
Given the equation 4 cos ( x2 )−3 x =0
i. Apply bisection method two times in the interval [1.0 ,1.2] to find the new
smaller interval where the root lies.
ii. The following iterative formulae are suggested to estimate the root of the
above equation
1
( i ) x n +1= ¿
4
State with reason which iterative formula will converge faster to the root
near x=1.1.
iii. Use the suitable iterative formula from the above two ((i) and (ii)) to find the
root correct to 2 decimal places.
iv. Use MATLAB built-in function “fzero(fun,x0)” to find all the roots of the
16
Fall 2024-2025
Verify whether the iterative formula will converge to the root near x 0=1.7 .
d. If the iterative formula converges to the root do the iteration two times to
estimate the root to 3 decimal places.
e. Write MATLAB commands “roots(p)” to find all the roots including complex
roots.
7. You are designing a spherical tank to hold water for a small village in a developing
π h [ 3 R−h ]
2
country. The volume of liquid it can hold can be computed as V =
3
Where V = volume [m3 ], h = depth of water in tank [m], and R = the tank radius [m]
If R = 3 m, to what depth must the tank be filled so that it holds 30 m3 ?
Use N-R method to calculate the depth.
17
Fall 2024-2025
r =S /(π √ r 2+ h2) as the iteration function. Start with r =17 m and calculate the first four
iterations.
[Ref. Numerical methods for Engineers and Scientists – Amos Gilat, Vish
Subramaniam, Page 89 ex-3.4]
18