0% found this document useful (0 votes)
19 views15 pages

Practical 3 Numerical Analysis

Uploaded by

Bharti yadav
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)
19 views15 pages

Practical 3 Numerical Analysis

Uploaded by

Bharti yadav
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/ 15

PRACTICAL 4

METHOD OF FALSE POSITION


QUES1.

Clear@x, f, a, b, m, n, iD
f@x_D := Log@1 + xD - Cos@xD;
Plot@f@xD, 8x, - 1, 2<D

-1.0 -0.5 0.5 1.0 1.5 2.0

-1

-2

-3

-4

OBSERVATION : FROM FIGURE IT CAN BE SEEN THAT SMALLEST POSITIVE ROOT OF THE GIVEN FUNCTION
LIES IN THE INTERVAL [0, 1]. SO IN THIS QUESTION WE TAKE OUR STARTING INTERVAL TO BE [0, 1].
a0 = 0;
b0 = 1;
a = N@a0D;
b = N@b0D;
n = Input@"Please enter maximum number of iterations "D
If @f@aD * f@bD > 0, Print@"We cannot continue with the false position Method as ",
f, "HaL.", f, "HbL>=0"D; Abort@DD
i = 1;

b-a
p = b - f@bD * ;
f@bD - f@aD
OutputDetails = 88i, a, p, b, f@pD<<;
b-a
WhileBi < n, If@Sign@f@aDD == Sign@f@pDD, a = p, b = pD; p = b - f@bD * ;
f@bD - f@aD
i ++; OutputDetails = Append@OutputDetails , 8i, a, p, b, f@pD<D;F
H*Combining the output details with the headings of the table*L
Print@NumberForm@
N@TableForm@OutputDetails , TableHeadings ® 8None, 8"i", "ai ", "pi ", "bi ", "f@pi D"<<DD,
8DD;H*Printing Table*L
Print@"Root after ", n, "iterations" ' NumberForm@N@pD, 8DD
H*8 is used to give the result with 8 digits precision*L
Print@"Function value at approximated root f@pD=", NumberForm@N@f@pDD, 8DD;

10
2 PRACTICAL 3 NUMERICAL ANALYSIS.nb

i ai pi bi f@pi D
1. 0. 0.86741939 1. -0.022239358
2. 0.86741939 0.8842599 1. -0.00032698348
3. 0.8842599 0.88450698 1. -4.7463948 ´ 10-6
4. 0.88450698 0.88451056 1. -6.8884227 ´ 10-8
5. 0.88451056 0.88451062 1. -9.9971098 ´ 10-10
6. 0.88451062 0.88451062 1. -1.4508728 ´ 10-11
7. 0.88451062 0.88451062 1. -2.1049829 ´ 10-13
8. 0.88451062 0.88451062 1. -2.9976022 ´ 10-15
9. 0.88451062 0.88451062 1. 0.
10. 0.88451062 0.88451062 0.88451062 0.
Root after 100.88451062 iterations ¢

Function value at approximated root f@pD=0.

QUES2.

Clear@x, f, a, b, m, n, iD
f@x_D := x3 + 2 x2 - 3 x - 1;
Plot@f@xD, 8x, - 2, 2<D

-2 -1 1 2

-2
PRACTICAL 3 NUMERICAL ANALYSIS.nb 3

a0 = 1;
b0 = 2;
a = N@a0D;
b = N@b0D;
n = Input@"Please enter maximum number of iterations "D
If @f@aD * f@bD > 0, Print@"We cannot continue with the false position Method as ",
f, "HaL.", f, "HbL>=0"D; Abort@DD
i = 1;

b-a
p = b - f@bD * ;
f@bD - f@aD
OutputDetails = 88i, a, p, b, f@pD<<;
b-a
WhileBi < n, If@Sign@f@aDD == Sign@f@pDD, a = p, b = pD; p = b - f@bD * ;
f@bD - f@aD
i ++; OutputDetails = Append@OutputDetails , 8i, a, p, b, f@pD<D;F
H*Combining the output details with the headings of the table*L
Print@NumberForm@
N@TableForm@OutputDetails , TableHeadings ® 8None, 8"i", "ai ", "pi ", "bi ", "f@pi D"<<DD,
8DD;H*Printing Table*L
Print@"Root after ", n, "iterations" ' NumberForm@N@pD, 8DD
H*8 is used to give the result with 8 digits precision*L
Print@"Function value at approximated root f@pD=", NumberForm@N@f@pDD, 8DD;
15

