Assignment-4
Assignment-4
Object
1. Bisection Method
2. Linear Interpolation (False Position) Method
Theory
Once we know that an interval contains a root, the bisection method can be used to
refine it. The idea is simple. Over some interval the function is known to pass through
zero because it changes sign. Evaluate the function at the interval’s midpoint and
examine its sign. Use the midpoint to replace whichever limit has the same sign. After
each iteration the bounds containing the root decrease by a factor of two.
The goal of the bisection method is to find a very small interval, perhaps two successive
floating-point numbers, on which the function changes sign. That is, we might not be
able to find a point where f (x) is exactly zero, because the notion of continuity does
not strictly apply to floating-point computation.
Bisection is slow, but it is completely reliable. If we can find a starting interval with
a change of sign, then bisection cannot fail to reduce that interval to two successive
floating-point numbers that bracket the desired result.
For functions that are smooth near a root, the linear interpolation method generally
converge faster that bisection. In this method the function is assumed to be approxi-
mately linear in the local region of interest, and the next improvement in the root is
taken as the point where the approximating line crosses the axis. After each iteration
one of the previous boundary points is discarded in favor of the latest estimate of the
root.
1
If f (x) has opposite signs at the endpoints of the interval (x1 , x2 ), then from the
similarity of the triangles in Figure 1 we can write
x2 − x3 f (x2 )
=
x2 − x1 f (x2 ) − f (x1 )
and
f (x2 )
x 3 = x2 − (x2 − x1 ) (1)
f (x2 ) − f (x1 )
from which f (x3 ) is found and, once again, interpolating linearly between the values
at which the function changes sign giving a new value for x3 . Iterative application of
this procedure will give improved estimates of the root, successively.
The method appears to be somewhat faster than the method of halving the interval,
giving about the same accuracy. The rate of convergence will be related to the rate of
change of the slope of the curve, which is measured by the magnitude of the second
derivative.
2
Procedure
1) Write a program to find the zeros of each of the following functions using the bisection
method:
a. f (x) = x3 − x2 − 2x + 1
b. f (x) = ex − 3x2
Discussion
1. Discuss the speed of convergence of the two methods for the above functions.
2. What are the advantages and disadvantages of the bisection method compared
with that of the linear interpolation method.
√
3. Find 80 using the bisection method.