procedure WeightsNewtonCotes(PolyOrder: Integer; const Points: TVec; const Weights: TVec; const FloatPrecision: TMtxFloatPrecision);
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
function IntFunc(const Parameters: TVec; const Constants: TVec; const ObjConst: Array of TObject): double;
var x: double;
begin
x := Parameters[0];
IntFunc := Sin(x);
end;
// Integrate
procedure DoIntegrate;
var bpoints,weights: Vector;
area: double;
begin
WeightsNewtonCotes(2,bpoints,weights); // 2 means Simpson
area := QuadGauss(IntFunc,0,PI,bpoints,weights,1);
end;