nag_monotonic_deriv (e01bgc) (PDF version)
e01 Chapter Contents
e01 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_monotonic_deriv (e01bgc)

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_monotonic_deriv (e01bgc) evaluates a piecewise cubic Hermite interpolant and its first derivative at a set of points.

2  Specification

#include <nag.h>
#include <nage01.h>
void  nag_monotonic_deriv (Integer n, const double x[], const double f[], const double d[], Integer m, const double px[], double pf[], double pd[], NagError *fail)

3  Description

nag_monotonic_deriv (e01bgc) evaluates a piecewise cubic Hermite interpolant, as computed by the NAG function nag_monotonic_interpolant (e01bec), at the points px[i] , for i=0,1,,m - 1. The first derivatives at the points are also computed. If any point lies outside the interval from x[0]  to x[n-1] , 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, nag_monotonic_evaluate (e01bfc) should be used.
The function 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 IntegerInput
On entry: n must be unchanged from the previous call of nag_monotonic_interpolant (e01bec).
2:     x[n] const doubleInput
3:     f[n] const doubleInput
4:     d[n] const doubleInput
On entry: x, f and d must be unchanged from the previous call of nag_monotonic_interpolant (e01bec).
5:     m IntegerInput
On entry: m , the number of points at which the interpolant is to be evaluated.
Constraint: m1 .
6:     px[m] const doubleInput
On entry: the m  values of x  at which the interpolant is to be evaluated.
7:     pf[m] doubleOutput
On exit: pf[i]  contains the value of the interpolant evaluated at the point px[i] , for i=0,1,,m - 1.
8:     pd[m] doubleOutput
On exit: pd[i]  contains the first derivative of the interpolant evaluated at the point px[i] , for i=0,1,,m - 1.
9:     fail NagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_INT_ARG_LT
On entry, m=value.
Constraint: m1.
On entry, n=value.
Constraint: n2.
NE_NOT_MONOTONIC
On entry, x[r-1] x[r]  for r=value  : x[r-1] = value, x[r] = value.
The values of x[r] , for r=0,1,,n - 1, are not in strictly increasing order.
NW_EXTRAPOLATE
Warning – some points in array px lie outside the range x[0] x[n-1] . Values at these points are unreliable as they have been computed by extrapolation.

7  Accuracy

The computational errors in the arrays pf and pd should be negligible in most practical situations.

8  Parallelism and Performance

Not applicable.

9  Further Comments

The time taken by nag_monotonic_deriv (e01bgc) 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 x[r-1],x[r] ). A single call of nag_monotonic_deriv (e01bgc) with m>1  is more efficient than several calls with m=1 .

10  Example

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

10.1  Program Text

Program Text (e01bgce.c)

10.2  Program Data

Program Data (e01bgce.d)

10.3  Program Results

Program Results (e01bgce.r)


nag_monotonic_deriv (e01bgc) (PDF version)
e01 Chapter Contents
e01 Chapter Introduction
NAG Library Manual

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