Lagrange Interpolating Polynomial

Author

Eric W. Weisstein
April 14, 2006

This notebook downloaded from http://mathworld.wolfram.com/notebooks/NumericalMath/LagrangeInterpolatingPolynomial.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/LagrangeInterpolatingPolynomial.html.

©2006 Wolfram Research, Inc. except for portions noted otherwise

Plot

MakeBoxes[xlabel,TraditionalForm]:="x"
MakeBoxes[ylabel[n_],TraditionalForm]:=RowBox[{SubscriptBox["P",MakeBoxes[n,TraditionalForm]],"(","x",")"}]

Lagrange[l_List,max_]:=Module[{n=Length[l],i,x},
Plot[Evaluate[InterpolatingPolynomial[l,x]],{x,0,max},DisplayFunction->Identity,PlotStyle->Red,AxesLabel->TraditionalForm/@{xlabel,ylabel[n]},Epilog->{Blue,PointSize[.03],Point/@Table[{i,l[[i]]},{i,n}]}]
]

pts={1,2,4,6,7};
Show[Graphics[GraphicsArray[Partition[Table[Lagrange[Take[pts,i],8],{i,2,Length[pts]}],2]]],ImageSize->500]

Degenerate

InterpolatingPolynomial[Range[5],x]

InterpolatingPolynomial[{1,2,4,6,7},x]//Expand