You are on page 1of 16

Root Finding With Relaxation

MecE 390 Lab 2


Saad Navaid
1356918
LAB H2
2 February, 2015

1. See Appendix A for code and Appendix B for diary output of part (d) and (e). The
function plotfunc(f) was used to obtain a graph of the functions which were then used to
make the initial guesses. The value of h obtained using the secant method was
h=0.43112m. Two other values were obtained but were rejected since h cannot be
negative and should be less than 2m since the maximum height of the tank is 2m.
2. See Appendix A for code and Appendix B for diary output of part (d). The code was
able to find the one root which was 0 however, it was unable to find the second root
since there was monotonic divergence in the region where x is greater than 1 for x
less than 1 we converge to x=0.
3. See Appendix B for the diary output of part (a) and (b). In part (a) only 1 root could be
obtained (0.43112) whereas in part (b) one root was obtained as well (2.9449).
4. All the graphs obtained are shown in Appendix C.
In Q.3 we were only able to find one root in part (a) and another root in part (b). In part
(a) there was monotonic divergence around x=2.9449 which is why we weren't able to
obtain that root. However, the function did monotonically converge to 0.43112 which is
the value for h. In part (b) we were able to monotonically converge to 2.9449 but there
was monotonically divergence around x=0.43112. Both part (a) and (b) didn't result in
any negative roots as both the auxiliary functions were positive for all x values.
Relaxation values greater than 1 resulted in faster convergence compared to no
relaxation for both Q.3 part (a) and (b) and convergence was much slower for relaxation
values lower than 1. This is as expected by the theory since values of W greater than 1
and less than 2 lead to faster convergence in monotonic convergence.
In general, we can see that convergence rate is much slower (less efficient) for Onepoint iteration compared to the secant method which is as expected by the theory.
Secant method requires significantly lesser number of iterations if the initial guess is
close to the root but could diverge if during iteration the root estimate falls close to a
minimum or maximum point. In One-point iteration initial guess plays a moderate role in
faster convergence. If the guess is close to the root then convergence will be faster but
if it's farther away then it could take a large number of iterations to converge to the root
as seen in Q.3 part (a). One-point iteration is hence more sensitive to initial guess.

