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

Integration by using Gauss quadrature algorithm with no additional parameters for Fun.

Pascal
function QuadGauss(Fun: TRealFunction; lb: double; ub: double; out StopReason: TIntStopReason; const FloatPrecision: TMtxFloatPrecision; QMethod: TQuadMethod = qmGauss; Tolerance: double = 1.0E-4; MaxIter: Integer = 8): double; overload;

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

This version calculates base points and weights on the fly.

Use this overload if integrating function is defined only by double parameter(s).

Evaluate fuction Sin(x)*Exp(-x^2) on interval [-PI/2, PI]. Use default Gauss base points and weights.

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 := QuadGauss(IntFunc,-0.5*PI,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 = QuadGauss(IntFun,0.0,5*PI,sr); }
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!