Senin, 07 Maret 2016

Newton Raphson METHOD

Newton Raphson METHOD

4 akar dari fungsi persamaan berikut :
(f = x^4+2*x^3-7*x^2+3)

KOde Matlab :

%NEWTON METHOD
syms x
f = x^4+2*x^3-7*x^2+3;
a =0.1;
n = 100;
ea = 0.000001;
N = [];
for i = 1:n;
    fa = subs (f,x,a);
    fb =  diff (f,x);
    fc = subs (fb,x,a);
    b = a - (fa/fc);
    es = abs ((b-a)/b);
    fd= subs (f,x,b);
    fe= subs(fb,x,b);
    c= b-(fd/fe);
    es2 = abs ((c-b)/c);
    ff=subs(f,x,c);
    fg=subs(fb,x,c);
    d= c-(ff/fg);
    es3= abs ((d-c)/d);
    if es <= ea
        break
    end
    a = b;
    N = [N; i a b c d es es2 es3]
end
plot (N(:,1),N(:,8),'--rs','LineWidth',3,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',5)
title ('Newton METHOD')
xlabel ('Iterasi')
ylabel ('%error')
grid

Grafik :





Tidak ada komentar:

Posting Komentar

 

Blogger news

About