(* Exploring splines *) (* To run on command line: math -run "<{Hue[1], Thickness[0.01]}, PlotLabel->"Original function", DisplayFunction -> Identity ] n=16; h = (b-a)/n; (* define knots *) data = Table[N[{x, F[x]}], {x, a, b, h}] (* produce data points at each knot *) (* Uncomment below to try spline fit for a parametric curve *) (* data = Table[N[{Sin[t], Cos[3t]}], {t, a, b, h}] (* parametric curve *) *) plotfunction = ParametricPlot[{Sin[t], Cos[3t]}, {t, a, b}, PlotStyle->{Hue[1], Thickness[0.005]}, PlotLabel->"A parametric curve" ] plotdata = ListPlot[data, PlotLabel -> "Data points", Prolog-> AbsolutePointSize [5] ] fit = SplineFit[data, Cubic] (* Do the Cubic spline interpolation *) plotfit = ParametricPlot[fit[t], {t, 0, n}, PlotStyle->{Hue[0.5], Thickness[0.005]}, PlotLabel-> "Cubic spline", DisplayFunction -> Identity ] (* Show all graphs at once *) Show[plotfunction, plotdata, plotfit, PlotLabel -> FontForm["red - original f(x), blue - Cubic Spline ", {"Courier", 15}], Prolog-> AbsolutePointSize[5], DisplayFunction -> $DisplayFunction ] (* Print the value of the spline at the leftmost knot. Output format {x,y} *) Print[fit[0.0]] (* And at a point just a bit to the right *) Print[fit[0.01]] Clear[data] Clear[fit]