MATH 371 -- Numerical Analysis

October 5, 2001

Error of Interpolation

Consider the degree 2 interpolating polynomial for

sin(x) constructed using x[0] = Pi/8 , x[1] = Pi/4 , x[2] = 3*Pi/8 ,

on the interval [0, Pi/2] .

> x[0]:=evalf(Pi/8): x[1]:=evalf(Pi/4): x[2]:=evalf(3*Pi/8):

> y[0]:=sin(x[0]): y[1]:=sin(x[1]): y[2]:=sin(x[2]):

The Lagrange polynomials L[n,k](x)

> L[2,0]:=expand((x-x[1])*(x-x[2])/((x[0]-x[1])*(x[0]-x[2])));

L[2,0] := 3.242277877*x^2-6.366197723*x+3.000000000...

> L[2,1]:=expand((x-x[0])*(x-x[2])/((x[1]-x[0])*(x[1]-x[2])));

L[2,1] := -6.484555755*x^2+10.18591636*x-3.00000000...

> L[2,2]:=expand((x-x[0])*(x-x[1])/((x[2]-x[0])*(x[2]-x[1])));

L[2,2] := 3.242277879*x^2-3.819718637*x+1.000000001...

The interpolating polyomial

> p:=expand(y[0]*L[2,0]+y[1]*L[2,1]+y[2]*L[2,2]);

p := -.349033150*x^2+1.237332266*x-.493905136e-1

> plot({sin(x),p},x=0..Pi/2);

[Maple Plot]

> plot(abs(sin(x)-p),x=0..Pi/2);

[Maple Plot]

>

Note the pretty close agreement between the interpolating polynomial and the

sin graph (especially toward the middle of the interval). At x = 0.6, for instance:

> abs(sin(.6)-subs(x=.6,p));

.27144386e-2

Using the bound M = 1 for the third derivative of sine, the error bound says

abs(f(x)-p(x)) <= 1*abs(x-x[0])*abs(x-x[1])*abs(x-x[2])/6

> abs(.6-x[0])*abs(.6-x[1])*abs(.6-x[2])/6;

.3703022092e-2

To get better approximations here we could try more interpolation points.