function Romberg(Fun: TRealFunction; lb: Double; ub: Double; const FloatPrecision: TMtxFloatPrecision; const Constants: TVec; const ObjConst: TObjectArray; out StopReason: TIntStopReason; Tolerance: Double; MaxIter: Integer): Double;
Numerical integration by using recursive Romberg algorithm.
| # | Name | Description |
|---|---|---|
| 1 | Fun | Integrating function. |
| 2 | Constants | Additional constants defining Fun function, usually nil/null. |
| 3 | ObjConst | Additional objects defining Fun function, usually nil/null. |
| 4 | lb | Defines lower bound. |
| 5 | ub | Defines upper bound. |
| 6 | StopReason | Returns algorithm stop reason. |
| 7 | Tolerance | Defines integration tolerance. |
| 8 | MaxIter | Defines maximum number of alorithm iterations. |
| 9 | FloatPrecision | Defines the computational precision to be used by the routine. |
Returns: Double - the numerical approximate on integral of function Fun between limits lb and ub.
Examples
Uses Math387, MtxIntDiff;
// Integrating function
function IntFunc(const Parameters: TVec; const Constants: TVec; const ObjConst: Array of TObject): double;
var x: double;
begin
x := Parameters[0];
IntFunc := Sin(x)*Exp(-x*x);
end;
// Integrate
procedure DoIntegrate;
var area: double;
sr: TIntStopReason;
begin
area := Romberg(IntFunc,0,0.5*PI,sr);
end;
See Also: MtxIntDiff.QuadGauss