16.2 Interpolate/Extrapolate Y from XMathInterExtrapoltateYfromX
Overview
Interpolation is a method of estimating and constructing new data points from a discrete set of known data points. Given an X vector, this function interpolates a vector Y based on the input curve (XY Range). Origin provides four options for data interpolation: Linear, Cubic spline, Cubic Bspline, Akima Spline.
Linear interpolation is the simplest and fastest data interpolation method. In linear interpolation, the arithmetic mean of two adjacent data points is calculated. This method is useful in situations where low precision can be tolerated. Linear interpolation is also useful for extremely large data sets, because the calculations are not time or computationpower intensive.
The generalization of linear interpolation is polynomial interpolation. Polynomial interpolation requires much more computation power than linear interpolation and when the polynomial order is high, the fit of the data oscillates wildly. These disadvantages can be avoided by using loworder polynomial fitting, or spline interpolation.
The Cubic spline method uses 3^{rd} order polynomials, and executes datafitting in a piecewise fashion. Spline interpolation incurs less error than linear interpolation, and the interpolant is smoother.
Similar to Cubic spline interpolation, Cubic Bspline interpolation also fits the data in a piecewise fashion, but it uses 3^{rd} order Bezier splines to approximate the data. Cubic BSplines allow the accurate modeling of more general classes of geometry.
To Interpolate Y from X
 Create a new worksheet with input data.
 Select desired data.
 Select Analysis: Mathematics:Interpolate/Extrapolate Y from X. This opens the interp1 dialog.
The interp1 XFunction is called to perform the calculation.
Note: To generate uniform linearly spaced interpolated values, use the Interpolate/Extrapolate... menu command.
Dialog Options
Recalculate

Controls recalculation of analysis results
For more information, see: Recalculating Analysis Results

X Values to Interpolate

The X column to interpolate on.

Input

The reference XY column(s) by which to interpolate Y from specify X column. Multiple XY columns can be choosed. If multiXY are selected, each set of XY will be used as reference to interpolate the same X column and output the corresponding Y column and the coefficient value.
For help with range controls, see: Specifying Your Input Data

Method

Specify interpolation methods
 Linear
 Linear interpolation is a fast method of estimating a data point by constructing a line between two neighboring data points. The resulting point may not be an accurate estimation of the missing data.
 Cubic Spline
 This method splits the input data into a given number of pieces, and fits each segment with a cubic polynomial. The second derivative of each cubic function is set equal to zero. With these boundary conditions met, an entire function can be constructed in a piecewise manner.
 Cubic BSpline
 This method also splits the input data into pieces, each segment is fitted with discrete Bezier splines.
 Akima Spline
 This method is based on a piecewise function composed of a set of polynomials. The akima interpolation is stable to outliers.

Extrapolate Option

When parts of the data range specified by X Values to Interpolate is outside that of the X range specified in Input, these range parts will be considered as the extrapolated range, because the resulted Y values for these parts will be computed from extrapolation. This option can then be used to specify how to extrapolate the corresponding Y values.
 Extrapolate
 Extrapolate Y using the last two points
 Set missing
 Set all Y values in the extrapolated range to be missing values.
 Repeat the last value
 Use the Y value of the closest input X value for all values in the extrapolated range.

Boundary

Boundary condition is only available in cubic spline method.
 Natural
 2nd derivatives are 0 on both ends.
 NotAKnot
 3rd derivatives are continuous on the second and lastsecond point.

Smoothing Factor

Smoothing is only available in Cubic BSpline method.

Result of interpolation

The Y column(s) to output the inteplated Y values.

Coefficients

Output the coefficients for Spline or Bspline method or not, and show them in which column.

Algorithm
Given a sequence of distinct pairs of data (, ), where . we are looking for the interpolated at by the following methods:
1. Linear interpolation (interp1q)
For
For
For
2. Cubic spline (spline)
Origin uses the natural cubic spline to do interpolation:
where:
And can be generated from:
For boundary points, we set and equal to zero.
3. Cubic Bspline (bspline)
For or perform linear interpolation.
For
Here, denotes the normalized cubic Bspline defined upon the knots , , ..., , And denotes the coefficient of the corresponding function.
The total number of these knots and their values , ..., are chosen automatically by the function. The knots , ..., are the interior knots; they divide the approximation interval [, ] in to subintervals. The coefficients , , ..., are then determined as the solution of the following constrained minimization problem:
minimize
subject to the constraint
where stands for the discontinuity jump in the third order derivative of at the interior knot , denotes the weighted residual , and S is a nonnegatative number to be specified by the user.
The quantity can be seen as a measure of the (lack of) smoothness of , while closeness of fit is measured through . By means of the parameter , 'the smoothing factor', the user will then control the balance between these two (usually conflicting) properties. If is too large, the spline will be too smooth and signal will be lost (underfit); if is too small, the spline will pick up too much noise (overfit). In the extreme cases the function will return an interpolating spline (=0) is is set to zero, and the weighted leastsquares cubic polynomial (=0) is if set very large. Experimenting with values between these two extremes should result in a good compromise.
4. Akima Spline (akima)
The Akima interpolation method is based on a piecewise function composed of a set of polynomials(third degree at most). This piecewise function can be applied to successive intervals of the given XY points. The slope of the input data plot at each given point can be assumed to be determined by the XY coordinates of 4 neighbor points and the point itself. Then from the slopes at two paired given points and their coordinates, a third degree polynomial is calculated, representing the interval curve between these two points, and the interpolation is then carried out based on the combination of polynomials. An additional estimation is made when calculating polynomials for end points.
Firstly the curve slope at a given point will be calculated. For a given point (point 3), there will then be five data points 1,2,3,4,5, and are slopes of line segments respectively, and . The curve slope is then determined by the following equations under different conditions:
When or ,
When and ,
Slopes for two end points need to be estimated at each end of the curve. To estimate them, we calculate its slope by interpolating a parabolic curve from its adjacent three points, e.g. for the first point's slope, we can interpolate a parabolic curve from first three points, and the first point's slope can be calculated by the derivative of the interpolated curve.
Then the polynomial for an interval between two consecutive data points and are determined by the following four conditions:


where and are the slopes at the two points.
References
1. Michelle Schatzman. Numerical Analysis: A Mathematical Introduction, Chapters 4 and 6. Clarendon Press, Oxford (2002).
2. William H. Press, etc. Numerical Recipes in C++. 2^{nd} Edition. Cambridge University Press (2002).
3. Nag C Library Function Document, nag_1d_spline_fit (e02bec).
4. Hiroshi Akima, Journal of the Association for Computing Machinery, Vol. 17, No. 4, (1970)
