Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Re: BUG or FEATURE in Interpolation[] ?
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Jarl R Sobel

Posts: 6
Registered: 12/7/04
Re: BUG or FEATURE in Interpolation[] ?
Posted: Aug 16, 1996 3:07 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

In article <4upfkc$48n@dragonfly.wolfram.com>, Stefan Schulz
<sschulz@chemie.fu-berlin.de> wrote:

> Dear Mathematica users,
> when I typed in the following lines:
> xdata = {-1., -0.5, 0., 1., 3., 6., 9.};
> ydata = Map[(Exp[-#]-1)^2&, xdata];
> data = Inner[List,xdata,ydata,List];
> int = Interpolation[data];
> Plot[int[x], {x,-1,9}]
> I found to my surprise, that the function returned by Interpolation
> is not smooth at some of the data points! For this reason I resorted to
> write a package Spline1D which returns a smooth cubic spline as a
> pure function, but is naturally slower than the built-in Interpolation
> command. Did I find a bug or is this a feature? If it is a feature
> it certainly makes the Interpolation command not suitable to obtain
> smooth curves. I would appreciate your comments an this. Many Thanks
> in advance.

I quote the Mathematica Reference Guide describing the function Interpolation:

Data can be given in the form {{xi, {fi, dfi, ddfi, Š }}, Š } to specify
derivatives as well as values of the function at the points xi. You can
specify different numbers of derivatives at different points.

Using this feature to specify the first derivatives of the function, gives
what you want:

xdata = {-1., -0.5, 0., 1., 3., 6., 9.};

data1 = Transpose[{xdata,
Transpose[{(Exp[-xdata] - 1)^2,
Derivative[1][(Exp[-#1] - 1)^2 & ][xdata]}

int1 = Interpolation[data1];

Plot[{(Exp[-x] - 1)^2,int1[x]}, {x,-1,9}]



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.