Cubic spline construction using the B-spline function.

    Under special circumstances a basis set of splines [Graphics:Images/B-SplinesMod_gr_1.gif] can be used to form a cubic B-spline function.  This concept makes the construction of a spline very easy, it is just at linear combination:   


All we need to do is solve for the  [Graphics:Images/B-SplinesMod_gr_3.gif] coefficients [Graphics:Images/B-SplinesMod_gr_4.gif].  And to make things even more appealing, the linear system to be solved has a tri-diagonal "appearance":   

        [Graphics:Images/B-SplinesMod_gr_5.gif][Graphics:Images/B-SplinesMod_gr_6.gif] = [Graphics:Images/B-SplinesMod_gr_7.gif].  

Caution must prevail when solving this underdetermined system of  [Graphics:Images/B-SplinesMod_gr_8.gif]  equations in  [Graphics:Images/B-SplinesMod_gr_9.gif] unknowns.  Two end conditions must be supplied for constructing the coefficients [Graphics:Images/B-SplinesMod_gr_10.gif] and [Graphics:Images/B-SplinesMod_gr_11.gif].  These end conditions are specially crafted to form either a natural cubic spline or a clamped cubic spline.  

    How can such an elegant construction possible ?  It's simple, you must have a uniform grid of points  [Graphics:Images/B-SplinesMod_gr_12.gif] on the interval  [Graphics:Images/B-SplinesMod_gr_13.gif].  The uniform spacing is [Graphics:Images/B-SplinesMod_gr_14.gif] and the interpolation nodes to be used are [Graphics:Images/B-SplinesMod_gr_15.gif] for  [Graphics:Images/B-SplinesMod_gr_16.gif].  The equally spaced abscissa's are


The corresponding ordinates are  [Graphics:Images/B-SplinesMod_gr_18.gif]  and the data points are  [Graphics:Images/B-SplinesMod_gr_19.gif].  They are often times referred to as the knots because this is where we join the piecewise cubics, like pieces of string "knotted" together to form a larger piece of string.  If this is your situation, then the B-spline construction is for you.  

Caveat. If you have unequally spaced points, then this is construction does not apply and construction of the cubic spline require a more cumbersome algorithm because each piecewise cubic will need to be individually crafted in order to meet all the conditions for a cubic spline.  


The basic B-spline function.

    Construction of cubic B-spline interpolation can be accomplished by first considering the following basic function.

The function [Graphics:Images/B-SplinesMod_gr_20.gif] is a piecewise continuous on the interval [Graphics:Images/B-SplinesMod_gr_21.gif] , it is zero elsewhere.  In advanced courses this simple concept is glamorized by saying that [Graphics:Images/B-SplinesMod_gr_22.gif] is a function with "compact support."  That is, it is supported (or non-zero) only on a small set.  



The graph of the function [Graphics:Images/B-SplinesMod_gr_24.gif] .











Verify that  [Graphics:Images/B-SplinesMod_gr_34.gif] is a cubic spline.

Each part of  [Graphics:Images/B-SplinesMod_gr_35.gif] is piecewise cubic.
Are the functions  [Graphics:Images/B-SplinesMod_gr_36.gif],  [Graphics:Images/B-SplinesMod_gr_37.gif]  and   [Graphics:Images/B-SplinesMod_gr_38.gif] continuous for all  [Graphics:Images/B-SplinesMod_gr_39.gif] ?
Since  [Graphics:Images/B-SplinesMod_gr_40.gif]  is composed of the piecewise functions [Graphics:Images/B-SplinesMod_gr_41.gif],[Graphics:Images/B-SplinesMod_gr_42.gif],[Graphics:Images/B-SplinesMod_gr_43.gif],[Graphics:Images/B-SplinesMod_gr_44.gif],[Graphics:Images/B-SplinesMod_gr_45.gif],[Graphics:Images/B-SplinesMod_gr_46.gif], all that is necessary is to see if they join up properly at the nodes  [Graphics:Images/B-SplinesMod_gr_47.gif].  However, this will take 15 computations to verify.  This is where Mathematica comes in handy.  Follow the link below if you are interested in the proof.  

