CurveFitting - Maple Programming Help

CurveFitting

 Spline
 compute a spline with specified end conditions

 Calling Sequence Spline(xydata, v, dgr, endpts) Spline(xdata, ydata, v, dgr, endpts)

Parameters

 xydata - list, Array, DataFrame, or Matrix of the form [[x0,y0], [x1,y1], ..., [xn,yn]]; data points xdata - list, Array, DataSeries, or Vector of the form [x0, x1, ..., xn]; independent values ydata - list, Array, DataSeries, or Vector or the form [y0, y1, ..., yn]; dependent values v - name or numeric value dgr - (optional) equation of the form degree=d where d is a positive integer endpts - (optional) equation of the form endpoints=e where e is one of 'natural', 'notaknot', or 'periodic' or is a list, Array, Matrix, or Vector

Description

 • The Spline routine computes a degree d piecewise polynomial in variable v that approximates the points $\left\{\left(\mathrm{x0},\mathrm{y0}\right),\left(\mathrm{x1},\mathrm{y1}\right),...,\left(\mathrm{xn},\mathrm{yn}\right)\right\}$.
 If v is a numerical value, the value of the polynomial at this point returns.  The default value of d is 3; this can be changed by using the degree=d option.
 • The intended purpose of the Spline function is to compute and return the piecewise formula of a spline interpolant.  To perform fast spline interpolation on numeric data, the CurveFitting[ArrayInterpolation] command should be used instead.
 • By default, natural end conditions are used.  This can be changed by using the endpoints=e option.  For more details on the other types of end conditions available, see Spline Continuity and End Conditions.
 • You can call the Spline routine in two ways.
 The first, Spline(xydata, v, dgr, endpts), accepts a list, Array, or Matrix, $[[\mathrm{x0},\mathrm{y0}],[\mathrm{x1},\mathrm{y1}],...,[\mathrm{xn},\mathrm{yn}]]$, of data points.
 The second, Spline(xdata, ydata, v, dgr, endpts), accepts two lists, two Arrays, or two Vectors. In this form, the first set of data contains the independent values, $[\mathrm{x0},\mathrm{x1},...,\mathrm{xn}]$, and the second set contains the dependent values, $[\mathrm{y0},\mathrm{y1},...,\mathrm{yn}]$.  Each element must be of type algebraic. All the independent values must be distinct.
 • The result returned by the Spline routine is determined by the degree d.
 If d is odd, the Spline routine returns a result in the form $\mathrm{piecewise}\left(v<{x}_{1},{p}_{1},...,{p}_{n}\right)$, where the n spline sections $\left\{{p}_{1},{p}_{2},...,{p}_{n}\right\}$ are polynomials of degree at most d.
 If d is even, the routine defines the spline knots at the midpoints of the nodes, unless the knots=data option is specified. In the default case, the Spline routine returns a result in the form $\mathrm{piecewise}\left(v<{z}_{1},{p}_{1},...,v<{z}_{n},{p}_{n},{p}_{n+1}\right)$, where ${z}_{i}=\frac{{x}_{i-1}}{2}+\frac{{x}_{i}}{2}$, for $i=1,2,...,n$, and the $n+1$ spline sections $\left\{{p}_{1},{p}_{2},...,{p}_{n+1}\right\}$ are polynomials of degree at most d. In the knots=data case, the result will have n spline sections and be of the form $\mathrm{piecewise}\left(v<{x}_{1},{p}_{1},...,{p}_{n}\right)$.
 For more details on the formation of the piecewise polynomials and additional examples involving different end conditions, see the Spline Continuity and End Conditions help page.
 • If a unique solution cannot be determined from the input data, a parametrized solution that uses parameters of the form a[i, j], where a is an automatically generated name, and i and j are integers, is returned.
 • For greater efficiency in large problems, it is recommended that xdata and ydata be stored as Vectors using a float datatype.  For the degree 2 and degree 3 cases involving floating-point data only, the Spline command uses a more efficient algorithm that takes advantage of the external Numerical Algorithms Group (NAG) library for solving the resulting matrix equations.

Examples

 > $\mathrm{with}\left(\mathrm{CurveFitting}\right):$
 > $\mathrm{Spline}\left(\left[\left[0,0\right],\left[1,1\right],\left[2,4\right],\left[3,3\right]\right],v\right)$
 $\left\{\begin{array}{cc}\frac{{4}}{{5}}{}{{v}}^{{3}}{+}\frac{{1}}{{5}}{}{v}& {v}{<}{1}\\ {-}{2}{}{{v}}^{{3}}{+}\frac{{42}}{{5}}{}{{v}}^{{2}}{-}\frac{{41}}{{5}}{}{v}{+}\frac{{14}}{{5}}& {v}{<}{2}\\ \frac{{6}}{{5}}{}{{v}}^{{3}}{-}\frac{{54}}{{5}}{}{{v}}^{{2}}{+}\frac{{151}}{{5}}{}{v}{-}\frac{{114}}{{5}}& {\mathrm{otherwise}}\end{array}\right\$ (1)
 > $\mathrm{Spline}\left(\left[\left[0,0\right],\left[1,5\right],\left[2,-1\right],\left[3,0\right]\right],v,\mathrm{degree}=2,\mathrm{endpoints}='\mathrm{periodic}'\right)$
 $\left\{\begin{array}{cc}\frac{{16}}{{5}}{}{{v}}^{{2}}{+}\frac{{24}}{{5}}{}{v}& {v}{<}\frac{{1}}{{2}}\\ {-}\frac{{44}}{{5}}{}{{v}}^{{2}}{+}\frac{{84}}{{5}}{}{v}{-}{3}& {v}{<}\frac{{3}}{{2}}\\ \frac{{28}}{{5}}{}{{v}}^{{2}}{-}\frac{{132}}{{5}}{}{v}{+}\frac{{147}}{{5}}& {v}{<}\frac{{5}}{{2}}\\ \frac{{16}}{{5}}{}{{v}}^{{2}}{-}\frac{{72}}{{5}}{}{v}{+}\frac{{72}}{{5}}& {\mathrm{otherwise}}\end{array}\right\$ (2)
 > $\mathrm{Spline}\left(\left[0,1,2,3\right],\left[0,1,4,3\right],v,\mathrm{degree}=1\right)$
 $\left\{\begin{array}{cc}{v}& {v}{<}{1}\\ {-}{2}{+}{3}{}{v}& {v}{<}{2}\\ {6}{-}{v}& {\mathrm{otherwise}}\end{array}\right\$ (3)