clear; clc;
disp('--------------------------------')
disp('program : Metode Olver')
disp('programer : SYAHARUDDIN ')
disp('--------------------------------')
f=input ('f(x) = ');
f_diff1=input ('df1(x) = ');
f_diff2=input ('df2(x) = ');
x1=input('x0 = ');
imax=input('Iterasi = ');
galat1=input('Error = ');
iter=0;
fprintf('\n Iterasi Akar f(Akar) Galat\n');
for k=1:imax
iter=iter+1;
%Rumus Olver
x2=x1-(feval(f,x1)/(feval(f_diff1,x1)))-0.5*(((feval(f,x1))^2*feval(f_diff2,x1))/(feval(f_diff1,x1))^3);
galat=abs((x2-x1)/x2);
x1=x2;
y=feval(f,x1);
fprintf('%10.0f %6.10f %6.10f %6.10f\n',[iter;x1;y;galat])
if (galat<galat1 || (iter>imax)),break,end
end
fprintf('Akarnya adalah = %6.10f\n',x1)
disp('--------------------------------')
disp('program : Metode Olver')
disp('programer : SYAHARUDDIN ')
disp('--------------------------------')
f=input ('f(x) = ');
f_diff1=input ('df1(x) = ');
f_diff2=input ('df2(x) = ');
x1=input('x0 = ');
imax=input('Iterasi = ');
galat1=input('Error = ');
iter=0;
fprintf('\n Iterasi Akar f(Akar) Galat\n');
for k=1:imax
iter=iter+1;
%Rumus Olver
x2=x1-(feval(f,x1)/(feval(f_diff1,x1)))-0.5*(((feval(f,x1))^2*feval(f_diff2,x1))/(feval(f_diff1,x1))^3);
galat=abs((x2-x1)/x2);
x1=x2;
y=feval(f,x1);
fprintf('%10.0f %6.10f %6.10f %6.10f\n',[iter;x1;y;galat])
if (galat<galat1 || (iter>imax)),break,end
end
fprintf('Akarnya adalah = %6.10f\n',x1)
No comments:
Post a Comment