You are here: Symbol Reference > MtxIntDiff Namespace > Functions > MtxIntDiff.MonteCarlo Function
MtxVec VCL
ContentsIndex
Example

Evaluate fuction Sin(x) on interval [0,PI] by using Monte Carlo algorithm.

// Integrating function function IntFunc(const Pars: TVec; const Constants: TVec; Const ObjConst: Array of TObject): double; var x: double; begin x := Pars[0]; IntFunc := Sin(x); end; // Integrate procedure DoIntegrate; var area: double; begin area := MonteCarlo(IntFunc,0,PI,16,[],[],65536); // 2^16 random points in [0,PI] interval end;
#include "MtxExpr.hpp" #include "Math387.hpp" #include "MtxIntDiff.hpp" 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); } void __fastcall Example(); { double area = MonteCarlo(IntFun,0.0,PI,NULL,NULL,65536); // 2^16 random points in [0,PI] interval }
Copyright (c) 1999-2025 by Dew Research. All rights reserved.