MathGroup Archive 1997

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

Search the Archive

Re: Datapoints -> InterpolatingFunction [Q?] Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg6741] Re: [mg6696] Datapoints -> InterpolatingFunction [Q?] Mathematica
  • From: Allan Hayes <hay at haystack.demon.co.uk>
  • Date: Tue, 15 Apr 1997 02:51:57 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Patrick Jemmer <padz at joule.pcl.ox.ac.uk>
[mg6696] Datapoints -> InterpolatingFunction [Q?] Mathematica


>Given a set of data points, for example:
>{{0, 1.}, {1., -0.0124666}, {2., 0.39147}, {3., -0.90908},
>{4., -0.922979}, {5., 0.0504471}, {6., -0.59904}, {7., 0.299662},
>{8., -0.82718}, {9., 0.299675}, {10., -0.802699}}
>
>is it possible to create an "InterpolatingFunction"
>object to represent this list: so that one can the differentiate
>it and so on... ?

Patrick,
Here are three approaches (but Fit does gives not an interpolating  
function but a least squares fit - it does not pass through the data  
points).


data ={{0, 1.}, {1., -0.0124666}, {2., 0.39147}, {3., -0.90908},
{4., -0.922979}, {5., 0.0504471}, {6., -0.59904}, {7., 0.299662},
{8., -0.82718}, {9., 0.299675}, {10., -0.802699}};


FitPoly=Fit[data,{1,x,x^2,x^3},x]

	1.023772202797186 - 1.01805753177933*x +
  	0.2047412731934736*x^2 - 0.01194244980575005*x^3

InterFn =Interpolation[data, InterpolationOrder->5]

	InterpolatingFunction[]

 InterPoly =
	InterpolatingPolynomial[data,x]; (*gives a big poly*)

Interpolating functions can be differentiated as in InterFn' for  
the derivative function of InterFn.

Here is a picture (we have to use Evaluate to compute derivatives  
before numerical substitutions)

Plot[
	Evaluate[{FitPoly, InterPoly,InterFn[x],
	D[FitPoly,x], D[InterPoly,x],InterFn'[x]}],
	{x,0,8},
	PlotStyle->
	{{Thickness[.02],Hue[0]},{Thickness[.02],Hue[.35]}, 	
	{Thickness[.02],Hue[.7]},
	{Hue[0]},{Hue[.35]},{Hue[.7]}},
	
	Epilog -> {Hue[.2],PointSize[.02],Point/@data}
];

Allan Hayes
hay at haystack.demon.co.uk
http://www.haystack.demon.co.uk


  • Prev by Date: mma-link.lisp for the Mac
  • Next by Date: Re: Lost greek letter list! Where is it?
  • Previous by thread: mma-link.lisp for the Mac
  • Next by thread: Re: Lost greek letter list! Where is it?