F = integralInterpolant(integrand, lower, upper)
F = integralInterpolant(integrand, lower, upper, name, value)
Fq = F(xq)
| Parameter | Description |
|---|---|
| integrand | function handle of the integrand, with the same requirements as for integral. |
| lower | lower limit of integration: real scalar, finite or infinite. |
| upper | upper limit of integration: real scalar, finite or infinite, different from lower. It can be less than lower (backward integration). |
| name, value | one or more name/value pairs: 'AbsoluteTolerance' (default 1e-10), 'RelativeTolerance' (default 1e-6), 'ArrayValued' (default false), 'Vectorized' (default true), 'Waypoints' (vector of real points used in the initial mesh). |
| xq | real numeric array of query points. |
| Parameter | Description |
|---|---|
| F | an integralInterpolant object. |
| Fq | values of the integral from lower to each query point: an array of the size of xq, or, when ArrayValued is true, an array with one row per query point. |
integralInterpolant evaluates a definite integral with a variable upper limit: the returned object F gives F(x), the integral of integrand from lower to x, for any x between lower and upper.
The integral from lower to upper is computed once with the adaptive Gauss-Kronrod quadrature of integral. Querying F(xq) adds the partial sums of the mesh intervals located before each query point to the Gauss-Kronrod rule applied on the part of the interval that contains it, so the queried values have the accuracy of the integral. Query points outside the integration interval return NaN.
The object has the read-only properties Integrand, LowerLimit, UpperLimit, Integral (value of the integral from lower to upper), ErrorBound (approximate upper bound on the absolute error), AbsoluteTolerance, RelativeTolerance and Subintervals (row vector of the mesh points, from lower to upper, including the waypoints). F(F.Subintervals) returns the partial sums of the integral.
Specify discontinuities of the integrand as Waypoints. Do not use waypoints to specify singularities at the integration limits. For faster but less accurate evaluations, sample F and build a griddedInterpolant.
f = @(x) 1 + cos(x).^2;
F = integralInterpolant(f, 0, 5)
xq = linspace(1, 3, 5);
Fq = F(xq)
f = @(x) x.^5 .* exp(-x) .* sin(x);
F = integralInterpolant(f, 0, Inf, 'RelativeTolerance', 1e-8, 'AbsoluteTolerance', 1e-13);
Fq = F([0 Inf])
k = 1:5;
f = @(x) sin(k * x);
F = integralInterpolant(f, 0, 1, 'ArrayValued', true);
partialSums = F(F.Subintervals(end-5:end))
f = @(x) x.^x;
F = integralInterpolant(f, 1, 2);
x = linspace(1, 2, 11);
G = griddedInterpolant(x, F(x), 'cubic');
Fq = F(1.88)
Gq = G(1.88)
| Version | Description |
|---|---|
| 2.0.0 | initial version |