From: spellucci@mathematik.tu-darmstadt.de (Peter Spellucci) Newsgroups: sci.math.num-analysis Subject: Re: splines! Date: 26 Nov 1998 17:58:10 GMT In article <365D764E.B814E0B0@vasteras.mpe.se>, Michael Berglund writes: |> How do I calculate a spline-curve!??!?!!? |> depends on which one you want. a very readable first approach is in forsythe&malcolm&moler: computer methods for mathematical computations (with f77 source) see also the corresonding chapter in "numerical recipes in c" (with c-source). these two cover the interpolating cubic polynomial spline. for more see de boor: a practical guide to splines. for software see http://www.netlib.org -> browse directory -> fitpack, diercks. definition: the cubic interpolating spline s is a function which is a cubic polynomial on each [x_i,x_{i+1}], which is in the class C2 and interpolates the given data (x_i,y_i), i=0,..,n+1 (say). basic idea: the polynomial spline s is a piecewise cubic C2-function, hence s'' is piecewise linear continuous. a piecewise linear and continuous function is uniquely represented by its values at the abscissae x_i, say M_i. (the bending moments of the physical spline model). now integrate s'' two times. this introduces two integration constants say c_i and d_i for every interval [x_i,x_{i+1}]. If you require that every piece interpolates the data y_i and y_{i+1}, this determines c_i and d_i uniquely (from x_j, y_j and the not yet determined M_j) this also makes the piecewise defined function itself continuous. now write down the condition that the piecewise defined function is one times continuously differentiable. this gives conditions of the form s_i'(x_{i+1}) = s_{i+1}'(x_{i+1}) i=0,..,n-1 , where x_1 ,...,x_n are the inner nodes of the grid and s_i is the name of the piece of s on [x_i,x_{i+1}]. a rather simple calculation results in a tridiagonal linear system of n equations for the n+2 moments M_0 , .., M_{n+1}. therefore there are many possibilities to define a spline. the reuirement M_0=M_{n+1}=0 is the simplest one to make the construction unique. this is the so called "natural" spline, already used by the Viking (but they didn't use this theory , I believe). hope this helps peter