Univariate Data Functions

This page describes AMA Spline Library functions which compute spline approximations and interpolants of independent variable data ${\bf X}\in{\rm R}^1$ and dependent variable data ${\bf Z}\in{\rm R}^1$.

The data is given as $(x_\ell,z_\ell,w_\ell,\epsilon_\ell)$, for $\ell=1,\ldots,N$, and the spline approximation is given as

\[ s(x) = \sum_{j=1}^{m}\alpha_jB_{d,j}(x|{\bf\Lambda}) \]

where $\alpha_j$, for $j=1,\ldots,m$, are the coefficients of the $m$ univariate B-splines $B_{d,j}(x|{\bf\Lambda})$ of degree $d$ defined by the knot vector ${\bf\Lambda}$. The knot vector is

\[ {\bf\Lambda} = ( \lambda_1, \cdots, \lambda_{d+1}, \lambda_{d+2}, \cdots, \lambda_m, \lambda_{m+1}, \cdots, \lambda_{m+d+1}) \]

where the number of B-spline coefficients $m$ and $\lambda_i$, for $i=1,\ldots,m+d+1$, depend on the method employed to approximate the data. The five methods available in the AMA Spline Library are Least Squares Approximation, Approximation, Interpolation, Monotonic Approximation and Monotonic Interpolation. For Interpolation and Monotonic Interpolation the independent variable data $x_\ell$ and the dependent variable data $z_\ell$, for $\ell=1,\ldots,N$, is required. For a Least Squares Approximation the weights $w_\ell$, for $\ell=1,\ldots,N$, and the knots $\lambda_i$, for $i=1,\ldots,m+d+1$, are required along with the independent and dependent variable data. And, for Approximation and Monotonic Approximation the approximation tolerances $\epsilon_\ell$, for $\ell=1,\ldots,N$, are required in addition to the independent and dependent variable data. These five approximation and interpolation methods are provided by the following AMA Spline Library functions:

Examples of the approximations produced by these functions are given in the following sections:

The examples illustrate approximations required to solve a minimum time to climb problem. The original minimum time to climb problem was presented by Byson et al. The basic problem is to choose the optimal control function $\alpha(t)$ (the angle of attack with respect to time, $t$) such that an airplane flies from a point on the runway to a specified final altitude as quickly as possible. Amongst other things, determining $\alpha(t)$ requires the representation of the aerodynamic forces on an airplane defined by the expressions

\begin{eqnarray*} C_L(M,t) &= &c_{L_\alpha}(M)\alpha(t) \cr C_D(M,t) &= &c_{D_o}(M) - \eta(M)c_{L_\alpha}(M)\alpha(t)^2 \cr \end{eqnarray*}

where $M$ is Mach; and $C_L(M,t)$ and $C_D(M,t)$ are the aerodynamic lift and drag coefficients, respectively. The definition of the lift and drag coefficients are given in terms of three "coefficients", namely $c_{L_\alpha}(M)$, $c_{D_o}(M)$ and $\eta(M)$, which are provided in Table Aerodynamic Data.

Aerodynamic Data
$ M$ 0.0 0.4 0.8 0.9 1.0 1.2 1.4 1.6 1.8
$c_{L_\alpha}$ 3.44 3.44 3.44 3.58 4.44 3.44 3.01 2.86 2.44
$c_{D_o}$ 0.013 0.013 0.013 0.014 0.031 0.041 0.039 0.036 0.035
$\eta$ 0.54 0.54 0.54 0.75 0.79 0.78 0.89 0.93 0.93

See A Collection of Optimal Control Test Problems for a complete description of the minimum time to climb problem.

In order to solve the minimum time to climb problem with a derivative based optimization technique a continuous representation of the "coefficients" data must be defined. In what follows the function AMA_UnvInterp() is employed to compute a linear spline interpolant of the coefficient data. A graphical illustration of the linear interpolant is presented in Figure Linear Interpolation of Coefficient Data. It consists of three panels each of which show the data, represented as red squares, and its spline interpolant, represented as a continuous blue curve. The left hand panel contains the data and interpolant for $c_{L_\alpha}(M)$, the center panel contains the data and interpolant for $c_{D_o}(M)$, and the right hand panel contains the data and interpolant for $\eta(M)$.

