Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Spline interpolation

From Wikipedia, the free encyclopedia
Mathematical method
For broader coverage of this topic, seeSpline (mathematics).
This article includes a list ofgeneral references, butit lacks sufficient correspondinginline citations. Please help toimprove this article byintroducing more precise citations.(July 2021) (Learn how and when to remove this message)

In themathematical field ofnumerical analysis,spline interpolation is a form ofinterpolation where the interpolant is a special type ofpiecewisepolynomial called aspline. That is, instead of fitting a single, high-degree polynomial to all of the values at once, spline interpolation fits low-degree polynomials to small subsets of the values, for example, fitting nine cubic polynomials between each of the pairs of ten points,[clarification needed] instead of fitting a single degree-nine polynomial to all of them. Spline interpolation is often preferred overpolynomial interpolation because theinterpolation error can be made small even when using low-degree polynomials for the spline.[1] Spline interpolation also avoids the problem ofRunge's phenomenon, in which oscillation can occur between points when interpolating using high-degree polynomials.

Introduction

[edit]
Interpolation with cubic splines between eight points. Hand-drawn technical drawings for shipbuilding are a historical example of spline interpolation; drawings were constructed using flexible rulers that were bent to follow pre-defined points.

Originally,spline was a term for elastic rulers that were bent to pass through a number of predefined points, orknots. These were used to maketechnical drawings forshipbuilding and construction by hand, as illustrated in the figure.

We wish to model similar kinds of curves using a set of mathematical equations. Assume we have a sequence ofn+1{\displaystyle n+1} knots,(x0,y0){\displaystyle (x_{0},y_{0})} through(xn,yn){\displaystyle (x_{n},y_{n})}. There will be a cubic polynomialqi(x)=y{\displaystyle q_{i}(x)=y} between each successive pair of knots(xi1,yi1){\displaystyle (x_{i-1},y_{i-1})} and(xi,yi){\displaystyle (x_{i},y_{i})} connecting to both of them, wherei=1,2,,n{\displaystyle i=1,2,\dots ,n}. So there will ben{\displaystyle n} polynomials, with the first polynomial starting at(x0,y0){\displaystyle (x_{0},y_{0})}, and the last polynomial ending at(xn,yn){\displaystyle (x_{n},y_{n})}.

Thecurvature of any curvey=y(x){\displaystyle y=y(x)} is defined as

