[go: up one dir, main page]

0% found this document useful (0 votes)
40 views7 pages

Bisection Method Analysis

The document describes using the bisection method to find the root of various functions with increasing coefficients on the cosine term. It runs the bisection method for each function, displaying the iteration values and requiring more iterations for functions with higher coefficients to achieve the desired accuracy.

Uploaded by

Waqar Ali Soomro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views7 pages

Bisection Method Analysis

The document describes using the bisection method to find the root of various functions with increasing coefficients on the cosine term. It runs the bisection method for each function, displaying the iteration values and requiring more iterations for functions with higher coefficients to achieve the desired accuracy.

Uploaded by

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

fun= @(x) cos(x)-x; % i=0

xRoot=fzero(fun,0.5);
nStep= BISECTION(fun,0,pi/2,1e-6,19,xRoot)
n a_n b_n p_n Error

1 0.00000000 1.57079633 0.78539816 0.04631303


2 0.00000000 0.78539816 0.39269908 0.34638605
3 0.39269908 0.78539816 0.58904862 0.15003651
4 0.58904862 0.78539816 0.68722339 0.05186174
5 0.68722339 0.78539816 0.73631078 0.00277436
6 0.73631078 0.78539816 0.76085447 0.02176934
7 0.73631078 0.76085447 0.74858262 0.00949749
8 0.73631078 0.74858262 0.74244670 0.00336157
9 0.73631078 0.74244670 0.73937874 0.00029361
10 0.73631078 0.73937874 0.73784476 0.00124037
11 0.73784476 0.73937874 0.73861175 0.00047338
12 0.73861175 0.73937874 0.73899524 0.00008989
13 0.73899524 0.73937874 0.73918699 0.00010186
14 0.73899524 0.73918699 0.73909112 0.00000599
15 0.73899524 0.73909112 0.73904318 0.00004195
16 0.73904318 0.73909112 0.73906715 0.00001798
17 0.73906715 0.73909112 0.73907913 0.00000600
18 0.73907913 0.73909112 0.73908513 0.00000001

With the bisection method, 18 repetitions are needed to obtain the absolute
error less than 0.00000100

nStep =

18

fun= @(x) 10*cos(x)-x; % i=1


xRoot=fzero(fun,0.5);
nStep= BISECTION(fun,0,pi/2,1e-6,19,xRoot)
n a_n b_n p_n Error

1 0.00000000 1.57079633 0.78539816 0.64215362


2 0.78539816 1.57079633 1.17809725 0.24945453
3 1.17809725 1.57079633 1.37444679 0.05310499
4 1.37444679 1.57079633 1.47262156 0.04506978
5 1.37444679 1.47262156 1.42353417 0.00401761
6 1.42353417 1.47262156 1.44807786 0.02052608
7 1.42353417 1.44807786 1.43580602 0.00825424
8 1.42353417 1.43580602 1.42967009 0.00211832
9 1.42353417 1.42967009 1.42660213 0.00094965
10 1.42660213 1.42967009 1.42813611 0.00058433
11 1.42660213 1.42813611 1.42736912 0.00018266
12 1.42736912 1.42813611 1.42775262 0.00020084
13 1.42736912 1.42775262 1.42756087 0.00000909
14 1.42736912 1.42756087 1.42746500 0.00008678
15 1.42746500 1.42756087 1.42751293 0.00003884
16 1.42751293 1.42756087 1.42753690 0.00001488
17 1.42753690 1.42756087 1.42754889 0.00000289
18 1.42754889 1.42756087 1.42755488 0.00000310
19 1.42754889 1.42755488 1.42755188 0.00000010

With the bisection method, 19 repetitions are needed to obtain the absolute
error less than 0.00000100

nStep =

19

fun= @(x) 100*cos(x)-x; %


i=2 xRoot=fzero(fun,0.5);
nStep= BISECTION(fun,0,pi/2,1e-6,19,xRoot)
n a_n b_n p_n Error

1 0.00000000 1.57079633 0.78539816 0.76984510


2 0.78539816 1.57079633 1.17809725 0.37714602
3 1.17809725 1.57079633 1.37444679 0.18079648
4 1.37444679 1.57079633 1.47262156 0.08262171
5 1.47262156 1.57079633 1.52170894 0.03353433
6 1.52170894 1.57079633 1.54625263 0.00899063
7 1.54625263 1.57079633 1.55852448 0.00328121
8 1.54625263 1.55852448 1.55238856 0.00285471
9 1.55238856 1.55852448 1.55545652 0.00021325
10 1.55238856 1.55545652 1.55392254 0.00132073
11 1.55392254 1.55545652 1.55468953 0.00055374
12 1.55468953 1.55545652 1.55507302 0.00017024
13 1.55507302 1.55545652 1.55526477 0.00002150
14 1.55507302 1.55526477 1.55516890 0.00007437
15 1.55516890 1.55526477 1.55521683 0.00002643
16 1.55521683 1.55526477 1.55524080 0.00000246
17 1.55524080 1.55526477 1.55525279 0.00000952
18 1.55524080 1.55525279 1.55524679 0.00000353
19 1.55524080 1.55524679 1.55524380 0.00000053

