2.1 Nonlinear Equs - BisectionFalse-Position

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

Bracketing Methods

(Bisection & False-position Methods )


 These methods exploit the fact that a
function typically changes sign in the vicinity
of the root.
 Two initial guesses for the root are required.
And the solution will be bracketed by the two
initial guesses.
 Different strategies are used to systematically
reduce the width of the bracket.
 Bisection and False-position methods are
examples of bracketing methods.

Numerical Methods 2
 Let’s look at the function
f(x)=ex+sin(x)
It’s a periodic function
With many roots.

How can we locate these roots?

Numerical Methods 3
Theorem

An equation f(x)=0, where f(x) is a real continuous function, has at least


one root between xl and xu if f(xl) f(xu) < 0.
f(x)

x
x
xu

At least one root exists between the two points if the


function is real, continuous, and changes sign.
Numerical Methods 4
If function f ( x ) does not change sign between two points, roots of
the equation f ( x ) = 0 may still exist between the two points.

f(x)

x x
xu

Numerical Methods 5
If the function f ( x ) does not change sign between two
points, there may not be any roots for the equation f ( x ) = 0
between the two points.
f(x)
f(x)

x xu
x x
x xu

Numerical Methods 6
f(x)

xu
x
x

If the function f ( x ) changes sign between two points, more than one
root for the equation f ( x ) = 0 may exist between the two points.

Numerical Methods 7
These graphs show some exceptions to the
general cases illustrated on the left. In (i), a
multiple root occurs where the function is
tangential to the x axis. There are an even
number of intersections for the interval. In
(ii) is depicted a discontinuous function with
an even number of roots and end points of
opposite signs. Finding the roots in such
cases requires special strategies.
In (i) and (iii), if the function is positive at both
the rule can be broken by two functions:
boundaries, there will be either an even number of
roots or no roots; in the other two graphs, if the 1. if the function is tangential to the x-axis between the two points.
function has opposite signs at the boundary points,
there will be an odd number of roots within the 2. if the function is a piecewise function and has two parts between
interval. the two points.

Numerical Methods 8
Numerical Methods 9
Choose x and xu as two guesses for the root such
that f(x) f(xu) < 0, or in other words, f(x) changes
sign between x and xu.
f(x)

x
x
xu

Numerical Methods 10
Estimate the root, xm of the equation f (x) = 0 as
the mid point between x and xu as

f(x)

x + xu
xm =
2

x xm
x
xu

Estimate of xm
Numerical Methods 11
Now check the following

a) If f ( xl ) f ( xm )  0 , then the root lies


xm
xl

between x and xm; then set xu = xm. xu

b) If f ( xl ) f ( xm )  0 , then the root lies xu


between xm and xu; then set x = xm . xl xm

c) If f ( xl ) f ( xm ) = 0 ; then the root is xm.


Stop the algorithm if this is true.

Numerical Methods 12
Find the new estimate of the root
x + xu
xm =
2
Find the absolute relative approximate error
x new − x old

a =  100
m m
new
x m

where
xmold = previous estimate of root
xmnew = current estimate of root

Numerical Methods 13
Compare the absolute relative approximate error a with
the pre-specified error tolerance s .
Go to Step 2 using new
Yes upper and lower
Is a s ? guesses.

No Stop the algorithm

Note one should also check whether the number of


iterations is more than the maximum number of iterations
allowed. If so, one needs to terminate the algorithm and
notify the user about it.

Numerical Methods 14
You are asked to find the depth to which the ball is
submerged when floating in water. The floating
ball has a specific gravity of 0.6 and has a radius of
5.5 cm.

Numerical Methods 15
The equation that gives the depth x to which the ball
is submerged under water is given by
x3 0.165x 2 3.993 10 4
0

a) Use the bisection method of finding roots of


equations to find the depth x to which the ball is
submerged under water. Conduct three iterations
to estimate the root of the above equation.
b) Find the absolute relative approximate error at the
end of each iteration, and the number of significant
digits at least correct at the end of each iteration.

Numerical Methods 16
From the physics of the problem, the ball would be
submerged between x = 0 and x = 2R,
where R = radius of the ball,
that is:

0  x  2R
R
0  x  2(0.055 )
0  x  0.11

Numerical Methods 17
Solution

To aid in the understanding


of how this method works to
find the root of an equation,
the graph of f(x) is shown to
the right,
where

f ( x ) = x 3 − 0.165 x 2 + 3.993  10 - 4
Graph of the function f(x)

