Senin, 11 Mei 2015

Mencari solusi persamaan nonlinear dengan metode titik tetap menggunakan program silab

Dipunyai persamaan :
dengan x0=2 error=0.00001

Penyelesaian:
x^3-2x+1=0
<=> x^3-2x=-1
<=> x(x^2-2)=-1
<=>x=-1/(x^2-2)

Source Code Scilab

function y=g(x)
    y=-1/(x^2-2);
endfunction

n=100;
i=0;

x0=1;
x1=2;
err=0.00001;

while abs(x1-x0)>err
    x2=g(x1);
    x0=x1;
    x1=x2;
    i=i+1;
    disp("iterasi  "+string(i)+ " => "+string(x0)+"    "+string(x1));
    if i >= n then
        disp("Maks iteration exceed");
    end;
end
disp("Solusi=  "+string(x2));



0 komentar:

Posting Komentar

You can replace this text by going to "Layout" and then "Page Elements" section. Edit " About "

Baca Selengkapnya Di : http://indonesianblog-jmk.blogspot.com/2012/06/cara-membuat-komentar-admin-berbeda.html#ixzz2kb6khEJE