Choice of nodes and interpolation error.

This demonstration shows the relationship between choice of nodes and interpolation error for some explicit functions.

f[x_] := (1/(1 + 100 (x^2)));

EqualNodes = Subdivide[-1,1,40];
EqualPoly = InterpolatingPolynomial[{#,f[#]}& /@ EqualNodes,x];
Show[{ListPlot[{#,f[#]}& /@ EqualNodes,Axes->True],Plot[{f[x],EqualPoly},{x,-1,1},Filling->{1->{{2},{Red,Blue}}}]},PlotRange->{{-1,1},{0,1}}]

Now we’re going to try to interpolate with a different choice of nodes (which is going to look completely weird!). Here are the “Chebyshev nodes”:

ChebyshevNodes = Cos /@ Subdivide[0.0,1.0π,40];

Graphics[Point[{#,0}]& /@ ChebyshevNodes,Axes->True]

ChebyshevPoly = InterpolatingPolynomial[{#,f[#]}& /@ ChebyshevNodes,x];

Show[{ListPlot[{#,f[#]}& /@ ChebyshevNodes,Axes->True],Plot[{f[x],ChebyshevPoly},{x,-1,1},Filling->{1->{{2},{Red,Blue}}},PlotRange->{{-1,1},{0,1}}]},PlotRange->{{-1,1},{0,1}}]

This is so striking that we’ll zoom in to convince ourselves that there is some error in the approximation!

Show[{ListPlot[{#,f[#]}& /@ ChebyshevNodes,Axes->True],Plot[{f[x],ChebyshevPoly},{x,-1,1},Filling->{1->{{2},{Red,Blue}}}]},PlotRange->{{-0.8,-0.6},{0,0.05}}]

Here the wavy curve is P(x) and the straighter one is (1/(1 + 100 (x^2))).