Numerical Methods 18
Let us assume
x = 0.00
xu = 0.11
Check if the function changes sign between x and xu .

f ( xl ) = f (0 ) = (0 ) − 0.165(0 ) + 3.993  10 −4 = 3.993  10 −4


3 2

f ( xu ) = f (0.11) = (0.11) − 0.165(0.11) + 3.993  10 − 4 = −2.662  10 − 4


3 2

Hence
( )( )
f ( xl ) f ( xu ) = f (0 ) f (0.11) = 3.993  10 −4 − 2.662  10 −4  0

So there is at least one root between x and xu, that is between 0 and 0.11

Numerical Methods 19
Iteration 1
x + xu 0 + 0.11
The estimate of the root is xm = = = 0.055
2 2

f ( xm ) = f (0.055) = (0.055 ) − 0.165(0.055) + 3.993  10 −4 = 6.655  10 −5


3 2

( )(
f ( xl ) f ( xm ) = f (0 ) f (0.055) = 3.993  10 − 4 6.655  10 −5  0 )
Hence the root is bracketed between xm and xu, that is, between 0.055
and 0.11. So, the lower and upper limits of the new bracket are
xl = 0.055, xu = 0.11
At this point, the absolute relative approximate error a cannot be
calculated as we do not have a previous approximation.

Numerical Methods 20
Iteration 2

The estimate of the root is


x + xu 0.055 + 0.11
xm = = = 0.0825
2 2
3 2
4 4
f xm f 0.0825 0.0825 0.165 0.0825 3.993 10 1.622 10
5 4
f xl f x m f 0.055 f 0.0825 6.655 10 1.622 10 0

Hence the root is bracketed between x and xm, that is, between 0.055
and 0.0825. So, the lower and upper limits of the new bracket are
xl = 0.055, xu = 0.0825

Numerical Methods 21
The absolute relative approximate error a at the end of Iteration 2 is

xmnew − xmold
a = new
 100
xm
0.0825 − 0.055
=  100
0.0825
= 33.333%

None of the significant digits are at least correct in the estimate root of
xm = 0.0825 because the absolute relative approximate error is greater
than 5%.

Numerical Methods 22
Iteration 3

The estimate of the root is


x + xu 0.055 + 0.0825
xm = = = 0.06875
2 2
f ( xm ) = f (0.06875 ) = (0.06875 ) − 0.165(0.06875 ) + 3.993  10 −4 = −5.563  10 −5
3 2

( )( )
f ( xl ) f ( xm ) = f (0.055) f (0.06875 ) = 6.655  10 −5 − 5.563  10 −5  0

Hence the root is bracketed between x and xm, that is, between 0.055
and 0.06875. So, the lower and upper limits of the new bracket are
xl = 0.055, xu = 0.06875

Numerical Methods 23
The absolute relative approximate error a at the end of Iteration 3 is

xmnew − xmold
a = new
 100
xm
0.06875 − 0.0825
=  100
0.06875
= 20%

Still none of the significant digits are at least correct in the estimated
root of the equation as the absolute relative approximate error is
greater than 5%.
Seven more iterations were conducted and these iterations are shown in
Table 1.

Numerical Methods 24
Table 1 Root of f(x)=0 as function of number of iterations for
bisection method.
m 2 - log 10 2 a
%

i xl xu f(xl) f(xu) xm f(xm) |Ɛa|% m


f(xl) f(xm)>0 , xl= xm 1 0 0.11 0.000399 -0.00027 0.05500 6.66E-05 - -
f(xl) f(xm)<0 , xu= xm 2 0.055 0.11 6.66E-05 -0.00027 0.08250 -0.00016 33.33333 0
f(xl) f(xm)<0 , xu= xm 3 0.055 0.0825 6.66E-05 -0.00016 0.06875 -5.6E-05 20.00000 0
f(xl) f(xm)>0 , xl= xm 4 0.055 0.06875 6.66E-05 -5.6E-05 0.061875 4.48E-06 11.11111 0
5 0.061875 0.06875 4.48E-06 -5.6E-05 0.065313 -2.6E-05 5.263158 0
6 0.061875 0.065313 4.48E-06 -2.6E-05 0.063594 -1.1E-05 2.702703 1
7 0.061875 0.063594 4.48E-06 -1.1E-05 0.062734 -3.2E-06 1.369863 1
8 0.061875 0.062734 4.48E-06 -3.2E-06 0.062305 6.5E-07 0.689655 1
9 0.062305 0.062734 6.5E-07 -3.2E-06 0.06252 -1.3E-06 0.343643 2
10 0.062305 0.06252 6.5E-07 -1.3E-06 0.062412 -3.1E-07 0.172117 2
11 0.062305 0.062412 6.5E-07 -3.1E-07 0.062358 1.71E-07 0.086133 2
12 0.062358 0.062412 1.71E-07 -3.1E-07 0.062385 -6.8E-08 0.043048 3