i ai pi bi f@pi D
1. 1. 1.1 2. -0.549
2. 1.1 1.1517436 2. -0.27440072
3. 1.1517436 1.1768409 2. -0.13074253
4. 1.1768409 1.1886277 2. -0.060875863
5. 1.1886277 1.1940789 2. -0.028040938
6. 1.1940789 1.1965821 2. -0.01285224
7. 1.1965821 1.1977278 2. -0.0058772415
8. 1.1977278 1.1982513 2. -0.0026848163
9. 1.1982513 1.1984904 2. -0.001225881
10. 1.1984904 1.1985996 2. -0.0005596125
11. 1.1985996 1.1986494 2. -0.00025543669
12. 1.1986494 1.1986721 2. -0.0001165895
13. 1.1986721 1.1986825 2. -0.000053214081
14. 1.1986825 1.1986873 2. -0.00002428788
15. 1.1986873 1.1986894 2. -0.000011085385
Root after 151.1986894 iterations ¢

Function value at approximated root f@pD=-0.000011085385

QUES3.
4 PRACTICAL 3 NUMERICAL ANALYSIS.nb

Clear@x, f, a, b, m, n, iD
f@x_D := x3 - 5 x + 1;
Plot@f@xD, 8x, - 2, 2<D

-2 -1 1 2

-2

a0 = - 1;
b0 = 1;
a = N@a0D;
b = N@b0D;
n = Input@"Please enter maximum number of iterations "D
If @f@aD * f@bD > 0, Print@"We cannot continue with the false position Method as ",
f, "HaL.", f, "HbL>=0"D; Abort@DD
i = 1;

b-a
p = b - f@bD * ;
f@bD - f@aD
OutputDetails = 88i, a, p, b, f@pD<<;
b-a
WhileBi < n, If@Sign@f@aDD == Sign@f@pDD, a = p, b = pD; p = b - f@bD * ;
f@bD - f@aD
i ++; OutputDetails = Append@OutputDetails , 8i, a, p, b, f@pD<D;F
H*Combining the output details with the headings of the table*L
Print@NumberForm@
N@TableForm@OutputDetails , TableHeadings ® 8None, 8"i", "ai ", "pi ", "bi ", "f@pi D"<<DD,
8DD;H*Printing Table*L
Print@"Root after ", n, "iterations" ' NumberForm@N@pD, 8DD
H*8 is used to give the result with 8 digits precision*L
Print@"Function value at approximated root f@pD=", NumberForm@N@f@pDD, 8DD;
10
PRACTICAL 3 NUMERICAL ANALYSIS.nb 5

i ai pi bi f@pi D
1. -1. 0.25 1. -0.234375
2. -1. 0.19402985 0.25 0.037155501
3. 0.19402985 0.20168865 0.25 -0.00023892045
4. 0.19402985 0.20163972 0.20168865 -2.2244344 ´ 10-7
5. 0.19402985 0.20163968 0.20163972 -2.0708346 ´ 10-10
6. 0.19402985 0.20163968 0.20163968 -1.9273472 ´ 10-13
7. 0.19402985 0.20163968 0.20163968 -4.4408921 ´ 10-16
8. 0.19402985 0.20163968 0.20163968 1.110223 ´ 10-16
9. 0.20163968 0.20163968 0.20163968 1.110223 ´ 10-16
10. 0.20163968 0.20163968 0.20163968 1.110223 ´ 10-16
Root after 100.20163968 iterations ¢

Function value at approximated root f@pD=1.110223 ´ 10-16

QUES4.

Clear@x, f, a, b, m, n, iD
f@x_D := Cos@xD - x ãx ;
Plot@f@xD, 8x, - 2, 2<D

-2 -1 1 2

-5

-10

-15
6 PRACTICAL 3 NUMERICAL ANALYSIS.nb

a0 = 0;
b0 = 1;
a = N@a0D;
b = N@b0D;
n = Input@"Please enter maximum number of iterations "D
If @f@aD * f@bD > 0, Print@"We cannot continue with the false position Method as ",
f, "HaL.", f, "HbL>=0"D; Abort@DD
i = 1;

