e01 Chapter Contents
e01 Chapter Introduction
NAG Library Manual

NAG Library Function Documentnag_monotonic_intg (e01bhc)

1  Purpose

nag_monotonic_intg (e01bhc) evaluates the definite integral of a piecewise cubic Hermite interpolant over the interval $\left[a,b\right]$.

2  Specification

 #include #include
 void nag_monotonic_intg (Integer n, const double x[], const double f[], const double d[], double a, double b, double *integral, NagError *fail)

3  Description

nag_monotonic_intg (e01bhc) evaluates the definite integral of a piecewise cubic Hermite interpolant, as computed by nag_monotonic_interpolant (e01bec), over the interval $\left[a,b\right]$.
If either $a$ or $b$ lies outside the interval from ${\mathbf{x}}\left[0\right]$ to ${\mathbf{x}}\left[n-1\right]$, computation of the integral involves extrapolation and a warning is returned.
The function is derived from routine PCHIA in Fritsch (1982).

4  References

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

5  Arguments

1:    $\mathbf{n}$IntegerInput
On entry: n must be unchanged from the previous call of nag_monotonic_interpolant (e01bec).
2:    $\mathbf{x}\left[{\mathbf{n}}\right]$const doubleInput
3:    $\mathbf{f}\left[{\mathbf{n}}\right]$const doubleInput
4:    $\mathbf{d}\left[{\mathbf{n}}\right]$const doubleInput
On entry: x, f and d must be unchanged from the previous call of nag_monotonic_interpolant (e01bec).
5:    $\mathbf{a}$doubleInput
6:    $\mathbf{b}$doubleInput
On entry: the interval $\left[a,b\right]$ over which integration is to be performed.
7:    $\mathbf{integral}$double *Output
On exit: the value of the definite integral of the interpolant over the interval $\left[a,b\right]$.
8:    $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 2.7 in How to Use the NAG Library and its Documentation).

6  Error Indicators and Warnings

NE_INT_ARG_LT
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_INTERVAL_EXTRAPOLATE
On entry, limits a, b must not be outside interval $\left[{\mathbf{x}}\left[0\right],{\mathbf{x}}\left[n-1\right]\right]$, ${\mathbf{a}}=〈\mathit{\text{value}}〉$, ${\mathbf{b}}=〈\mathit{\text{value}}〉$, ${\mathbf{x}}\left[0\right]=〈\mathit{\text{value}}〉$, ${\mathbf{x}}\left[〈\mathit{\text{value}}〉\right]=〈\mathit{\text{value}}〉$. Extrapolation was performed to compute the integral. The value returned is therefore unreliable.

7  Accuracy

The computational error in the value returned for integral should be negligible in most practical situations.

8  Parallelism and Performance

nag_monotonic_intg (e01bhc) is not threaded in any implementation.

The time taken by nag_monotonic_intg (e01bhc) is approximately proportional to the number of data points included within the interval $\left[a,b\right]$.

10  Example

This example program reads in values of n, x, f and d. It then reads in pairs of values for a and b, and evaluates the definite integral of the interpolant over the interval $\left({\mathbf{a}},{\mathbf{b}}\right)$ until end-of-file is reached.

10.1  Program Text

Program Text (e01bhce.c)

10.2  Program Data

Program Data (e01bhce.d)

10.3  Program Results

Program Results (e01bhce.r)