0% found this document useful (0 votes)
10 views1 page

1. Bisection

Numerical analysis

Uploaded by

farhanaakter
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

1. Bisection

Numerical analysis

Uploaded by

farhanaakter
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

1. Bisection.

nb 1

In[1]:= Clear"`"

In[2]:= fx_  x ^ 4  6x ^ 3  3x  9;


FindRootfx  0, x, 1
Solvefx  0  N
a0  Input"Enter the left value of an interval"
b0  Input"Enter the right value of an interval"
n  Input"Enter the maximum number of iteration"
tol  Input"Enter the tolerance"
Iffa0  fb0  0, "No roots within the interval",
ai  bi
Fori  0, i  n && Absai  bi  tol, i , ci  
 ;
2.0
Iffai  fci  0, ai  1  ai; bi  1  ci,
ai  1  ci; bi  1  bi;
Print"The required solution is ", ci  1;
sl  ListPlotci  1, fci  1,
PlotStyle  PointSize0.05, DisplayFunction  Identity;
pl  Plotfx, x, a0, b0, DisplayFunction  Identity;
Showsl, pl, DisplayFunction  $DisplayFunction;
t  Tablej, aj, bj, cj, fcj, j, 0, i  1;
TableFormt, TableHeadings  None, "n", "a", "b", "x", "fx"

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 fx
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

You might also like