Appendix A
Code used for Q.1 to plot the graph of the function
function plotfunc(funcname)
% function is a character variable containing the name of function to solve
% Syntax: plotfunc('func01')
%Initializing variables
%Turns diary on and saves input in a file named snavaid_lab02
diary snavaid_lab02;
%Get input function to plot
funcname=input('Enter function to plot:
','s');
%plot the function from x=-20 to x=20
a=-50;
b=50;
answer='y';
while(answer~='n')%runs the loop only if diary is not equal to n/ equal to y
clf; %clear figure window
ezplot('0',[a,b]); %plot a solid line on x axis from -50 to 50
grid on; %turns gridlines on to improve guessing
hold on;
ezplot(funcname,[a,b]); % plot the input function from -50 to 50
ylabel('f(x)'); %y axis label
xlabel('x'); %x axis label
title ('Graph of function vs. x') %title of graph
%ask if the interval needs to change for better visualization of roots
answer=input('New interval (y/n)? ','s');
if answer=='y'
a= input('New value of a:
');
b= input('New value of b:
');
end
end

Here are the M-files containing the name of the functions


function y1=func4(x)
y1=x.^2-4;%function y1
function f= func5(h)
%spherical tank formula to find height h in m
r=1; % Units = m
V=0.5; %Units = m^3
f=((pi*h.^2*(3*r-h))/3)-V;

Note: both the functions above were created in separate M-files.

Code used for Q.1 to find root of a function using the secant method
function secroot
% Function to find root with Secant Method
% Syntax: Secant Root
diary snavaid_lab03; %Turns diary on
% The function has been defined in another M-file
f=input('Enter name of the function: ','s'); %Get input function
% Get two starting values
xi=input('Enter guess 1: ');
xi1= input('Enter guess 2: ');
% initializing variables
count=0; % counts the no. of iterations
maxitr=500; % maximum no. of iterations
relerr=1; % initializing relative error
abserr=1; % initializing absolute error
f_root=1; % initializing function value
small=1.e-15; % a very small value to prevent division by zero
reltol=10^-4; % relative tolerance
abstol=10^-8; % absolute tolerance
ftol=10^-8; % tolerance in function value
% printing the top labeling line
fprintf('\n
#
root
abs error rel error
fxi1\n\n');
%check if the specified error is less than actual error and the count
% is less than the maximum number of allowable iterations
while ((relerr>reltol) && (abserr>abstol) || (abs(f_root)>ftol)) &&
(count<maxitr)
count=count+1;
x0=xi; %discard oldest iterate
xi=xi1; %save previous iterate
%find value of function at xi and xi_1
fx0=feval(f,x0);
fxi=feval(f,xi);
fprime=(fxi-fx0)/(xi-x0); %derivative of the function
% check if estimated derivative/denominator is close to zero
if abs(fprime) < small
disp('Error: denominator approaching zero.')
disp('Try another initial guess.')
return
end
xi1=xi-fxi/fprime;% root found using the secant method
relerr=abs(xi1-xi)/(xi1+small); % relative error
abserr=abs(xi1-xi); %absolute true error
f_root=feval(f,xi1);
% printing each iteration result
fprintf('%3g %5.6g %10.5g %10.5g
%10.5g\n',count,xi1,abserr,relerr,abs(f_root));
end
disp(['Total no. of iterations: ' num2str(count)])
disp(['Obtained root: ' num2str(xi1)])

Code used for Q.2 to find root of a function using the One-point Iteration method
function OPI
% Function to find root with One-point iteration method
% Syntax: One-point Iteration
diary snavaid_lab03; %Turns diary on
% The function has been defined in another M-file
f=input('Enter name of the function: ','s'); %Get input function
% Get one starting function, one starting value and a relaxation parameter
gx=input('Enter auxilary function: ','s'); %this has to be defined in another
M-file
xi= input('Enter starting value: ');
W=input('Enter relaxation parameter: '); %Relaxation parameter
% initializing variables
count=0; % counts the no. of iterations
maxitr=500; % maximum no. of iterations
relerr=1; % initializing relative error
abserr=1; % initializing absolute error
f_root=1; % initializing function value
small=1.e-15; % a very small value to prevent division by zero
reltol=10^-4; % relative tolerance
abstol=10^-8; % absolute tolerance
ftol=10^-8; % tolerance in function value
max_x_value= 3.40*10^38; %defining a maximum x value
% printing the top labeling line
fprintf('\n
#
root
abs error rel error
fxi\n\n');
%check if the specified error is less than actual error and the count
% is less than the maximum number of allowable iterations
while ((relerr>reltol) && (abserr>abstol) || (abs(f_root)>ftol)) &&
(count<maxitr)
count=count+1;
xold=xi; %save previous iterate
xi=feval(gx,xold);
relerr=abs(xi-xold)/(xi+small); % relative error in percentage
abserr=abs(xi-xold); %absolute true error
delta_x=xi-xold; %error between the two values
xi=xold+W*delta_x; %introducing the relaxation parameter
f_root=feval(f,xi);%fincding value of the function at root
if abs(xi)>max_x_value %stopping iteration if value exceeds the max x value
disp('No root found')
return
end
% printing each iteration result
fprintf('%3g %5.6g %10.5g %10.5g
%15.5g\n',count,xi,abserr,relerr,abs(f_root));
end
disp(['Total no. of iterations: ' num2str(count)])
disp(['Obtained root: ' num2str(xi)])

Code used for Q.2 to define auxiliary function and actual function
function y4 = func7(x)
y4=x.^2-x;%function y4

function y3=func6(x)
y3=x.^2; %auxiliary function g1

Code used for Q.3 to define auxiliary functions


function g2=func8(h)
r=1; % Units = m
V=0.5; %Units = m^3
g2=((h.^3+(3*V/pi))/3).^0.5;
function g1=func3(h)
r=1; % Units = m
V=0.5; %Units = m^3
g1=(3*((r*h.^2)-(V/pi))).^(1/3); %y as a function of h

Note: both the functions above were created in separate M-files.

Appendix B
Diary file for Q.1 part (d)
plotfunc
Enter function to plot:
func4
New interval (y/n)? y
New value of a:
-10
New value of b:
10
New interval (y/n)? n
secroot
Enter name of the function: func4
Enter guess 1: -1.5
Enter guess 2: -1.6
#

root

abs error

rel error

fxi1

1 -2.06452
0.46452
-0.225
0.26223
2 -1.99296
0.071558 -0.035906
0.028119
3 -1.99989 0.0069303 -0.0034653 0.00044789
4
-2 0.00011217 -5.6087e-05 7.8998e-07
5
-2 1.975e-07 -9.875e-08 2.2116e-11
Total no. of iterations: 5
Obtained root: -2
secroot
Enter name of the function: func4
Enter guess 1: 2.1
Enter guess 2: 2.2
#

root

abs error

rel error

fxi1

1 2.00465
0.19535
0.097448
0.018626
2 2.00022 0.0044299 0.0022147
0.000885
3
2 0.00022098 0.00011049 1.0278e-06
4
2 2.5693e-07 1.2846e-07 5.6843e-11
Total no. of iterations: 4
Obtained root: 2

Diary file for Q.1 part (e)


plotfunc
Enter function to plot:
func5
New interval (y/n)? y
New value of a:
-10
New value of b:
10
New interval (y/n)? y
New value of a:
-2
New value of b:
4
New interval (y/n)? y
New value of a:
-1
New value of b:
3
New interval (y/n)? n
secroot
Enter name of the function: func5
Enter guess 1: -0.4
Enter guess 2: -0.5

root

abs error

rel error

fxi1

1 -0.379899
0.1201
-0.31614
0.01082
2 -0.376694 0.0032049 -0.008508 0.0017615
3 -0.376071 0.00062322 -0.0016572 1.0325e-05
4 -0.376067 3.6744e-06 -9.7706e-06 9.9595e-09
Total no. of iterations: 4
Obtained root: -0.37607
secroot
Enter name of the function: func5
Enter guess 1: 0.4
Enter guess 2: 0.3
#

root

abs error

rel error

fxi1

1 0.435529
0.13553
0.31118 0.0094015
2 0.430531 0.0049981
0.011609 0.0012529
3 0.431118 0.00058776 0.0013633 4.6224e-06
4 0.431121 2.1764e-06 5.0483e-06 2.2955e-09
Total no. of iterations: 4
Obtained root: 0.43112
secroot
Enter name of the function: func5
Enter guess 1: 2.6
Enter guess 2: 2.7
#

root

abs error

rel error

fxi1

1 3.03066
0.33066
0.10911
0.79494
2 2.92898
0.10168
0.034715
0.13799
3 2.94402
0.01504 0.0051086 0.0080559
4 2.94496 0.00093244 0.00031662 9.0737e-05
5 2.94495 1.0386e-05 3.5266e-06 5.8502e-08
6 2.94495 6.6917e-09 2.2723e-09 4.2499e-13
Total no. of iterations: 6
Obtained root: 2.9449

Diary file for Q.2 part (d)


Enter
Enter
Enter
Enter
#

name of the function: func7


auxilary function: func6
starting value: 0.5
relaxation parameter: 1
root

abs error

rel error

1 0.25
0.25
1
2 0.0625
0.1875
3
3 0.00390625
0.058594
15
4 1.52588e-05
0.003891
255
5 2.32831e-10 1.5259e-05
65535
6 5.42101e-20 2.3283e-10 2.3282e+05
Total no. of iterations: 6
Obtained root: 5.421e-20

fxi
0.1875
0.058594
0.003891
1.5259e-05
2.3283e-10
5.421e-20

OPI
Enter
Enter
Enter
Enter

name of the function: func7


auxiliary function: func6
starting value: 1.5
relaxation parameter: 1

root

abs error

rel error

1
2
3
4
5
6
7

2.25
0.75
0.33333
5.0625
2.8125
0.55556
25.6289
20.566
0.80247
656.841
631.21
0.96098
431440 4.3078e+05
0.99848
1.8614e+11 1.8614e+11
3.46482e+22 3.4648e+22
No root found

fxi

1
1

2.8125
20.566
631.21
4.3078e+05
1.8614e+11
3.4648e+22
1.2005e+45

Diary file for Q.3 part (a)


W = 1.0
OPI
Enter
Enter
Enter
Enter
#

name of the function: func5


auxiliary function: func8
starting value: 0.5
relaxation parameter: 1
root

abs error

rel error

1 0.448131
0.051869
0.11574
2 0.434917
0.013214
0.030383
3 0.431946 0.0029718 0.0068801
4 0.431299 0.00064674 0.0014995
5 0.431159 0.0001397 0.00032401
6 0.431129 3.0128e-05 6.9881e-05
7 0.431122 6.4949e-06 1.5065e-05
8 0.431121 1.4001e-06 3.2475e-06
9 0.431121 3.018e-07 7.0004e-07
10 0.431121 6.5057e-08 1.509e-07
11 0.431121 1.4024e-08 3.2528e-08
Total no. of iterations: 11
Obtained root: 0.43112
OPI
Enter name of the function: func5
Enter auxilary function: func8
Enter starting value: 3
Enter relaxation parameter: 1
#
1
2
3
4
5
6

root
3.02641
3.06577
3.12476
3.21393
3.35039
3.56305

abs error
0.02641
0.039359
0.058995
0.089171
0.13646
0.21266

rel error
0.0087264
0.012838
0.01888
0.027745
0.040729
0.059685

fxi
0.036658
0.0080932
0.0017539
0.00037852
8.1614e-05
1.7594e-05
3.7926e-06
8.1753e-07
1.7623e-07
3.7987e-08
8.1886e-09

fxi
0.75331
1.1473
1.7757
2.8141
4.6188
7.9855

7 3.90349
0.34044
0.087213
14.916
8 4.47049
0.567
0.12683
31.275
9 5.47179
1.0013
0.18299
77.999
10 7.40057
1.9288
0.26063
252.89
11 11.6304
4.2298
0.36368
1223
12 22.9031
11.273
0.49219
10933
13 63.2834
40.38
0.63809
2.5282e+05
14 290.653
227.37
0.78227
2.5448e+07
15 2860.89
2570.2
0.8984
2.4495e+10
16 88347
85486
0.96762
7.2209e+14
17 1.5161e+07 1.5073e+07
0.99417
3.6493e+21
18 3.40823e+10 3.4067e+10
0.99956
4.1459e+31
19 3.63273e+15 3.6327e+15
0.99999
5.0203e+46
20 1.26412e+23 1.2641e+23
1
2.1154e+69
21 2.59492e+34 2.5949e+34
1
1.8298e+103
No root found
OPI
Enter name of the function: func5
Enter auxiliary function: func8
Enter starting value: 2.5
Enter relaxation parameter: 1
#

root

abs error

rel error

1 2.31678
0.18322
0.079082
2 2.07467
0.24211
0.1167
3 1.77082
0.30385
0.17159
4 1.41779
0.35303
0.249
5 1.05315
0.36464
0.34623
6 0.74062
0.31253
0.42199
7 0.542743
0.19788
0.36459
8 0.460919
0.081823
0.17752
9 0.437944
0.022975
0.052461
10 0.432612 0.0053319
0.012325
11 0.431443 0.0011692 0.0027099
12 0.43119 0.00025298 0.00058669
13 0.431136 5.4576e-05 0.00012659
14 0.431124 1.1766e-05 2.7292e-05
15 0.431121 2.5365e-06 5.8834e-06
16 0.431121 5.4677e-07 1.2682e-06
17 0.431121 1.1786e-07 2.7338e-07
18 0.431121 2.5406e-08 5.8931e-08
19 0.431121 5.4766e-09 1.2703e-08
Total no. of iterations: 19
Obtained root: 0.43112

fxi
3.3402
3.6708
3.5364
2.8306
1.7612
0.7978
0.258
0.064879
0.014582
0.0031738
0.00068558
0.00014785
3.1874e-05
6.8709e-06
1.4811e-06
3.1926e-07
6.8821e-08
1.4835e-08
3.1978e-09

Using this auxiliary function only one root of the equation was obtained which is
0.43112.
W = 0.8
OPI
Enter name of the function: func5
Enter auxilary function: func8

Enter starting value: 0.5


Enter relaxation parameter: 0.8
#

root

abs error

rel error

1 0.458505
0.051869
0.11574
2 0.44159
0.021144
0.048344
3 0.435059 0.0081635
0.018835
4 0.432593 0.0030827 0.0071362
5 0.43167 0.0011541
0.002675
6 0.431325 0.00043067 0.00099869
7 0.431197 0.00016052 0.00037229
8 0.431149 5.9801e-05 0.00013871
9 0.431131 2.2275e-05 5.1667e-05
10 0.431125 8.2966e-06 1.9244e-05
11 0.431122 3.0901e-06 7.1676e-06
12 0.431121 1.1509e-06 2.6696e-06
13 0.431121 4.2866e-07 9.9428e-07
14 0.431121 1.5965e-07 3.7032e-07
15 0.431121 5.9462e-08 1.3792e-07
16 0.431121 2.2147e-08 5.137e-08
17 0.431121 8.2484e-09 1.9133e-08
Total no. of iterations: 17
Obtained root: 0.43112

fxi
0.059508
0.022441
0.0083968
0.0031327
0.0011675
0.00043494
0.00016201
6.0341e-05
2.2474e-05
8.3706e-06
3.1176e-06
1.1611e-06
4.3247e-07
1.6107e-07
5.9991e-08
2.2343e-08
8.3218e-09

W = 1.2
OPI
Enter
Enter
Enter
Enter

name of the function: func5


auxilary function: func8
starting value: 0.5
relaxation parameter: 1.2

root

abs error

rel error

1 0.437757
0.051869
0.11574
2 0.431534 0.0051865
0.01199
3 0.431145 0.00032392 0.0007512
4 0.431122 1.9081e-05 4.4259e-05
5 0.431121 1.1198e-06 2.5974e-06
6 0.431121 6.5703e-08 1.524e-07
7 0.431121 3.8549e-09 8.9417e-09
Total no. of iterations: 7
Obtained root: 0.43112

fxi
0.014181
0.00087796
5.1689e-05
3.0334e-06
1.7798e-07
1.0442e-08
6.1268e-10

Diary file for Q.3 part (b)


W = 1.0
OPI
Enter
Enter
Enter
Enter

name of the function: func5


auxilary function: func3
starting value: 2.5
relaxation parameter: 1

10

root

abs error

rel error

1 2.6339
0.1339
0.050838
2 2.72948
0.095581
0.035018
3 2.79663
0.067144
0.024009
4 2.84329
0.046659
0.01641
5 2.87547
0.032185
0.011193
6 2.89756
0.022091 0.0076239
7 2.91267
0.015111 0.0051879
8 2.92299
0.010312
0.003528
9 2.93001 0.0070267 0.0023982
10 2.93479 0.0047828 0.0016297
11 2.93805 0.0032531 0.0011072
12 2.94026 0.0022116 0.00075217
13 2.94176
0.001503 0.00051092
14 2.94278 0.0010212 0.00034703
15 2.94348 0.00069377 0.0002357
16 2.94395 0.00047127 0.00016008
17 2.94427 0.0003201 0.00010872
18 2.94449 0.00021741 7.3837e-05
19 2.94463 0.00014766 5.0146e-05
20 2.94473 0.00010029 3.4056e-05
21 2.9448 6.8109e-05 2.3128e-05
22 2.94485 4.6256e-05 1.5707e-05
23 2.94488 3.1414e-05 1.0667e-05
24 2.9449 2.1334e-05 7.2445e-06
25 2.94492 1.4489e-05
4.92e-06
26 2.94493 9.8399e-06 3.3413e-06
27 2.94493 6.6826e-06 2.2692e-06
28 2.94494 4.5384e-06 1.5411e-06
29 2.94494 3.0821e-06 1.0466e-06
30 2.94494 2.0932e-06 7.1077e-07
31 2.94494 1.4215e-06 4.827e-07
32 2.94494 9.6541e-07 3.2782e-07
33 2.94494 6.5564e-07 2.2263e-07
34 2.94495 4.4526e-07 1.512e-07
35 2.94495 3.0239e-07 1.0268e-07
36 2.94495 2.0536e-07 6.9734e-08
37 2.94495 1.3947e-07 4.7358e-08
38 2.94495 9.4717e-08 3.2162e-08
39 2.94495 6.4325e-08 2.1842e-08
40 2.94495 4.3685e-08 1.4834e-08
41 2.94495 2.9668e-08 1.0074e-08
42 2.94495 2.0148e-08 6.8416e-09
43 2.94495 1.3683e-08 4.6464e-09
44 2.94495 9.2927e-09 3.1555e-09
45 2.94495 6.311e-09 2.143e-09
46 2.94495 4.286e-09 1.4554e-09
47 2.94495 2.9107e-09 9.8838e-10
48 2.94495 1.9768e-09 6.7124e-10
49 2.94495 1.3425e-09 4.5586e-10
50 2.94495 9.1171e-10 3.0959e-10
51 2.94495 6.1917e-10 2.1025e-10
52 2.94495 4.205e-10 1.4279e-10
Total no. of iterations: 52

fxi
2.1597
1.6105
1.1657
0.82672
0.57824
0.40065
0.27582
0.18906
0.12921
0.088122
0.06002
0.040842
0.027774
0.018879
0.012829
0.0087165
0.0059213
0.0040221
0.0027319
0.0018555
0.0012602
0.00085586
0.00058126
0.00039476
0.00026809
0.00018207
0.00012365
8.3976e-05
5.7031e-05
3.8731e-05
2.6304e-05
1.7864e-05
1.2132e-05
8.239e-06
5.5953e-06
3.8e-06
2.5807e-06
1.7526e-06
1.1902e-06
8.0833e-07
5.4896e-07
3.7282e-07
2.5319e-07
1.7195e-07
1.1678e-07
7.9306e-08
5.3859e-08
3.6577e-08
2.4841e-08
1.687e-08
1.1457e-08
7.7807e-09

11

Obtained root: 2.9449

W = 0.8
OPI
Enter
Enter
Enter
Enter
#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

name of the function: func5


auxilary function: func3
starting value: 2.5
relaxation parameter: 0.8
root

2.60712
2.68983
2.75307
2.80107
2.8373
2.86454
2.88496
2.90024
2.91165
2.92016
2.9265
2.93123
2.93474
2.93736
2.9393
2.94075
2.94183
2.94263
2.94322
2.94367
2.94399
2.94424
2.94442
2.94456
2.94466
2.94473
2.94479
2.94483
2.94486
2.94488
2.9449
2.94491
2.94492
2.94493
2.94493
2.94494
2.94494
2.94494
2.94494
2.94494
2.94494
2.94494
2.94494
2.94495

abs error

rel error

0.1339
0.050838
0.10339
0.038144
0.079046
0.028548
0.059995
0.021327
0.04529
0.015912
0.034053
0.01186
0.025529 0.0088333
0.019096 0.0065758
0.014261 0.0048932
0.010638 0.0036402
0.0079276 0.0027074
0.005904 0.0020134
0.0043948
0.001497
0.0032701
0.001113
0.0024326 0.00082748
0.0018092 0.00061516
0.0013454 0.0004573
0.0010004 0.00033994
0.00074376 0.00025269
0.00055294 0.00018783
0.00041106 0.00013962
0.00030557 0.00010378
0.00022715 7.7144e-05
0.00016885 5.7342e-05
0.00012551 4.2623e-05
9.3296e-05 3.1682e-05
6.9349e-05 2.355e-05
5.1548e-05 1.7505e-05
3.8316e-05 1.3011e-05
2.8481e-05 9.6713e-06
2.117e-05 7.1887e-06
1.5736e-05 5.3434e-06
1.1697e-05 3.9718e-06
8.6941e-06 2.9522e-06
6.4624e-06 2.1944e-06
4.8035e-06 1.6311e-06
3.5705e-06 1.2124e-06
2.654e-06 9.0119e-07
1.9727e-06 6.6986e-07
1.4663e-06 4.9791e-07
1.0899e-06 3.701e-07
8.1014e-07 2.751e-07
6.0218e-07 2.0448e-07
4.476e-07 1.5199e-07

fxi
2.2965
1.85
1.4599
1.1345
0.87161
0.66398
0.50264
0.37872
0.28435
0.21295
0.15917
0.1188
0.08858
0.065993
0.049136
0.036569
0.027208
0.020238
0.015051
0.011192
0.0083211
0.0061864
0.0045991
0.0034189
0.0025415
0.0018893
0.0014044
0.0010439
0.00077595
0.00057678
0.00042873
0.00031868
0.00023688
0.00017607
0.00013088
9.7281e-05
7.231e-05
5.3748e-05
3.9951e-05
2.9696e-05
2.2073e-05
1.6407e-05
1.2195e-05
9.0649e-06

12

45 2.94495 3.327e-07 1.1297e-07


46 2.94495 2.473e-07 8.3975e-08
47 2.94495 1.8382e-07 6.2419e-08
48 2.94495 1.3663e-07 4.6396e-08
49 2.94495 1.0156e-07 3.4486e-08
50 2.94495 7.549e-08 2.5634e-08
51 2.94495 5.6112e-08 1.9054e-08
52 2.94495 4.1708e-08 1.4163e-08
53 2.94495 3.1002e-08 1.0527e-08
54 2.94495 2.3044e-08 7.8249e-09
55 2.94495 1.7129e-08 5.8163e-09
56 2.94495 1.2732e-08 4.3233e-09
57 2.94495 9.4636e-09 3.2135e-09
58 2.94495 7.0343e-09 2.3886e-09
59 2.94495 5.2286e-09 1.7755e-09
60 2.94495 3.8864e-09 1.3197e-09
61 2.94495 2.8888e-09 9.8094e-10
62 2.94495 2.1473e-09 7.2914e-10
63 2.94495 1.5961e-09 5.4197e-10
64 2.94495 1.1864e-09 4.0285e-10
65 2.94495 8.8183e-10 2.9944e-10
66 2.94495 6.5547e-10 2.2257e-10
67 2.94495 4.8721e-10 1.6544e-10
Total no. of iterations: 67
Obtained root: 2.9449

6.738e-06
5.0084e-06
3.7227e-06
2.7671e-06
2.0568e-06
1.5288e-06
1.1364e-06
8.4468e-07
6.2786e-07
4.6669e-07
3.4689e-07
2.5785e-07
1.9166e-07
1.4246e-07
1.0589e-07
7.8709e-08
5.8505e-08
4.3487e-08
3.2324e-08
2.4026e-08
1.7859e-08
1.3275e-08
9.8671e-09

W = 1.2
OPI
Enter
Enter
Enter
Enter
#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

name of the function: func5


auxilary function: func3
starting value: 2.5
relaxation parameter: 1.2
root

abs error

rel error

2.66068
0.1339
0.050838
2.76592
0.087701
0.03191
2.83322
0.056077
0.019871
2.87561
0.035325
0.012315
2.90206
0.022048 0.0076089
2.91848
0.013683 0.0046928
2.92864 0.0084619
0.002891
2.9349 0.0052218 0.0017798
2.93877
0.003218 0.0010953
2.94114 0.0019815 0.00067381
2.94261 0.0012195 0.00041447
2.94351 0.00075032 0.00025492
2.94406 0.00046156 0.00015678
2.9444 0.00028389 9.6419e-05
2.94461 0.0001746 5.9295e-05
2.94474 0.00010738 3.6465e-05
2.94482 6.6036e-05 2.2425e-05
2.94487 4.061e-05 1.379e-05
2.9449 2.4974e-05 8.4804e-06

fxi
2.0155
1.3753
0.90198
0.57717
0.36374
0.22709
0.14095
0.087176
0.053798
0.033155
0.020416
0.012565
0.007731
0.0047557
0.0029251
0.001799
0.0011064
0.00068041
0.00041843

13

20 2.94492 1.5358e-05 5.2151e-06


21 2.94493 9.4446e-06 3.2071e-06
22 2.94494 5.808e-06 1.9722e-06
23 2.94494 3.5717e-06 1.2128e-06
24 2.94494 2.1964e-06 7.4583e-07
25 2.94494 1.3507e-06 4.5865e-07
26 2.94494 8.3062e-07 2.8205e-07
27 2.94495 5.108e-07 1.7345e-07
28 2.94495 3.1412e-07 1.0666e-07
29 2.94495 1.9317e-07 6.5593e-08
30 2.94495 1.1879e-07 4.0337e-08
31 2.94495 7.305e-08 2.4805e-08
32 2.94495 4.4923e-08 1.5254e-08
33 2.94495 2.7625e-08 9.3806e-09
34 2.94495 1.6988e-08 5.7687e-09
35 2.94495 1.0447e-08 3.5475e-09
36 2.94495 6.4245e-09 2.1815e-09
37 2.94495 3.9508e-09 1.3415e-09
38 2.94495 2.4296e-09 8.2499e-10
39 2.94495 1.4941e-09 5.0733e-10
40 2.94495 9.1879e-10 3.1199e-10
41 2.94495 5.6501e-10 1.9186e-10
Total no. of iterations: 41
Obtained root: 2.9449

0.00025732
0.00015824
9.7314e-05
5.9844e-05
3.6801e-05
2.2631e-05
1.3917e-05
8.5585e-06
5.2631e-06
3.2366e-06
1.9903e-06
1.224e-06
7.5269e-07
4.6287e-07
2.8464e-07
1.7504e-07
1.0764e-07
6.6196e-08
4.0708e-08
2.5033e-08
1.5394e-08
9.4669e-09

14

Appendix C

Figure 1: Graph of

x 24

Figure 2: Graph for Q.1 (e)

Figure 3: Graph for Q.3 (a)


for Q.3 (b)

Figure 4: Graph

15

You might also like