Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
12 views

Successive Approximation Method

The document describes using numerical methods to find the root of an equation. It defines functions for the equation and its derivative, then iteratively calculates values using the initial guess and derivative until the difference between values is less than the desired accuracy.

Uploaded by

asit kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Successive Approximation Method

The document describes using numerical methods to find the root of an equation. It defines functions for the equation and its derivative, then iteratively calculates values using the initial guess and derivative until the difference between values is less than the desired accuracy.

Uploaded by

asit kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

MATLAB Command Window Page 1

>> f=@(x) exp(x)*cos(x)-1.2*sin(x)-0.5;


g=@(x) asin((exp(x)*cos(x)-0.5)/1.2);
dg=@(x) (exp(x)*(cos(x)-sin(x)))/(sqrt(1.19-(exp(x)*cos(x))^2+1*exp(x)*cos(x)));
x0=input('\n Enter initial guess x0=');
acc=input('\n Enter desired acc =');
a=dg(x0);
disp(' i x0 x1 accuracy');
while abs(a)>1
x0=input('\n Get initial guess again x0=' );
a=dg(x0);
end
i=1;
x1=g(x0);
while abs(x1-x0)>acc
i=i+1;
x0=x1;
x1=g(x0);
fprintf('%d \t\t %f \t\t %f \t\t %f\n' ,[i;x0;x1;abs(x1-x0)])
end
fprintf('\nprint root of eqn x=%f',x1);

Enter initial guess x0=0

Enter desired acc =0.1


i x0 x1 accuracy
2 0.429775 0.844472 0.414696
3 0.844472 1.057327 0.212855
4 1.057327 0.865890 0.191437
5 0.865890 1.048958 0.183068
6 1.048958 0.877514 0.171444
7 0.877514 1.043321 0.165807
8 1.043321 0.885178 0.158142
9 0.885178 1.039185 0.154007
10 1.039185 0.890716 0.148469
11 0.890716 1.035991 0.145275
12 1.035991 0.894942 0.141049
13 0.894942 1.033438 0.138495
14 1.033438 0.898290 0.135148
15 0.898290 1.031344 0.133054
16 1.031344 0.901013 0.130331
17 0.901013 1.029596 0.128583
18 1.029596 0.903273 0.126322
19 0.903273 1.028113 0.124839
20 1.028113 0.905180 0.122933
21 0.905180 1.026840 0.121661
22 1.026840 0.906808 0.120033
23 0.906808 1.025738 0.118930
24 1.025738 0.908213 0.117525
25 0.908213 1.024774 0.116562
26 1.024774 0.909436 0.115338
27 0.909436 1.023927 0.114491
MATLAB Command Window Page 2

28 1.023927 0.910509 0.113418


29 0.910509 1.023177 0.112668
30 1.023177 0.911456 0.111721
31 0.911456 1.022510 0.111054
32 1.022510 0.912296 0.110214
33 0.912296 1.021914 0.109618
34 1.021914 0.913045 0.108869
35 0.913045 1.021379 0.108335
36 1.021379 0.913715 0.107664
37 0.913715 1.020898 0.107183
38 1.020898 0.914317 0.106581
39 0.914317 1.020464 0.106147
40 1.020464 0.914860 0.105604
41 0.914860 1.020071 0.105211
42 1.020071 0.915350 0.104721
43 0.915350 1.019714 0.104364
44 1.019714 0.915795 0.103920
45 0.915795 1.019390 0.103595
46 1.019390 0.916198 0.103192
47 0.916198 1.019094 0.102896
48 1.019094 0.916565 0.102529
49 0.916565 1.018825 0.102259
50 1.018825 0.916900 0.101924
51 0.916900 1.018578 0.101678
52 1.018578 0.917206 0.101372
53 0.917206 1.018353 0.101147
54 1.018353 0.917486 0.100867
55 0.917486 1.018146 0.100660
56 1.018146 0.917742 0.100404
57 0.917742 1.017956 0.100214
58 1.017956 0.917977 0.099979

print root of eqn x=0.917977>>

You might also like