Numerical Analysis (aimee)

Newton’s Divided Difference (2)

Posted by: aimeemarie88 on: December 12, 2008


We learned a more efficient way to code Newton’s divided difference in class last week. We began by trying the code with the equation f(x)=sin(\pi*x) with five equally spaced points:

f=@(x) sin(pi*x)

n=5

x=linspace(-1,1,n)’

c=zeros(n,1)

F=f(x)

c(1)=F(1)

for i=1:n-1

F = diff(F)./(x(i+1:n)-x(1:n-i))

c(i+1)=F(1)

end

m=101;

xx = linspace(-1,1,m)’;

phi = ones(m,n);

for i=2:n

phi(:,i) = phi(:,i-1).*(xx-x(i-1));

end

P=phi*c;

plot(xx,f(xx),‘-r’)

hold on

plot(xx,P,‘-ob’)

sinpix

With the error:

sin_equi_error

Using the same function with Gaussian points:

sin_gauss

With the error:

sin_gauss_error

Next we used Gaussian points with the equation f(x)= \frac{1}{1+4x^2}

%f=@(x) sin(pi*x)

f=@(x) 1./(1+4.*x.^2)

n=7

%x=linspace(-1,1,n)’

x = -cos(pi*(0:n-1)/(n-1))

c=zeros(n,1)

F=f(x)

c(1)=F(1)

for i=1:n-1

F = diff(F)./(x(i+1:n)-x(1:n-i))

c(i+1)=F(1)

end

m=101;

xx = linspace(-1,1,m)’;

phi = ones(m,n);

for i=2:n

phi(:,i) = phi(:,i-1).*(xx-x(i-1));

end

P=phi*c;

plot(xx,f(xx),‘-r’)

hold on

plot(xx,P,‘-ob’)

runge_gauss

With the error:

runge_gauss_error

Using the same function with equidistant points:

runge_equi

With the error:

runge_equi_error

I thought it would be interesting to do a little research into finding out some more information on the Runge Phenomenon. The Runge phenomenon occurs with polynomial interpolation for polynomials of high degree. The higher the order of the polynomial used, the larger the bound of error becomes, showing that instead of moving towards zero, the error is increasing.

Using equally spaced points, as the degree of the polynomial increases, the error near the endpoints gets increasingly larger. It can be proven that the error of the Runge phenomenon using equally spaced points will approach infinity as the degree of the polynomial increases. This contradicts the Weierstrass approximation theorem that explains that there exists a sequence of approximating polynomials with the error converging to zero.

The following picture demonstrates this:

graph1


The red curve is the Runge function.

The blue curve is a 5th order interpolating polynomial.

The green curve is a 9th order interpolating polynomial

At the interpolating points, the error between the function f(x) and the polynomial p(x) is zero. Between the interpolating points, especially near the endpoints, as the degree of the polynomial increases, the error increases.

The following table shows the Runge function, its derivatives, and their evaluations at x=1

  f(x)= \frac{1}{1+25x^2}   |f(1)|=0.038462
  f'(x)= -\frac{50x}{(1+25x^2)^2}   |f'(1)|=0.073964
  f''(x)= \frac{50*(75x^2-1)}{(1+25x^2)^3}   |f''(1)|=0.210514
  f'''(x)= \frac{-15000x(25x^2-1)}{(25x^2+1)^4}   |f'''(1)|=0.787788

Since the magnitude of higher order derivatives of the Runge function gets larger, the bound for error for higher order polynomial interpolations is larger.

The Runge phenomenon shows that using equally spaced points with interpolation of higher degree polynomials can cause problems. Using Gaussian points, the error appears to be more regular, oscillations are minimized, and the error decreases as the degree of the polynomial interpolation increases.

Using the cubic spline interpolation method can help to avoid this since it uses piecewise polynomials.

Leave a Reply


  • dankatzumd: That is interesting. Putting the points $latex p_1$ and $latex p_2$ in terms of the golden ratio $latex \phi$ gives $latex p_1 = (2\phi + \sqrt{2},
  • aheryudono: Dear Students, I just want to clarify things that we discuss in class. Maybe my guidance in class is not clear for some of you. Some of you ask me
  • sigalgottlieb: Nice observation. Now take a look at the value of g'(x) on that domain and connect it to the speed of convergence. Explain why it is connected.

Categories