Interpolation Error: Estimation

Harri Hakula, 2021

Setup

We use the same set of  nodes (Subscript[x, i]) for interpolating two functions below.

xp = Subdivide[0,1,3]

Case 1: f(x) = (e^x)

f[x_]:=Exp[x];

yp=f[xp];

data=Transpose[{xp,yp}];

ip=InterpolatingPolynomial[data,x];

n=Exponent[ip,x]

Let us plot the absolute value of the error.

Plot[Abs[f[x]-ip],{x,0,1}]

Over the interval, the absolute value of the 4th derivative of the function is bounded from above by M = e:

M=Exp[1];

We need to maximize the absolute value of the product term. We proceed as usual, here we can cheat and use the power of Mathematica.

pr=Times@@(x-xp);

max=First@Maximize[{pr,0≤x≤1},x]
min=First@Minimize[{pr,0≤x≤1},x]

bound=Max[Abs[min],Abs[max]]

Plot[{Abs[f[x]-ip],M bound/(n+1)!},{x,0,1}]

Of course, we could skip the estimation and compute directly.

max=First@NMaximize[{Abs[f[x]-ip],0≤x≤1},x]

Plot[{Abs[f[x]-ip],M bound/(n+1)!,max},{x,0,1}]

Case 2: f(x) = sin(x)

f[x_]:=Sin[x];

yp=f[xp];

data=Transpose[{xp,yp}];

ip=InterpolatingPolynomial[data,x];

n=Exponent[ip,x]

Let us plot the absolute value of the error.

Plot[Abs[f[x]-ip],{x,0,1}]

Over the interval, the absolute value of the 4th derivative of the function is bounded from above by M = 1:

Plot[{1,Sin[x]},{x,0,1}]

M=1;

We need to maximize the absolute value of the product term. We proceed as usual, here we can cheat and use the power of Mathematica.

pr=Times@@(x-xp);

max=First@Maximize[{pr,0≤x≤1},x]
min=First@Minimize[{pr,0≤x≤1},x]

bound=Max[Abs[min],Abs[max]]

Plot[{Abs[f[x]-ip],M bound/(n+1)!},{x,0,1}]

Of course, we could skip the estimation and compute directly.

max=First@NMaximize[{Abs[f[x]-ip],0≤x≤1},x]

Plot[{Abs[f[x]-ip],M bound/(n+1)!,max},{x,0,1}]

Amusingly, 1/3456 is a pretty good approximation.

Plot[{Abs[f[x]-ip],M bound/(n+1)!,max,1/3456},{x,0,1}]