NAG FL Interface
e01bhf (dim1_​monotonic_​intg)

1 Purpose

e01bhf evaluates the definite integral of a piecewise cubic Hermite interpolant over the interval a,b.

2 Specification

Fortran Interface
Subroutine e01bhf ( n, x, f, d, a, b, pint, ifail)
Integer, Intent (In) :: n
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: x(n), f(n), d(n), a, b
Real (Kind=nag_wp), Intent (Out) :: pint
C Header Interface
#include <nag.h>
void  e01bhf_ (const Integer *n, const double x[], const double f[], const double d[], const double *a, const double *b, double *pint, Integer *ifail)
The routine may be called by the names e01bhf or nagf_interp_dim1_monotonic_intg.

3 Description

e01bhf evaluates the definite integral of a piecewise cubic Hermite interpolant, as computed by e01bef, over the interval a,b.
If either a or b lies outside the interval from x1 to xn computation of the integral involves extrapolation and a warning is returned.
The routine is derived from routine PCHIA in Fritsch (1982).

4 References

Fritsch F N (1982) PCHIP final specifications Report UCID-30194 Lawrence Livermore National Laboratory

5 Arguments

1: n Integer Input
2: xn Real (Kind=nag_wp) array Input
3: fn Real (Kind=nag_wp) array Input
4: dn Real (Kind=nag_wp) array Input
On entry: n, x, f and d must be unchanged from the previous call of e01bef.
5: a Real (Kind=nag_wp) Input
6: b Real (Kind=nag_wp) Input
On entry: the interval a,b over which integration is to be performed.
7: pint Real (Kind=nag_wp) Output
On exit: the value of the definite integral of the interpolant over the interval a,b.
8: ifail Integer Input/Output
On entry: ifail must be set to 0, -1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of -1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value -1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, n=value.
Constraint: n2.
ifail=2
On entry, r=value, xr-1=value and xr=value.
Constraint: xr-1<xr for all r.
ifail=3
Warning – either a or b is outside the range x1xn. The result has been computed by extrapolation and is unreliable. a=value b=value.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

The computational error in the value returned for pint should be negligible in most practical situations.

8 Parallelism and Performance

e01bhf is not threaded in any implementation.

9 Further Comments

The time taken by e01bhf is approximately proportional to the number of data points included within the interval a,b.

10 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 a,b until end-of-file is reached.

10.1 Program Text

Program Text (e01bhfe.f90)

10.2 Program Data

Program Data (e01bhfe.d)

10.3 Program Results

Program Results (e01bhfe.r)