Example 2.  Find the "clamped cubic spline" that satisfies  
        [Graphics:Images/HermitePolyMod_gr_38.gif]   

 

Solution 2.

Set up the formulas for the two cubic polynomials and form the equations to solve.  Subscripted variables are used if you prefer you can use ordinary variables  [Graphics:../Images/HermitePolyMod_gr_39.gif].  

[Graphics:../Images/HermitePolyMod_gr_40.gif]



[Graphics:../Images/HermitePolyMod_gr_41.gif]
[Graphics:../Images/HermitePolyMod_gr_42.gif]

Set up eight equations using the prescribed endpoint conditions. Then find the solution set to this linear system and store it in the variable solset.

[Graphics:../Images/HermitePolyMod_gr_43.gif]

[Graphics:../Images/HermitePolyMod_gr_44.gif]

[Graphics:../Images/HermitePolyMod_gr_45.gif]

[Graphics:../Images/HermitePolyMod_gr_46.gif]

[Graphics:../Images/HermitePolyMod_gr_47.gif]

[Graphics:../Images/HermitePolyMod_gr_48.gif]

[Graphics:../Images/HermitePolyMod_gr_49.gif]

[Graphics:../Images/HermitePolyMod_gr_50.gif]

[Graphics:../Images/HermitePolyMod_gr_51.gif]

[Graphics:../Images/HermitePolyMod_gr_52.gif]

Use the solution given above for the coefficients and form the cubic functions.  Remember that we must dig out one set of braces using [Graphics:../Images/HermitePolyMod_gr_53.gif]  before we can use the ReplaceAll command.

[Graphics:../Images/HermitePolyMod_gr_54.gif]


[Graphics:../Images/HermitePolyMod_gr_55.gif]
[Graphics:../Images/HermitePolyMod_gr_56.gif]

Now graph the portion of each cubic in the interval over which it is to be used.  Then combine the two piecewise cubic graphs to form the spline.

[Graphics:../Images/HermitePolyMod_gr_57.gif]


[Graphics:../Images/HermitePolyMod_gr_58.gif]

[Graphics:../Images/HermitePolyMod_gr_59.gif]
[Graphics:../Images/HermitePolyMod_gr_60.gif]

Remark.  Note that the individual cubics were graphed over different intervals and then the graphs were combined. If they were plotted together over a common interval it would look different.

[Graphics:../Images/HermitePolyMod_gr_61.gif]


[Graphics:../Images/HermitePolyMod_gr_62.gif]

[Graphics:../Images/HermitePolyMod_gr_63.gif]
[Graphics:../Images/HermitePolyMod_gr_64.gif]

Remark.  It would be nice to have one piecewise cubic function S[z] that is used. The following formulas for  S[x]  uses the condition syntax  [Graphics:../Images/HermitePolyMod_gr_65.gif]  for making a piecewise function.  Under the help menu we can find the following information about Condition.
patt  [Graphics:../Images/HermitePolyMod_gr_66.gif]  test is a pattern which matches only if the evaluation of test yields True

 

[Graphics:../Images/HermitePolyMod_gr_67.gif]

Caution.  We cannot print the formula for a piecewise function with the Print command.  It is only possible to interrogate the system and determine what rule it is storing for  S.  Hence, it was a good idea to always use two formulas f1 and f2 to define  S, since they can be printed.

[Graphics:../Images/HermitePolyMod_gr_68.gif]

Global`S

[Graphics:../Images/HermitePolyMod_gr_69.gif]

[Graphics:../Images/HermitePolyMod_gr_70.gif]

 

When a plot is made, it only uses real numbers specified in the conditions.

[Graphics:../Images/HermitePolyMod_gr_71.gif]


[Graphics:../Images/HermitePolyMod_gr_72.gif]

[Graphics:../Images/HermitePolyMod_gr_73.gif]
[Graphics:../Images/HermitePolyMod_gr_74.gif]

The clamped cubic spline forces the slope at the endpoints to be prescribed values.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(c) John H. Mathews 2004