e01 Chapter Contents
e01 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_monotonic_evaluate (e01bfc)

## 1  Purpose

nag_monotonic_evaluate (e01bfc) evaluates a piecewise cubic Hermite interpolant at a set of points.

## 2  Specification

 #include #include
 void nag_monotonic_evaluate (Integer n, const double x[], const double f[], const double d[], Integer m, const double px[], double pf[], NagError *fail)

## 3  Description

A piecewise cubic Hermite interpolant, as computed by nag_monotonic_interpolant (e01bec), is evaluated at the points ${\mathbf{px}}\left[\mathit{i}\right]$, for $\mathit{i}=0,1,\dots ,m-1$. If any point lies outside the interval from ${\mathbf{x}}\left[0\right]$ to ${\mathbf{x}}\left[{\mathbf{n}}-1\right]$, a value is extrapolated from the nearest extreme cubic, and a warning is returned.
The algorithm is derived from routine PCHFE in Fritsch (1982).

## 4  References

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

## 5  Arguments

1:     nIntegerInput
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:     mIntegerInput
On entry: $m$, the number of points at which the interpolant is to be evaluated.
Constraint: ${\mathbf{m}}\ge 1$.
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: ${\mathbf{pf}}\left[\mathit{i}\right]$ contains the value of the interpolant evaluated at the point ${\mathbf{px}}\left[\mathit{i}\right]$, for $\mathit{i}=0,1,\dots ,m-1$.
8:     failNagError *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, ${\mathbf{m}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{m}}\ge 1$.
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 2$.
NE_NOT_MONOTONIC
On entry, ${\mathbf{x}}\left[r-1\right]\ge {\mathbf{x}}\left[r\right]$ for $r=〈\mathit{\text{value}}〉$: ${\mathbf{x}}\left[r-1\right]$, ${\mathbf{x}}\left[r\right]=〈\mathit{values}〉$.
The values of ${\mathbf{x}}\left[\mathit{r}\right]$, for $\mathit{r}=0,1,\dots ,n-1$, are not in strictly increasing order.
NW_EXTRAPOLATE
Warning – some points in array PX lie outside the range ${\mathbf{x}}\left[0\right]\dots {\mathbf{x}}\left[n-1\right]$. Values at these points are unreliable as they have been computed by extrapolation.

## 7  Accuracy

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

The time taken by nag_monotonic_evaluate (e01bfc) is approximately proportional to the number of evaluation points, $m$. The evaluation will be most efficient if the elements of px are in non-decreasing order (or, more generally, if they are grouped in increasing order of the intervals $\left[{\mathbf{x}}\left(r-1\right),{\mathbf{x}}\left(r\right)\right]$). A single call of nag_monotonic_evaluate (e01bfc) with $m>1$ is more efficient than several calls with $m=1$.

## 9  Example

This example program reads in values of n, x, f, d and m, and then calls nag_monotonic_evaluate (e01bfc) to evaluate the interpolant at equally spaced points.

### 9.1  Program Text

Program Text (e01bfce.c)

### 9.2  Program Data

Program Data (e01bfce.d)

### 9.3  Program Results

Program Results (e01bfce.r)