Matematical Metods in Science and Engineeing Cubic Spline Intepolation by Solving a Recuence Equation Instead of a Tidiagonal Matix Pete Z Revesz Depatment of Compute Science and Engineeing Univesity of Nebaska-Lincoln Lincoln, Nebaska 68588-0115 Email: evesz@cseunledu ttp://cseunledu/evesz Telepone: 1+ 40 47 488 Abstact Te cubic spline intepolation metod is pobably te most widely-used polynomial intepolation metod fo functions of one vaiable Howeve, te cubic spline metod equies solving a tidiagonal matix-vecto equation wit an On computational time complexity wee n is te numbe of data measuements Even an On time complexity may be too muc in some time-ciitical applications, suc as continuously estimating and updating te fligt pats of moving objects Tis pape sows tat unde cetain bounday conditions te tidiagonal matix solving step of te cubic spline metod could be entiely eliminated and instead te coefficients of te unknown cubic polynomials can be found by solving a single ecuence equation in muc faste time I INTRODUCTION Cubic spline intepolation is a widely-used polynomial intepolation metod fo functions of one vaiable [] Cubic splines can be descibed as follows Let f be a function fom R to R Suppose we know about f only its value at locations x 0 < < x n Let fx i = a i Piecewise cubic spline intepolation of f is te poblem of finding te b i, c i and d i coefficients of te cubic polynomials S i fo 0 i n 1 witten in te fom: S i x = a i + b i x x i + c i x x i + d i x x i 1 wee eac piece S i intepolates te inteval [x i, x i+1 ] and fits te adjacent pieces by satisfying cetain smootness conditions Taking once and twice te deivative of Equation 1 yields, espectively te equations: S ix = b i + c i x x i + d i x x i S i x = c i + 6d i x x i Equations 1- imply tat S i x i = a i, S i x i = b i and S i x i = c i Fo a smoot fit between te adjacent pieces te cubic spline intepolation equies tat te following conditions old fo 0 i n : S i x i+1 = S i+1 x i+1 = a i+1, 4 S ix i+1 = S i+1x i+1 = b i+1 5 S i x i+1 = S i+1x i+1 = c i+1 6 Tis pape is oganized as follows Section II eview te usual solution fo cubic splines by solving a tidiagonal matix Section?? II THE TRIDIAGONAL MATRIX-BASED SOLUTION In tis section we eview te usual tidiagonal matix-based solution fo cubic splines Let i = x i+1 x i Substituting Equations 1- into Equations 4-6, espectively, yields: a i + b i i + c i i + d i i = a i+1 7 b i + c i i + d i i = b i+1 8 c i + d i i = c i+1 9 Equation 9 yields a value fo d i, wic we can substitute into Equations 7-8 Hence Equations 7-9 can be ewitten as: a i+1 a i = b i i + c i + c i+1 i 10 b i+1 b i = c i + c i+1 i 11 d i = 1 i c i+1 c i 1 Solving Equation 10 fo b i yields: b i = a i+1 a i 1 c i + c i+1 i 1 i wic implies fo j n te condition: 1 b i+1 = a i+ a i+1 c i+1 + c i+ i+1 14 i+1 ISBN: 978-1-61804-56-9 1
Matematical Metods in Science and Engineeing Substituting into Equation 11 te values fo b i and b i+1 fom Equations 1-14 yields: a i+1 a i 1 c i + c i+1 i i + c i + c i+1 i = 1 a i+ a i+1 c i+1 + c i+ i+1 i+1 Te above can be ewitten as: i c i + i + i+1 c i+1 + i+1 c i+ = a i + a i+1 + a i+ i i i+1 i+1 Te above olds fo 0 i n Howeve, canging te index downwad by one te following olds fo 1 j n : i 1 c i 1 + i 1 + i c i + i c i+1 = a i 1 + a i + a i+1 15 i 1 i 1 i i Te above is a system of n 1 linea equations fo te unknowns c i fo 0 i n By Equation S 0 x 0 = and by extending Equation 6 to j = n 1, S n 1x n = c n Te cubic spline intepolation allows us to specify seveal possible bounday conditions egading te values of, c n A commonly used bounday condition called a natual cubic spline assumes tat = c n = 0, wic is equivalent to setting te second deivative of te splines at te ends to zeo Altenatively, in te clamped cubic spline intepolation, te assumed bounday condition is b 0 = f x 0 and b n = f x n wee te deivatives of te f at x 0 and x n ae known constants In addition, in sovling a cubic spline a unifom sampling is also commonly assumed and available, tat is, eac i as te same constant value Ten dividing Equation 15 by yields: c i 1 + 4c i + c i+1 = a i 1 a i + a i+1 16 Since te values of a i ae known, te values of c i can be found by solving te tidiagonal matix-vecto equation Ax = B Unde te natual cubic spline intepolation, we ave: 1 0 0 0 0 0 0 0 1 4 1 0 0 0 0 0 0 1 4 1 0 0 0 0 0 0 0 0 1 4 1 0 0 0 0 0 0 1 4 1 0 0 0 0 0 0 0 1 te vecto of unknowns is: c 1 x = c n and te vecto of constants is: 0 a 0 a 1 + a B = a n a n 1 + a n 0 Similaly, unde te clamped spline intepolation we ave: 1 0 0 0 0 0 0 1 4 1 0 0 0 0 0 0 1 4 1 0 0 0 0 0 0 0 0 1 4 1 0 0 0 0 0 0 1 4 1 0 0 0 0 0 0 1 te same vecto of unknowns: c 1 x = c n and te following vecto of constants: a 1 a 0 f x 0 a 0 a 1 + a B = a n a n 1 + a n f x n a n a n 1 Bot te natual cubic spline and te clamped cubic spline bounday conditions yield a system of n + 1 linea equations wit only n + 1 unknowns Suc a system nomally yields a unique solution except in some special cases Moeove, eite system is a tidiagonal matix sytem tat can be solved in On time Once te c i values ae found, te d i and te b i values also can be found by Equations 1 and 1, espectively Computating te b i and d i coefficients can be done also witin On time III A NEW RECURRENCE EQUATION-BASED SOLUTION In ou solution to te cubic spline intepolation poblem, we cose a bounday condition tat equies solving te following tidiagonal system wee x i ae ational vaiables, d i ae ational constants and 0 is a ational constant, and A is: ISBN: 978-1-61804-56-9
Matematical Metods in Science and Engineeing 1 0 0 0 0 0 0 1 4 1 0 0 0 0 0 0 1 4 1 0 0 0 0 0 0 0 0 1 4 1 0 0 0 0 0 0 1 4 1 0 0 0 0 0 0 0 1 Futemoe, x = x 1 x x n 1 x n and b = e 1 e e n 1 e n A Relationsip to Clamped and Natual Cubic Splines Ou new matix is closely elated to clamped cubic splines Conside te fist equation fo te clamped cubic spline, wic can be witten as: + c 1 = a 1 a 0 f x 0 Te above equation becomes te following afte multiplying by /: + c 1 = a 1 a 0 f x 0 Adding 1 /c 1 yields: + c 1 = a 1 a 0 f x 0 + 1 c 1 Hence te fist ow of ou new matix A is equivalent to fist ow of te clamped cubic spline fo any 0 if e 1 is: e 1 = a 1 a 0 f x 0 + 1 c 1 wee c 1 is an estimate fo te value of c 1 Te last ow of te new matix allows fixing te value of c n Tis is a genealization of natual cubic spline wic fixes te value to be 0 B A Recuence Equation-Based Solution In tis section, we solve te new system using te value = + 7 In tat case, te fist tee equations can be witten as: x 1 + x = e 1 x 1 + 4x + x = e x + 4x + x 4 = e Multiplying te second ow by, subtacting fom it te fist ow, and ten dividing it by gives: x 1 + x = e 1 x + x = e e 1 x + 4x + x 4 = e Multiplying now te tid ow by, subtacting fom it te second ow, and ten dividing it by gives: x 1 + x = e 1 x + x = e e 1 x + x 4 = e e + e 1 Continuing tis pocess until te last ow, we get: x n + x n = e n en 4 x n + x n 1 = e n en x n 1 + x n = e n 1 en x n = e n + en 5 n 4 e1 + 1 n 4 + en 4 n e1 + 1 n + en n e1 + 1 n Dividing eac ow except te last one by yields: x n + xn x n + xn 1 x n 1 + xn x n = en = en = en 1 = e n en 4 n 4 e1 + + 1 n en en + en 4 n e1 + 1 n + en n e1 + 1 n 1 Note tat eac ow 1 i n 1 will be te following: x i + x i 1 = 1 k e i k k+1 0 k i 1 We define te values fo α 0, α i fo 1 < i n 1, and α n, espectively, as follows: α 0 = 0 α i = e i α i 1 = 0 k i 1 1 k e i k k+1 α n = e n 17 Te solution to te linea equation system can be descibed in tems of te α constants as follows: ISBN: 978-1-61804-56-9
Matematical Metods in Science and Engineeing x n = α n α n x n = α n α n 1 x n 1 = α n 1 α n x n = α n + α n 1 + α n α n Teefoe, x i fo eac ow 1 i n will be: x n = α n 18 x i = α i 1 x i+1 Te above can be solved in closed fom as follows: x i = 0 k n i k 1 α i+k 19 Note tat no matte wat exactly ae te initial values fo e, we ave pe-solved te system Tis can lead to a faste evaluation of te cubic spline tan solving te tidiagonal system eac time We need only On multiplications and subtactions to compute te values of all te x i Moeove, wen any new measuement is made, te conventional tidiagonal matix-based algoitm equies a complete edo of te entie computation in On time In contast, Equation 18 leads to a faste update because to eac x i fo i n we need to add only te tem: n+1 i 1 α n+1 We also need to make x n+1 = α n+1 Aftewad updating te ote α i constants can be done also similaly efficiently C A Moving Object Example Suppose tat an object is eleased fom a eigt of 400 feet wit zeo initial velocity Suppose also tat we measue te object s position to be 84, 6 and 56 feet fom eat at one, two and tee seconds afte elease We also suspect tat te object is in fee fall wit a gavitational acceleation of ft/sec at one second afte elease and at tee seconds afte elease Find a cubic spline appoximation fo te object s position at all times fom te elease to tee seconds afte We will measue te distance taveled fom te elease point Te cubic polynomials we need to find fo te intevals [0, 1], [1, ] and [, ] can be expessed as follows: S 0 x = a 0 + b 0 x + x + d 0 x S 1 x = a 1 + b 1 x 1 + c 1 x 1 + d 1 x 1 S x = a + b x + c x + d x We ave n = 4, a 0 = 400, a 1 = 84, a = 6, a = 56 and te unifom step size is = 1 By ou assumptions of zeo initial velocity f 0 = 0 and fee fall at one second c 1 = 16 and fee fall at fou seconds c = 16, wic implies e 4 = 16 Te matix A and te vectos x and B ae: 1 0 0 1 4 1 0 0 1 4 1, x = 0 0 0 1 because B = e 1 e e e 4 By Equation 17, we ave: c 1 c c and B = 16 16 96 96 16 1 16 + 16 = 400 84 + 6 84 6 + 56 16 α 1 = e 1 α = e α 1 α = e α = 16 16 α 4 = e 4 = 16 = 16 16 = 16 16 By Equation 18 we also ave wen calculating in evese ode: c = α 4 = 16 c = α c = 16 c 1 = α c = 16 = α 1 c 1 = 16 Solving fo te b i coefficients by Equation 1 gives: ISBN: 978-1-61804-56-9 4
Matematical Metods in Science and Engineeing b 0 = 1 1 84 400 1 16 = 0 b 1 = 1 1 6 84 1 16 = b = 1 1 56 6 1 16 = 64 Solving fo te d i coefficients by Equation 1 gives: d 0 = 1 16 16 = 0 d 1 = 1 16 16 = 0 d = 1 16 16 = 0 Te above values sow tat an object in fee fall as an inceasing velocity but its acceleation emains constant Using te above values, te cubic spine intepolation can be descibed as: S 0 x = 400 16x S 1 x = 84 x 1 16x 1 = 400 16x S x = 6 64x 16x = 400 16x Hence in eac piece te cubic spline intepolation gives 400 16x, wic agees wit te expected pysics equation fo te position of a moving object tat stats wit zeo velocity fom an elevation of 400 feet and feely falls downwad wit an acceleation of ft/sec IV CONCLUSION Te geneal metod descibed in tis pape can be used in a wide vaiety of applications wic equie intepolation of a function of one vaiable Fo example, intepolation of measuement data can geneate constaint databases tat can be efficiently queied using constaint quey languages [5], [6] Te simple one-vaiable function intepolation can be also extended to ige dimensions yielding intepolations of ige-dimensional functions tat descibe sufaces [4] and tee-dimensional spatio-tempoal o moving objects [1], [] Tis extension emains an inteesting futue wok REFERENCES [1] S Andeson and P Z Revesz, Efficient MaxCount and tesold opeatos of moving objects, Geoinfomatica, 1 4, 55 96, 009 [] R L Buden and J D Faies, Numeical Analysis, 9t ed New Yok, USA: Spinge, 014 [] J Comicki and P Z Revesz, Constaint-based inteopeability of spatiotempoal databases, Geoinfomatica,, 11-4, 1999 [4] L Li and P Z Revesz, Intepolation metods fo spatio-tempoal geogapic data, Computes, Envionment and Uban Systems, 8, 01-7, 004 [5] P C Kanellakis, G M Kupe and P Z Revesz, Constaint quey languages, Jounal of Compute and System Sciences, 51 1, 6-5, 1995 [6] P Z Revesz, Intoduction to Databases: Fom Biological to Spatio- Tempoal, New Yok, USA: Spinge, 010 ISBN: 978-1-61804-56-9 5