       Re: Help with Spline Interpolation

• To: mathgroup at smc.vnet.net
• Subject: [mg113244] Re: Help with Spline Interpolation
• From: "Tim McShane" <tmcshane1 at verizon.net>
• Date: Wed, 20 Oct 2010 04:08:31 -0400 (EDT)

```Thank you Chris for your good suggestion.  I added an extra point on either
end to match the specified 1st derivatives.  This did result in a curve with
slopes much closer to -1 and 1 at the end points (-0.512 and +0.634).

However, I was looking for an exact mathematical boundary condition for the
1st derivatives at the end points of the cubic spline curve.  There is a
Mathematica algorithm for doing this written by Joseph M. Herrmann available
on the Wolfram Library Archive.  I wanted to see if I could do the same
thing by using the built-in Mathematica Interpolation function.
Thanks,
Tim McShane

----- Original Message -----
From: "Christopher Arthur" <aarthur at tx.rr.com>
To: <mathgroup at smc.vnet.net>
Sent: Tuesday, October 19, 2010 5:56 AM
Subject: [mg113244] [mg113223] Re: Help with Spline Interpolation

> Hi Tim,
>
> As an experiment, try to put a point on either side of the bounds so
> that the spline isn't terminating at 2 and 20 but flows through it...see
> if the derivatives are better then.  Perhaps the endpoints are not
> differentiable in the model, and that is why the problem is.
> Christopher Arthur
>
> Tim McShane a =E9crit :
>> 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'
>> 0.139481
>>
>> sfun'
>> -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
>>