( Sir, sorry po late nkapost nghintay po kasi ako sa retrieved password ko sa blog..ng forgot password po kasi ako kasi di ma-open kanina..sorry po late)
CODE:
f=inline(' 1/(x+1) ');
fa=inline(' x^2+x+1 ');
delta=10^-10;
ya=1;
n=100;
disp('iteration a ya b ');
%ya=a;
for k=1:n
a=ya;
ya=feval(f,a)
b=a-ya;
d= [k,a,ya,b];
disp(d);
if abs(b)< delta,break,end
end
OUTPUT:
iteration a ya b
ya =
0.5000
1.0000 1.0000 0.5000 0.5000
ya =
0.6667
2.0000 0.5000 0.6667 -0.1667
ya =
0.6000
3.0000 0.6667 0.6000 0.0667
ya =
0.6250
4.0000 0.6000 0.6250 -0.0250
ya =
0.6154
5.0000 0.6250 0.6154 0.0096
ya =
0.6190
6.0000 0.6154 0.6190 -0.0037
ya =
0.6176
7.0000 0.6190 0.6176 0.0014
ya =
0.6182
8.0000 0.6176 0.6182 -0.0005
ya =
0.6180
9.0000 0.6182 0.6180 0.0002
ya =
0.6181
10.0000 0.6180 0.6181 -0.0001
ya =
0.6180
11.0000 0.6181 0.6180 0.0000
ya =
0.6180
12.0000 0.6180 0.6180 -0.0000
ya =
0.6180
13.0000 0.6180 0.6180 0.0000
ya =
0.6180
14.0000 0.6180 0.6180 -0.0000
ya =
0.6180
15.0000 0.6180 0.6180 0.0000
ya =
0.6180
16.0000 0.6180 0.6180 -0.0000
ya =
0.6180
17.0000 0.6180 0.6180 0.0000
ya =
0.6180
18.0000 0.6180 0.6180 -0.0000
ya =
0.6180
19.0000 0.6180 0.6180 0.0000
ya =
0.6180
20.0000 0.6180 0.6180 -0.0000
ya =
0.6180
21.0000 0.6180 0.6180 0.0000
ya =
0.6180
22.0000 0.6180 0.6180 -0.0000
ya =
0.6180
23.0000 0.6180 0.6180 0.0000
ya =
0.6180
24.0000 0.6180 0.6180 -0.0000
ya =
0.6180
25.0000 0.6180 0.6180 0.0000
Friday, July 24, 2009
Subscribe to:
Posts (Atom)