Newton Divided Difference and Interpolation Polynomials | MTH 351, Study notes of Mathematical Methods for Numerical Analysis and Optimization

Material Type: Notes; Class: INTRODUCTION TO NUMERICAL ANALYSIS; Subject: Mathematics; University: Oregon State University; Term: Spring 2001;

Typology: Study notes

Pre 2010

Uploaded on 08/30/2009

koofers-user-k48
koofers-user-k48 ๐Ÿ‡บ๐Ÿ‡ธ

5

(1)

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Newton Divided Differences and Interpolation Polynomials
Mth 351 May 8 2001 - Maple 5.00
Bent E. Petersen
Filename: 351s2001_newton_divided_diff.mws
> restart;
The procedure divdiff() computes symbolic Newton divided differences recursively. Not much error
checking is done so be careful. Note the use of a limit in the code. This allows us to compute the
divided differences even when the nodes are not all distinct. The purpose of this procedure is to give
you something to experiment with when you study Newton divided differences.
We use the divdiff() procedure to compute interpolation polynomials of functions in the procedure
Ninterp() below. One nice feature is that Ninterp() does the right thing for the case of repeated nodes.
Of course, Maple does have built-in interpolation, and one should use it. The Maple routine however
works with lists of points, rather than functions. Thus Maple has no sensible way of handling repeated
nodes, and returns an error in this case. We show below how the Maple routine can be used to
interpolate functions and how to handle repeated nodes in that case simply by blowing up the repeated
points and then passing to a limit.
> divdiff:=proc(f)
> local x;
> if nargs < 2 then ERROR(FAIL); fi;
> if nargs = 2 then RETURN(f(args[2]));
> else
>
limit((divdiff(f,args[3..nargs])-divdiff(f,x,args[3..nargs-1]))/(a
rgs[nargs]-x),x=args[2]);
> fi;
> end:
Here's some examples:
> divdiff(f,a);
( )f a
> divdiff(f,a,a);
( )( )Dfa
> divdiff(f,a,b);
โˆ’ โˆ’ ( )f b( )f a
โˆ’ + b a
> divdiff(f,a,a,a);
Page 1
pf3
pf4

Partial preview of the text

Download Newton Divided Difference and Interpolation Polynomials | MTH 351 and more Study notes Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

Newton Divided Differences and Interpolation Polynomials

Mth 351 May 8 2001 - Maple 5.

Bent E. Petersen Filename: 351s2001_newton_divided_diff.mws

> restart;

The procedure divdiff() computes symbolic Newton divided differences recursively. Not much error checking is done so be careful. Note the use of a limit in the code. This allows us to compute the divided differences even when the nodes are not all distinct. The purpose of this procedure is to give you something to experiment with when you study Newton divided differences.

We use the divdiff() procedure to compute interpolation polynomials of functions in the procedure Ninterp() below. One nice feature is that Ninterp() does the right thing for the case of repeated nodes. Of course, Maple does have built-in interpolation, and one should use it. The Maple routine however works with lists of points, rather than functions. Thus Maple has no sensible way of handling repeated nodes, and returns an error in this case. We show below how the Maple routine can be used to interpolate functions and how to handle repeated nodes in that case simply by blowing up the repeated points and then passing to a limit.

**> divdiff:=proc(f)

local x; if nargs < 2 then ERROR(FAIL); fi; if nargs = 2 then RETURN(f(args[2])); else

limit((divdiff(f,args[3..nargs])-divdiff(f,x,args[3..nargs-1]))/(a rgs[nargs]-x),x=args[2]);

fi; end:**

Here's some examples:

> divdiff(f,a);

f ( a ) > divdiff(f,a,a);

D( ) f ( a ) > divdiff(f,a,b);

โˆ’

f( b )โˆ’f( a ) โˆ’ b + a > divdiff(f,a,a,a);

( D(^2 ))( ) f ( a )

> divdiff(f,a,a,b);

f( b ) โˆ’ f( a )โˆ’ D( ) f ( a ) b +D( ) f ( a ) a ( โˆ’ b + a )^2 > divdiff(f,a,b,c);

โˆ’

f( c ) b โˆ’ f( c ) a + f( b ) a โˆ’ f( b ) c + f( a ) c โˆ’f( a ) b ( โˆ’ c + b )( โˆ’ b + a )( a โˆ’ c )

Here's a routine to compute interpolation polynomials using Newton's divided differences formula. Note Maple does have built in support for interpolation. One should really use it. See below.

**> Ninterp:=proc(f,x)

local k,A,n; n:=3; if nargs < n then ERROR(FAIL); fi; if nargs = n then RETURN(x->f(args[3])); else A:=divdiff(f,args[n..nargs]); for k from nargs-1 to n by -1 do A:=A(x-args[k])+divdiff(f,args[n..k]); od; fi; A; end:*

Here's a few examples.

The tangent line

> Ninterp(f,t,a,a);

D( ) f ( a )( t โˆ’ a ) +f( a )

The parabola of contact order 2, that is, the Taylor polynomial at a of degree at most 2:

> Ninterp(f,t,a,a,a);

( D(^2 ))( ) f ( a )( t โˆ’ a ) D( ) f ( a ) ( t โˆ’ a ) f( a )

The parabola with order of contact 1 at a and order of contact 0 at b

> Ninterp(f,s,a,a,b);

It's not immediately obvious that p3 is equal to p, so let's look at the difference.

> simplify(p-p3);

0

Sure enough!

>