{VERSION 3 0 "IBM INTEL NT" "3.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 }{CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 256 "Helvetica" 1 14 128 0 0 1 0 0 2 0 0 0 0 0 0 } {CSTYLE "" -1 257 "" 0 24 0 0 255 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "Helvetica" 0 1 128 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 259 "He lvetica" 0 1 128 0 0 1 0 0 0 0 0 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Heading 1" 0 3 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 }1 0 0 0 8 4 0 0 0 0 0 0 -1 0 }{PSTYLE "Headin g 2" 3 4 1 {CSTYLE "" -1 -1 "" 1 14 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 8 2 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 3" 4 5 1 {CSTYLE "" -1 -1 " " 1 12 0 0 0 0 1 0 0 0 0 0 0 0 0 }0 0 0 -1 0 0 0 0 0 0 0 0 -1 0 } {PSTYLE "Maple Output" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 11 12 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Title" -1 256 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 1 2 2 2 1 1 1 }1 1 0 0 12 12 1 0 1 0 2 2 19 1 }} {SECT 0 {EXCHG {PARA 256 "" 0 "" {TEXT 257 56 "Newton Divided Differen ces and Interpolation Polynomials" }}{PARA 0 "" 0 "" {TEXT 256 31 "Mth 351 May 8 2001 - Maple 5.00" }}{PARA 0 "" 0 "" {TEXT 258 16 "Bent E. \+ Petersen" }}{PARA 0 "" 0 "" {TEXT 259 42 "Filename: 351s2001_newton_di vided_diff.mws" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 374 "The procedure divdiff() computes sy mbolic Newton divided differences recursively. Not much error checking is done so be careful. Note the use of a limit in the code. This allo ws us to compute the divided differences even when the nodes are not a ll distinct. The purpose of this procedure is to give you something to experiment with when you study Newton divided differences." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 637 "We use the div diff() 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 Mapl e 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 inte rpolate functions and how to handle repeated nodes in that case simply by blowing up the repeated points and then passing to a limit." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "divdiff:=proc(f)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 9 " local x; " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 35 " if nargs < 2 then ERROR(FAIL); fi;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 38 " if nargs = 2 then RETURN(f (args[2]));" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "else" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 92 " limit((divdiff(f,args[3..nargs])-divdiff(f,x,ar gs[3..nargs-1]))/(args[nargs]-x),x=args[2]);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "fi;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "end:" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 21 "He re's some examples:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "divdiff(f,a);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%\"fG6#%\"aG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "divdiff(f,a,a);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#--%\"DG6#%\"f G6#%\"aG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "divdiff(f,a,b); " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#,$*&,&-%\"fG6#%\"bG\"\"\"-F'6#%\"a G!\"\"\"\"\",&F)F.F-F*!\"\"F." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "divdiff(f,a,a,a);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#,$---%#@@G6 $%\"DG\"\"#6#%\"fG6#%\"aG#\"\"\"F*" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "divdiff(f,a,a,b);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6# *&,*-%\"fG6#%\"bG\"\"\"-F&6#%\"aG!\"\"*&--%\"DG6#F&F+F)F(F)F-*&F/\"\" \"F,F)F)F4*$),&F(F-F,F)\"\"#F4!\"\"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "divdiff(f,a,b,c);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6# ,$*&,.*&-%\"fG6#%\"cG\"\"\"%\"bGF+F+*&F'\"\"\"%\"aGF+!\"\"*&-F(6#F,F+F /F.F+*&F2F.F*F+F0*&-F(6#F/F+F*F.F+*&F6F.F,F.F0F.*(,&F*F0F,F+\"\"\",&F, F0F/F+\"\"\",&F/F+F*F0\"\"\"!\"\"F0" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 191 "Here's a routine to compute in terpolation polynomials using Newton's divided differences formula. No te Maple does have built in support for interpolation. One should real ly use it. See below." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "Ninterp:=proc(f,x)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "local k,A,n; n:=3;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "if nargs < n then ERROR(FAIL); fi;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "if nargs = n then RETURN(x->f(args[3]));" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "else" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "A:=divdiff(f,args[n..nargs]);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 76 "f or k from nargs-1 to n by -1 do A:=A*(x-args[k])+divdiff(f,args[n..k]) ; od;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "fi;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "A;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "end:" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 22 "He re's a few examples." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 16 "The tangent line" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "Ninterp(f,t,a,a);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#,&*&--%\"DG6#%\"fG6#%\"aG\"\"\",&%\"tGF,F+! \"\"F,F,-F)F*F," }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 89 "The parabola of contact order 2, that is, the Taylor polynomial at a of degree at most 2:" }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "Ninterp(f,t,a,a,a);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#,&*&,&*&---%#@@G6$%\"DG\"\"#6#%\"fG6#% \"aG\"\"\",&%\"tGF2F1!\"\"F2#F2F---F,F.F0F2F2F3\"\"\"F2-F/F0F2" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 69 "Th e parabola with order of contact 1 at a and order of contact 0 at b" } }{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "Ninterp(f,s,a,a,b);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#,&*&,&*&* &,*-%\"fG6#%\"bG\"\"\"-F*6#%\"aG!\"\"*&--%\"DG6#F*F/F-F,F-F1*&F3\"\"\" F0F-F-F-,&%\"sGF-F0F1F-F8*$),&F,F1F0F-\"\"#F8!\"\"F-F3F-F-F9F8F-F.F-" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 73 "The polynomial of degree at most 3 with order of contact 1 at a and a t b:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "p:=Ninterp(f,x,a,a,b,b);" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#>%\"pG,&*&,&*&,&*&*&,.*&--%\"DG6#%\"fG6#%\"bG\"\"\"F4F5 !\"\"*&F.\"\"\"%\"aGF5F5-F2F3\"\"#-F26#F9!\"#*&-F/F=F5F4F8F6*&F@F8F9F8 F5F5,&%\"xGF5F4F6F5F8*$),&F4F6F9F5\"\"$F8!\"\"F5*&,*F:F5F \+ " 0 "" {MPLTEXT 1 0 17 "pf:=unapply(p,x):" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 6 "pf(a);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%\"fG6#% \"aG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "pf(b): simplify(%); " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%\"fG6#%\"bG" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 9 "D(pf)(a);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6# --%\"DG6#%\"fG6#%\"aG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "D( pf)(b): simplify(%);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#--%\"DG6#%\"fG 6#%\"bG" }}}{EXCHG {PARA 5 "" 0 "" {TEXT -1 0 "" }}{PARA 4 "" 0 "" {TEXT -1 36 "Using Maple's interpolation facility" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 349 "Let's now try to obtain \+ this last polynomial by using Maple's built-in interpolation. The Mapl e routine requires that the nodes all be distinct, so first we use dis tinct nodes, and then we pass to the limit as two of the nodes approac h the other two nodes. Note the use of the map() function to obtain a \+ list of ordinates from the list of abscissas." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "p2:=interp( [a,aa,b,bb],map(f,[a,aa,b,bb]),x):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "p3:=limit(limit(p2,aa=a),bb=b);" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#>%#p3G*&,\\o**)%\"aG\"\"#\"\"\"%\"bG\"\"\"%\"xGF---%\"D G6#%\"fG6#F,F-F-*(-F06#F)F-)F,F*F+F(F+!\"\"*(-F3F7F-F)F-F8F+\"\"$*(F(F +F/F+F8F+F-*(F)F+)F.F*F+-F3F4F-!\"$*(F)F+F?F+F;F+F<*()F.F " 0 "" {MPLTEXT 1 0 15 "simplify(p- p3);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"!" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 12 "Sure enough!" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "34" 0 }{VIEWOPTS 1 1 0 1 1 1803 }