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=1trapezoidal ruled=2Simpson's ruled=33/8-ruled=4Boole's ruled=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
| Type | Name | Default | Description |
|---|---|---|---|
| Modelica.Math.Nonlinear.Interfaces.partialScalarFunction | f | Integrand function | |
| Real | a | Lower limit of integration interval | |
| Real | b | Upper limit of integration interval | |
| Integer | N | 360 | Number of intervals |
| Integer | d | 1 | Degree of interpolation polynominal |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real | integral | Integral value |