## functions in spline.i - t

tspline

d2ydx2= tspline(tension, y, x) -or- yp= tspline(tension, d2ydx2, y, x, xp) -or- yp= tspline(tension, y, x, xp) computes a tensioned spline curve passing through the points (X, Y). The first argument, TENSION, is a positive number which determines the "tension" in the spline. In a cubic spline, the second derivative of the spline function varies linearly between the points X. In the tensioned spline, the curvature is concentrated near the points X, falling off at a rate proportional to the tension. Between the points of X, the function varies as: y= C1*exp(k*x) + C2*exp(-k*x) + C3*x + C4 The parameter k is proportional to the TENSION; for k->0, the function reduces to the cubic spline (a piecewise cubic function), while for k->infinity, the function reduces to the piecewise linear function connecting the points. The TENSION argument may either be a scalar value, in which case, k will be TENSION*(numberof(X)-1)/(max(X)-min(X)) in every interval of X, or TENSION may be an array of length one less than the length of X, in which case the parameter k will be abs(TENSION/X(dif)), possibly varying from one interval to the next. You can use a variable tension to flatten "bumps" in one interval without affecting nearby intervals. Internally, tspline forces k*X(dif) to lie between 0.01 and 100.0 in every interval, independent of the value of TENSION. Typically, the most dramatic variation occurs between TENSION of 1.0 and 10.0. With three arguments, Y and X, spline returns the derivatives D2YDX2 at the points, an array of the same length as X and Y. The D2YDX2 values are chosen so that the tensioned spline function returned by the five argument call will have a continuous first derivative. The X array must be strictly monotonic; it may either increase or decrease. The values Y and the derivatives D2YDX2 uniquely determine a tensioned spline function, whose value is returned in the five argument form. In this form, tspline is analogous to the piecewise linear interpolator interp; usually you will regard it as a continuous function of its fifth (or fourth) argument, XP. The XP array may have any dimensionality; the result YP will have the same dimensions as XP. The D2YDX2 argument will normally have been computed by a previous call to the three argument tspline function. If you will be computing the values of the spline function for many sets of XP, use this five argument form. If you only want the tspline evaluated at a single set of XP, use the four argument form. This is equivalent to: yp= tspline(tension, tspline(tension,y,x), y, x, xp) The keywords DYDX1 and DYDX0 can be used to set the values of the returned DYDX(1) and DYDX(0) -- the first and last values of the slope, respectively. If either is not specified or nil, the slope at that end will be chosen so that the second derivative is zero there. The function tspline (tensioned spline) gives an interpolation function which lies between spline and interp, at the cost of requiring you to specify another parameter (the tension). Interpreted function, defined at i/spline.i line 122SEE ALSO: interp, tspline