nag_monotonic_interpolant (e01bec) (PDF version)
e01 Chapter Contents
e01 Chapter Introduction
NAG C Library Manual

NAG Library Function Document

nag_monotonic_interpolant (e01bec)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_monotonic_interpolant (e01bec) computes a monotonicity-preserving piecewise cubic Hermite interpolant to a set of data points.

2  Specification

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

3  Description

nag_monotonic_interpolant (e01bec) estimates first derivatives at the set of data points x r , f r , for r=0,1,,n - 1, 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 algorithm is derived from routine PCHIM in Fritsch (1982).
Values of the computed interpolant can subsequently be computed by calling nag_monotonic_evaluate (e01bfc).

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:     nIntegerInput
On entry: n , the number of data points.
Constraint: n2 .
2:     x[n]const doubleInput
On entry: x[r]  must be set to x r , the r th value of the independent variable (abscissa), for r=0,1,,n - 1.
Constraint: x[r] < x[r+1] .
3:     f[n]const doubleInput
On entry: f[r]  must be set to f r , the r th value of the dependent variable (ordinate), for r=0,1,,n - 1.
4:     d[n]doubleOutput
On exit: estimates of derivatives at the data points. d[r]  contains the derivative at x[r] .
5:     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, n=value.
Constraint: n2.
NE_NOT_MONOTONIC
On entry, x[r-1] x[r]  for r = value : x[r-1] , x[r] = values .
The values of x[r] , for r=0,1,,n - 1, are not in strictly increasing order.

7  Accuracy

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

8  Further Comments

The time taken by nag_monotonic_interpolant (e01bec) is approximately proportional to n .
The values of the computed interpolant at the points i , for i=0,1,,m - 1, may be obtained in the real array pf, of length at least m , by the call:
e01bfc (n, x, f, d, m, px, pf, &fail)
where n, x and f are the input arguments to nag_monotonic_interpolant (e01bec) and d is the output argument from nag_monotonic_interpolant (e01bec).

9  Example

This example program reads in a set of data points, calls nag_monotonic_interpolant (e01bec) to compute a piecewise monotonic interpolant, and then calls nag_monotonic_evaluate (e01bfc) to evaluate the interpolant at equally spaced points.

9.1  Program Text

Program Text (e01bece.c)

9.2  Program Data

Program Data (e01bece.d)

9.3  Program Results

Program Results (e01bece.r)


nag_monotonic_interpolant (e01bec) (PDF version)
e01 Chapter Contents
e01 Chapter Introduction
NAG C Library Manual

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