E01BEF (PDF version)
E01 Chapter Contents
E01 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

E01BEF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

E01BEF computes a monotonicity-preserving piecewise cubic Hermite interpolant to a set of data points.

2  Specification

SUBROUTINE E01BEF ( N, X, F, D, IFAIL)
INTEGER  N, IFAIL
REAL (KIND=nag_wp)  X(N), F(N), D(N)

3  Description

E01BEF estimates first derivatives at the set of data points xr,fr, for r=1,2,,n, which determine a piecewise cubic Hermite interpolant to the data, that preserves monotonicity over ranges where the data points are monotonic. If the data points are only piecewise monotonic, the interpolant will have an extremum at each point where monotonicity switches direction. The estimates of the derivatives are computed by a formula due to Brodlie, which is described in Fritsch and Butland (1984), with suitable changes at the boundary points.
The routine is derived from routine PCHIM in Fritsch (1982).
Values of the computed interpolant, and of its first derivative and definite integral, can subsequently be computed by calling E01BFF, E01BGF and E01BHF, as described in Section 9.

4  References

Fritsch F N (1982) PCHIP final specifications Report UCID-30194 Lawrence Livermore National Laboratory
Fritsch F N and Butland J (1984) A method for constructing local monotone piecewise cubic interpolants SIAM J. Sci. Statist. Comput. 5 300–304

5  Parameters

1:     N – INTEGERInput
On entry: n, the number of data points.
Constraint: N2.
2:     XN – REAL (KIND=nag_wp) arrayInput
On entry: Xr must be set to xr, the rth value of the independent variable (abscissa), for r=1,2,,n.
Constraint: Xr<Xr+1.
3:     FN – REAL (KIND=nag_wp) arrayInput
On entry: Fr must be set to fr, the rth value of the dependent variable (ordinate), for r=1,2,,n.
4:     DN – REAL (KIND=nag_wp) arrayOutput
On exit: estimates of derivatives at the data points. Dr contains the derivative at Xr.
5:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. 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<2.
IFAIL=2
The values of Xr, for r=1,2,,N, are not in strictly increasing order.
IFAIL=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.8 in the Essential Introduction for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

7  Accuracy

The computational errors in the array D should be negligible in most practical situations.

8  Parallelism and Performance

Not applicable.

9  Further Comments

The time taken by E01BEF is approximately proportional to n.
The values of the computed interpolant at the points PXi, for i=1,2,,M, may be obtained in the real array PF, of length at least M, by the call:
CALL E01BFF(N,X,F,D,M,PX,PF,IFAIL)
where N, X and F are the input parameters to E01BEF and D is the output parameter from E01BEF.
The values of the computed interpolant at the points PXi, for i=1,2,,M, together with its first derivatives, may be obtained in the real arrays PF and PD, both of length at least M, by the call:
CALL E01BGF(N,X,F,D,M,PX,PF,PD,IFAIL)
where N, X, F and D are as described above.
The value of the definite integral of the interpolant over the interval A to B can be obtained in the real variable PINT by the call:
CALL E01BHF(N,X,F,D,A,B,PINT,IFAIL)
where N, X, F and D are as described above.

10  Example

This example reads in a set of data points, calls E01BEF to compute a piecewise monotonic interpolant, and then calls E01BFF to evaluate the interpolant at equally spaced points.

10.1  Program Text

Program Text (e01befe.f90)

10.2  Program Data

Program Data (e01befe.d)

10.3  Program Results

Program Results (e01befe.r)


E01BEF (PDF version)
E01 Chapter Contents
E01 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2015