κ=y(1+y2)3/2,{\displaystyle \kappa ={\frac {y''}{(1+y'^{2})^{3/2}}},}

wherey{\displaystyle y'} andy{\displaystyle y''} are the first and second derivatives ofy(x){\displaystyle y(x)} with respect tox{\displaystyle x}.To make the spline take a shape that minimizes the bending (under the constraint of passing through all knots), we will define bothy{\displaystyle y'} andy{\displaystyle y''} to be continuous everywhere, including at the knots. Each successive polynomial must have equal values (which are equal to the y-value of the corresponding datapoint), derivatives, and second derivatives at their joining knots, which is to say that

{qi(xi)=qi+1(xi)=yiqi(xi)=qi+1(xi)qi(xi)=qi+1(xi)1in1.{\displaystyle {\begin{cases}q_{i}(x_{i})=q_{i+1}(x_{i})=y_{i}\\q'_{i}(x_{i})=q'_{i+1}(x_{i})\\q''_{i}(x_{i})=q''_{i+1}(x_{i})\end{cases}}\qquad 1\leq i\leq n-1.}

This can only be achieved if polynomials of degree 3 (cubic polynomials) or higher are used. The classical approach is to use polynomials of exactly degree 3 —cubic splines.

In addition to the three conditions above, anatural cubic spline has the condition thatq1(x0)=qn(xn)=0{\displaystyle q''_{1}(x_{0})=q''_{n}(x_{n})=0}.

In addition to the three main conditions above, aclamped cubic spline has the conditions thatq1(x0)=f(x0){\displaystyle q'_{1}(x_{0})=f'(x_{0})} andqn(xn)=f(xn){\displaystyle q'_{n}(x_{n})=f'(x_{n})} wheref(x){\displaystyle f'(x)} is the derivative of the interpolated function.

In addition to the three main conditions above, anot-a-knot spline has the conditions thatq1(x1)=q2(x1){\displaystyle q'''_{1}(x_{1})=q'''_{2}(x_{1})} andqn1(xn1)=qn(xn1){\displaystyle q'''_{n-1}(x_{n-1})=q'''_{n}(x_{n-1})}.[2]

Algorithm to find the interpolating cubic spline

[edit]

We wish to find each polynomialqi(x){\displaystyle q_{i}(x)} given the points(x0,y0){\displaystyle (x_{0},y_{0})} through(xn,yn){\displaystyle (x_{n},y_{n})}. To do this, we will consider just a single piece of the curve,q(x){\displaystyle q(x)}, which will interpolate from(x1,y1){\displaystyle (x_{1},y_{1})} to(x2,y2){\displaystyle (x_{2},y_{2})}. This piece will have slopesk1{\displaystyle k_{1}} andk2{\displaystyle k_{2}} at its endpoints. Or, more precisely,

q(x1)=y1,{\displaystyle q(x_{1})=y_{1},}
q(x2)=y2,{\displaystyle q(x_{2})=y_{2},}
q(x1)=k1,{\displaystyle q'(x_{1})=k_{1},}
q(x2)=k2.{\displaystyle q'(x_{2})=k_{2}.}

The full equationq(x){\displaystyle q(x)} can be written in the symmetrical form

q(x)=(1t(x))y1+t(x)y2+t(x)(1t(x))((1t(x))a+t(x)b),{\displaystyle q(x)={\big (}1-t(x){\big )}\,y_{1}+t(x)\,y_{2}+t(x){\big (}1-t(x){\big )}{\Big (}{\big (}1-t(x){\big )}\,a+t(x)\,b{\Big )},}1

where

t(x)=xx1x2x1,{\displaystyle t(x)={\frac {x-x_{1}}{x_{2}-x_{1}}},}2
a=k1(x2x1)(y2y1),{\displaystyle a=k_{1}(x_{2}-x_{1})-(y_{2}-y_{1}),}3
b=k2(x2x1)+(y2y1).{\displaystyle b=-k_{2}(x_{2}-x_{1})+(y_{2}-y_{1}).}4

But what arek1{\displaystyle k_{1}} andk2{\displaystyle k_{2}}? To derive these critical values, we must consider that

q=dqdx=dqdtdtdx=dqdt1x2x1.{\displaystyle q'={\frac {dq}{dx}}={\frac {dq}{dt}}{\frac {dt}{dx}}={\frac {dq}{dt}}{\frac {1}{x_{2}-x_{1}}}.}

It then follows that

q=y2y1x2x1+(12t)a(1t)+btx2x1+t(1t)bax2x1,{\displaystyle q'={\frac {y_{2}-y_{1}}{x_{2}-x_{1}}}+(1-2t){\frac {a(1-t)+bt}{x_{2}-x_{1}}}+t(1-t){\frac {b-a}{x_{2}-x_{1}}},}5
q=2b2a+(ab)3t(x2x1)2.{\displaystyle q''=2{\frac {b-2a+(a-b)3t}{{(x_{2}-x_{1})}^{2}}}.}6

Settingt =0 andt =1 respectively in equations (5) and (6), one gets from (2) that indeed first derivativesq′(x1) =k1 andq′(x2) =k2, and also second derivatives

q(x1)=2b2a(x2x1)2,{\displaystyle q''(x_{1})=2{\frac {b-2a}{{(x_{2}-x_{1})}^{2}}},}7
q(x2)=2a2b(x2x1)2.{\displaystyle q''(x_{2})=2{\frac {a-2b}{{(x_{2}-x_{1})}^{2}}}.}8

If now(xi,yi),i = 0, 1, ...,n aren + 1 points, and

qi=(1t)yi1+tyi+t(1t)((1t)ai+tbi),{\displaystyle q_{i}=(1-t)\,y_{i-1}+t\,y_{i}+t(1-t){\big (}(1-t)\,a_{i}+t\,b_{i}{\big )},}9

wherei = 1, 2, ...,n, andt=xxi1xixi1{\displaystyle t={\tfrac {x-x_{i-1}}{x_{i}-x_{i-1}}}} aren third-degree polynomials interpolatingy in the intervalxi−1xxi fori = 1, ...,n such thatq′i (xi) =q′i+1(xi) fori = 1, ...,n − 1, then then polynomials together define adifferentiable function in the intervalx0xxn, and

ai=ki1(xixi1)(yiyi1),{\displaystyle a_{i}=k_{i-1}(x_{i}-x_{i-1})-(y_{i}-y_{i-1}),}10
bi=ki(xixi1)+(yiyi1){\displaystyle b_{i}=-k_{i}(x_{i}-x_{i-1})+(y_{i}-y_{i-1})}11

fori = 1, ...,n, where

k0=q1(x0),{\displaystyle k_{0}=q_{1}'(x_{0}),}12
ki=qi(xi)=qi+1(xi),i=1,,n1,{\displaystyle k_{i}=q_{i}'(x_{i})=q_{i+1}'(x_{i}),\qquad i=1,\dots ,n-1,}13
kn=qn(xn).{\displaystyle k_{n}=q_{n}'(x_{n}).}14

If the sequencek0,k1, ...,kn is such that, in addition,q′′i(xi) =q′′i+1(xi) holds fori = 1, ...,n − 1, then the resulting function will even have a continuous second derivative.

From (7), (8), (10) and (11) follows that this is the case if and only if

ki1xixi1+(1xixi1+1xi+1xi)2ki+ki+1xi+1xi=3(yiyi1(xixi1)2+yi+1yi(xi+1xi)2){\displaystyle {\frac {k_{i-1}}{x_{i}-x_{i-1}}}+\left({\frac {1}{x_{i}-x_{i-1}}}+{\frac {1}{x_{i+1}-x_{i}}}\right)2k_{i}+{\frac {k_{i+1}}{x_{i+1}-x_{i}}}=3\left({\frac {y_{i}-y_{i-1}}{{(x_{i}-x_{i-1})}^{2}}}+{\frac {y_{i+1}-y_{i}}{{(x_{i+1}-x_{i})}^{2}}}\right)}15

fori = 1, ...,n − 1. The relations (15) aren − 1 linear equations for then + 1 valuesk0,k1, ...,kn.

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 withq′′ = 0. Asq′′ should be acontinuous function ofx, "natural splines" in addition to then − 1 linear equations (15) should have

q1(x0)=23(y1y0)(k1+2k0)(x1x0)(x1x0)2=0,{\displaystyle q''_{1}(x_{0})=2{\frac {3(y_{1}-y_{0})-(k_{1}+2k_{0})(x_{1}-x_{0})}{{(x_{1}-x_{0})}^{2}}}=0,}
qn(xn)=23(ynyn1)(2kn+kn1)(xnxn1)(xnxn1)2=0,{\displaystyle q''_{n}(x_{n})=-2{\frac {3(y_{n}-y_{n-1})-(2k_{n}+k_{n-1})(x_{n}-x_{n-1})}{{(x_{n}-x_{n-1})}^{2}}}=0,}

i.e. that

2x1x0k0+1x1x0k1=3y1y0(x1x0)2,{\displaystyle {\frac {2}{x_{1}-x_{0}}}k_{0}+{\frac {1}{x_{1}-x_{0}}}k_{1}=3{\frac {y_{1}-y_{0}}{(x_{1}-x_{0})^{2}}},}16
1xnxn1kn1+2xnxn1kn=3ynyn1(xnxn1)2.{\displaystyle {\frac {1}{x_{n}-x_{n-1}}}k_{n-1}+{\frac {2}{x_{n}-x_{n-1}}}k_{n}=3{\frac {y_{n}-y_{n-1}}{(x_{n}-x_{n-1})^{2}}}.}17

Eventually, (15) together with (16) and (17) constituten + 1 linear equations that uniquely define then + 1 parametersk0,k1, ...,kn.

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 thethird derivative is also continuous at thex1 andxn−1 points.For the "not-a-knot" spline, the additional equations will read:

q1(x1)=q2(x1)1Δx12k0+(1Δx121Δx22)k11Δx22k2=2(Δy1Δx13Δy2Δx23),{\displaystyle q'''_{1}(x_{1})=q'''_{2}(x_{1})\Rightarrow {\frac {1}{\Delta x_{1}^{2}}}k_{0}+\left({\frac {1}{\Delta x_{1}^{2}}}-{\frac {1}{\Delta x_{2}^{2}}}\right)k_{1}-{\frac {1}{\Delta x_{2}^{2}}}k_{2}=2\left({\frac {\Delta y_{1}}{\Delta x_{1}^{3}}}-{\frac {\Delta y_{2}}{\Delta x_{2}^{3}}}\right),}
qn1(xn1)=qn(xn1)1Δxn12kn2+(1Δxn121Δxn2)kn11Δxn2kn=2(Δyn1Δxn13ΔynΔxn3),{\displaystyle q'''_{n-1}(x_{n-1})=q'''_{n}(x_{n-1})\Rightarrow {\frac {1}{\Delta x_{n-1}^{2}}}k_{n-2}+\left({\frac {1}{\Delta x_{n-1}^{2}}}-{\frac {1}{\Delta x_{n}^{2}}}\right)k_{n-1}-{\frac {1}{\Delta x_{n}^{2}}}k_{n}=2\left({\frac {\Delta y_{n-1}}{\Delta x_{n-1}^{3}}}-{\frac {\Delta y_{n}}{\Delta x_{n}^{3}}}\right),}

whereΔxi=xixi1, Δyi=yiyi1{\displaystyle \Delta x_{i}=x_{i}-x_{i-1},\ \Delta y_{i}=y_{i}-y_{i-1}}.

Example

[edit]
Interpolation with cubic "natural" splines between three points

In case of three points the values fork0,k1,k2{\displaystyle k_{0},k_{1},k_{2}} are found by solving thetridiagonal linear equation system

[a11a120a21a22a230a32a33][k0k1k2]=[b1b2b3]{\displaystyle {\begin{bmatrix}a_{11}&a_{12}&0\\a_{21}&a_{22}&a_{23}\\0&a_{32}&a_{33}\\\end{bmatrix}}{\begin{bmatrix}k_{0}\\k_{1}\\k_{2}\\\end{bmatrix}}={\begin{bmatrix}b_{1}\\b_{2}\\b_{3}\\\end{bmatrix}}}

with

a11=2x1x0,{\displaystyle a_{11}={\frac {2}{x_{1}-x_{0}}},}
a12=1x1x0,{\displaystyle a_{12}={\frac {1}{x_{1}-x_{0}}},}
a21=1x1x0,{\displaystyle a_{21}={\frac {1}{x_{1}-x_{0}}},}
a22=2(1x1x0+1x2x1),{\displaystyle a_{22}=2\left({\frac {1}{x_{1}-x_{0}}}+{\frac {1}{x_{2}-x_{1}}}\right),}
a23=1x2x1,{\displaystyle a_{23}={\frac {1}{x_{2}-x_{1}}},}
a32=1x2x1,{\displaystyle a_{32}={\frac {1}{x_{2}-x_{1}}},}
a33=2x2x1,{\displaystyle a_{33}={\frac {2}{x_{2}-x_{1}}},}
b1=3y1y0(x1x0)2,{\displaystyle b_{1}=3{\frac {y_{1}-y_{0}}{(x_{1}-x_{0})^{2}}},}
b2=3(y1y0(x1x0)2+y2y1(x2x1)2),{\displaystyle b_{2}=3\left({\frac {y_{1}-y_{0}}{{(x_{1}-x_{0})}^{2}}}+{\frac {y_{2}-y_{1}}{{(x_{2}-x_{1})}^{2}}}\right),}
b3=3y2y1(x2x1)2.{\displaystyle b_{3}=3{\frac {y_{2}-y_{1}}{(x_{2}-x_{1})^{2}}}.}

For the three points

(1,0.5), (0,0), (3,3),{\displaystyle (-1,0.5),\ (0,0),\ (3,3),}

one gets that

k0=0.6875, k1=0.1250, k2=1.5625,{\displaystyle k_{0}=-0.6875,\ k_{1}=-0.1250,\ k_{2}=1.5625,}

and from (10) and (11) that

a1=k0(x1x0)(y1y0)=0.1875,{\displaystyle a_{1}=k_{0}(x_{1}-x_{0})-(y_{1}-y_{0})=-0.1875,}
b1=k1(x1x0)+(y1y0)=0.3750,{\displaystyle b_{1}=-k_{1}(x_{1}-x_{0})+(y_{1}-y_{0})=-0.3750,}
a2=k1(x2x1)(y2y1)=3.3750,{\displaystyle a_{2}=k_{1}(x_{2}-x_{1})-(y_{2}-y_{1})=-3.3750,}
b2=k2(x2x1)+(y2y1)=1.6875.{\displaystyle b_{2}=-k_{2}(x_{2}-x_{1})+(y_{2}-y_{1})=-1.6875.}

In the figure, the spline function consisting of the two cubic polynomialsq1(x){\displaystyle q_{1}(x)} andq2(x){\displaystyle q_{2}(x)} given by (9) is displayed.

See also

[edit]

References

[edit]
  1. ^Hall, Charles A.; Meyer, Weston W. (1976)."Optimal Error Bounds for Cubic Spline Interpolation".Journal of Approximation Theory.16 (2):105–122.doi:10.1016/0021-9045(76)90040-X.
  2. ^Burden, Richard; Faires, Douglas (2015).Numerical Analysis (10th ed.). Cengage Learning. pp. 142–157.ISBN 9781305253667.

Further reading

[edit]

External links

[edit]
Retrieved from "https://en.wikipedia.org/w/index.php?title=Spline_interpolation&oldid=1325889537"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp