MtxIntDiff::WeightsNewtonCotes Function

void WeightsNewtonCotes(int PolyOrder, TVec *Points, TVec *Weights, const TMtxFloatPrecision FloatPrecision = TMtxFloatPrecision::mvDouble);

Newton-Cotes base points and weights.

#NameTypeDescription
1PolyOrderintDefines the interpolating polynomial order.
2PointsTVec *Returns base points coordinate.
3WeightsTVec *Returns weights.
4FloatPrecision = TMtxFloatPrecision::mvDoubleconst TMtxFloatPrecisionSpecifies the precision of the weights to be returned.
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
#include "MtxExpr.h"
#include "MtxVec.h"
#include "Units.Math387.h"
#include "Units.MtxIntDiff.h"

using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units;
using namespace Dew::Math::Units::Math387;
using namespace Dew::Math::Units::MtxIntDiff;

// Integrating function
static double IntFunc(TVec* Parameters, TVec* c, const DewArray<tObject*>& o)
{
    double x = (*Parameters)[0];
    return Sin(x);
}
// Integrate
void Example()
{
    Vector bpoints(0);
    Vector weights(0);
    MtxIntDiff::WeightsNewtonCotes(2, bpoints, weights); // 2 means Simpson
    double area = QuadGauss(IntFunc, 0, PI, bpoints, weights, 1);
}
See Also: MtxIntDiff::WeightsChebyshevGauss, MtxIntDiff::WeightsGauss
Declared in Dew::Math::Units::MtxIntDiff · Dew.Math/Units.MtxIntDiff.h · Cross-compiler