Interpolation by periodic cubic splines

Directly to the input form

 
  • Here we have a code for computing periodic cubic interpolating splines. These may serve for approximating a given periodic function f by a two times differentiable function, composed from polynomials of degree not larger than three. While interpolation by polynomials gives useful results on small intervals only, this type of approximation is not sensitive against the total length of the interval but only to the distance of the abscissae.
  • The function obtained, we name it S here, is piecewise defined, and each such piece lives between two successive abscissae of the grid
    a = x1 < x2 < ... < xn = b
  • These pieces, named Si, i=1,...,n-1 here, are determined from the following conditions:
    1. Si(x) is a polynomial of degree not greater 3.
    2. S(x) = Si(x) for xi <= x <= xi+1
    3. Si(xi) = f(xi) (or yi).
    4. Si(xi+1) = f(xi+1).
    5. S'i(xi+1) = S'i+1(xi+1), i=1,..,n-2 (continuity of S').
    6. S''i(xi+1) = S''i+1(xi+1), i=1,...,n-2 (continuity of S'').
    Observe that continuity of S itself is obtained by the interpolation condition.
  • These conditions lead to a linear system of 4(n-2)+2 equations for the 4(n-1) coefficients which is broken down here in a special way into an almost tridiagonal linear system and n-1 uncoupled systems of dimension 3 with a triangular structure.
  • This construction is always possible, but not unique. There remain two degrees of freedom, which allow to fix properties of S at the boundaries of its interval of definition. Here we use the periodicity conditions
    S'(x1) = S'(xn)
    S''(x1) = S''(xn)
    which make the solution unique.
  • The resultung spline S however will be a periodic function of period xn-x1 if and only if also
    y1 = yn .
    We do not check this condition here, hence don't wonder about obscure results if your input does not satisfy this.
  • The resulting linear system has a tridiagonal structure with two additional entries in the position (1,n) and (n,1) and in the LU decomposition this makes (only) the last column of U and the last row of L full. We use a special Gauss solver for this situation.
  • This spline has the remarkable property of minimizing the total curvature integral
    ab (g''(x))2dx
    over the set of all two times continuously differentiable functions g which satisfy the interpolation and the boundary conditions specified.
  • The approximation error of this construction is of the order h4, with h = max(xi+1-xi), provided that f is four times continuously differentiable on [a,b] and periodic with period b-a.
 

Input

 
  • You can choose between input of a data set of your own or the artificial generation of such a data set using a predefined or self defined function.
  • If you specify your own data set then only its length and the data are specified . You may want to see explicitly the piecewise definition of the spline.
  • In the other case you are in the situation of a numerical experiment concerning the approximation properties of this spline. you specify a piece of code to compute your function, the data set is computed using this and then the spline and its error curve is shown. There are 3 predefined functions and you can specify a function yourself.
    1. In the case of specification of a function of your own you must follow FORTRAN conventions.
    2. You specify the number n of abscissae, 4 <= n <= 200.
    3. You specify the interval [a,b]. The abscissae are taken equidistant from there.
 

Output

 
  • In case of data of your own you get a plot of the data and the interpolating spline, and if wanted, the formula representation of the spline.
  • In the other case, you get a protocol showing
    1. The number of data and the choice of the function.
    2. Two plots showing f(x) and S(x) resp. the error f(x)-S(x).
 

Questions?!

 
  • How developes the spline if you increase n?
  • How may you check the correctness of the statement concerning the order of convergence?
  • What takes place if f is nonsmooth?
  • Compare the spline and the polynomial interpolation on the same set of data!
 

To the input form

 
 
Back to the top!

18.02.2015