Definite Integral interval [a, b]: Sf(x)dx = G(b) - G(a) where G'(x) = f(x) , or differential of G(x) = f(x).
Integrals appear in many practical situations.
Consider a swimming pool. If it is rectangular, then from its length, width, and depth we can easily determine the volume of water it can contain (to fill it), the area of its surface (to cover it), and the length of its edge (to rope it).
But if it is oval with a rounded bottom, all of these quantities call for integrals. Practical approximations may suffice for such trivial examples, but precision engineering (of any discipline) requires exact and rigorous values for these elements.
I create the query which calculate integral of 3 * X^2 - 2 * X in interval [2, 4]....
S(3 * X^2 - 2 * X)dx = X^3 - X^2 and exact value of integral will be
S = (4^3 - 4^2) - (2^3 - 2^2) = 48 - 4 = 44.
We know nothing in our solution about exact value and differential and suppose to calculate approximate value of integral.
Process will stop when the absolute difference between current value of integral and previous become less or equal some epsreal number.
Source (Xstart, Xfinish, imgFunc, eps) as
(select double(2), double(4), '3 * X^2 - 2 * X', double(1.e-3)
Integral_calc (Xs, Xf, Xc, step, curint, prevint, eps, iterno) as
(select Xstart, Xfinish, double(Xstart - (Xfinish - Xstart) / 10.) Xc,
double((Xfinish - Xstart) / 10.) step, double(0), double(0), eps, int(0)
select Xs, Xf, Xc + step, step, curint + Fc * step, prevint, eps, iterno + 1
from Integral_calc, table
(select 3 * power(Xc + step, 2) - 2 * (Xc + step) Fc
from sysibm.sysdummy1 ) it
where Xc + step <= Xf
select Xs, Xf, Xs - (step / 2.), step / 2., 0., curint, eps, iterno + 1
where Xc + step > Xf
and abs(curint - prevint) > eps
Integral(integral_value, integral_image) as
(select curint, 'interval: [' || varchar(Xs) || ', ' || varchar(Xf) || ']: S' || '('
|| imgFunc || ')dx = ' || varchar(round(curint, 3))
from Integral_calc, Source
where iterno = (select max(iterno) from Integral_calc)
select integral_value, integral_image from Integral