Metode Euler merupakan
satu dari tiga metode pencarian akar persamaan non-linier yang diturunkan dari
persamaan Taylor orde dua. Sedangkan dua metode lainnya adalah Chebyshev dan
Hybrid (Putra & Kurniawati, 2011).
Adapun Scrips atau Kode Matlab atau M-File dari metode Euler
clear; clc;
disp('--------------------------------')
disp('program : Metode Euler')
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 Euler
L=feval(f_diff2,x1)*feval(f,x1)/feval(f_diff1,x1)^2;
x2=x1-((feval(f,x1))/(feval(f_diff1,x1))*(2/(1+sqrt(1-2*L))));
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)
Adapun Scrips atau Kode Matlab atau M-File dari metode Euler
clear; clc;
disp('--------------------------------')
disp('program : Metode Euler')
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 Euler
L=feval(f_diff2,x1)*feval(f,x1)/feval(f_diff1,x1)^2;
x2=x1-((feval(f,x1))/(feval(f_diff1,x1))*(2/(1+sqrt(1-2*L))));
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)
Output Matlab: Solusi Persamaan Polinomial Wilkinson
--------------------------------
program : Metode Euler
programer : SYAHARUDDIN
--------------------------------
f(x) = inline('x^20 - 210*x^19 + 20615*x^18 - 1256850*x^17 + 53327946*x^16 - 1672280820*x^15 + 40171771630*x^14 - 756111184500*x^13 + 11310276995381*x^12 - 135585182899530*x^11 + 1307535010540395*x^10 - 10142299865511450*x^9 + 63030812099294896*x^8 - 311333643161390640*x^7 + 1206647803780373360*x^6 - 3599979517947607200*x^5 + 8037811822645051776*x^4 - 12870931245150988800*x^3 + 13803759753640704000*x^2 - 8752948036761600000*x + 2432902008176640000','x')
df1(x) = inline('20*x^19 - 3990*x^18 + 371070*x^17 - 21366450*x^16 + 853247136*x^15 - 25084212300*x^14 + 562404802820*x^13 - 9829445398500*x^12 + 135723323944572*x^11 - 1491437011894830*x^10 + 13075350105403950*x^9 - 91280698789603050*x^8 + 504246496794359168*x^7 - 2179335502129734480*x^6 + 7239886822682240160*x^5 - 17999897589738036000*x^4 + 32151247290580207104*x^3 - 38612793735452966400*x^2 + 27607519507281408000*x - 8752948036761600000','x')
df2(x) = inline('380*x^18 - 71820*x^17 + 6308190*x^16 - 341863200*x^15 + 12798707040*x^14 - 351178972200*x^13 + 7311262436660*x^12 - 117953344782000*x^11 + 1492956563390292*x^10 - 14914370118948300*x^9 + 117678150948635550*x^8 - 730245590316824448*x^7 + 3529725477560514176*x^6 - 13076013012778406400*x^5 + 36199434113411200000*x^4 - 71999590358952140800*x^3 + 96453741871740616704*x^2 - 77225587470905933824*x + 27607519507281408000','x')
x0 = 0.5
Iterasi = 20
Error = 0.00001
Iterasi Akar f(Akar) Galat
1 0.7516118646 24943492765038592.0000000000 0.4101854794
2 0.8947907686 18388169380553728.0000000000 0.2633985260
3 1.0114186083 -1340710995606528.0000000000 0.1159450835
4 0.9999950914 597092531200.0000000000 0.0121499336
5 1.0000000000 -1024.0000000000 0.0000095541
Akarnya adalah = 1.0000000000
>>
No comments:
Write komentar