b-a
p = b - f@bD * ;
f@bD - f@aD
OutputDetails = 88i, a, p, b, f@pD<<;
b-a
WhileBi < n, If@Sign@f@aDD == Sign@f@pDD, a = p, b = pD; p = b - f@bD * ;
f@bD - f@aD
i ++; OutputDetails = Append@OutputDetails , 8i, a, p, b, f@pD<D;F
H*Combining the output details with the headings of the table*L
Print@NumberForm@
N@TableForm@OutputDetails , TableHeadings ® 8None, 8"i", "ai ", "pi ", "bi ", "f@pi D"<<DD,
8DD;H*Printing Table*L
Print@"Root after ", n, "iterations" ' NumberForm@N@pD, 8DD
H*8 is used to give the result with 8 digits precision*L
Print@"Function value at approximated root f@pD=", NumberForm@N@f@pDD, 8DD;
8

i ai pi bi f@pi D
1. 0. 0.31466534 1. 0.51987117
2. 0.31466534 0.44672814 1. 0.20354478
3. 0.44672814 0.49401534 1. 0.070802349
4. 0.49401534 0.50994614 1. 0.023607719
5. 0.50994614 0.51520101 1. 0.0077601137
6. 0.51520101 0.51692221 1. 0.0025388647
7. 0.51692221 0.51748468 1. 0.00082935789
8. 0.51748468 0.51766834 1. 0.00027078573
Root after 80.51766834 iterations ¢

Function value at approximated root f@pD=0.00027078573

QUES5.
PRACTICAL 3 NUMERICAL ANALYSIS.nb 7

Clear@x, f, a, b, m, n, iD
f@x_D := ã-x - x;
Plot@f@xD, 8x, - 1, 1<D

-1.0 -0.5 0.5 1.0

a0 = 0;
b0 = 1;
a = N@a0D;
b = N@b0D;
n = Input@"Please enter maximum number of iterations "D
If @f@aD * f@bD > 0, Print@"We cannot continue with the false position Method as ",
f, "HaL.", f, "HbL>=0"D; Abort@DD
i = 1;

b-a
p = b - f@bD * ;
f@bD - f@aD
OutputDetails = 88i, a, p, b, f@pD<<;
b-a
WhileBi < n, If@Sign@f@aDD == Sign@f@pDD, a = p, b = pD; p = b - f@bD * ;
f@bD - f@aD
i ++; OutputDetails = Append@OutputDetails , 8i, a, p, b, f@pD<D;F
H*Combining the output details with the headings of the table*L
Print@NumberForm@
N@TableForm@OutputDetails , TableHeadings ® 8None, 8"i", "ai ", "pi ", "bi ", "f@pi D"<<DD,
8DD;H*Printing Table*L
Print@"Root after ", n, "iterations" ' NumberForm@N@pD, 8DD
H*8 is used to give the result with 8 digits precision*L
Print@"Function value at approximated root f@pD=", NumberForm@N@f@pDD, 8DD;
10
8 PRACTICAL 3 NUMERICAL ANALYSIS.nb

i ai pi bi f@pi D
1. 0. 0.61269984 1. -0.070813948
2. 0. 0.57218141 0.61269984 -0.0078882729
3. 0. 0.56770321 0.57218141 -0.00087739198
4. 0. 0.56720555 0.56770321 -0.000097572726
5. 0. 0.56715021 0.56720555 -0.000010850621
6. 0. 0.56714406 0.56715021 -1.2066458 ´ 10-6
7. 0. 0.56714338 0.56714406 -1.3418529 ´ 10-7
8. 0. 0.5671433 0.56714338 -1.4922102 ´ 10-8
9. 0. 0.56714329 0.5671433 -1.6594154 ´ 10-9
10. 0. 0.56714329 0.56714329 -1.8453561 ´ 10-10
Root after 100.56714329 iterations ¢

Function value at approximated root f@pD=-1.8453561 ´ 10-10

QUES6.

Clear@x, f, a, b, m, n, iD
f@x_D := x3 - 5 x + 1;
Plot@f@xD, 8x, - 2, 2<D

-2 -1 1 2

-2
PRACTICAL 3 NUMERICAL ANALYSIS.nb 9

a0 = Input@"Enter the left end point of interval"D;


b0 = Input@"Enter the right end point of interval"D;
a = N@a0D;
b = N@b0D;
error = Input@"Please enter error tolerance "D
If @f@aD * f@bD > 0, Print@"We cannot continue with the false position Method as ",
f, "HaL.", f, "HbL>=0"D; Abort@DD
i = 1;

