e01ba determines a cubic spline interpolant to a given set of data.

# Syntax

C# |
---|

public static void e01ba( int m, double[] x, double[] y, double[] lamda, double[] c, out int ifail ) |

Visual Basic |
---|

Public Shared Sub e01ba ( _ m As Integer, _ x As Double(), _ y As Double(), _ lamda As Double(), _ c As Double(), _ <OutAttribute> ByRef ifail As Integer _ ) |

Visual C++ |
---|

public: static void e01ba( int m, array<double>^ x, array<double>^ y, array<double>^ lamda, array<double>^ c, [OutAttribute] int% ifail ) |

F# |
---|

static member e01ba : m : int * x : float[] * y : float[] * lamda : float[] * c : float[] * ifail : int byref -> unit |

#### Parameters

- m
- Type: System..::..Int32
*On entry*: $m$, the number of data points.*Constraint*: ${\mathbf{m}}\ge 4$.

- x
- Type: array<System..::..Double>[]()[][]An array of size [m]
*On entry*: ${\mathbf{x}}\left[\mathit{i}-1\right]$ must be set to ${x}_{\mathit{i}}$, the $\mathit{i}$th data value of the independent variable $x$, for $\mathit{i}=1,2,\dots ,m$.*Constraint*: ${\mathbf{x}}\left[\mathit{i}-1\right]<{\mathbf{x}}\left[\mathit{i}\right]$, for $\mathit{i}=1,2,\dots ,{\mathbf{m}}-1$.

- y
- Type: array<System..::..Double>[]()[][]An array of size [m]
*On entry*: ${\mathbf{y}}\left[\mathit{i}-1\right]$ must be set to ${y}_{\mathit{i}}$, the $\mathit{i}$th data value of the dependent variable $y$, for $\mathit{i}=1,2,\dots ,m$.

- lamda
- Type: array<System..::..Double>[]()[][]An array of size [lck]
*On exit*: the value of ${\lambda}_{\mathit{i}}$, the $\mathit{i}$th knot, for $\mathit{i}=1,2,\dots ,m+4$.

- c
- Type: array<System..::..Double>[]()[][]An array of size [lck]
*On exit*: the coefficient ${c}_{\mathit{i}}$ of the B-spline ${N}_{\mathit{i}}\left(x\right)$, for $\mathit{i}=1,2,\dots ,m$. The remaining elements of the array are not used.

- ifail
- Type: System..::..Int32%
*On exit*: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# Description

e01ba determines a cubic spline $s\left(x\right)$, defined in the range ${x}_{1}\le x\le {x}_{m}$, which interpolates (passes exactly through) the set of data points $\left({x}_{\mathit{i}},{y}_{\mathit{i}}\right)$, for $\mathit{i}=1,2,\dots ,m$, where $m\ge 4$ and ${x}_{1}<{x}_{2}<\cdots <{x}_{m}$. Unlike some other spline interpolation algorithms, derivative end conditions are not imposed. The spline interpolant chosen has $m-4$ interior knots ${\lambda}_{5},{\lambda}_{6},\dots ,{\lambda}_{m}$, which are set to the values of ${x}_{3},{x}_{4},\dots ,{x}_{m-2}$ respectively. This spline is represented in its B-spline form (see Cox (1975)):

where ${N}_{i}\left(x\right)$ denotes the normalized B-spline of degree $3$,
defined upon the knots ${\lambda}_{i},{\lambda}_{i+1},\dots ,{\lambda}_{i+4}$, and ${c}_{i}$ denotes its coefficient, whose value is to be determined by the method.

$$s\left(x\right)=\sum _{i=1}^{m}{c}_{i}{N}_{i}\left(x\right)\text{,}$$ |

The use of B-splines requires eight additional knots ${\lambda}_{1}$, ${\lambda}_{2}$,
${\lambda}_{3}$, ${\lambda}_{4}$,
${\lambda}_{m+1}$, ${\lambda}_{m+2}$,
${\lambda}_{m+3}$ and ${\lambda}_{m+4}$ to be specified; e01ba sets the first four of these to ${x}_{1}$ and the last four to ${x}_{m}$.

