Lecture notes on Vritionl nd Approximte Methods in Applied Mthemtics - A Peirce UBC Lecture 4: Piecewise Cubic Interpoltion Compiled 5 September In this lecture we consider piecewise cubic interpoltion in which cubic polynomil pproximtion is ssumed over ech subintervl In order to obtin sufficient informtion to determine these coefficients, we require continuity of the interpolting polynomils in neighboring intervls s well s the continuity of number of derivtives Depending on the number of derivtives tht we require to be continuous t the stitching points we obtin different pproximtion schemes in which dditionl dt bout the function fx being pproximted might hve to be furnished in order tht there is sufficient dt to determine the coefficients of the cubic polynomils Key Concepts: Piecewise cubic interpoltion, Cubic Splines, Cubic Hermite Interpoltion 4 Piecewise Cubic Interpoltion 4 Degree of freedom nlysis of piecewise cubic interpolnts Consider the domin [, b] tht is prtitioned into N intervls hving N + nodes nd N internl nodes In ech of these subintervls ssume tht different cubic polynomil is to be constructed Let p 3,N x be the combintion of ll these cubic polynomils We now discuss the lterntive pproximtion schemes tht one obtins depending on the different schemes of constrint Schemes of constrint: Piecewise Cubic Hermite polynomils: p 3,N x nd p 3,N x re continuous t interior nodes There re four unknown coefficients for ech of the N intervls nd N constrints due to the continuity requirements on p 3,N x nd p 3,N x DOF : 4N N = N + specify function vlue nd its derivtive t ll N + nodes Hve to specify f & f t ll N + nodes! Cubic Spline: p 3,N x, p 3,N x, nd p 3,N x re ll continuous t interior points DOF : 4N 3N = N + 3 = N + }{{} + specify f t ll N + nodes nd impose EXTRA CONDITIONS The extr conditions re up to the user to prescribe depending on the ppliction, eg p 3x = = p 3x N whics clled the nturl spline
4 Piecewise Cubic Hermite polynomils x = x x N = L DOF: 4N N = N + prescribe fx i nd f x i t i =,, N Representtion of f in terms of Hermite bsis functions h i x nd h i x: N N fx hx = fx i h i x + f x i h i x where h d i x j = δ ij nd dx h i x j = δ ij d dx h i x j = h i x j = Constructing bsis functions on the cnonicl intervl [, ]: i= i= } We use the liner Lgrnge bsis functions N ξ = +ξ ξ : N ξ b = δ b, ξ,b = ± h h h Let h ξ = α ξ + β [N ξ] ; h ξ = α ξ + β[n ξ] h ξ = γ ξ + δ [N ξ] ; h ξ = γ ξ + δ [N ξ] - h ξ To find α i, β i, γ i nd δ i we impose the conditions : = h = β α = h = α + β α = α β α = nd β = h ξ = 4 + ξ ξ Similrly h ξ = 4 ξ + ξ For the derivtive bsis functions = h = δ γ = h = γ δ } Similrly h ξ = 4 ξ + ξ δ = γ = h ξ = 4 + ξ ξ
Expressions for bsis functions on n rbitrry intervl [x i, x i+ ] Interpoltion 3 Use the liner trnsformtion xξ = x i N ξ + x i+n ξ = x i ξ + x i+ + ξ xi + x i+ = + x i+ x i ξ The inverse trnsformtion is: ξx = x x i + x i+ x i+ x i = x x i + x i+ x i + ξ = x i+ x i + x x i x i+ = x x i x i+ x i x i+ x i + ξ = x i + x x i x i ξ = x i+ x ξ = x i + x i+ x x i+ x i x i Here x i = x i+ x i nd observe tht h i x = [ x i + x x i ] x i+ x x i 3 4 h i+ x = [ x i + x i+ x] x x i x i 3 4 h i x = x x ix i+ x x i 43 h i+ x = x i+ xx x i x i 44 d dξ ξ = d dx ξx dx dξ = d dx ξx x i Error involved: For function vlues the error is given by: while for derivtives the error is : fx hx f 4 x 4 384 f x h x f 4 3 x 3 6
4 43 Piecewise Cubic Spline interpoltion NDOF: 4N 3N = N + + specify fx i t x,, x N + extr conditions 43 Derivtion using Cubic Hermie interpoltion Since we hve similr piecewise cubic polynomils to the Piecewise Cubic Hermite polynomils on ech subintervl but with dditionl continuity required t the N interior nodes, our strting point is the Hermite cubic bsis expnsion We then impose dditionl conditions to mke up for the derivtives f x i which re not known or required in the cse of splines On [x k, x k+ ] x k x k x k+ [ x k + x x k ] x k+ x [ x k + x k+ x] x x k sx = f k x k 3 + f k+ x k 3 +s x x k x k+ x k x k + s x x k+ x x k k+ x k where the f k nd f k+ from the Hermite expnsion hve been replced by the unknown quntities s k nd s k+ which re to be determined by system of equtions which ensure tht x is continuous t internl nodes The first nd second derivtives of sx must be continuous t the interieor points x j, j = N Continuity of the first derivtive is lredy obtined by our choice of bsis functions So we pply continuity of x to get equtions for the coefficients s k Tht is, we clculte s x on the two intervls [x k, x k ] nd [x k, x k+ ] nd require continuity t x k After some lgebr x k s k + x k + x k s k + x k s k+ = 3f[x k, x k+ ] x k + f[x k, x k ] x k We hve N equtions nd N + unknowns s, s,, s N so we need more conditions Sy we specify I f = s nd s N = f N then on uniform mesh x k = x: 4 s 4 s 4 4 s N = 3 f[x, x ] + f[x, x ] f[x, x 3 ] + f[x, x ] f[x N, x N ] + f[x N, x N ] s s N A tridigonl system of equtions esy to solve!
Interpoltion 5 43 Alterntive cubic spline derivtion for derivtive primry vribles y i y i+ Y i x x i x i+ Let Y i x = i x x i 3 + b i x x i + c i x x i + d i Y i x = 3 i x x i + b i x x i + c i Y i x = 6 i x x i + b i y i = Y i x i = d i y i+ = Y i x i+ = i h 3 i + b i h i + c i + y i where = x i+ x i Let s i = Y i x i = c i s i+ = Y i x i+ = 3 i h i + b i + s i Y i x i = b i = Y ix i = 6 i + b i [ ] [ ] [ h 3 i h i i yi+ y 3h = i s i h ] i i b i s i+ s i / / i = y i+ y i s i h 4 i s i+ s ih i h 4 i 6 y i { b i = h 3 i s i+ s i 3h i y i+ y i s i } / h 4 i yi+ y i i = h 3 + s i+ + s i i h i yi+ y i s b i = 3 i+ + s i h i s i+ + s i = y i + 6 s i + s i + 6 y i s i + s i 6 y i + y i = s i+ + 4 s i + 4 s i + s i s i+ + + s i + s i = 3f[x i, x i ] + f[x i, x i+ ]
6 433 Another spline derivtion with i y i y i y i+ s primry vribles Y i x Y i x Y i+ x x i x i x i+ Let Y i x = i x x i 3 + b i x x i + c i x x i + d i Y i x = 3 i x x i + b i x x i + c i Y i x = 6 i x x i + b i t x i : y i = Y i x i = d i interpoltes the function t x i 45 y i+ = Y i x i+ = i h 3 i + b i h i + c i + y i enforce continuity 46 Introduce primry vrible : i = Y i x i = b i b i = / 47 Build in continuity of Y i+ = Y i x i+ = 6 i + i i = s Impose continuity of first derivtives: c i = y i i i+ s i s i+ Y i x = s i x x i 3 + s 6 x x i + c i x x i + y i s i+ y i+ = s i h 3i + s i 6 + c i + y i yi+ y i s i+ c i = s i s i 6 hi = y i s i+ + s i 6 s Y i+ + s i 6 Y i x i = 3 i x i x i + b i x i x i + c i = c i ix i = 3 i h i + b i + c i s = 3 i i 6 h i + i + { yi 6 48 s i + s 6 i } or i 3 + 6 + + i + i+ = 6 yi yi i + + i + i+ = 6 yi yi i =, N EXTRA CONDITIONS N EQ
434 Extr Conditions y y y n x h x x h n x N X N Nturl Spline: = = N two extr condtions Interpoltion 7 h + h h h h + h h h N h N h N + h N N = 6 y y h y y h y 3y h yy h y N y N h N y Ny N h N Clmped Spline: Specified first derivtives Given f x = A nd f x n = B A = Y x = c = y y h h s + h 6 = A h + h = 6 y y h A B = Y Nx n = 3 n h n + b n h n + c n sn s n = 3 h n + s n h n + y n y n hn n + h n n 6h n h n 6 6 B y n y n = 3h n n 3h n n + 6h n n h n n h n n h n 6 B y ny n h n = h n n + h n n But h + h + h + h = 6 {[f [x, x ] f [x, x ]} h h h h + h h h n h n + h n h n h n h n N N = 6 y y /h A y y /h yy h y n y n /h n y n y n /h n B y ny n y h n
8 3 Qudrtic boundry intervl representtion = s s 6h qudrtic = N = N = n = s N s N 6h N qudrtic 3h + h h h h + h h 4 Liner extrpoltion h N3 + h N h N h N h N + 3h N N = 6 f[x, x ] f[x, x ] f[x N, x N f[x N, x N ] S x S S S x x x = s = h h h h + h + h + h = 6f[x, x ] f[x, x ] = h + h h h h + h h h + h h + h s + h = RHS h h h h + h h h + h + h = RHS h h +h h h h + h h h h h h + h h h h
Interpoltion 9 5 Not--knot condition Y x Y x Y N x Y N x Unknowns = 4N Constrints = 3N 3 4N 3N 3 = N + unknowns the vlues t x,, x N i + + i + i+ = 6f[x, x ] f[x, x ] Y x = x x 3 + b x x + c x x + d Y x = 3 x x + b x x + c Y x = 6 x x + b, x x = h s = Y x = 6 x x + 6h / = h + h = h + h h h h But h + h + h + h = 6f[x, x ] f[x, x ] + h h + h + h h h Also + h N h N + h N N + h N h N h N h + h = 6f[x, x ] f[x, x ] h N + h N N = 6f[x N, x N ] f[x N, x N ] + h h h + h h h h + h h h + h h 6 A periodic spline: h N h N h N + h N x + = x N x + = x N h N + h N h N h N + h N N N
III Smoothness property of nturl spline x = = x N In order to impose this condition it is convenient to consider the k s unknowns in which cse the equtions become: x k k + x k + x k+ k + x k+ k+ = 6f[x k, x k+ ] f[x k, x k ] k =,, N NOTE: Importnt identity: y [y + ] = y y + = y Let yx be ny other interpolnt of fx t x,, x N then y dx Now dx = y dx = y s y dx + = y s = y s b b b y dx N x k y s dx = const on ech subintervl k= x k N x k c k y s botnterpolnts k= If we choose s : = = b for exmple or if y nd s botnterpolte f t nd b then y dx = y dx + x k dx dx Thus s is the interpolnt with the MINIMUM CURVATURE ie smoothest Error involved in spline interpoltion: fx = sx f 4 5 x4 384 f x s x f 4 x 3 4 f x i s x i f 5 x 4 6 y dx = x = mx x : for nonuniform points nd ll x [x, x N ] for nonuniform points nd ll x [x, x N ] for uniform smple points x i cubic spline provides n excellent technique for NUMERICAL DIFFERENTIATION
Interpoltion How do we solve for the { k }? d c d c 3 d 3 d n c n n dn x x x n = b b n d d x + c x = b 4 d x + d x + c x 3 = b 4 d c x + c x 3 = b b d d d x + c x 3 = b d = d d c b = b d b Similrly d k+x k+ + c k+ x k+ = b k+ 43 where d k+ = d k+ k+ d k c k b k+ = b k+ k+ d b k 44 k d c d c d n c n d n x x n = b b b n Bck Substitution x n = b n/d n x n = b n c n x/d n x n = b n/d n 45 x k = b k c k x k+ /d k k = n,, 46
Note, if we let m k = k d k then A = m m n d c cn d n LU = LU Forwrd Ly = b y = L b Bck Ux = y Substitution