Example 3.  Find the "natural cubic spline" that satisfies  
        [Graphics:Images/HermitePolyMod_gr_77.gif]    

Solution 3.

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_78.gif].  

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


[Graphics:../Images/HermitePolyMod_gr_80.gif]
[Graphics:../Images/HermitePolyMod_gr_81.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_82.gif]

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

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

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

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

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

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

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

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

[Graphics:../Images/HermitePolyMod_gr_91.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_92.gif]  before we can use the ReplaceAll command.

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


[Graphics:../Images/HermitePolyMod_gr_94.gif]
[Graphics:../Images/HermitePolyMod_gr_95.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_96.gif]


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

[Graphics:../Images/HermitePolyMod_gr_98.gif]
[Graphics:../Images/HermitePolyMod_gr_99.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_100.gif]  for making a piecewise function.  Under the help menu we can find the following information about Condition.
patt  [Graphics:../Images/HermitePolyMod_gr_101.gif]  test is a pattern which matches only if the evaluation of test yields True

 

 

[Graphics:../Images/HermitePolyMod_gr_102.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_103.gif]

Global`S

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

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

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

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

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

[Graphics:../Images/HermitePolyMod_gr_108.gif]
[Graphics:../Images/HermitePolyMod_gr_109.gif]

Notice that the natural cubic spline is different from the clamped cubic spline, it is "a relaxed curve." (and happy too!)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(c) John H. Mathews 2004