Algoritma metode Secant :
procedure TForm1.Button1Click(Sender: TObject);
var
x0,x1,x2,y0,y1,y2,e,d,m,j:real;
i,n:integer;
begin
x0:=strtofloat(edit1.text);
x1:=strtofloat(edit2.Text);
e:=0.0001;
d:=0.0001;
i:=0;
n:=strtoint(edit4.Text);
repeat
i:=i+1;
listbox8.Items.Add(inttostr(i));
//menampilkan iterasi
listbox1.Items.add(format('%8.4f',[x0]));
//menampilkan x0
listbox2.items.Add(format('%8.4f',[x1]));
//menampilkan x1
y0:=x0+cos(x0);
y1:=x1+cos(x1);
listbox4.Items.add(format('%8.4f',[y0]));
listbox5.Items.add(format('%8.4f',[y1]));
j:=abs(y1-y0);
if j<d then showmessage ('terlalukecil');
x2:=((x0*y1)-(x1*y0))/(y1-y0);
listbox3.Items.add(format('%8.4f',[x2]));
y2:=x2+cos(x2);
m:=abs(y2);
listbox6.Items.add(format('%8.4f',[y2]));
x0:=x1;
x1:=x2;
if i=n then m:=e;
until
m<e;
edit3.Text:=format('%8.4f',[x2]);
end;
end.
metode Secant merupakan pengembangan dari metode newton raphson, pengembangan yang dilakukan adalah pada x2 baru yang ditemukan. x2 baru pada metode secant sama dengan x2 baru pada metode posisi palsu. oleh karena itu, proses ini akan sangat efektif.
gambar :
No comments:
Post a Comment