You are here: Symbol Reference > MtxIntDiff Namespace > Functions > MtxIntDiff.Romberg Function
MtxVec VCL
ContentsIndex
PreviousUpNext
MtxIntDiff.Romberg Function

Numerical integration by using recursive Romberg algorithm.

Pascal
function Romberg(Fun: TRealFunction; lb: double; ub: double; const FloatPrecision: TMtxFloatPrecision; Const Constants: TVec; Const ObjConst: Array of TObject; out StopReason: TIntStopReason; Tolerance: double = 1.0e-4; MaxIter: Integer = 100): double;
Parameters 
Description 
Fun 
Integrating function. 
lb 
Defines lower bound. 
ub 
Defines upper bound. 
FloatPrecision 
Defines the computational precision to be used by the routine. 
Constants 
Additional constants defining Fun function, usually nil/null. 
ObjConst 
Additional objects defining Fun function, usually nil/null. 
StopReason 
Returns algorithm stop reason. 
Tolerance 
Defines integration tolerance. 
MaxIter 
Defines maximum number of alorithm iterations. 

the numerical approximate on integral of function Fun between limits lb and ub.

Evaluate fuction Sin(x)*Exp(-x^2) on interval [0,PI/2] by using Romberg algorithm.

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;
#include "MtxExpr.hpp" #include "Math387.hpp" #include "MtxIntDiff.hpp" // Integrating function double __fastcall IntFun(TVec* const Parameters, TVec* const Constants, System::TObject* const * ObjConst, const int ObjConst_Size) { double x = (*Parameters)[0]; return Math.Sin(x)*Math.Exp(-x*x); } void __fastcall Example(); { TIntStopReason sr; double area = Romberg(IntFun,0.0,5*PI,NULL,NULL,sr); }
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!