unit Unit2;
interface
uses
unit1;
procedure TRAPZD(A, B:real;var S:real; N:integer);
implementation
procedure TRAPZD(A, B:real;var S:real; N:integer);
var
J,IT:integer;
TNM,DEL,X,SUM:real;
begin
If N = 1 Then
begin
S:=0.5 * (B - A) * (FUNC(A) + FUNC(B));
IT:=1;
end
Else
begin
IT:=Trunc(exp((N - 2)*Ln(2)));
TNM:=IT;
DEL:=(B - A) / TNM;
X:=A + 0.5 * DEL;
Sum:=0;
For J:=1 To IT do
begin
Sum:=Sum + FUNC(X);
X:=X + DEL;
end;
S:=0.5 * (S + (B - A) * Sum / TNM);
end;
end;
end.