b-a
p = b - f@bD * ;
f@bD - f@aD
OutputDetails = 88i, a, p, b, f@pD<<;
WhileBAbs@f@pDD > error,
b-a
If@Sign@f@aDD == Sign@f@pDD, a = p, b = pD; p = b - f@bD * ;
f@bD - f@aD
i ++; OutputDetails = Append@OutputDetails , 8i, a, p, b, f@pD<D;F
Print@NumberForm@
N@TableForm@OutputDetails , TableHeadings ® 8None, 8"i", "ai ", "pi ", "bi ", "f@pi D"<<DD, 8DD;
Print@"Root after ", n, "iterations" ' NumberForm@N@pD, 8DD
Print@"Function value at approximated root f@pD=", NumberForm@f@pD, 8DD;
1
10 000

i ai pi bi f@pi D
1. 0. 0.25 1. -0.234375
2. 0. 0.20253165 0.25 -0.0043505686
3. 0. 0.20165433 0.20253165 -0.000071505985
Root after n0.20165433 iterations ¢

Function value at approximated root f@pD=-0.000071505985

QUES7.

Clear@x, f, a, b, m, n, iD
f@x_D := Cos@xD - x Exp@xD;
Plot@f@xD, 8x, - 2, 2<D

-2 -1 1 2

-5

-10

-15
10 PRACTICAL 3 NUMERICAL ANALYSIS.nb

a0 = Input@"Enter the left end point of interval"D;


b0 = Input@"Enter the right end point of interval"D;
a = N@a0D;
b = N@b0D;
error = Input@"Please enter error tolerance "D
If @f@aD * f@bD > 0, Print@"We cannot continue with the false position Method as ",
f, "HaL.", f, "HbL>=0"D; Abort@DD
i = 1;

b-a
p = b - f@bD * ;
f@bD - f@aD
OutputDetails = 88i, a, p, b, f@pD<<;
WhileBAbs@f@pDD > error,
b-a
If@Sign@f@aDD == Sign@f@pDD, a = p, b = pD; p = b - f@bD * ;
f@bD - f@aD
i ++; OutputDetails = Append@OutputDetails , 8i, a, p, b, f@pD<D;F
Print@NumberForm@
N@TableForm@OutputDetails , TableHeadings ® 8None, 8"i", "ai ", "pi ", "bi ", "f@pi D"<<DD, 8DD;
Print@"Root after ", n, "iterations" ' NumberForm@N@pD, 8DD
Print@"Function value at approximated root f@pD=", NumberForm@f@pD, 8DD;
1
10 000

i ai pi bi f@pi D
1. 0. 0.31466534 1. 0.51987117
2. 0.31466534 0.44672814 1. 0.20354478
3. 0.44672814 0.49401534 1. 0.070802349
4. 0.49401534 0.50994614 1. 0.023607719
5. 0.50994614 0.51520101 1. 0.0077601137
6. 0.51520101 0.51692221 1. 0.0025388647
7. 0.51692221 0.51748468 1. 0.00082935789
8. 0.51748468 0.51766834 1. 0.00027078573
9. 0.51766834 0.51772831 1. 0.00008839713
Root after n0.51772831 iterations ¢

Function value at approximated root f@pD=0.00008839713

QUES8.
PRACTICAL 3 NUMERICAL ANALYSIS.nb 11

Clear@x, f, a, b, m, n, iD
f@x_D := x4 + 3 x2 + x - 10;
Plot@f@xD, 8x, - 2, 4<D
200

150

100

50

-2 -1 1 2 3 4

a0 = Input@"Enter the left end point of interval"D;


b0 = Input@"Enter the right end point of interval"D;
a = N@a0D;
b = N@b0D;
error = Input@"Please enter error tolerance "D
If @f@aD * f@bD > 0, Print@"We cannot continue with the false position Method as ",
f, "HaL.", f, "HbL>=0"D; Abort@DD
i = 1;

b-a
p = b - f@bD * ;
f@bD - f@aD
OutputDetails = 88i, a, p, b, f@pD<<;
WhileBAbs@f@pDD > error,
b-a
If@Sign@f@aDD == Sign@f@pDD, a = p, b = pD; p = b - f@bD * ;
f@bD - f@aD
i ++; OutputDetails = Append@OutputDetails , 8i, a, p, b, f@pD<D;F
Print@NumberForm@
N@TableForm@OutputDetails , TableHeadings ® 8None, 8"i", "ai ", "pi ", "bi ", "f@pi D"<<DD, 8DD;
Print@"Root after ", n, "iterations" ' NumberForm@N@pD, 8DD
Print@"Function value at approximated root f@pD=", NumberForm@f@pD, 8DD;
1
10 000
We cannot continue with the false position Method as fHaL.fHbL>=0

