Sie sind auf Seite 1von 1

disp('Persamaan non linear dengan metode secant');

x1=input('nilai x1= ');


x2=input('nilai x2= ');
tol=input('nilai toleransi= ');
f1=((2.543*0.0001*(x1^3))-(x1^2)+(388*x1)+26000);
f2=((2.543*0.0001*(x2^3))-(x2^2)+(388*x2)+26000);
while e>=tol
x3=(x2-(f2*(x2-x1)/(f2-f1)));
f3=((2.543*0.0001*(x3^3))-(x3^2)+(388*x3)+26000);
ite=ite+1;
e=abs(f3);
if abs(f1)>abs(f2)
x1=x2;
x2=x3;
f1=f2;
f2=f3;
else
x2=x3;
f2=f3;
x1=x1;
f1=f1;
end
end
disp(['nilai x3= ',num2str(x3)])

Das könnte Ihnen auch gefallen