Graphics Programs Reference
In-Depth Information
root = NaN; return
end
if f3 == 0.0
root = x3; return
end
if f2*f3 < 0.0
x1=x3;f1=f3;
else
x2=x3;f2=f3;
end
end
root=(x1 + x2)/2;
EXAMPLE 4.2
Use bisection to find the root of f ( x )
=
x 3
10 x 2
+
5
=
0thatlies in the interval
(0
.
6
,
0
.
8).
Solution The best way to implement themethodistouse the table shownbelow. Note
that the intervaltobe bisectedis determinedbythe sign of f ( x ), not its magnitude.
x
f ( x )
Interval
.
.
0
6
1
616
0
.
8
0
.
888
(0
.
6
,
0
.
8)
(0
.
6
+
0
.
8)
/
2
=
0
.
7
0
.
443
(0
.
7
,
0
.
8)
(0
.
8
+
0
.
7)
/
2
=
0
.
75
0
.
203
(0
.
7
,
0
.
75)
(0
.
7
+
0
.
75)
/
2
=
0
.
725
0
.
125
(0
.
725
,
0
.
75)
(0
.
75
+
0
.
725)
/
2
=
0
.
7375
0
.
038
(0
.
725
,
0
.
7375)
(0
.
725
+
0
.
7375)
/
2
=
0
.
73125
0
.
044
(0
.
7375
,
0
.
73125)
(0
.
7375
+
0
.
73125)
/
2
=
0
.
73438
0
.
003
(0
.
7375
,
0
.
73438)
(0
.
7375
+
0
.
73438)
/
2
=
0
.
73594
0
.
017
(0
.
73438
,
0
.
73594)
(0
.
73438
+
0
.
73594)
/
2
=
0
.
73516
0
.
007
(0
.
73438
,
0
.
73516)
(0
.
73438
+
0
.
73516)
/
2
=
0
.
73477
0
.
002
(0
.
73438
,
0
.
73477)
(0
.
73438
+
0
.
73477)
/
2
=
0
.
73458
0
.
000
The final result x
=
0
.
7346iscorrect within four decimal places.
Search WWH ::




Custom Search