The program exampleAMA_Unv.c was used to compute the spline approximations and interpolants discussed throughout this page and to generate the VisIt files used to produce the figures.

Linear Interpolation of Coefficient Data
$c_{L_\alpha}(M)$ $c_{D_o}(M)$ $\eta(M)$

Examination of Figure Linear Interpolation of Coefficient Data shows the linear spline interpolant provides a continuous representation of the data. It also highlights the Mach intervals over which the data is increasing, derivative of the spline is positive; decreasing, derivative of the spline is negative; and constant, derivative of the spline is zero. The sign of the spline interpolant's derivative for the three coefficients is summarized in Table Sign of Linear Spline's First Derivative. It shows the Mach intervals in which the coefficient's data indicates a positive derivative (+), a negative derivative (-) and a derivative equal to zero (0). The value of $M$ is the left endpoint of the interval. For example, the coefficient $c_{L_\alpha}(M)$ has a positive derivative (+) for $M\in (0.9,1.0)$ and a negative derivative (-) for $M\in (1.0,1.2)$.

Sign of Linear Spline's First Derivative
$M$ 0.0 0.4 0.8 0.9 1.0 1.2 1.4 1.6
$c_{L_\alpha}$ 0 0 + + - - - -
$c_{D_o}$ 0 0 + + + - - -
$\eta$ 0 0 + + - + + 0

