1. Bisection.
nb 1
In[1]:= Clear"`"
In[2]:= fx_ x ^ 4 6x ^ 3 3x 9;
FindRootfx 0, x, 1
Solvefx 0 N
a0 Input"Enter the left value of an interval"
b0 Input"Enter the right value of an interval"
n Input"Enter the maximum number of iteration"
tol Input"Enter the tolerance"
Iffa0 fb0 0, "No roots within the interval",
ai bi
Fori 0, i n && Absai bi tol, i , ci
;
2.0
Iffai fci 0, ai 1 ai; bi 1 ci,
ai 1 ci; bi 1 bi;
Print"The required solution is ", ci 1;
sl ListPlotci 1, fci 1,
PlotStyle PointSize0.05, DisplayFunction Identity;
pl Plotfx, x, a0, b0, DisplayFunction Identity;
Showsl, pl, DisplayFunction $DisplayFunction;
t Tablej, aj, bj, cj, fcj, j, 0, i 1;
TableFormt, TableHeadings None, "n", "a", "b", "x", "fx"
Out[3]= x 1.20528
Out[4]= x 0.62362 0.929723 , x 0.62362 0.929723 , x 5.95804, x 1.20528
Out[5]= 1
Out[6]= 1.5
Out[7]= 50
Out[8]= 0.0001
The required solution is 1.20526
10
7.5
2.5
1.1 1.2 1.3 1.4 1.5
-2.5
-5
Out[9]//TableForm=
n a b x fx
0 1 1.5 1.25 1.41016
1 1 1.25 1.125 2.23022
2 1.125 1.25 1.1875 0.526596
3 1.1875 1.25 1.21875 0.411653
4 1.1875 1.21875 1.20313 0.0648794
5 1.20313 1.21875 1.21094 0.171519
6 1.20313 1.21094 1.20703 0.052855
7 1.20313 1.20703 1.20508 0.00612815
8 1.20508 1.20703 1.20605 0.0233344
9 1.20508 1.20605 1.20557 0.00859588
10 1.20508 1.20557 1.20532 0.00123205
11 1.20508 1.20532 1.2052 0.0024485
12 1.2052 1.20532 1.20526 0.000608339