Dew MtxVec NET
WeightsGauss Routine
Summary
Gauss base points and weights.

Unit
MtxIntDiff

Declaration
Procedure WeightsGauss(NumPoints: Integer; Points, Weights: TVec);

Description
Calculates base points and weight factors by using the so called Gauss algorithm given by Davis and Rabinowitz in 'Methods of Numerical Integration', page 365, Academic Press, 1975.
 See Also 
WeightsChebyshevGauss 
WeightsNewtonCotes 

Example 1

Use a ten point Gauss formula to evaluate six(x) on interval [0,PI]. For start use only one subsection.
// Integrating function function IntFunc(Parameters: TVec; Const Constants: Array of TSample; Const ObjConst: Array of TObject): TSample; var x: TSample; begin x := Parameters[0]; Result := Sin(x); end; // Integrate procedure DoIntegrate; var bpoints,weights: Vector; area: TSample; begin WeightsGauss(10,bpoints,weights); area := QuadGauss(IntFunc,0,PI,bpoints,weights,1); end;
#include "MtxVecCpp.h" #include "Math387.hpp" #include "MtxIntDiff.hpp" // Integrating function double __fastcall IntFun(TVec * Parameters, const double * Constants, const int Constants_Size, System::TObject* const * ObjConst, const int ObjConst_Size) { double x = (*Parameters)[0]; return Math.Sin(x)*Math.Exp(-x*x); } void __fastcall Example(); { Vector bpoints, weights; WeightsGauss(10,bpoints,weights); double area = QuadGauss(IntFun,-0.5*PI,PI,bpoints,weights,64); }
private double IntFun(TVec x, double[] c, object[] o) { double x = x[0]; return System.Math.Sin(x)*System.Math.Exp(-x*x); } private void Example() { Vector bpoints = new Vector(0); Vector weights = new Vector(0); MtxIntDiff.WeightsGauss(10,bpoints,weights); double area = MtxIntDif.QuadGauss(IntFun,-0.5*System.Math.PI,System.Math.PI,bpoints,weights,64); }

Copyright 2008 Dew Research
http://www.dewresearch.com