{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 Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 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 "Helvetica" 0 1 128 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 260 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 261 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 262 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 263 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 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" 0 18 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 1 0 0 0 0 0 0 }3 0 0 -1 12 12 0 0 0 0 0 0 19 0 }{PSTYLE "" 18 256 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 }} {SECT 0 {EXCHG {PARA 256 "" 0 "" {TEXT 257 23 "Newton-Cotes Quadrature " }}{PARA 0 "" 0 "" {TEXT 256 19 "Mth 351 Summer 1999" }}{PARA 0 "" 0 "" {TEXT 258 16 "Bent E. Petersen" }}{PARA 0 "" 0 "" {TEXT 259 26 "Fil ename: newton_cotes.mws" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 71 "We investigate various compound (closed) Newton-Cote s quadrature rules." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 80 "Newton-Cotes quadrature proceeds as follows - w e wish to approximate an integral" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "Int(f(x),x=a..b);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6# -%$IntG6$-%\"fG6#%\"xG/F);%\"aG%\"bG" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 48 "We subdivide the interval [a,b] into m (the " }{TEXT 260 6 "degree" }{TEXT -1 82 ") subintervals of equal length. The correspond ing m+1 endpoints are called the " }{TEXT 261 5 "nodes" }{TEXT -1 322 ". Now let p be the unique interpolation polynomial of degree at most m through the points on the graph of f corresponding to the \+ nodes. Then the integral of p is our approximation to the integral o f f. The Lagrange formula for the interpolation polynomial, a chang e of variable and a quick calculation show that" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 71 "Int(p(x),x=a..b)= (b-a)*Sum(f(a+k*(b-a)/m),k=0 ..m)*Int(p[k](x),x=0..1);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-%$IntG6 $-%\"pG6#%\"xG/F*;%\"aG%\"bG*(,&F.\"\"\"F-!\"\"\"\"\"-%$SumG6$-%\"fG6# ,&F-F1*&*&%\"kGF1F0F1F3%\"mG!\"\"F1/F=;\"\"!F>F1-F%6$-&F(6#F=F)/F*;FBF 1F1" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 59 "where p[k] is the interp olation polynomial which is 1 at " }{XPPEDIT 18 0 "k/m;" "6#*&%\"kG\" \"\"%\"mG!\"\"" }{TEXT -1 33 " and 0 at the other multiples of " } {XPPEDIT 18 0 "1/m;" "6#*&\"\"\"\"\"\"%\"mG!\"\"" }{TEXT -1 132 ". Th e integrals of the p[k] are called the Newton-Cotes coefficients of \+ degree n. Here's a routine to compute these coefficients:" }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "NCC: =proc(m)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 28 " local k,h,xx,y,yy,coef ,q,w;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 23 " xx:=[seq(k/m,k=0..m)];" } }{PARA 0 "> " 0 "" {MPLTEXT 1 0 10 " coef:=[];" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 20 " y:=[seq(0,k=0..m)];" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "for k from 0 to m do" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 56 " yy: =subsop(k+1=1,y); # make kth component in y 1 in yy" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 21 " q:=interp(xx,yy,x);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 19 " w:=int(q,x=0..1);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 50 " coef:=[op(coef),w]; # push onto list of weights" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "od;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "coef; " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "end:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 19 "Let's check a few. " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 16 "Tapezoida l rule:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "NCC(1);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7$#\"\"\"\"\"#F$" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 15 "Simpson's rule:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "NCC(2);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7%#\"\"\"\"\"'#\"\"#\"\"$F$" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 19 "Simpson's 3/8 rule:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "NCC(3);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7&#\"\"\"\" \")#\"\"$F&F'F$" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 13 "Boole's rule: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "NCC(4);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7'#\"\"(\"#!*#\"#;\"#X#\"\"#\"#:F'F$" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "NCC(5);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7(#\"#>\"$)G#\"#D\"#'*#F(\"$W\"F*F'F$" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "NCC(6);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6 #7)#\"#T\"$S)#\"\"*\"#N#F(\"$!G#\"#M\"$0\"F*F'F$" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "NCC(7);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7*# \"$^(\"&!G<#\"%xNF&#\"#\\\"$S'#\"%*)HF&F,F)F'F$" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 7 "NCC(8);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7+# \"$*)*\"&]$G#\"%WH\"&vT\"#!$k%F)#\"%[_F)#!$a%\"%NGF,F*F'F$" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 324 "Somethin g important happened here. For the case of degree 8 we have some neg ative weights. When the weights are all positive we can integrate nonn egative functions without worrying about loss of significance errors. \+ When some weights are negative this is no longer the case. As a result the degree 8 method is not popular." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "NCC(9);" }}{PARA 11 "" 1 " " {XPPMATH 20 "6#7,#\"%dG\"&+'*)#\"&Td\"F&#\"#F\"%SA#\"%47\"%+c#\"%*)G \"&+[%F/F,F)F'F$" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "NCC(10); " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7-#\"&ng\"\"'_()f#\"&vl#\"')o\\\"# !&vh\"\"'%e*>#\"%vc\"&uC\"#!%D[\"&)36#\"&2y\"\"&[\\#F0F-F*F'F$" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 65 "De gree 9 is well-behaved but degree 10 again has a sign problem. " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 235 "This pro blem with the sign of the weights makes it useless to increase the deg ree in an effort to increase accuracy. We may see a decrease in trunca tion error, but an increase in roundoff error. Thus compound methods a re usually used. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 64 "The idea in the compound methods is we break the interval into " }{XPPEDIT 18 0 "n;" "6#%\"nG" }{TEXT -1 22 " subintervals wh ere " }{XPPEDIT 18 0 "n;" "6#%\"nG" }{TEXT -1 30 " is divisible by t he degree " }{XPPEDIT 18 0 "m;" "6#%\"mG" }{TEXT -1 80 " that we pla n to use. Then we use the Newton-Cotes method on the first set of " } {XPPEDIT 18 0 "m;" "6#%\"mG" }{TEXT -1 124 " subintervals, then on th e second set, and so on, and then add the reuslts together. Let's writ e a routine to do it for us:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "NCCint:=proc(f,r::range,m,n) " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 27 " local k,j,a,b,q,C,h,hh,S;" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "if type(n, numeric) then " }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 " if not type(n,posint) then ERROR( \"n must be positive\"); fi;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 61 " i f not type(m,posint) then ERROR(\"m must be positive\"); fi;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 72 " if not irem(n,m)=0 then ERROR(\"m (degr ee) must divide n (order)\"); fi;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "fi;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 56 "a:=op(1,r); b:=op(2,r); q:= n/m; h:=(b-a)/n; hh:=(b-a)/q;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "C: =NCC(m); S:=0;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "for j from 0 to q -1 do" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 22 " for k from 0 to m do" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 " S:=S+C[k+1]*f(a+j*hh+k*h);" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "od; od;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 63 "S:=hh*S; # rescale, recall intervals here have lengt h (b-a)/q " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "end:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 79 "For example her e is the (compound) Simpson's rule with 6 subintervals on [a,b]." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "NCCint(f,a..b,2,6);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#*&,&%\"bG #\"\"\"\"\"$%\"aG#!\"\"F(F',0-%\"fG6#F)#F'\"\"'-F.6#,&F)#\"\"&F1F%F0# \"\"#F(-F.6#,&F)F7F%F&F&-F.6#,&F)#F'F8F%F?F7-F.6#,&F)F&F%F7F&-F.6#,&F) F0F%F5F7-F.6#F%F0F'" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 82 "If we mult iply by 6 and simplify we see the familiar 1,4,2,4,2,....,2,4,1 patter n." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 43 "Now let's compare some order 36 methods for" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "rng:=2..5: ex:=Int(exp(x),x=rng);" }}{PARA 11 "" 1 " " {XPPMATH 20 "6#>%#exG-%$IntG6$-%$expG6#%\"xG/F+;\"\"#\"\"&" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 73 "`(1,36) rel_error (trapezoid al)`; evalf((ex-NCCint(exp,rng,1,36))/ex,40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%?(1,36)~rel_error~(trapezoidal)G" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!IJPLwDTVlpb]>Q6\"=Nnjy&!#V" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 71 "`(2,36) rel_error (Simpson's)`; evalf((ex-NCCint(e xp,rng,2,36))/ex,40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%=(2,36)~rel_ error~(Simpson's)G" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!IPl9O5/1]g)yjM 7XO\\qpn#!#Y" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 73 "`(3,36) rel _error (Simpson 3/8)`; evalf((ex-NCCint(exp,rng,3,36))/ex,40);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#%?(3,36)~rel_error~(Simpson~3/8)G" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#$!I\\\")o))\\B)ogEkOgR5057#=g!#Y" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 67 "`(4,36) rel_error (Boole)`; \+ evalf((ex-NCCint(exp,rng,4,36))/ex,18);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%9(4,36)~rel_error~(Boole)G" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$ !3rA'\\#eQ-iq!#F" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "`(6,36) rel_error`; evalf((ex-NCCint(exp,rng,6,36))/ex,40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%1(6,36)~rel_errorG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!IuX!GPT-i\\A!)>ncs)3.5qC!#^" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "`(9,36) rel_error`; evalf((ex-NCCint(exp,rng,9,36))/e x,40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%1(9,36)~rel_errorG" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#$!Ic(yITfoG$))R+(*pwq0je$3#!#`" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "`(12,36) rel_error`; evalf(( ex-NCCint(exp,rng,12,36))/ex,40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#% 2(12,36)~rel_errorG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!Iwp;A**>s(\\3 g:73Fw$*4$\\@!#e" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "`(18,36 ) rel_error`; evalf((ex-NCCint(exp,rng,18,36))/ex,40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%2(18,36)~rel_errorG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!IqbW\\J*[)4*=7&)e(fJWIunH!#l" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 60 "Note each of these methods required 37 function evaluations." } }{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 103 "In comp uting the error we use the actual value of the integral and both ex \+ and NCCint() are computed " }{TEXT 262 14 "symbolically. " }{TEXT -1 49 "The difference is found and divided by ex, also " }{TEXT 263 12 " symbolically" }{TEXT -1 197 ". We then convert to floating point at a \+ prescribed precision. By using a very high precision we are able to co mpute the error with minimal roundoff - so we are seeing mostly trunca tion error here." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 31 "Let's consider another example:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "rng:=0..Pi: ex:=Int(sin(x),x=rng);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%#exG-%$IntG6$-%$sinG6#%\"xG/F+;\"\"! %#PiG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 73 "`(1,36) rel_error \+ (trapezoidal)`; evalf((ex-NCCint(sin,rng,1,36))/ex,40);" }}{PARA 11 " " 1 "" {XPPMATH 20 "6#%?(1,36)~rel_error~(trapezoidal)G" }}{PARA 11 " " 1 "" {XPPMATH 20 "6#$\"I+]=SeMcW,Gezz-xv=+Zj!#V" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 71 "`(2,36) rel_error (Simpson's)`; evalf((ex-NC Cint(sin,rng,2,36))/ex,40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%=(2,36 )~rel_error~(Simpson's)G" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!I+++b.SL W " 0 "" {MPLTEXT 1 0 73 "`(3,3 6) rel_error (Simpson 3/8)`; evalf((ex-NCCint(sin,rng,3,36))/ex,40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%?(3,36)~rel_error~(Simpson~3/8)G" } }{PARA 11 "" 1 "" {XPPMATH 20 "6#$!I+++lC\">*)ei!\\Dy^*4cCDE(!#Y" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 67 "`(4,36) rel_error (Boole)`; \+ evalf((ex-NCCint(sin,rng,4,36))/ex,18);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%9(4,36)~rel_error~(Boole)G" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$ \"3+++++Fr%Q*!#F" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "`(6,36) rel_error`; evalf((ex-NCCint(sin,rng,6,36))/ex,40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%1(6,36)~rel_errorG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!I+++++]Z)fd%z6ca#)e#f&QO!#^" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "`(9,36) rel_error`; evalf((ex-NCCint(sin,rng,9,36))/e x,40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%1(9,36)~rel_errorG" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#$\"I++++++]kvf_?)[B-mF%[M!#`" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "`(12,36) rel_error`; evalf(( ex-NCCint(sin,rng,12,36))/ex,40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#% 2(12,36)~rel_errorG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"I+++++++++X6 f/$)zX**QSW!#e" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "`(18,36) \+ rel_error`; evalf((ex-NCCint(sin,rng,18,36))/ex,40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%2(18,36)~rel_errorG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!I++++++++++++]\"Ga`Lw)*)!#l" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 25 "One more set of examples:" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "f:=x->exp(x): rng:=3..8: ex:=Int(f(x),x=rng); " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%#exG-%$IntG6$-%$expG6#%\"xG/F+;\"\"$\"\")" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 71 "`(1,36) rel_error (trapezoid al)`; evalf((ex-NCCint(f,rng,1,36))/ex,40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%?(1,36)~rel_error~(trapezoidal)G" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!I>$)3(G_#3x>5NnhZX2P*pg\"!#U" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 69 "`(2,36) rel_error (Simpson's)`; evalf((ex-NCCint (f,rng,2,36))/ex,40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%=(2,36)~rel_ error~(Simpson's)G" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!IAzt " 0 "" {MPLTEXT 1 0 71 "`(3,36) rel _error (Simpson 3/8)`; evalf((ex-NCCint(f,rng,3,36))/ex,40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%?(3,36)~rel_error~(Simpson~3/8)G" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!IDagq:(3(yYBJrtF^d44IY!#X" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 65 "`(4,36) rel_error (Boole)`; evalf(( ex-NCCint(f,rng,4,36))/ex,18);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%9(4 ,36)~rel_error~(Boole)G" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!3A4g%QK+R ]\"!#D" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 57 "`(6,36) rel_error `; evalf((ex-NCCint(f,rng,6,36))/ex,40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%1(6,36)~rel_errorG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!IPgH_qO GMKVd'eO!RuZ4[9!#\\" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 57 "`(9, 36) rel_error`; evalf((ex-NCCint(f,rng,9,36))/ex,40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%1(9,36)~rel_errorG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!I\"e30l&p(pu(3+t)Q[l*R#fK$!#^" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "`(12,36) rel_error`; evalf((ex-NCCint(f,rng,12,36))/e x,40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%2(12,36)~rel_errorG" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#$!IarxFwm`AB*3)f4G)*3o$)oD!#b" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "`(18,36) rel_error`; evalf(( ex-NCCint(f,rng,18,36))/ex,40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%2( 18,36)~rel_errorG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!IzBM(4Z)RJz^'y; 0!QiC&=,(!#h" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "f:=evaln(f) : # unassign" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 225 "For our (nice and smooth) examples the higher degree \+ methods are much superior. The composite Boole's method is no harder t o apply than Simpson's rule, even for hand calculations, but has small er error (for smooth functions)." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 31 "Compound Boole, 12 subintervals" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 64 "N CCint(f,a..b,4,12): algsubs(b-a=12*h,%): (1/90)*simplify(90*%);" }} {PARA 12 "" 1 "" {XPPMATH 20 "6#,$*&,<-%\"fG6#%\"aG\"\"(-F'6#,&F)\"\" \"%\"hGF.\"#K-F'6#,&F)F.F/\"\"#\"#7-F'6#,&F)F.F/\"\"$F0-F'6#,&F)F.F/\" \"%\"#9-F'6#,&F)F.F/\"\"&F0-F'6#,&F)F.F/\"\"'F5-F'6#,&F)F.F/F*F0-F'6#, &F)F.F/\"\")F>-F'6#,&F)F.F/\"\"*F0-F'6#,&F)F.F/\"#5F5-F'6#,&F)F.F/\"#6 F0-F'6#,&F)F.F/F5F*F.F/F.#F4\"#X" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 30 "Compound Boole, 8 subintervals" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 62 "NCCint(f,a..b,4,8): algsubs(b-a=8*h,%): (1/90)*simplify(90*%);" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#,$*&,4-%\"fG6#%\"aG\"\"(-F'6#,&F)\" \"\"%\"hGF.\"#K-F'6#,&F)F.F/\"\"#\"#7-F'6#,&F)F.F/\"\"$F0-F'6#,&F)F.F/ \"\"%\"#9-F'6#,&F)F.F/\"\"&F0-F'6#,&F)F.F/\"\"'F5-F'6#,&F)F.F/F*F0-F'6 #,&F)F.F/\"\")F*F.F/F.#F4\"#X" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 34 "We see we have a coefficient of " } {XPPEDIT 18 0 "2*h/45;" "6#*&*&\"\"#\"\"\"%\"hGF&F&\"#X!\"\"" }{TEXT -1 178 " and then the sequence 7 32 12 32 14 32 12 32 14 ... .... 14 32 12 32 7. The 14's come from two 7's at the points \+ where two of the interpolation intervals meet." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 239 "Since Boole's rule depen ds on interpolation of degree 4 it is obviously exact for polynomials \+ of degree at most 4. However, just as for Simpson's rule, it is actual ly exact for one degree more, that is, for polynomials of degree at mo st 5." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "collect(NCCint(x->x^5,a..b,4,4),b);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#,&*$)%\"bG\"\"'\"\"\"#\"\"\"F'*$)%\"aGF'F(#!\"\"F'" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 187 "The degree 9 rule is one of the higher degree rules which has p ositive weights. We can expect it to be fairly well-behaved. Why don't you experiment a bit with compound degree 9 rule?" }}}}{MARK "64 1 \+ 0" 104 }{VIEWOPTS 1 1 0 1 1 1803 }