Errors in Polynomial Interpolation

Marcin Bownik
Department of Mathematics
University of Oregon

The following procedure computes interpolating polynomials to the Runge functin f(x)=1/(1+x^2)^2. 

In the first example we use equally spaced nodes. Note that the error of approximation actually grows with n. 

However, in the second example we use the Chebushev nodes. In this case interpolating polynomials behave much better and the error of approximation decreases to 0 as n→∞.

F[x_]:=1/(1+x*x)
a=-5; b=5;

Manipulate[ 
data=N[Table[{x,F[x]},{x,a,b,(b-a)/n}]];
P[x_]:=InterpolatingPolynomial[data,x];
t1=ListPlot[data,PlotRange->{{a,b},{-5,5}}];
t2=Plot[Evaluate[P[x]] ,{x,a, b},PlotRange->{{a,b},{-5,5}}];
Show[t1,t2],
 {n,1,30,1}]

Manipulate[ 
inputs=Table[(a+b)/2+(a-b)/2*Cos[(2i+1)Pi/(2n+2)],{i,0,n}];
data=N[Partition[Riffle[inputs,F[inputs]],2]];
P[x_]:=InterpolatingPolynomial[data,x];
t1=ListPlot[data,PlotRange->{{a,b},{-5,5}}];
t2=Plot[Evaluate[P[x]] ,{x,a, b},PlotRange->{{a,b},{-5,5}}];
Show[t1,t2],
 {n,1,30,1}]