$Aborted
12 PRACTICAL 3 NUMERICAL ANALYSIS.nb

i ai pi bi f@pi D
1. 2. 1.7530864 3. 10.418269
2. 1.7530864 1.6096725 3. 6.0963262
3. 1.6096725 1.520362 3. 3.7979001
4. 1.520362 1.4625493 3. 2.4552383
5. 1.4625493 1.4242438 3. 1.6243476
6. 1.4242438 1.3984873 3. 1.09081
7. 1.3984873 1.3810019 3. 0.73978399
8. 1.3810019 1.3690559 3. 0.50505144
9. 1.3690559 1.3608594 3. 0.34634926
10. 1.3608594 1.3552191 3. 0.23824394
11. 1.3552191 1.3513301 3. 0.16422541
12. 1.3513301 1.348645 3. 0.11336661
13. 1.348645 1.3467894 3. 0.078336042
14. 1.3467894 1.3455062 3. 0.054167149
15. 1.3455062 1.3446184 3. 0.037472801
16. 1.3446184 1.344004 3. 0.025932157
17. 1.344004 1.3435787 3. 0.017949798
18. 1.3435787 1.3432842 3. 0.012426494
19. 1.3432842 1.3430804 3. 0.0086036913
20. 1.3430804 1.3429392 3. 0.0059573574
21. 1.3429392 1.3428415 3. 0.0041252008
22. 1.3428415 1.3427738 3. 0.0028566181
23. 1.3427738 1.3427269 3. 0.0019781996
24. 1.3427269 1.3426945 3. 0.001369921
25. 1.3426945 1.342672 3. 0.00094869402
26. 1.342672 1.3426564 3. 0.00065699246
27. 1.3426564 1.3426456 3. 0.00045498502
28. 1.3426456 1.3426382 3. 0.00031509067
29. 1.3426382 1.342633 3. 0.00021821026
30. 1.342633 1.3426294 3. 0.0001511178
31. 1.3426294 1.3426269 3. 0.0001046542
32. 1.3426269 1.3426252 3. 0.000072476649
Root after n1.3426252 iterations ¢

Function value at approximated root f@pD=0.000072476649

QUES9.

Clear@x, f, a, b, m, n, iD
f@x_D := ãx + x2 - x - 4;
Plot@f@xD, 8x, - 2, 2<D

-2 -1 1 2

-2
PRACTICAL 3 NUMERICAL ANALYSIS.nb 13

a0 = Input@"Enter the left end point of interval"D;


b0 = Input@"Enter the right end point of interval"D;
a = N@a0D;
b = N@b0D;
error = Input@"Please enter error tolerance "D
If @f@aD * f@bD > 0, Print@"We cannot continue with the false position Method as ",
f, "HaL.", f, "HbL>=0"D; Abort@DD
i = 1;

b-a
p = b - f@bD * ;
f@bD - f@aD
OutputDetails = 88i, a, p, b, f@pD<<;
WhileBAbs@f@pDD > error,
b-a
If@Sign@f@aDD == Sign@f@pDD, a = p, b = pD; p = b - f@bD * ;
f@bD - f@aD
i ++; OutputDetails = Append@OutputDetails , 8i, a, p, b, f@pD<D;F
Print@NumberForm@
N@TableForm@OutputDetails , TableHeadings ® 8None, 8"i", "ai ", "pi ", "bi ", "f@pi D"<<DD, 8DD;
Print@"Root after ", n, "iterations" ' NumberForm@N@pD, 8DD
Print@"Function value at approximated root f@pD=", NumberForm@f@pD, 8DD;
1
1 000 000
We cannot continue with the false position Method as fHaL.fHbL>=0

$Aborted
14 PRACTICAL 3 NUMERICAL ANALYSIS.nb

