PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_interp_1d_monotonic_intg (e01bh)
Purpose
nag_interp_1d_monotonic_intg (e01bh) evaluates the definite integral of a piecewise cubic
Hermite interpolant over the interval .
Syntax
Description
nag_interp_1d_monotonic_intg (e01bh) evaluates the definite integral of a piecewise cubic
Hermite interpolant, as computed by
nag_interp_1d_monotonic (e01be), over the interval
.
If either or lies outside the interval from to computation of the integral involves extrapolation and a warning is returned.
The function is derived from function PCHIA in
Fritsch (1982).
References
Fritsch F N (1982) PCHIP final specifications Report UCID-30194 Lawrence Livermore National Laboratory
Parameters
Compulsory Input Parameters
- 1:
– double array
- 2:
– double array
- 3:
– double array
-
n,
x,
f and
d must be unchanged from the previous call of
nag_interp_1d_monotonic (e01be).
- 4:
– double scalar
- 5:
– double scalar
-
The interval over which integration is to be performed.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the arrays
x,
f,
d. (An error is raised if these dimensions are not equal.)
n,
x,
f and
d must be unchanged from the previous call of
nag_interp_1d_monotonic (e01be).
Output Parameters
- 1:
– double scalar
-
The value of the definite integral of the interpolant over the interval .
- 2:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
Cases prefixed with W are classified as warnings and
do not generate an error of type NAG:error_n. See nag_issue_warnings.
-
-
-
-
The values of , for , are not in strictly increasing order.
- W
-
On entry, at least one of
a or
b lies outside the interval [
], and extrapolation was performed to compute the integral. The value returned is therefore unreliable.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
The computational error in the value returned for
pint should be negligible in most practical situations.
Further Comments
The time taken by nag_interp_1d_monotonic_intg (e01bh) is approximately proportional to the number of data points included within the interval .
Example
This example reads in values of
n,
x,
f and
d. It then reads in pairs of values for
a and
b, and evaluates the definite integral of the interpolant over the interval
until end-of-file is reached.
Open in the MATLAB editor:
e01bh_example
function e01bh_example
fprintf('e01bh example results\n\n');
x = [7.99 8.09 8.19 8.7 9.2 10 12 15 20];
f = [0 2.7643e-05 0.04375 0.16918 0.46943 0.94374 0.99864 0.99992 0.99999];
d = [0;
0.00055251;
0.33587;
0.34944;
0.59696;
0.060326;
0.000898335;
2.93954e-05;
0];
m = 11;
dx = (x(end)-x(1))/(m-1);
px = [x(1):dx:x(end)];
ia = [1 6 7 8];
ib = [9 7 6 8];
fprintf(' Integral\n');
fprintf(' a b over (a,b)\n');
for i = 1:4
a = x(ia(i));
b = x(ib(i));
[pint, ifail] = e01bh( ...
x, f, d, a, b);
fprintf('%13.4f%13.4f%13.4f\n', a, b, pint);
end
e01bh example results
Integral
a b over (a,b)
7.9900 20.0000 10.7648
10.0000 12.0000 1.9622
12.0000 10.0000 -1.9622
15.0000 15.0000 0.0000
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015