Proof  B-Splines  B-Splines  


The above proof that  [Graphics:Images/B-SplinesMod_gr_48.gif]  is a cubic spline used the formulas [Graphics:Images/B-SplinesMod_gr_49.gif],[Graphics:Images/B-SplinesMod_gr_50.gif],[Graphics:Images/B-SplinesMod_gr_51.gif],[Graphics:Images/B-SplinesMod_gr_52.gif],[Graphics:Images/B-SplinesMod_gr_53.gif],[Graphics:Images/B-SplinesMod_gr_54.gif].
It is the analytic way to do things and illustrates "precise mathematical" reasoning.

If you trust graphs, then just look at the graphs of  [Graphics:Images/B-SplinesMod_gr_55.gif],  [Graphics:Images/B-SplinesMod_gr_56.gif],  and  [Graphics:Images/B-SplinesMod_gr_57.gif] and try to determine if they are continuous.  
However, there might be problems lurking about.  If you seek the mathematical truth you should look at the next cell link.  

A careful look at the derivatives.  B-Splines  B-Splines  



Let's translate the B-spline over to the node [Graphics:Images/B-SplinesMod_gr_58.gif] and use the uniform step size [Graphics:Images/B-SplinesMod_gr_59.gif].  




Now form the linear combination for the spline.



At each of the nodes [Graphics:Images/B-SplinesMod_gr_66.gif] for  [Graphics:Images/B-SplinesMod_gr_67.gif] computation will reveal that











If the B-spline is to go through the points  [Graphics:Images/B-SplinesMod_gr_78.gif] for  [Graphics:Images/B-SplinesMod_gr_79.gif], then the following equations must hold true

    [Graphics:Images/B-SplinesMod_gr_80.gif]   for   [Graphics:Images/B-SplinesMod_gr_81.gif].  

For the natural cubic spline, we want the second derivatives to be zero at the left endpoint  [Graphics:Images/B-SplinesMod_gr_82.gif].  

Therefore we must have   [Graphics:Images/B-SplinesMod_gr_83.gif].  

Computation will reveal that


To construct the natural cubic spline, we must have


We can solve this equation for the spline coefficient [Graphics:Images/B-SplinesMod_gr_86.gif]



For the natural cubic spline, we want the second derivatives to be zero at the right endpoint  [Graphics:Images/B-SplinesMod_gr_89.gif].   

Therefore we must have   [Graphics:Images/B-SplinesMod_gr_90.gif].  

Computation will reveal that


To construct the natural cubic spline, we must have


We can solve this equation for the spline coefficient [Graphics:Images/B-SplinesMod_gr_93.gif]



The above construction shows how to calculate all the coefficients [Graphics:Images/B-SplinesMod_gr_96.gif].












Computer Programs  B-Splines  B-Splines  


Method I.  B-spline construction using equations.

Illustration using 7 knots.

The following example uses  n = 6.  There are  n+3 = 9  equations to solve and  n+1 = 7  data points or knots.  First set up the 9 equations to be solved.  



Example 1.  Construct the natural cubic spline for the 7 points  [Graphics:Images/B-SplinesMod_gr_111.gif]  
This requires that the spline has the second derivative endpoint constraints   [Graphics:Images/B-SplinesMod_gr_112.gif].  
Solution 1.


Example 2.  The construction in Example 1 used the basic functions [Graphics:Images/B-SplinesMod_gr_154.gif] which have support that is slightly wider than the interval containing the abscissas.
This can be verified by graphing  [Graphics:Images/B-SplinesMod_gr_155.gif] on a larger interval.  
Solution 2.


Research Experience for Undergraduates

B-Splines  B-Splines  Internet hyperlinks to web sites and a bibliography of articles.  


Download this Mathematica Notebook B-Splines


Return to Numerical Methods - Numerical Analysis




















(c) John H. Mathews 2004