Professional Documents
Culture Documents
% Max no of iteration
tol=10^(-5);
% Tolerance
u=feval(f,a);
v=feval(f,b);
c=(b*u-a*v)/(u-v);
% False Position
Equation
fprintf('-------------------------------------------\n'
);
fprintf('
i
a
b
c
f(c)\n');
fprintf('-------------------------------------------\n'
);
while(i<=MAX_ITER)
c=(b*u-a*v)/(u-v);
fprintf('%3.0f
%12.4f
%12.4f
%12.4f
%12.6f\n',i, a, b, c, f(c));
if (f(c)<0)
a=c;u=f(c);
end;
if (f(c)>0)
b=c;v=f(c);
end;
i=i+1;
c=(b*u-a*v)/(u-v);
if (abs(f(c))<tol)
fprintf('%3.0f
%12.4f
%12.4f
%12.4f
%12.6f\n',i,a,b,c,f(c));
end
return;
end
ANSWER
FUNCTION:
X3-X2-1
------------------------------------------i
f(c)
------------------------------------------0
1.0000
2.0000
1.2500
-0.609375
1.2500
2.0000
1.3766
-0.286264
1.3766
2.0000
1.4309
-0.117660
1.4309
2.0000
1.4524
-0.045671
1.4524
2.0000
1.4606
-0.017331
1.4606
2.0000
1.4637
-0.006520
1.4637
2.0000
1.4649
-0.002445
1.4649
2.0000
1.4653
-0.000916
1.4653
2.0000
1.4655
-0.000343
1.4655
2.0000
1.4655
-0.000128
10
1.4655
2.0000
1.4656
-0.000048
11
1.4656
2.0000
1.4656
-0.000018
12
1.4656
2.0000
1.4656
-0.000007