- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
type func = function (x : real) : real;
const
eps = 0.0000003;
pi = 3.14159265358979;
function Integral (f : func; a, b : real) : real;
var center : real;
begin
center := (a + b) / 2;
if abs(b - a) < eps then
Integral := f(center) * (b - a)
else Integral := Integral(f, a, center) +
Integral(f, center, b);
end;
function myFunc(x : real) : real;
begin
myFunc := cos(x) / x;
end;
begin
writeln(Integral(myFunc, pi/2, pi));
readln;
end.