Trapezoidal rule
Pascal Algorithms
numeric integration
Flowchart (ISO 5807)
Source code
function trapez(a, b: real; n: integer): real;
var h, s, x: real;
i: integer;
begin
h := (b - a) / n;
s := (a * a + b * b) / 2;
for i := 1 to n - 1 do
begin
x := a + i * h;
s := s + x * x;
end;
trapez := s * h;
end;