Professional Documents
Culture Documents
In this lecture we consider piecewise cubic interpolation in which a cubic polynomial approximation is assumed over
each subinterval. In order to obtain sufficient information to determine these coefficients, we require continuity of the
interpolating polynomials in neighboring intervals as well as the continuity of a number of derivatives. Depending on
the number of derivatives that we require to be continuous at the ”stitching points” we obtain different approximation
schemes in which additional data about the function f (x) being approximated might have to be furnished in order that
there is sufficient data to determine the coefficients of the cubic polynomials.
Key Concepts: Piecewise cubic interpolation, Cubic Splines, Cubic Hermite Interpolation.
Consider the domain [a, b] that is partitioned into N intervals having N + 1 nodes and N − 1 internal nodes. In each
of these subintervals assume that different a cubic polynomial is to be constructed. Let p3,N (x) be the combination
of all these cubic polynomials. We now discuss the alternative approximation schemes that one obtains depending
on the different schemes of constraint.
Schemes of constraint:
(1) Piecewise Cubic Hermite polynomials: p3,N (x) and p03,N (x) are continuous at interior nodes.
There are four unknown coefficients for each of the N intervals and 2(N − 1) constraints due to the continuity
requirements on p3,N (x) and p03,N (x).
(2) Cubic Spline: p3,N (x), p03,N (x), and p003,N (x) are all continuous at interior points.
⇒ DOF : 4N − 3(N − 1) = N + 3 = N + 1 +2
| {z }
⇒ specify f at all N + 1 nodes
and impose 2 EXTRA CONDITIONS
The extra conditions are up to the user to prescribe depending on the application, e.g. p003 (x0 ) = 0 = p003 (xN )
which is called the natural spline.
2
4.2 Piecewise Cubic Hermite polynomials
x0 x1 xN
=a =L
where )
(0) d (1)
hi (xj ) = δij and dx hi (xj ) = δij
d (0) (1) (1)
dx hi (xj ) = 0 hi (xj ) =0
Constructing basis functions on the canonical interval [−1, 1]:
(0) (0)
h1 h2
We use the linear Lagrange basis func-
tions
1
Na1 (ξ) = (1+ξa ξ) : Na1 (ξb ) = δab , ξa,b = ±1 (1)
h1
2
Let -1 0 1
ξ
(1)
(0) (0) h2
h1 (ξ) = (α1 ξ + β1 )[N11 (ξ)]2 ; h2 (ξ) = (α2 ξ + β)[N21 (ξ)]2
(1) (1)
h1 (ξ) = (γ1 ξ + δ1 )[N11 (ξ)]2 ; h2 (ξ) = (γ2 ξ + δ2 )[N21 (ξ)]2
(1) (1)
Use the linear transformation x(ξ) = xi N1 (ξ) + xi+1 N2 (ξ)
1 1
= xi (1 − ξ) + xi+1 (1 + ξ)
µ 2 ¶ 2
xi + xi+1 (xi+1 − xi )
= + ξ
2 2
2x − (xi + xi+1 ) 2x − (xi + xi+1 )
The inverse transformation is: ξ(x) = =
(xi+1 − xi ) ∆xi
Error involved:
For function values the error is given by:
4
|f (x) − h(x)| ≤ ||f (4) ||∞ ∆x
384
while for derivatives the error is :
√
3∆x3
|f 0 (x) − h0 (x)| ≤ ||f (4) ||∞ 216
4
4.3 Piecewise Cubic Spline interpolation
Since we have similar piecewise cubic polynomials to the Piecewise Cubic Hermite polynomials on each subinterval
but with additional continuity required at the N − 1 interior nodes, our starting point is the Hermite cubic basis
expansion. We then impose additional conditions to make up for the derivatives f 0 (xi ) which are not known (or
required) in the case of splines.
∆xk s0k−1 + 2(∆xk + ∆xk−1 )s0k + ∆xk−1 s0k+1 = 3(f [xk , xk+1 ]∆xk−1 + f [xk−1 , xk ]∆xk )
We have N − 1 equations and (N + 1) unknowns s00 , s01 , . . . , s0N so we need 2 more conditions. Say we specify
Yi (x)
xi xi+1
Let Yi (x) = ai (x − xi )3 + bi (x − xi )2 + ci (x − xi ) + di
Yi0 (x) = 3ai (x − xi )2 + 2bi (x − xi ) + ci
Yi00 (x) = 6ai (x − xi ) + 2bi
yi = Yi (xi ) = di yi+1 = Yi (xi+1 ) = ai h3i + bi h2i + ci hi + yi where hi = xi+1 − xi .
Let s0i = Yi0 (xi ) = ci s0i+1 = Yi0 (xi+1 ) = 3ai h2i + 2bi hi + s0i
Yi00 (xi ) = 2bi = Yi−100
(xi ) = 6ai−1 hi−1 + 2bi−1
· 3 2
¸· ¸ · ¸
hi hi ai yi+1 − yi − s0i hi
=
3h2i 2hi bi s0i+1 − s0i
Á Á
ai = 2hi (yi+1 − yi − si hi ) (−hi ) − (si+1 − si )hi (−h4i )
0 4 0 0 2
n oÁ
3 0 0 2 0
bi = hi (si+1 − si ) − 3hi (yi+1 − yi − si hi ) (−h4i )
µ ¶
yi+1 − yi s0i+1 + s0i
∴ ai = −2 +
h3i h2
µ ¶ µ 0 i ¶
yi+1 − yi si+1 + 2s0i
bi = 3 −
h2i hi
µ 0 ¶
6 ∆yi 2 ¡ 0 ¢ −12 ∆yi−1 s + s0i−1 6 ∆yi−1 (s0 + 2s0i−1 )
∴ − si+1 + 2s0i = +6 i + −2 i
hi hi hi hi−1 hi−1 hi−1 hi−1 hi−1 hi−1
∆yi ∆yi−1
∴ 6( hi−1+ hi ) = 2hi−1 s0i+1 + 4hi−1 s0i + 4hi s0i + 2hi s0i−1
hi hi−1
∴ hi−1 s0i+1 + 2(hi−1 + hi )s0i + hi s0i−1 = 3(f [xi−1 , xi ]hi + f [xi , xi+1 ]hi−1 ).
6
4.3.3 Another spline derivation with s00i as primary variables
yi−1 yi+1
yi
hi
xi−1 xi xi+1
Let Yi (x) = ai (x − xi )3 + bi (x − xi )2 + ci (x − xi ) + di
Yi0 (x) = 3ai (x − xi )2 + 2bi (x − xi ) + ci
Yi00 (x) = 6ai (x − xi ) + 2bi
at xi : yi = Yi (xi ) = di ← interpolates the function at xi (4.5)
yi+1 = Yi (xi+1 ) = ai h3i + bi h2i + ci hi + yi ← enforce continuity (4.6)
s00
i+1 −si
00
Build in continuity of Y 00 ⇒ s00i+1 = Yi00 (xi+1 ) = 6ai hi + s00i ⇒ ai = 6hi (4.8)
µ ¶
s00i+1 − s00i s00
∴ Yi (x) = (x − xi )3 + (x − xi )2 + ci (x − xi ) + yi
6hi 2
µ 00 00 ¶ 00
si+1 − si s
(2) ⇒ yi+1 = h3i + i h2i + ci hi + yi
6hi 2
µ ¶ µ 00 ¶
yi+1 − yi si+1 − s00i s00
ci = − hi − i hi
hi 6 2
µ 00 00 ¶
∆yi si+1 + 2si
= − hi
hi 6
Impose continuity of first derivatives:
³ ´
∆yi ∆yi−1
hi−1 s00i−1 (−3 + 6 − 2) + (2hi + 2hi−1 )s00i + hi s00i+1 =6 hi − hi−1
or
³ ´
∆yi ∆yi−1
hi−1 s00i−1 + (2hi + 2hi−1 )s00i + hi s00i+1 =6 hi − hi−1
i = 1, . . . N − 1 N − 1 EQ
2 EXTRA CONDITIONS
Interpolation 7
4.3.4 Extra Conditions
yn−1 (x)
y0 y1
h0 hn−1
x0 x1 xN −1 XN
s001
(2h0 + 2h1 ) h1 y2 −y1
− y1 −y0
h1 s002 h1 h0
(2h 1 + 2h2 ) h2 y3 −y2
− y2 −y1
h2 h1
..
.
..
.
= 6 .
. .. ..
. . . ..
..
.
.
hN −2
yN −yN −1 yN −1 −yN −2
hN −2 (2hN −2 + 2hN −1 ) −
s00N −1 hN −1 hN −2
2h0 h0 s000 (y1 − y0 )/h0 − A
h0 (2h0 + 2h1 ) h1 s001 (y2 − y1 )/h1 − y1h−y 0
0
..
= 6 .
..
.
00
hn−2 (2hn−2 + 2hn−1 ) hn−1 sN −1 (yn − yn−1 )/hn−1 − (yn−1 − yn−2 )/hn−2
hn−1 2hn−1 s00N B − yny −y n−1
hn−1
8
3. Quadratic boundary interval representation
³ ´
s00
1 −s0
00 s00 00
N −sN −1
a0 = 6h0 =0 an−1 = 6hN −1
∴ a quadratic a quadratic
s00
(3h0 + 2h1 ) h1 0 1 f [x1 , x2 ] − f [x0 , x1 ]
h1 (2h + 2h ) h 0 0 s002
1 2 2
.
.
. = 6
(2hN −3 + 2hN −2 )hN −2
hN −2 (2hN −2 + 3hN −1 ) s00N −1 f [xN −1 , xN ) − f [xN −2 , xN −1 ]
4. Linear extrapolation
S 00 (x)
S 00 2
S 00 1
S 00 0
x0 x1 x2
Unknowns = 4(N − 2)
Constraints = 3(N − 3)
h0
(2 + h1 )(h0 + h1 ) (1 − hh10 )(h1 + h0 ) 0 ... 0
s001
h1 2(h1 + h2 ) h2 0 ...
0 s00
0 2
..
.
s00
hN −2 N −2
(1 − hN −1 hN −1 s00N −1
hN −2 )(hN −2 + hN −1 ) (2 + hN −2 )(hN −2 + hN −1 )
6. A periodic spline:
In order to impose this condition it is convenient to consider the s00k as unknowns in which case the equations become:
∆xk s00k−1 + 2(∆xk + ∆xk+1 )s00k + ∆xk+1 s00k+1 = 6(f [xk , xk+1 ] − f [xk−1 , xk ]) k = 1, . . . , N − 1.
Important identity: (y 00 − s00 )[(y 00 − s00 ) + 2s00 ] = (y 00 − s00 )(y 00 + s00 ) = (y 00 )2 − (s00 )2
NOTE:
Rb
If we choose s : s00 (a) = 0 = s00 (b) for example or if y and s both interpolate f 0 at a and b then s00 (y 00 −s00 )dx =
a
0.
Zb Zb Zb Zb
00 00
2 00 00 2 00 2
∴ y dx = (y − s ) dx + (s ) dx ≥ s 2 dx.
a a a a
Thus s is the interpolant with the MINIMUM CURVATURE (i.e. smoothest)
(2) Error involved in spline interpolation:
∆x̄4
|f (x) = s(x)| ≤ ||f (4) ||∞ 5 ∆x̄ = max ∆x : for nonuniform points and all x ∈ [x0 , xN ]
384
3
∆x̄
|f 0 (x) − s0 (x)| ≤ ||f (4) ||∞ for nonuniform points and all x ∈ [x0 , xN ]
24
4
∆x
|f 0 (xi ) − s0 (xi )| ≤ ||f (5) ||∞ for uniform sample points xi
60
∴ cubic spline provides an excellent technique for NUMERICAL DIFFERENTIATION.
Interpolation 11
How do we solve for the {s00k }?
d1 c1
a2 d2 c2 0 x1 b1
x2
0 a3 d3
.. .. =
. .
0 dn−1 cn−1
..
.
xn bn
an dn
d1 6= 0 d1 x1 + c1 x2 = b1 (4.1)
a2 x1 + d2 x2 + c2 x3 = b2 (4.2)
µ ¶
a2 a2 a2
(2) − (1) ⇒ d2 − c1 x2 + c2 x3 = b2 − b1
d1 d1 d1
a2
d02 x2 + c2 x3 = b02 d02 = d2 − c1
d1
a2
b02 = b2 − b1
d1
Similarly
d01 c1 x1 b01
d02 c2 .. b02
.
=
..
d0n−1 cn−1 .
d0n xn b0n
Back Substitution
xn = b0n /d0n
xn−1 = (b0n−1 − cn−1 x)/d0n−1