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

Numerical integration by using regular Gaussian quadrature scheme.

Pascal
function QuadGauss(Fun: TRealFunction; lb: double; ub: double; const BasePoints: TVec; const Weights: TVec; Parts: Integer): double; overload;

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

Check the following link to learn more about this algorithm

Evaluate fuction Sin(x)*Exp(-x^2) on interval -PI/2, PI.

Uses MtxExpr, 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 bpoints,weights: Vector; area: double; begin WeightsGauss(10,bpoints,weights); area := QuadGauss(IntFunc,-0.5*PI,PI,bpoints,weights,64); 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(); { sVector bpoints, weights; WeightsGauss(10,bpoints,weights); double area = QuadGauss(IntFun,-0.5*PI,PI,bpoints,weights,64); }
Examples on GitHub
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!