With the bisection method, 19 repetitions are needed to obtain the absolute
error less than 0.00000100
nStep =

19

fun= @(x) 1000*cos(x)-x; % i=3


xRoot=fzero(fun,0.5);
xRoot=fzero(fun,0.5);
nStep= BISECTION(fun,0,pi/2,1e-6,19,xRoot)
n a_n b_n p_n Error

1 0.00000000 1.57079633 0.78539816 0.78382894


2 0.78539816 1.57079633 1.17809725 0.39112985
3 1.17809725 1.57079633 1.37444679 0.19478031
4 1.37444679 1.57079633 1.47262156 0.09660554
5 1.47262156 1.57079633 1.52170894 0.04751816
6 1.52170894 1.57079633 1.54625263 0.02297446
7 1.54625263 1.57079633 1.55852448 0.01070262
8 1.55852448 1.57079633 1.56466040 0.00456670
9 1.56466040 1.57079633 1.56772837 0.00149873
10 1.56772837 1.57079633 1.56926235 0.00003525
11 1.56772837 1.56926235 1.56849536 0.00073174
12 1.56849536 1.56926235 1.56887885 0.00034825
13 1.56887885 1.56926235 1.56907060 0.00015650
14 1.56907060 1.56926235 1.56916647 0.00006063
15 1.56916647 1.56926235 1.56921441 0.00001269
16 1.56921441 1.56926235 1.56923838 0.00001128
17 1.56921441 1.56923838 1.56922639 0.00000071

With the bisection method, 17 repetitions are needed to obtain the absolute
error less than 0.00000100

nStep =

17

fun= @(x) 10000*cos(x)-x; % i=4


xRoot=fzero(fun,0.5);
nStep= BISECTION(fun,0,pi/2,1e-6,19,xRoot)
n a_n b_n p_n Error

1 0.00000000 1.57079633 0.78539816 0.78524110


2 0.78539816 1.57079633 1.17809725 0.39254202
3 1.17809725 1.57079633 1.37444679 0.19619248
4 1.37444679 1.57079633 1.47262156 0.09801771
5 1.47262156 1.57079633 1.52170894 0.04893032
6 1.52170894 1.57079633 1.54625263 0.02438663
7 1.54625263 1.57079633 1.55852448 0.01211478
8 1.55852448 1.57079633 1.56466040 0.00597886
9 1.56466040 1.57079633 1.56772837 0.00291090
10 1.56772837 1.57079633 1.56926235 0.00137692
11 1.56926235 1.57079633 1.57002934 0.00060993
12 1.57002934 1.57079633 1.57041283 0.00022643
13 1.57041283 1.57079633 1.57060458 0.00003468
14 1.57060458 1.57079633 1.57070045 0.00006119
15 1.57060458 1.57070045 1.57065252 0.00001325
16 1.57060458 1.57065252 1.57062855 0.00001072
17 1.57062855 1.57065252 1.57064053 0.00000127
18 1.57062855 1.57064053 1.57063454 0.00000472
19 1.57063454 1.57064053 1.57063754 0.00000173

nStep =

19

fun= @(x) 100000*cos(x)-x; % i=5


xRoot=fzero(fun,0.5);
nStep= BISECTION(fun,0,pi/2,1e-6,19,xRoot)
n a_n b_n p_n Error

1 0.00000000 1.57079633 0.78539816 0.78538246


2 0.78539816 1.57079633 1.17809725 0.39268337
3 1.17809725 1.57079633 1.37444679 0.19633383
4 1.37444679 1.57079633 1.47262156 0.09815906
5 1.47262156 1.57079633 1.52170894 0.04907168
6 1.52170894 1.57079633 1.54625263 0.02452798
7 1.54625263 1.57079633 1.55852448 0.01225614
8 1.55852448 1.57079633 1.56466040 0.00612022
9 1.56466040 1.57079633 1.56772837 0.00305225
10 1.56772837 1.57079633 1.56926235 0.00151827
11 1.56926235 1.57079633 1.57002934 0.00075128
12 1.57002934 1.57079633 1.57041283 0.00036779
13 1.57041283 1.57079633 1.57060458 0.00017604
14 1.57060458 1.57079633 1.57070045 0.00008017
15 1.57070045 1.57079633 1.57074839 0.00003223
16 1.57074839 1.57079633 1.57077236 0.00000826
17 1.57077236 1.57079633 1.57078434 0.00000372
18 1.57077236 1.57078434 1.57077835 0.00000227
19 1.57077835 1.57078434 1.57078135 0.00000073

