Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Bracketing Methods
1
Root
We are given f(x), a function of x, and we
want to find such that
f() = 0
2
Example: Interest Rate
Suppose you want to buy an electronic appliance from
a shop and you can either pay an amount of 12,000 or
have a monthly payment of 1,065 for 12 months. What
is the corresponding interest rate?
A. Bracketing Methods
A.1. Bisection Method
A.2. Regula Falsi (False-position Method)
B. Open Methods
B.1. Fixed Point Iteration
B.2. Newton Raphson's Method
B.3. Secant Method
5
Bracketing Methods
Theorem: If a function f(x) is
continuous in the interval
[a, b] and f(a)f(b) < 0, then
the equation f(x) = 0 has at
least one real root in the
interval (a, b).
6
Usually
f(a)f(b) > 0 implies zero or even
number of roots
[figure (a) and (c)]
7
Exceptional Cases
Multiple roots
Roots that overlap at one
point.
e.g.: f(x) = (x-1)(x-1)(x-2) has
a multiple root at x=1.
8
Algorithm for bracketing
methods
Step 1: Choose two points xl and xu such that f(xl)f(xu) < 0
if f(xl)f(xr) = 0
xr is the root
9
How to select xr in step 2?
1. Bisection Method
Guess without considering the characteristics of
f(x) in (xl, xu)
10
A.1. Bisection Method
xu xl
xr
2
11
Bisection Method Example
667.38
f ( x) (1 e 0.146843 x ) 40
x
Find the root of f(x) = 0 with an
approximated error below
0.5%. (True root: =14.7802)
12
new old
xr xr
a 100%
Example (continue) xr
new
14.7802 14.8125
t 100% 0.219%
14.7802
13
Error Bounds
The true root, , must lie between xl and xu.
xl xr xu
2 2
15
Error Bounds
In general, after the nth iteration, the solution, xr(n),
should be within an accuracy of
1 (n) 1 ( n 1) ( n 1) 1 (1)
xu xl 2 xu xl
(n)
... n xu xl(1)
2 2 2
If we want to achieve an absolute error of no more
than E
1 (1)
n
xu xl
(1)
E
2
xu(1) xl(1)
n log 2 ( )
E
16
Implementation Issues
The condition f(xl)f(xr) = 0 (in step 3) is difficult to
achieve due to errors.
if (xr != 0)
ea = fabs((xr xr_old) / xr) * 100;
if (test < 0)
xu = xr;
else
if (test > 0)
xl = xr;
else
ea = 0;
return xr;
}
19
Additional Implementation
Issues
Function call is a relatively slow operation.
20
Revised Bisection Method (as C
function)
double Bisect(double xl, double xu, double es,
int iter_max)
{
double xr; // Est. Root
double xr_old; // Est. root in the previous step
double ea; // Est. error
int iter = 0; // Keep track of # of iterations
double fl, fr; // Save values of f(xl) and f(xr)
test = fl * fr;
if (test < 0)
xu = xr;
else
if (test > 0) {
xl = xr;
fl = fr;
}
else
ea = 0;
return xr;
}
22
Additional Implementation
Issues
Testing if f(xl)f(xr) is positive or negative directly
could result in underflow or overflow.
23
Comments on Bisection
Method
The method is guaranteed to converge.
24
A.2. Regula Falsi Method
Also known as the false-position method, or linear
interpolation method.
Unlike the bisection method which divides the
search interval by half, regula falsi interpolates
f(xu) and f(xl) by a straight line and the intersection
of this line with the x-axis is used as the new
search position.
The slope of the line connecting f(xu) and f(xl)
represents the "average slope" (i.e., the value of
f'(x)) of the points in [xl, xu ].
25
f ( xu ) f ( xl ) f ( xu )( xl xu )
xr xu
xu xr xl xr f ( xl ) f ( x26u )
False-position vs Bisection
False position in general performs better
than bisection method.
Exceptional Cases:
(Usually) When the deviation of f'(x) is high
and the end points of the interval are selected
poorly.
For example,
f ( x) x10 1
with xl 0, xu 1.3
27
Bisection Method (Converge quicker)
Iteration xl xu xr a (%) t (%)
1 0 1.3 0.65 35
2 0.65 1.3 0.975 33.3 25
3 0.975 1.3 1.1375 14.3 13.8
4 0.975 1.1375 1.05625 7.7 5.6
5 0.975 1.05625 1.015625 4.0 1.6
False-position Method
Iteration xl xu xr a (%) t (%)
1 0 1.3 0.09430 90.6
2 0.09430 1.3 0.18176 48.1 81.8
3 0.18176 1.3 0.26287 30.9 73.7
4 0.26287 1.3 0.33811 22.3 66.2
5 0.33811 1.3 0.40788 17.1 59.2 28
f ( x) x 1
10
with xl 0, xu 1.3
29
Summary
Bracketing Methods
f(x) has the be continuous in the interval [xl, xu] and
f(xl)f(xu) < 0
Always converge
Usually slower than open methods
Bisection Method
Slow but guarantee the best worst-case convergent
rate.
False-position method
In general performs better than bisection method
(with some exceptions).
30