对于给定点的数据集,我们可以用段三次多项式在数据点之间构建一个三次样条.如果表示对函数进行插值的样条函数,那么需要:
其中一项选择条件可以得到给定与的钳位三次样条(clamped cubic spline),另外,我们可以设这样就得到自然三次样条.自然三次样条几乎等同于样条设备生成的曲线.
在这些所有的二次连续可导函数中,钳位与自然三次样条可以得到相对于待插值函数的最小震荡.
如果选择另外一些条件,可以得到周期性的三次样条.
如果选择,可以得到complete三次样条.
Algorithm to find the interpolating cubic spline
We wish to find each polynomial given the points through . To do this, we will consider just a single piece of the curve, , which will interpolate from to . This piece will have slopes and at its endpoints. Or, more precisely,
The full equation can be written in the symmetrical formwhere
But what are and ? To derive these critical values, we must consider thatIt then follows thatSetting and respectively in equations and , one gets from that indeed first derivatives and , and also second derivativesIf now are points, andwhere , and are third-degree polynomials interpolating in the interval for such that for , then the polynomials together define a differentiable function in the interval , andfor , whereIf the sequence is such that, in addition, holds for , then the resulting function will even have a continuous second derivative.
From ,, and follows that this is the case if and only iffor . The relations are linear equations for the values .
For the elastic rulers being the model for the spline interpolation, one has that to the left of the left-most "knot" and to the right of the right-most "knot" the ruler can move freely and will therefore take the form of a straight line with . As should be a continuous function of , "natural splines" in addition to the linear equations should havei.e. that
Eventually, together with and constitute linear equations that uniquely define the parameters .
There exist other end conditions, "clamped spline", which specifies the slope at the ends of the spline, and the popular "not-a-knot spline", which requires that the third derivative is also continuous at the and points.
For the "not-a-knot" spline, the additional equations will read:where .
Example
In case of three points the values for are found by solving the tridiagonal linear equation system with
For the three points
one gets that
and from and that
In the figure, the spline function consisting of the two cubic polynomials and given by is displayed.
- 插值特性,
- 样条相连,
- 二阶可导,以及.
其中一项选择条件可以得到给定与的钳位三次样条(clamped cubic spline),另外,我们可以设这样就得到自然三次样条.自然三次样条几乎等同于样条设备生成的曲线.
在这些所有的二次连续可导函数中,钳位与自然三次样条可以得到相对于待插值函数的最小震荡.
如果选择另外一些条件,可以得到周期性的三次样条.
如果选择,可以得到complete三次样条.
Algorithm to find the interpolating cubic spline
We wish to find each polynomial given the points through . To do this, we will consider just a single piece of the curve, , which will interpolate from to . This piece will have slopes and at its endpoints. Or, more precisely,
The full equation can be written in the symmetrical formwhere
But what are and ? To derive these critical values, we must consider thatIt then follows thatSetting and respectively in equations and , one gets from that indeed first derivatives and , and also second derivativesIf now are points, andwhere , and are third-degree polynomials interpolating in the interval for such that for , then the polynomials together define a differentiable function in the interval , andfor , whereIf the sequence is such that, in addition, holds for , then the resulting function will even have a continuous second derivative.
From ,, and follows that this is the case if and only iffor . The relations are linear equations for the values .
For the elastic rulers being the model for the spline interpolation, one has that to the left of the left-most "knot" and to the right of the right-most "knot" the ruler can move freely and will therefore take the form of a straight line with . As should be a continuous function of , "natural splines" in addition to the linear equations should havei.e. that
Eventually, together with and constitute linear equations that uniquely define the parameters .
There exist other end conditions, "clamped spline", which specifies the slope at the ends of the spline, and the popular "not-a-knot spline", which requires that the third derivative is also continuous at the and points.
For the "not-a-knot" spline, the additional equations will read:where .
Example
In case of three points the values for are found by solving the tridiagonal linear equation system with
For the three points
one gets that
and from and that
In the figure, the spline function consisting of the two cubic polynomials and given by is displayed.