Chapter Two Solution of Nonlinear Equations 11
Table 2.1: Solution of x3 = 2x + 1 by bisection method
n Left Right Function Value
Endpoint an Midpoint cn Endpoint bn f (cn )
01 1.500000 1.750000 2.000000 0.8593750
02 1.500000 1.625000 1.750000 0.0410156
03 1.500000 1.562500 1.625000 -0.3103027
04 1.562500 1.593750 1.625000 -0.1393127
05 1.593750 1.609375 1.625000 -0.0503273
06 1.609375 1.617188 1.625000 -0.0049520
f unction y = f n(x)
y = x.ˆ 3 − 2 ∗ x − 1;
then use the single commands:
>> s = bisect(′ f n′ , 1.5, 2, 1e − 2)
We can easily find the roots (1.61803399, −1.00, −0.61803399) of the equation x3 = 2x + 1 by
defining the coefficients of the polynomial equation using MATLAB commands as:
>> CP = [1 0 − 2 − 1]; Sol = roots(CP );
Example 2.2 Find the point of intersection of the graphs y = x3 + 2x − 1 and y = sin x, then use
bisection method within accuracy 10−3 .
Solution. The graphs in the Figure 2.3 show that there is an intersection at about point (0.66, 0.61).
Using the function f (x) = x3 + 2x − sin x − 1 and the starting interval [0.5, 1.0], we compute:
a1 = 0.5 : f (a1 ) = −0.3544,
b1 = 1.0 : f (b1 ) = 1.1585.
Since f (x) is continuous on [0.5, 1.0] and f (0.5).f (1.0) < 0, so that a root of f (x) = 0 lies in the
interval [0.5, 1.0]. Using formula (2.2) (when n = 1), we get:
a1 + b1
c1 = = 0.75; f (c1 ) = 0.240236.
2
Hence the function changes sign on [a1 , c1 ] = [0.5, 0.75]. To continue, we squeeze from right and
set a2 = a1 and b2 = c1 . Then the midpoint is:
a2 + b2
c2 = = 0.625; f (c2 ) = −0.090957.
2
Then continue in this manner we obtain a sequence {ck } of approximation shown by Table 2.2.
12 2.2 Method of Bisection
2 1.2
1.8
1
1.6
0.8
1.4 y = x3 + 2x − 1
y = x3 + 2x − sin x − 1
0.6
1.2
y
1
y
0.4
0.8
0.2
0.6
α
y = sin x
0
0.4
−0.2
0.2
0 −0.4
0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1
x x
Figure 2.3: Graphical Solution of sin x = x3 + 2x − 1 and x3 + 2x − sin x = 1.
Table 2.2: Solution of x3 + 2x − sin x − 1 by bisection method
n Left Right Function Value
Endpoint an Endpoint bn Midpoint cn f (cn )
01 0.5000 1.0000 0.750000 0.240236
02 0.5000 0.7500 0.625000 -0.090957
03 0.6250 0.7500 0.687500 0.065344
.. .. .. .. ..
. . . . .
07 0.6563 0.6641 0.660156 -0.005228
08 0.6602 0.6641 0.662109 -0.000302
Program 2.1
MATLAB m-file for the Bisection Method
function sol=bisect(fn,a,b,tol)
f a = f eval(f n, a); f b = f eval(f n, b);
if f a ∗ f b > 0; fprintf(’Endpoints have same sign’) return end
while abs (b − a) > tol c = (a + b)/2; f c = f eval(f n, c);
if f a ∗ f c < 0; b = c; else a = c; end; end; sol=(a + b)/2;
We see that the functional values are approaching zero as the number of iterations is increase.
We got the desired approximation to the root of the given equation is c8 = 0.662109 ≈ α after 8
iterations with accuracy ϵ = 10−3 . •
Theorem 2.1 (Bisection Convergence and Error Theorem)
Let f (x) be continuous function defined on the given initial interval [a0 , b0 ] = [a, b] and suppose that
f (a)f (b) < 0. Then bisection method (2.2) generates a sequence {cn }∞ n=1 approximating α ∈ (a, b)
with the property
b−a
|α − cn | ≤ n , n ≥ 1. (2.3)
2