SELAMAT DATANG

Rapshon dan Rapshon Termodifikasi

mcontoh penjabaran Algoritma

untuk f(x) = x^3 - 3x^2 - x + 9
dan x0= - 1
 => Rapshon
clc
clear all
err=0.00001;
x( 1)=-1;
i=1;
f=x(i)^3-3*x(i)^2-x(i)+9;
f1=3*x(i)^2-6*x(i)-1;
x(i+1)=x(i)-f/f1;
while abs(x(i)-x(i+1))>err
    i=i+1;
    f=x(i)^3-3*x(i)^2-x(i)+9;
    f1=3*x(i)^2-6*x(i)-1;
    x(i+1)=x(i)-f/f1;
    disp(sprintf('%3g %8.5f %8.5f',i,x(i),f))
end
disp(sprintf('hasil akar = %8.5f',x(i)))
xg=linspace(-2,2);
yg=xg.^3-3*xg.^2-xg+9;
plot(xg,yg,'*m')
grid on

=>Rapshon Termodifikasi
clc
clear all
err=0.00001;
x( 1)=-1;
i=1;

f=x(i)^3-3*x(i)^2-x(i)+9;
f1=3*x(i)^2-6*x(i)-1;
f2=6*x(i)-6;
x(i+1)=x(i)-f*f1/(f1^2-f*f2);
while abs(x(i)-x(i+1))>err
    i=i+1;
    f=x(i)^3-3*x(i)^2-x(i)+9;
    f1=3*x(i)^2-6*x(i)-1;
    f2=6*x(i)-6;
    x(i+1)=x(i)-f*f1/(f1^2-f*f2);
    disp(sprintf('%3g %8.5f %8.5f',i,x(i),f))
end
disp(sprintf('hasil akar = %8.5f',x(i)))
xg=linspace(-2,2);
yg=xg.^3-3*xg.^2-xg+9;
plot(xg,yg,'*m')
grid on


persi ini dalam satu lembar kerja..

selamat mencoba

untuk f(x)= x^3 - 5x^2 + 7x - 3

clc
clear all
err=0.00001;
x(1)=2;
i=1;
f=x(i)^3-5*x(i)^2+7*x(i)-3;
f1=3*x(i)^2-10*x(i)+7;
f2=6*x(i)-10;
x(i+1)=x(i)-f*f1/(f1^2-f*f2);
while abs(x(i)-x(i+1))>=err
    i=i+1;
    f=x(i)^3-5*x(i)^2+7*x(i)-3;
    f1=3*x(i)^2-10*x(i)+7;
    f2=6*x(i)-10;
    x(i+1)=x(i)-f*f1/(f1^2-f*f2);
    disp(sprintf('%3g %8.5f %8.5f',i,x(i),f))
end
disp(sprintf('hasil akar = %8.5f',x(i)))
xg=linspace(-1,2);
yg=xg.^3-5*xg.^2+7*xg-3;
plot(xg,yg,'*m')
grid on

0 komentar:

Posting Komentar

Flag Counter