NAG Library Routine Document

e01bef  (dim1_monotonic)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

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

2
Specification

Fortran Interface
Subroutine e01bef ( n, x, f, d, ifail)
Integer, Intent (In):: n
Integer, Intent (Inout):: ifail
Real (Kind=nag_wp), Intent (In):: x(n), f(n)
Real (Kind=nag_wp), Intent (Out):: d(n)
C Header Interface
#include nagmk26.h
void  e01bef_ ( const Integer *n, const double x[], const double f[], double d[], Integer *ifail)

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
Arguments

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 argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation 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 argument, 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.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

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

8
Parallelism and Performance

e01bef is not threaded in any implementation.

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 arguments to e01bef and d is the output argument 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)

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