Help with Spline Interpolation
- To: mathgroup at smc.vnet.net
- Subject: [mg113193] Help with Spline Interpolation
- From: "Tim McShane" <tmcshane1 at verizon.net>
- Date: Mon, 18 Oct 2010 05:46:51 -0400 (EDT)
Hi,
I am trying to interpolate 5 data points using spline curves in
Mathematica using the Interpolation function. I also want to specify
the first derivative or slope of the spline curve at the end points
only. This is known as a "clamped" cubic spline.
I used the following code:
data1={{{2},3,-1},{{5},4,Automatic},{{9},6,Automatic},{{14},7,Automatic},{{20},5,1}}
data1Plot=Table[{data1[[i,1,1]],data1[[i,2]]},{i,1,Length[data1]}]
sfun=Interpolation[data1,Method->"Spline"]
grfx1=ListPlot[data1Plot,AxesOrigin=EF=82=AE{0,0}];
grfx2=Plot[sfun[x],{x,2,20}];
Show[grfx1,grfx2]
sfun'[2]
0.139481
sfun'[20]
-0.63457
This draws a smooth curve through the data points but does not reproduce
the specified first derivatives at the end points. The slope at the
beginning and end points should be -1 and 1 respectively. The
interpolating function returned by Mathematica gives 0.139 and -0.635
Did I give the proper input parameters? Please help.
Thank you,
Tim McShane