MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: BUG or FEATURE in Interpolation[] ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg4641] Re: BUG or FEATURE in Interpolation[] ?
  • From: jsobel at sdav01.seinf.abb.se (Jarl R Sobel)
  • Date: Thu, 22 Aug 1996 03:54:58 -0400
  • Organization: ABB Industrial Systems
  • Sender: owner-wri-mathgroup at wolfram.com

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

> Dear Mathematica users,
>=20
> when I typed in the following lines:
>=20
> xdata =3D {-1., -0.5, 0., 1., 3., 6., 9.};
> ydata =3D Map[(Exp[-#]-1)^2&, xdata];
> data  =3D Inner[List,xdata,ydata,List];
> int   =3D Interpolation[data];
> Plot[int[x], {x,-1,9}]
>=20
> I found to my surprise, that the function returned by Interpolation=20
> 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=20
> pure function, but is naturally slower than the built-in Interpolation=20
> 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=20
> smooth curves. I would appreciate your comments an this. Many Thanks
> in advance.
>=20
I quote the Mathematica Reference Guide describing the function Interpola=
tion:

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

Using this feature to specify the first derivatives of the function, give=
s
what you want:

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

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

int1   =3D Interpolation[data1];

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

Bye

      Jarl

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: fitting differential eq. to data
  • Next by Date: Graphics Output (publication quality) from Mathematica?
  • Previous by thread: BUG or FEATURE in Interpolation[] ?
  • Next by thread: Re: BUG or FEATURE in Interpolation[] ?