# Degrafa Natural Cubic Spline Demo 3

I remember my professor in my first numerical analysis course talking about Lagrange interpolating polynomials and sampling the test function f(x) = 1/(1 + x2).  We already knew about oscillations in higher-order polynomials, so this discussion was about sampling increments.  The natural thought is to sample in equal increments across an interval.  Thus started a discussion about Chebyshev polynomials and Chebyshev nodes.  I actually found a good blog post about this very topic at John Cook’s blog.  John has a great blog on math and computation, btw.

I wanted one more demo showing how to create cubic spline nodes in script and highlight sections of the spline that were not necessarily in-between knots.  The new demo samples the above function at Chebyshev nodes in [-5,5] and fits a natural cubic spline to the nodes.  The area under the curve in [-1,1] is highlighted as shown in the screenshot below (by clicking the ‘Show Highlight’ button.

Click on the ‘Show Function’ button to show the original function plotted point-to-point to see a visual comparison of the spline approximation.  If you are interested, change the interpolation points and study the change in quality of fit.

Now that my trip down memory lane is complete, next step is to complete the Degrafa spline architecture (which is only about halfway there) and add a parametric spline.  I did correct a typo in the code, so you will need to update SVN.