Topic : Additional Interpolation Topics
Simulation : Higher Order Interpolation is a Bad Idea
Language : Mathematica 4.1
Authors : Nathan Collier,Autar Kaw
Date : 26 November 2002
Abstract : In 1901, Carl Runge published his work on dangers of higher order interpolation. He took a simple looking function f(x)=1/(1+25x2) on the interval [-1,1].  He took points equidistantly spaced in [-1,1] and interpolated the points with polynomials.  He found that as he took more points, the polynomials and the original curve differed considerably.

ClearAll;

INPUTS: Enter the following

You can make 3 seperate choices for the number of equidistant points in [-1,1]. So if you choose n1=5, you are using a 4th order polynomial to approximate 1/(1+25*x^2).

n1 := 5

n2 := 9

n3 := 17

SOLUTION

f[x_] := 1/(1 + 25*x^2)

Runge = Plot[f[x], {x, -1, 1}];

x1 := Table[2/(n1 - 1)*i - 1, {i, 0, n1 - 1}]
y1 := f[x1]
M = 
        Table[x1[[i + 1]]^j, {i, 0, n1 - 1}, {j, 0, 
            n1 - 1}];
M[[(n1 + 1)/2, 1]] = 1;
A = LinearSolve[M, y1];

\(\(\(f1[z_]\)\(:=\)\(Sum[
        A[\([i]\)]*z^\((i - 1)\), {i, 1, n1}]\)\(	\)\)\)

plot1 = Plot[f1[z], {z, -1, 1}];

x2 := Table[2/(n2 - 1)*i - 1, {i, 0, n2 - 1}]
y2 := f[x2]
M = 
        Table[x2[[i + 1]]^j, {i, 0, n2 - 1}, {j, 0, 
            n2 - 1}];
M[[(n2 + 1)/2, 1]] = 1;
A = LinearSolve[M, y2];

\(\(\(f2[z_]\)\(:=\)\(Sum[
        A[\([i]\)]*z^\((i - 1)\), {i, 1, n2}]\)\(	\)\)\)

plot2 = Plot[f2[z], {z, -1, 1}];

x3 := Table[2/(n3 - 1)*i - 1, {i, 0, n3 - 1}]
y3 := f[x3]
M = 
        Table[x3[[i + 1]]^j, {i, 0, n3 - 1}, {j, 0, 
            n3 - 1}];
M[[(n3 + 1)/2, 1]] = 1;
A = LinearSolve[M, y3];

\(\(\(f3[z_]\)\(:=\)\(Sum[
        A[\([i]\)]*z^\((i - 1)\), {i, 1, n3}]\)\(	\)\)\)

plot3 = Plot[f3[z], {z, -1, 1}];

Show[Runge, plot1, plot2, plot3];