With the bisection method, 19 repetitions are needed to obtain the absolute
error less than 0.00000100

nStep =

19

fun= @(x) 1000000*cos(x)-x; % i=6


xRoot=fzero(fun,0.5);
nStep= BISECTION(fun,0,pi/2,1e-6,19,xRoot)
n a_n b_n p_n Error

1 0.00000000 1.57079633 0.78539816 0.78539659


2 0.78539816 1.57079633 1.17809725 0.39269751
3 1.17809725 1.57079633 1.37444679 0.19634797
4 1.37444679 1.57079633 1.47262156 0.09817320
5 1.47262156 1.57079633 1.52170894 0.04908581
6 1.52170894 1.57079633 1.54625263 0.02454212
7 1.54625263 1.57079633 1.55852448 0.01227028
8 1.55852448 1.57079633 1.56466040 0.00613435
9 1.56466040 1.57079633 1.56772837 0.00306639
10 1.56772837 1.57079633 1.56926235 0.00153241
11 1.56926235 1.57079633 1.57002934 0.00076542
12 1.57002934 1.57079633 1.57041283 0.00038192
13 1.57041283 1.57079633 1.57060458 0.00019018
14 1.57060458 1.57079633 1.57070045 0.00009430
15 1.57070045 1.57079633 1.57074839 0.00004637
16 1.57074839 1.57079633 1.57077236 0.00002240
17 1.57077236 1.57079633 1.57078434 0.00001041
18 1.57078434 1.57079633 1.57079033 0.00000442
19 1.57079033 1.57079633 1.57079333 0.00000143

nStep =

19

fun= @(x) 10000000*cos(x)-x; % i=7


xRoot=fzero(fun,0.5);
nStep= BISECTION(fun,0,pi/2,1e-6,19,xRoot)
n a_n b_n p_n Error

1 0.00000000 1.57079633 0.78539816 0.78539801


2 0.78539816 1.57079633 1.17809725 0.39269892
3 1.17809725 1.57079633 1.37444679 0.19634938
4 1.37444679 1.57079633 1.47262156 0.09817461
5 1.47262156 1.57079633 1.52170894 0.04908723
6 1.52170894 1.57079633 1.54625263 0.02454354
7 1.54625263 1.57079633 1.55852448 0.01227169
8 1.55852448 1.57079633 1.56466040 0.00613577
9 1.56466040 1.57079633 1.56772837 0.00306780
10 1.56772837 1.57079633 1.56926235 0.00153382
11 1.56926235 1.57079633 1.57002934 0.00076683
12 1.57002934 1.57079633 1.57041283 0.00038334
13 1.57041283 1.57079633 1.57060458 0.00019159
14 1.57060458 1.57079633 1.57070045 0.00009572
15 1.57070045 1.57079633 1.57074839 0.00004778
16 1.57074839 1.57079633 1.57077236 0.00002381
17 1.57077236 1.57079633 1.57078434 0.00001183
18 1.57078434 1.57079633 1.57079033 0.00000584
19 1.57079033 1.57079633 1.57079333 0.00000284

nStep =19

fun= @(x) 100000000*cos(x)-x; % i=8


xRoot=fzero(fun,0.5);
nStep= BISECTION(fun,0,pi/2,1e-6,19,xRoot)
n a_n b_n p_n Error

1 0.00000000 1.57079633 0.78539816 0.78539815


2 0.78539816 1.57079633 1.17809725 0.39269907
3 1.17809725 1.57079633 1.37444679 0.19634953
4 1.37444679 1.57079633 1.47262156 0.09817475
5 1.47262156 1.57079633 1.52170894 0.04908737
6 1.52170894 1.57079633 1.54625263 0.02454368
7 1.54625263 1.57079633 1.55852448 0.01227183
8 1.55852448 1.57079633 1.56466040 0.00613591
9 1.56466040 1.57079633 1.56772837 0.00306795
10 1.56772837 1.57079633 1.56926235 0.00153397
11 1.56926235 1.57079633 1.57002934 0.00076697
12 1.57002934 1.57079633 1.57041283 0.00038348
13 1.57041283 1.57079633 1.57060458 0.00019173
14 1.57060458 1.57079633 1.57070045 0.00009586
15 1.57070045 1.57079633 1.57074839 0.00004792
16 1.57074839 1.57079633 1.57077236 0.00002395
17 1.57077236 1.57079633 1.57078434 0.00001197
18 1.57078434 1.57079633 1.57079033 0.00000598
19 1.57079033 1.57079633 1.57079333 0.00000298

nStep = 19
TABLE

You might also like