Information Technology Articles :: SEO Tips :: WAP Articles :: Search Engine Marketing :: Internet Tips

Goedangilmu

Source Code Metode Newton Cotes Open Formula

Posted on April 27th, 2007 in Programming, 216 views

Berikut ini merupakan source code metode newton cotes open formula yang saya buat dengan delphi.

procedure TForm1.Button1Click(Sender: TObject);
var
fx: array [1..10] of real;
w: array [1..10] of real;
y: array [1..10] of real;
i,n: integer;
a,b,jumlah,h,c,alpha,hasil: real;


begin
a:=strtofloat(edit2.text);
b:=strtofloat(edit1.text);
n:=strtoint(edit3.text);
jumlah:=0;
c:=0;

h:=(b-a)/(n+2);

for i:=1 to 7 do  //nilai i tergantung banyaknya w[i]
begin
if i=1 then
begin
fx[i]:=a;
end
else
begin
if i=2 then
begin
c:=a;
end;

fx[i]:=c+h;
c:=fx[i];
end;
end;

w[1]:=0;
w[2]:=11;
w[3]:=-14;
w[4]:=26;
w[5]:=-14;
w[6]:=11;
w[7]:=0;
alpha:=6/20;

for i:=2 to 6 do //nilai i tergentung banyaknya w[i]
begin
y[i]:=w[i]*(1/(fx[i]-1));
jumlah:=jumlah+y[i];
end;

hasil:=(alpha*h)*jumlah;

edit4.Text:=floattostr(hasil);
end;

Related Posts :

Published by Adith

No Comments

Leave a comment