Natural Cubic Spline

This applet computes a Cubic Spline between each of the nodes (Black Circles). To experiment with Cubic Splines select a node with your mouse and drag the node to the desired location. You can also choose the random button to have the nodes move randomly.

See the note below for a description of a Cubic Spline.

Cubic splines are the most popular spline functions. They are smooth functions with which to fit data, and when used for interpolation, they do not have the oscillatory behavior that is characteristic of high-degree polynomial interpolation (like Lagrange Interpolation, Hermite Interpolation, etc.)

The idea behind computing a cubic spline is as follows:

Let s(x) = a(i) + b(i)*x + c(i)*x^2 + d(i)*x*3 for x(i-1)<= x <= x(i), i = 1,..,n

This gives 4*n unknown coefficients. So, we need 4*n constraints to solve the problem.

First we require (i) s(x(i)) = y(i) for i = 0,1,...,n

Next we require (ii) s(x(i)+0) = s(x(i)-0); (iii) s'(x(i)+0) = s'(x(i)-0); (iv) s''(x(i)+0) = s''(x(i)-0) for i = 1,...,n-1

This gives us n+1 constraints from (i) and 3(n-1) constraints from (ii)-(iv). Thus, we have 4n-2 constraints leaving 2 degrees of freedom for choosing the coefficients.

If we make the second derivative of the 1st node and the last node zero then we have a "natural" cubic spline. This constraint is what has been chosen for the above cubic spline.

Another choice for the 2 degrees of freedom is to make s'''(x) to be continuous at x(1) and x(n-1). This choice is called the "not-a-knot" condition.

Note: In order to run the applet above your browser must use the JRE 1.1 or higher

Next applet