NAG FL Interface
e01bgf (dim1_​monotonic_​deriv)

1 Purpose

e01bgf evaluates a piecewise cubic Hermite interpolant and its first derivative at a set of points.

2 Specification

Fortran Interface
Subroutine e01bgf ( n, x, f, d, m, px, pf, pd, ifail)
Integer, Intent (In) :: n, m
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: x(n), f(n), d(n), px(m)
Real (Kind=nag_wp), Intent (Out) :: pf(m), pd(m)
C Header Interface
#include <nag.h>
void  e01bgf_ (const Integer *n, const double x[], const double f[], const double d[], const Integer *m, const double px[], double pf[], double pd[], Integer *ifail)
The routine may be called by the names e01bgf or nagf_interp_dim1_monotonic_deriv.

3 Description

e01bgf evaluates a piecewise cubic Hermite interpolant, as computed by e01bef, at the points pxi, for i=1,2,,m. The first derivatives at the points are also computed. If any point lies outside the interval from x1 to xn, values of the interpolant and its derivative are extrapolated from the nearest extreme cubic, and a warning is returned.
If values of the interpolant only, and not of its derivative, are required, e01bff should be used.
The routine is derived from routine PCHFD 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: m Integer Input
On entry: m, the number of points at which the interpolant is to be evaluated.
Constraint: m1.
6: pxm Real (Kind=nag_wp) array Input
On entry: the m values of x at which the interpolant is to be evaluated.
7: pfm Real (Kind=nag_wp) array Output
On exit: pfi contains the value of the interpolant evaluated at the point pxi, for i=1,2,,m.
8: pdm Real (Kind=nag_wp) array Output
On exit: pdi contains the first derivative of the interpolant evaluated at the point pxi, for i=1,2,,m.
9: ifail Integer Input/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 4 in the Introduction to the NAG Library FL Interface 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=value.
Constraint: n2.
ifail=2
On entry, r=value, xr-1=value and xr=value.
Constraint: xr-1<xr for all r.
ifail=3
On entry, m=value.
Constraint: m1.
ifail=4
Warning – some points in array px lie outside the range x1xn. Values at these points are unreliable because computed by extrapolation.
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 errors in the arrays pf and pd should be negligible in most practical situations.

8 Parallelism and Performance

e01bgf is not threaded in any implementation.

9 Further Comments

The time taken by e01bgf is approximately proportional to the number of evaluation points, m. The evaluation will be most efficient if the elements of px are in nondecreasing order (or, more generally, if they are grouped in increasing order of the intervals xr-1,xr). A single call of e01bgf with m>1 is more efficient than several calls with m=1.

10 Example

This example reads in values of n, x, f and d, and calls e01bgf to compute the values of the interpolant and its derivative at equally spaced points.

10.1 Program Text

Program Text (e01bgfe.f90)

10.2 Program Data

Program Data (e01bgfe.d)

10.3 Program Results

Program Results (e01bgfe.r)
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 0 0.2 0.4 0.6 0.8 1 1.2 8 10 12 14 16 18 20 x Example Program Monotonic Hermite interpolant gnuplot_plot_1 Function gnuplot_plot_2 Derivative gnuplot_plot_3 Original data points