This table also summarizes the "local monotonicity" constraints for the three coefficients. For example, it shows the "local monotonicity" constraints for $c_{L_\alpha}(M)$ are $c^{'}_{L_\alpha}(M) = 0.0$ for $M\in (0.0,8.0)$, $c^{'}_{L_\alpha}(M) > 0.0$ for $M\in (8.0.0,1.0)$ and $c^{'}_{L_\alpha}(M) < 0.0$ for $M\in (1.0,1.8)$. By their nature piecewise linear spline interpolants satisfy the local monotonicity constraints inherent in discrete data. However, their derivatives are piecewise constant and discontinuous at the data and, since most derivative based optimization methods require the objective function to be twice continuously differentiable, piecewise linear spline interpolants are not ideal representations of the aerodynamic coefficients for solving the minimum time to climb problem with a derivative based optimization technique. A much better choice for representing the aerodynamic coefficients is piecewise cubic spline approximation or interpolation.

In the next four sections the AMA Spline Library Univariate Data Functions are used to compute cubic spline approximations and interpolants of the coefficient data. Each section contains a figure which presents a graphical illustration of the spline produced by its corresponding function. As in Figure Linear Interpolation of Coefficient Data the figures consist of three panels each of which show the data, represented as red squares, and its cubic spline approximation, represented as a continuous blue curve. The left hand panel contains the data and approximation for $c_{L_\alpha}(M)$, the center panel contains the data and approximation for $c_{D_o}(M)$, and the right hand panel contains the data and approximation for $\eta(M)$.

AMA_UnvLstsqr() - Least Squares Approximation of Univariate Data

The least squares approximation function AMA_UnvLstsqr() requires the independent variable data $x_\ell$, the dependent variable data $z_\ell$, the weights $w_\ell$, $\ell = 1,\ldots,N$; along with either the knot vector ${\bf\Lambda}$ or ${\bf\Lambda}^o$, see AMA_UnvLstsqr(). For this example the weights are $w_\ell=1.0$, for $1\le\ell\le 9$, and the knot vector ${\bf\Lambda}^o = (0.0,0.8,0.9,1.0,1.2,1.4,1.8)$ is used. This knot vector defines sufficient spline coefficients for the least squares approximation to interpolate the data, that is, $\max_\ell\vert s(M_\ell) - z_\ell\vert = 10^{-6}$. The resulting least squares approximations for the three coefficients are illustrated in Figure Least Squares Approximation of Coefficient Data.

Least Squares Approximation of Coefficient Data
$c_{L_\alpha}(M)$ $c_{D_o}(M)$ $\eta(M)$

Examination of the above plots shows for all three coefficients the curves interpolate the data but behave in a manner inconsistent with the data. For example, for all three coefficients the data indicates the coefficient is constant in the interval $M\in [0.0,0.8]$, but the approximations oscillate through the data points. Over the interval $M\in [0.8,1.0]$ the curves for $c_{L_\alpha}(M)$ and $c_{D_o}(M)$ attain a local minimum which is smaller than the data value at the endpoints. Also, the approximations for $c_{L_\alpha}(M)$ and $\eta(M)$ exceed the local maximum at $M=1.0$. Similar behavior occurs at $M=1.2$ for $c_{D_o}(M)$. In summary, the least squares approximations do not satisfy the local monotonicity constraints and attain local minimum and maximum inconsistent with the data.

AMA_UnvApprox() - Approximation of Univariate Data

The approximation function AMA_UnvApprox() requires the independent variable data $x_\ell$, the dependent variable data $z_\ell$ and the approximation tolerances $\epsilon_\ell$, $\ell = 1,\ldots,N$. The approximation tolerances used for this example are given in Table Approximation Tolerances. The tolerances are contrived and are based on the number of significant digits for the data. It would be better to define tolerances based on a statistical analysis of the process which produced the data, but the values defined below serve to illustrate the approximations produced by AMA_UnvApprox().

Approximation Tolerances
$M$ 0.0 0.4 0.8 0.9 1.0 1.2 1.4 1.6 1.8
$c_{L_\alpha}$ 0.005 0.005 0.005 0.005 0.005 0.005 0.005 0.005 0.005
$c_{D_o}$ 0.0005 0.0005 0.0005 0.0005 0.0005 0.0005 0.0005 0.0005 0.0005
$\eta$ 0.005 0.005 0.005 0.005 0.005 0.005 0.005 0.005 0.005

Based on the data AMA_UnvApprox() defines a knot vector ${\bf\Lambda}$ which provides sufficient spline coefficients to satisfy the approximation constraints $z_\ell - \epsilon_\ell \le s(M_\ell) \le z_\ell + \epsilon_\ell$, for $1\le\ell\le 9$,see AMA_UnvApprox(). Since the approximation tolerances can be equal to zero, the knot vector used by AMA_UnvApprox() does provides sufficient spline coefficients to interpolate the data. The resulting approximations for the three coefficients are illustrated in Figure Approximation of Coefficient Data.

Approximation of Coefficient Data
$c_{L_\alpha}(M)$ $c_{D_o}(M)$ $\eta(M)$

Because AMA_UnvApprox() minimizes the variation of the second derivative and the approximation tolerances are nonzero, these approximations do not interpolate the data even though the function defines a knot vector ${\bf\Lambda}$ which provides sufficient spline coefficients to interpolate. The nonzero approximation tolerances do mitigate the magnitude of the oscillations in the interval $M\in[0.0,0.8]$, but these approximations behave in much the same manner as the least squares approximations, that is; they do not satisfy the local monotonicity constraints and they attain local minimum and maximum inconsistent with the data.

AMA_UnvInterp() - Interpolation of Univariate Data

The interpolation function AMA_UnvInterp() requires the independent variable data $x_\ell$ and the dependent variable data $z_\ell$, for $\ell = 1,\ldots,N$. The knot vector ${\bf\Lambda}$ is defined by AMA_UnvInterp() and it provides sufficient spline coefficients to interpolate the data and to satisfy the boundary conditions $s^{(2)}(0.0) = 0.0$ and $s^{(2)}(1.8) = 0.0$, see AMA_UnvInterp(). The resulting interpolants for the three coefficients are illustrated in Figure Interpolation of Coefficient Data.

Interpolation of Coefficient Data
$c_{L_\alpha}(M)$ $c_{D_o}(M)$ $\eta(M)$

Although the second derivative boundary constraints mitigate the magnitude of the oscillations in the interval $M\in[0.0,0.4]$ they do not significantly improve the curve over the interval of constant data. The interpolants also do not satisfy the local monotonicity constraints and they attain local minimum and maximum inconsistent with the data. Such behavior can only be removed if explicit constraints are imposed on the approximations. Two functions which allow for the imposition of such constraints are presented in the following sections.

AMA_UnvMonoApprox() - Monotonic Approximation of Univariate Data

The monotonic approximation function AMA_UnvMonoApprox() requires the independent variable data $x_\ell$, the dependent variable data $z_\ell$ and the approximation tolerances $\epsilon_\ell$, $\ell = 1,\ldots,N$. The approximation tolerances given in the table in Section AMA_UnvApprox() - Approximation of Univariate Data were also used for this example. Based on the data AMA_UnvMonoApprox() defines a knot vector ${\bf\Lambda}$ which provides sufficient spline coefficients to satisfy the approximation constraints $z_\ell - \epsilon_\ell \le s(M_\ell) \le z_\ell + \epsilon_\ell$, for $1\le\ell\le 9$, and the local monotonicity constraints, see AMA_UnvMonoApprox() for a definition of the local monotonicity constraints it imposes. The resulting monotonic approximations for the three coefficients are illustrated in Figure Monotonic Approximation of Coefficient Data.

Monotonic Approximation of Coefficient Data
$c_{L_\alpha}(M)$ $c_{D_o}(M)$ $\eta(M)$

As expected the monotonic approximations satisfy the local monotonicity constraints and do not attain local minimum and maximum inconsistent with the data when the nonzero approximation tolerances are considered. Also, due to the nonzero approximation tolerances, they do not interpolate the data. Other notable features are apparent in $c_{D_o}(M)$ over the interval $M\in[1.6,1.8]$ and in $\eta(M)$ over the interval $M\in[1.0,1.2]$, where both approximations are constant, even through the data implies the curves should have a negative derivative. This suggests the contrived values for the approximation tolerances are too lenient, but they do serve to illustrate the effect of the tolerances on the approximation. Clearly, more realistic tolerances are required in order to produce approximations useful for solving the minimum time to climb problem. In the absence of more realistic tolerances a better representation of the aerodynamic coefficients can be obtained with the monotonic interpolation function discussed below.

AMA_UnvMonoInterp() - Monotonic Interpolation of Univariate Data

The monotonic interpolation function AMA_UnvMonoInterp() requires the independent variable data $x_\ell$ and the dependent variable data $z_\ell$, for $\ell = 1,\ldots,N$. The knot vector ${\bf\Lambda}$ is defined by AMA_UnvMonoInterp() and it provides sufficient spline coefficients to satisfy the interpolation constraints $s(M_\ell) = z_\ell$, for $1\le\ell\le 9$, and local monotonicity constraints, see AMA_UnvMonoInterp() for a definition of the local monotonicity constraints it imposes. The resulting monotonic interpolants for the three coefficients are illustrated in Figure Monotonic Interpolation of Coefficient Data.

Monotonic Interpolation of Coefficient Data
$c_{L_\alpha}(M)$ $c_{D_o}(M)$ $\eta(M)$

The plots above show that monotonic interpolants satisfy the local monotonicity constraints, never attain local minimum or maximum within an interval which exceed the data values at the interval's endpoints, and interpolate the data. However, there are features in the above interpolants which may be considered undesirable. For example, consider the $c_{D_o}(M)$ curve about $M=1.2$ at which the curve obtains it's global maximum. It appears the curve remains relatively flat over too large of an interval about $M=1.2$. Similar behavior can be seen in the $\eta(M)$ curve about the local maximum at $M=1.0$. That curve remains perfectly flat for most of the interval $M\in[1.0,1.2]$ before rapidly decreasing to obtain the local minimum at $M=1.2$. This behavior is a consequence of the default knot placement used for the monotonic interpolants and may nor may not be acceptable. If it is deemed unacceptable, then one solution is to use a quartic spline interpolant instead of a cubic. Also, since quartic splines have three continuous derivatives and representations of the coefficients with two continuous derivatives are sufficient for solving the minimum time to climb problem, the continuity of the quartic spline at the data points can be reduced by invoking AMA_OptionsSetContinuity() with kindex = 1 and continuity equal to AMA_Continuity_Reduced. The resulting monotonic quartic interpolants for the three coefficients are illustrated in Figure Monotonic Interpolation of Coefficient Data with Quartic Spline.

Monotonic Interpolation of Coefficient Data with Quartic Spline
$c_{L_\alpha}(M)$ $c_{D_o}(M)$ $\eta(M)$

Maintaining local monotonicity and local minimum and maximum are useful characteristics for determining if monotonic approximation or interpolation methods produce better data approximations than least squares or interpolation methods; but, they can not differentiate the quality of a monotonic quartic versus a monotonic cubic. However, the above plots indicate the quartic interpolant is arguably better than the cubic interpolant as they suggest the solution of the minimum time to climb problem based on the quartic interpolant is probably more realistic then the solution based on the cubic interpolant.