Interpolating a Set of Data

Manipulate[Quiet@Plot[Evaluate[Interpolation[Sort[pts,(#[[1]]<#2[[1]]&)]//.{left___,{x1_,y1_},{x1_,y2_},right___}->{left,{x1-(10^(-4)),y1},{x1,y2},right},InterpolationOrder->ord][x]],{x,0,1},PlotRange->{-1,1},Frame->True,FrameTicks->None,Filling->Axis,FillingStyle->LightGreen,ImageSize->450],{{pts,Table[{x,x Sin[8x]},{x,0,1,0.1}]},{0,-1},{1,1},Locator,LocatorAutoCreate->{1,∞}},{{ord,2,"interpolation order"},0,Length[pts]-1,1,Appearance->"Labeled"}]

CAPTION

Change the interpolation order to see the best interpolation of the points with piecewise polynomials of different degrees.

THIS NOTEBOOK IS THE SOURCE CODE FROM

"Interpolating a Set of Data" from the Wolfram Demonstrations Project
 http://demonstrations.wolfram.com/InterpolatingASetOfData/

Contributed by: Stephen Wolfram

A full-function Wolfram Mathematica system (Version 6 or higher) is required to edit this notebook.
GET WOLFRAM MATHEMATICA »

© Wolfram Demonstrations Project & Contributors   |   Terms of Use   |   Make a new version of this Demonstration »