Numerical Methods 25
Hence the number of significant digits at least correct is given by the
largest value or m for which
a  0.5  10 2 − m
0.1721  0.5  10 2 − m
0.3442  10 2 − m
log (0.3442 )  2 − m
m  2 − log (0.3442 ) = 2.463 m 2 - log 10 2 a
%

So
m=2

The number of significant digits at least correct in the estimated root


of 0.06241 at the end of the 10th iteration is 2.

Numerical Methods 26
 Always convergent
 The root bracket gets halved with each
iteration - guaranteed.

Numerical Methods 27
◼ Slow convergence
◼ If one of the initial guesses is close to
the root, the convergence is slower

Numerical Methods 28
 If a function f(x) is such that it just touches
the x-axis it will be unable to find the lower
and upper guesses.
f(x) f (x ) = x 2

Numerical Methods 29
◼ Function changes sign but root does not
exist
1
f(x) f (x ) =
x

Numerical Methods 30
 The bisection method is relatively inefficient.
It requires large number of iterations to
converge for a solution.
 False-position refines the interval narrowing
technique in the Bisection method.
 Instead of halving the interval, f(xl) and f(xu)
are joined by a straight line. The intersection
of this line with the x-axis represent the
improved estimate of the root.

Numerical Methods 31
f(x)

f(x u)

xl

xu x

f(xl)

Numerical Methods 32
 In this case the computation of the root estimate can
be derived, by using the similarity between the two
triangles:
f(x)

f xl f xu
f(xu)
xr xl xu xr

 This can be solved to give the


False-position iterative formula: xr

xl
x
f x u xl xu xu
xr xu
f xl f xu f(xl)

See example 5.5 page 125


in your text book
Numerical Methods 33
 Determine the drag coefficient c needed
for parachutist to fall safely within s =1%.
The force balance given in the following
relation :
667.38 0.1468 c
f (c ) 1 e 40 0
c
(a) Using Bisection method
(b) Using False-position method

 Hint: Use graphical inspection of the


function to estimate proper initial guesses.

Numerical Methods 34
Numerical Methods 35
i xl xu f(xl) f(xu) xm f(xm) |Ɛa|% m Using the initial guess:
1 1 20 51.11962 -8.40215 10.5 9.953 - - xl= 1
2 10.5 20 9.953 -8.40215 15.25 -0.90234 31.14754 0 xu=20
3 10.5 15.25 9.953 -0.90234 12.875 4.004873 18.4466 0
4 12.875 15.25 4.004873 -0.90234 14.0625 1.435811 8.444444 0
5 14.0625 15.25 1.435811 -0.90234 14.65625 0.239504 4.051173 1
8 iterations are needed to
6 14.65625 15.25 0.239504 -0.90234 14.95313 -0.33803 1.985371 1
7 14.65625 14.95313 0.239504 -0.33803 14.80469 -0.05094 1.002639 1
get the needed accuracy of
8 14.65625 14.80469 0.239504 -0.05094 14.73047 0.093859 0.503845 1 an error less than 1%
9 14.73047 14.80469 0.093859 -0.05094 14.76758 0.021353 0.25129 2
10 14.76758 14.80469 0.021353 -0.05094 14.78613 -0.01482 0.125487 2

20 14.77852 14.77856 1.01E-05 -6.1E-05 14.77854 -2.5E-05 0.000123 5

i xl xu f(xl) f(xu) xr f(xr) |Ɛa|% m


1 1 20 51.11962 -8.40215 17.31794 -4.49545 - -
2 1 17.31794 51.11962 -4.49545 15.99894 -2.26961 8.244328 0
3 1 15.99894 51.11962 -2.26961 15.36132 -1.11061 4.150777 1
4 1 15.36132 51.11962 -1.11061 15.05595 -0.53496 2.028277 1
5 1 15.05595 51.11962 -0.53496 14.91038 -0.2557 0.9763 1
6 1 14.91038 51.11962 -0.2557 14.84114 -0.12176 0.46649 2 5 iterations are needed to
7 1 14.84114 51.11962 -0.12176 14.80825 -0.05788 0.222107 2 get the needed accuracy

Numerical Methods 36

You might also like