# NAG CL Interfacee01bgc (dim1_​monotonic_​deriv)

Settings help

CL Name Style:

## 1Purpose

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

## 2Specification

 #include
 void e01bgc (Integer n, const double x[], const double f[], const double d[], Integer m, const double px[], double pf[], double pd[], NagError *fail)
The function may be called by the names: e01bgc, nag_interp_dim1_monotonic_deriv or nag_monotonic_deriv.

## 3Description

e01bgc evaluates a piecewise cubic Hermite interpolant, as computed by the NAG function e01bec, at the points ${\mathbf{px}}\left[\mathit{i}\right]$, for $\mathit{i}=0,1,\dots ,m-1$. The first derivatives at the points are also computed. If any point lies outside the interval from ${\mathbf{x}}\left[0\right]$ to ${\mathbf{x}}\left[n-1\right]$, 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, e01bfc should be used.
The function is derived from routine PCHFD in Fritsch (1982).

## 4References

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

## 5Arguments

1: $\mathbf{n}$Integer Input
On entry: n must be unchanged from the previous call of e01bec.
2: $\mathbf{x}\left[{\mathbf{n}}\right]$const double Input
3: $\mathbf{f}\left[{\mathbf{n}}\right]$const double Input
4: $\mathbf{d}\left[{\mathbf{n}}\right]$const double Input
On entry: x, f and d must be unchanged from the previous call of e01bec.
5: $\mathbf{m}$Integer Input
On entry: $m$, the number of points at which the interpolant is to be evaluated.
Constraint: ${\mathbf{m}}\ge 1$.
6: $\mathbf{px}\left[{\mathbf{m}}\right]$const double Input
On entry: the $m$ values of $x$ at which the interpolant is to be evaluated.
7: $\mathbf{pf}\left[{\mathbf{m}}\right]$double Output
On exit: ${\mathbf{pf}}\left[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: $\mathbf{pd}\left[{\mathbf{m}}\right]$double Output
On exit: ${\mathbf{pd}}\left[\mathit{i}\right]$ contains the first derivative of the interpolant evaluated at the point ${\mathbf{px}}\left[\mathit{i}\right]$, for $\mathit{i}=0,1,\dots ,m-1$.
9: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error 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]=⟨\mathit{\text{value}}⟩$, ${\mathbf{x}}\left[r\right]=⟨\mathit{\text{value}}⟩$.
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.

## 7Accuracy

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

## 8Parallelism and Performance

e01bgc is not threaded in any implementation.

The time taken by 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 $\left[{\mathbf{x}}\left[r-1\right],{\mathbf{x}}\left[r\right]\right]$). A single call of e01bgc with $m>1$ is more efficient than several calls with $m=1$.

## 10Example

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

### 10.1Program Text

Program Text (e01bgce.c)

### 10.2Program Data

Program Data (e01bgce.d)

### 10.3Program Results

Program Results (e01bgce.r)