Académique Documents
Professionnel Documents
Culture Documents
o Bisection Method:
o Root of a function:
f(a) = 0
Example:
Function: f(x) = x2 - 4
Roots: x = -2, x = 2
Because:
f(-2) = (-2)2 - 4 = 4 - 4 = 0
f(2) = (2)2 - 4 = 4 - 4 = 0
A Mathematical Property
o Well-known Mathematical Property:
Example:
The Bisection Method
o The Bisection Method is a successive approximation
method that narrows down an interval that contains a root of the
function f(x)
o The Bisection Method is given an initial interval
[a..b] that contains a root
(We can use the property sign of f(a) ≠ sign of f(b) to find such
an initial interval)
o The Bisection Method will cut the interval into 2 halves and
check which half interval contains a root of the function
o The Bisection Method will keep cut the interval in halves until
the resulting interval is extremely small
The root is then approximately equal to any value in the final (very
small) interval.
o Example:
Suppose the interval [a..b] is as follows:
We cut the interval [a..b] in the middle: m = (a+b)/2
Because sign of f(m) ≠ sign of f(a) , we proceed with
the search in the new interval [a..b]:
We can use this statement to change to the new interval:
b = m;
o
o In the above example, we have changed the end point b to obtain
a smaller interval that still contains a root
f(0) = 02 − 5 = −5
f(4) = 42 − 5 = 11
Start:
a = 0; f(a) = -5
b = 4; f(b) = 11
Iteration 1:
m = (a + b)/2 = 2
f(m) = 22 − 5 = -1
a = 2; f(a) = -1
b = 4; f(b) = 11
Iteration 2:
m = (a + b)/2 = 3
f(m) = 32 − 5 = 4
a = 2; f(a) = -1
b = 3; f(b) = 4
Iteration 3:
m = (a + b)/2 = 2.5
a = 2; f(a) = -1
b = 2.5; f(b) = 1.25
And so on....
o
o Structure Diagram of the Bisection Algorithm:
o
o
o Example execution:
f(x) = x2 - 3
f(0) = 02 − 3 = −3
f(4) = 42 − 3 = 13
Result:
o
o
o Java program:
a = 0; b = 4;
Output:
code)
Prog file: click here
f(x) = x3 + x - 3
// Solves: x^3 + x - 3 = 0
a = 0; b = 4;
code)
Prog file: click here
o We had to change the body of the Java program to find the root of
a different function
y_m = f(m);
y_a = f(a);