The algorithm for determining the coefficients is as described in
Cox (1975) except that $QR$ factorization is used instead of $LU$ decomposition. The implementation of the algorithm involves setting up appropriate information for the related
method (E02BAF not in this release) followed by a call of that method. (See (E02BAF not in this release) for further details.)

Values of the spline interpolant, or of its derivatives or definite integral, can subsequently be computed as detailed in
[Further Comments].

# References

Cox M G (1975) An algorithm for spline interpolation

*J. Inst. Math. Appl.***15**95–108Cox M G (1977) A survey of numerical methods for data and function approximation

*The State of the Art in Numerical Analysis*(ed D A H Jacobs) 627–668 Academic Press# Error Indicators and Warnings

Errors or warnings detected by the method:

- ${\mathbf{ifail}}=1$
On entry, ${\mathbf{m}}<4$, or ${\mathbf{lck}}<{\mathbf{m}}+4$, or ${\mathbf{lwrk}}<6\times {\mathbf{m}}+16$.

- ${\mathbf{ifail}}=2$
- The x-values fail to satisfy the condition${\mathbf{x}}\left[0\right]<{\mathbf{x}}\left[1\right]<{\mathbf{x}}\left[2\right]<\cdots <{\mathbf{x}}\left[{\mathbf{m}}-1\right]$.

- ${\mathbf{ifail}}=-9000$
- An error occured, see message report.
- ${\mathbf{ifail}}=-1000$
- The array lengths are not the same for arrays
- ${\mathbf{ifail}}=-8000$
- Negative dimension for array $\u2329\mathit{\text{value}}\u232a$
- ${\mathbf{ifail}}=-6000$
- Invalid Parameters $\u2329\mathit{\text{value}}\u232a$

# Accuracy

The rounding errors incurred are such that the computed spline is an exact interpolant for a slightly perturbed set of ordinates ${y}_{i}+\delta {y}_{i}$. The ratio of the root-mean-square value of the $\delta {y}_{i}$ to that of the ${y}_{i}$ is no greater than a small multiple of the relative machine precision.

# Parallelism and Performance

None.

# Further Comments

The time taken by e01ba is approximately proportional to $m$.

All the ${x}_{i}$ are used as knot positions except ${x}_{2}$ and ${x}_{m-1}$. This choice of knots
(see Cox (1977)) means that $s\left(x\right)$ is composed of $m-3$ cubic arcs as follows. If $m=4$, there is just a single arc space spanning the whole interval ${x}_{1}$ to ${x}_{4}$. If $m\ge 5$, the first and last arcs span the intervals ${x}_{1}$ to ${x}_{3}$ and ${x}_{m-2}$ to ${x}_{m}$ respectively. Additionally if $m\ge 6$, the $\mathit{i}$th arc, for $\mathit{i}=2,3,\dots ,m-4$, spans the interval ${x}_{\mathit{i}+1}$ to ${x}_{\mathit{i}+2}$.

After the call
the following operations may be carried out on the interpolant $s\left(x\right)$.

The value of $s\left(x\right)$ at $x={\mathbf{x}}$ can be provided in the real variable s by the call
(see e02bb).

The values of $s\left(x\right)$ and its first three derivatives at $x={\mathbf{x}}$ can be provided in the real array s
of dimension $4$, by the call
(see (E02BCF not in this release)).

Here
left
must specify whether the left- or right-hand value of the third derivative is required (see (E02BCF not in this release) for details).

The value of the integral of $s\left(x\right)$ over the range ${x}_{1}$ to ${x}_{m}$ can be provided in the
real variable
dint
by
(see (E02BDF not in this release)).

# Example

This example sets up data from $7$ values of the exponential function in the interval $0$ to $1$. e01ba is then called to compute a spline interpolant to these data.