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

Goedangilmu

Source Code Metode Newton Cotes Close Formula

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

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

procedure TForm1.Button1Click(Sender: TObject);
var
x: 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;

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

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

w[1]:=7;
w[2]:=32;
w[3]:=12;
w[4]:=32;
w[5]:=7;
alpha:=2/45;

for i:=1 to 5 do //nilai i tergentung banyaknya w[i]
begin
y[i]:=w[i]*(x[i]*x[i]);
jumlah:=jumlah+y[i];
end;

hasil:=(alpha*h)*jumlah;

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

Related Posts :

Published by Adith

No Comments

Leave a comment