Example 3.  Find the "natural cubic spline" that satisfies  

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



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.











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.



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.




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




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.





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




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