void WeightsNewtonCotes(Int32 PolyOrder, TVec Points, TVec Weights, TMtxFloatPrecision FloatPrecision)
Newton-Cotes base points and weights.
| # | Name | Description |
|---|---|---|
| 1 | PolyOrder | Defines the interpolating polynomial order. |
| 2 | Points | Returns base points coordinate. |
| 3 | Weights | Returns weights. |
| 4 | FloatPrecision | Specifies the precision of the weights to be returned. |
Result: stored in self (calling object)
Remarks:
Uses the Newton-Cotes formulas to calculate base points and weights for numerical integration. Check the following link to learn more about Newton-Cotes formulas.
Examples
// Integrating function
private double IntFunc(TVec Parameters, TVec c, params object[] o)
{
double x = Parameters[0];
return System.Math.Sin(x);
}
// Integrate
private void DoIntegrate()
{
Vector bpoints = new Vector(0);
Vector weights = new Vector(0);
MtxIntDiff.WeightsNewtonCotes(2,bpoints,weights); // 2 means Simpson
double area = QuadGauss(IntFunc,0,System.Math.PI,bpoints,weights,1);
}