i ai pi bi f@pi D
1. 1. 0.83267265 2. -1.2417932
2. 0.83267265 0.72877854 2. -0.76443974
3. 0.72877854 0.66143381 2. -0.49246096
4. 0.66143381 0.61659633 2. -0.32646214
5. 0.61659633 0.58622001 2. -0.22050642
6. 0.58622001 0.56540041 2. -0.15081676
7. 0.56540041 0.55101795 2. -0.10403422
8. 0.55101795 0.54102846 2. -0.072184413
9. 0.54102846 0.53406414 2. -0.050288478
10. 0.53406414 0.52919621 2. -0.035133047
11. 0.52919621 0.52578745 2. -0.024593248
12. 0.52578745 0.52339744 2. -0.01723901
13. 0.52339744 0.52172023 2. -0.012095575
14. 0.52172023 0.52054249 2. -0.0084924634
15. 0.52054249 0.51971512 2. -0.0059654951
16. 0.51971512 0.51913371 2. -0.0041918306
17. 0.51913371 0.51872505 2. -0.0029462012
18. 0.51872505 0.51843777 2. -0.0020710587
19. 0.51843777 0.5182358 2. -0.0014560374
20. 0.5182358 0.51809379 2. -0.0010237357
21. 0.51809379 0.51799394 2. -0.00071982676
22. 0.51799394 0.51792372 2. -0.00050615733
23. 0.51792372 0.51787435 2. -0.00035592239
24. 0.51787435 0.51783963 2. -0.00025028436
25. 0.51783963 0.51781522 2. -0.00017600223
26. 0.51781522 0.51779805 2. -0.00012376757
27. 0.51779805 0.51778597 2. -0.000087035933
28. 0.51778597 0.51777748 2. -0.000061205775
29. 0.51777748 0.51777151 2. -0.000043041529
30. 0.51777151 0.51776731 2. -0.000030268021
31. 0.51776731 0.51776436 2. -0.000021285365
32. 0.51776436 0.51776228 2. -0.000014968514
33. 0.51776228 0.51776082 2. -0.000010526321
34. 0.51776082 0.5177598 2. -7.4024389 ´ 10-6
35. 0.5177598 0.51775907 2. -5.2056289 ´ 10-6
36. 0.51775907 0.51775857 2. -3.6607638 ´ 10-6
37. 0.51775857 0.51775821 2. -2.5743661 ´ 10-6
38. 0.51775821 0.51775796 2. -1.8103768 ´ 10-6
39. 0.51775796 0.51775778 2. -1.2731151 ´ 10-6
40. 0.51775778 0.51775766 2. -8.9529549 ´ 10-7
Root after 80.51775766 iterations ¢

Function value at approximated root f@pD=-8.9529549 ´ 10-7

QUES10.
PRACTICAL 3 NUMERICAL ANALYSIS.nb 15

Clear@x, f, a, b, m, n, iD
f@x_D := x3 + 2 x2 - 3 x - 1;
Plot@f@xD, 8x, - 2, 2<D

-2 -1 1 2

-2

a0 = Input@"Enter the left end point of interval"D;


b0 = Input@"Enter the right end point of interval"D;
a = N@a0D;
b = N@b0D;
error = Input@"Please enter error tolerance "D
If @f@aD * f@bD > 0, Print@"We cannot continue with the false position Method as ",
f, "HaL.", f, "HbL>=0"D; Abort@DD
i = 1;

b-a
p = b - f@bD * ;
f@bD - f@aD
OutputDetails = 88i, a, p, b, f@pD<<;
WhileBAbs@f@pDD > error,
b-a
If@Sign@f@aDD == Sign@f@pDD, a = p, b = pD; p = b - f@bD * ;
f@bD - f@aD
i ++; OutputDetails = Append@OutputDetails , 8i, a, p, b, f@pD<D;F
Print@NumberForm@
N@TableForm@OutputDetails , TableHeadings ® 8None, 8"i", "ai ", "pi ", "bi ", "f@pi D"<<DD, 8DD;
Print@"Root after ", n, "iterations" ' NumberForm@N@pD, 8DD
Print@"Function value at approximated root f@pD=", NumberForm@f@pD, 8DD;
1
20 000

i ai pi bi f@pi D
1. -1. -0.25 0. -0.140625
2. -1. -0.28358209 -0.25 -0.01122146
3. -1. -0.28625185 -0.28358209 -0.00081969868
4. -1. -0.28644682 -0.28625185 -0.000059445627
5. -1. -0.28646096 -0.28644682 -4.3087946 ´ 10-6
Root after n-0.28646096 iterations ¢

Function value at approximated root f@pD=-4.3087946 ´ 10-6

You might also like