functionquadratureNewtonCotes

Quadrature using the Newton-Cotes formulas

Extends from Modelica.Icons.Function (Icon for functions).

Information

Syntax

quadratureNewtonCotes(function f(), a, b);
quadratureNewtonCotes(function f(), a, b, N=1440);
quadratureNewtonCotes(function f(), a, b, N=1440, d=1);

Description

Compute definite integral over function f(u,...) from u=a up to u=b using the closed Newton-Cotes formulas.

N refers to the number of intervals to be used.
1 ≤ d ≤ 6 refers to the degree of the used interpolation polynomial:

  • d=1 trapezoidal rule
  • d=2 Simpson's rule
  • d=3 3/8-rule
  • d=4 Boole's rule
  • d=5 -
  • d=6 -

Note

Higher degree of interpolation polynomial are not supported as it increases the chance of high error (Runge's phenomenon).
Even degrees of interpolation polynomial should be preferred, since they integrate the same polynomial as the next higher odd degree exactly.

Note

The formulas are non-adaptive but composite implementations, i.e. dividing the interval [a, b] into sub-intervals and apply the Newton-Cotes formula to each sub-interval.

Inputs

TypeNameDefaultDescription
Modelica.Math.Nonlinear.Interfaces.partialScalarFunctionfIntegrand function
RealaLower limit of integration interval
RealbUpper limit of integration interval
IntegerN360Number of intervals
Integerd1Degree of interpolation polynominal

Outputs

TypeNameDefaultDescription
RealintegralIntegral value