{VERSION 4 0 "IBM INTEL LINUX22" "4.0" }
{USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0
1 0 0 0 0 1 }{CSTYLE "" -1 256 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }
{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 2 2 0
0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 0" -1
256 1 {CSTYLE "" -1 -1 "10x20" 1 20 0 0 0 0 2 2 2 0 0 0 0 0 0 0 }0 0
0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 2" -1 257 1 {CSTYLE ""
-1 -1 "Courier" 1 24 0 0 0 0 2 2 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0
0 0 0 0 -1 0 }{PSTYLE "R3 Font 3" -1 258 1 {CSTYLE "" -1 -1 "Times" 1
32 0 0 0 0 2 2 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }
{PSTYLE "R3 Font 4" -1 259 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 0 2
2 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 259
260 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }0 0 0 -1
-1 -1 0 0 0 0 0 0 -1 0 }}
{SECT 0 {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA
258 "" 0 "" {TEXT -1 61 "Integrals and Riemann Sums in One, Two, and \+
Three Variables\n" }}{PARA 258 "" 0 "" {TEXT -1 36 "Approximating sums
in dimension one\n" }}{PARA 0 "" 0 "" {TEXT -1 377 "Here are some exa
mples of commands that use Maple to calculate approximating\nsums for
integrals in one, two, and three variables.\n\nThe first few inputs m
ay look mysterious; they simply define some of the commands\nwe'll ne
ed for future reference. There's no need to worry too much about\nth
e precise details of how they're defined, but do watch the syntax in \+
the\nexamples.\n\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 329 "midpointsum \+
:= proc (f,interval,n) local a,b,x,i,step,total;\n a := op(1,op(2
,interval));\n b := op(2,op(2,interval));\n x := op(1,interval
);\n step := (b-a)/n;\n total := 0;\n for i from 1 to n do
\n total := total + evalf( subs(x=a+i*step-step/2,f) );\n od;
\n total := evalf( total*step );\n end:\n" }}}{EXCHG {PARA 0 "
" 0 "" {TEXT -1 484 "The previous command defined a midpoint rule Ri
emann sum for functions of\none variable. Here are some examples to
show how it works. The\nlast input tells how many subdivisions of th
e interval of integration\nthe rule should use. We'd expect that w
ith more subdivisions, the answer ought\nto get closer and closer to t
he `exact' value of the integral.\n\nSuppose, e.g., that we want to in
tegrate sin(x) from x=0 to x=1. The answer\nis easy to find by \+
antidifferentiation:\n\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "int( si
n(x),x=0..1);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 33 "\nLet's find a n
umerical version:\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "evalf(%);" }}
}{EXCHG {PARA 0 "" 0 "" {TEXT -1 137 "\nNow let's compare this with so
me approximations to the same integral,\nusing the midpoint rule. Fir
st we'll use just four subdivisions:\n" }}{PARA 0 "> " 0 "" {MPLTEXT
1 0 32 "midpointsum( sin(x), x=0..1, 4);" }}}{EXCHG {PARA 0 "" 0 ""
{TEXT -1 115 "\nThe answer isn't too bad an approximation, given the s
mall number of subdivisions.\nBut let's bump that number up.\n" }}
{PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "midpointsum( sin(x), x=0..1, 8);" }
}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "midpointsum( sin(x), x=0..
1, 100);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 272 " \nThe estimates see
m to behave as they should---larger numbers of subdivisions\ntend to g
ive better estimates. But it's striking how well the method works \+
even\nfor small numbers of subdivisions. \n\nTry the same idea on s
ome other functions and/or other intervals. " }}{PARA 0 "" 0 ""
{TEXT -1 0 "" }}{PARA 259 "" 0 "" {TEXT 256 35 "Approximating sums in \+
dimension two" }}{PARA 259 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 ""
{TEXT -1 425 "Now let's do some approximating sums for a function f(x
,y) of two variables. The\nidea is to approximate the integral of s
uch a function over a rectangle [a,b] x [c,d] .\nFirst we have to te
ll Maple the two-dimensional version of the midpoint sum\nrule. (Th
ink about what midpoint means in this case!) As above, there's no
\nneed to worry about details of the Maple procedure below---what it d
oes\nis what's important." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}
{PARA 0 "> " 0 "" {MPLTEXT 1 0 552 "doublemidpointsum := proc (f,inter
val1,interval2,n)\n local a,b,c,d,x,y,i,j,stepx,stepy,total;\n \+
a := op(1,op(2,interval1));\n b := op(2,op(2,interval1));\n c
:= op(1,op(2,interval2));\n d := op(2,op(2,interval2));\n x :
= op(1,interval1);\n y := op(1,interval2);\n stepx := (b-a)/n;
\n stepy := (d-c)/n;\n total := 0;\n for i from 1 to n do
\n for j from 1 to n do\n total := total +\n evalf( subs(x
=a+i*stepx-stepx/2,y=c+j*stepy-stepy/2,f));\n od;\n od;\n \+
total := evalf( total*stepx*stepy );\n end:" }}}{EXCHG {PARA 0 ""
0 "" {TEXT -1 282 "\nNotice that there are now two intervals involved-
--one in the x-variable and\none in the y-variable. \n\nLet's apply
the rule to the function f(x,y) = sin(x)sin(y), on the rectangle\n[
0,1] x [0,1], using 10 subdivisions in each direction. (This produce
s a grid\nof 100 squares.)\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1
0 54 "doublemidpointsum( sin(x)*sin(y), x=0..1, y=0..1, 10);" }}}
{EXCHG {PARA 0 "" 0 "" {TEXT -1 386 "The answer is an approximation to
the integral of sin(x)sin(y) over the same\nsquare. Geometrical
ly, such an integral tells the volume of the solid whose base\nis on \+
the square [0,1] x [0,1] in the xy-plane, and whose ``top'' is t
he surface\nz=f(x,y). Let's look at this figure, to see whether the
number above seems\nlike any sort of sensible approximation to its vo
lume:\n\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "plot3d( sin(x)*sin(y),
x=0..1, y=0..1, axes=boxed);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 204
"\n\nTake a close look. Does it seem possible that the volume is aro
und 0.2?\n\nTo find the volume ``exactly,'' we can use an iterated i
ntegral, i.e., we can\nintegrate in one variable and then the other:\n
\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "int( sin(x)*sin(y), x=0..1);
" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 115 "The result is a function of \+
y (as it should be ---think about it).\n\nNow we can integrate in t
he other variable:\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "int(%,y=0..
1);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 69 "\n\nWe could have done the
same thing all in one step, if we'd wanted:\n" }}{PARA 0 "> " 0 ""
{MPLTEXT 1 0 43 "int( int( sin(x)*sin(y), x=0..1), y=0..1 );" }}}
{EXCHG {PARA 0 "" 0 "" {TEXT -1 30 "\nLet's get a decimal value:\n"
}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "ev
alf(%);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 160 "\nNotice how similar \+
that number is to the one we found using the midpoint rule. With\nfe
wer subdivisions, we get less good agreement (but still not too bad):
\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 53 "doublemidpointsum( sin(x)*sin
(y), x=0..1, y=0..1, 4);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 76 "Try t
he same idea on some other functions f(x,y) and some other intervals.
\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 "\n" }}{PARA 260 "" 0 ""
{TEXT -1 37 "Approximating sums in dimension three" }}{PARA 259 "" 0 "
" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 359 "Approximating sums wor
k much the same way for a function g(x,y,z) of three variables. \nT
his time, we approximate the integral of such a function over a cube\n
\n [a,b] x [c,d] x [e,f] .\n\nHere is Maple's thre
e-dimensional version of the midpoint sum. It's even\nmessier than t
he earlier versions, and you can safely ignore its Maple code:\n" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 809 "triplemidpointsum := proc (
g,interval1,interval2,interval3,n)\n local a,b,c,d,e,f,x,y,z,i,j,k
,stepx,stepy,stepz,total;\n a := op(1,op(2,interval1));\n b :=
op(2,op(2,interval1));\n c := op(1,op(2,interval2));\n d := o
p(2,op(2,interval2));\n e := op(1,op(2,interval3));\n f := op(
2,op(2,interval3));\n x := op(1,interval1);\n y := op(1,interv
al2);\n z := op(1,interval3);\n stepx := (b-a)/n;\n stepy \+
:= (d-c)/n;\n stepz := (f-e)/n;\n total := 0;\n for i from
1 to n do\n for j from 1 to n do\n for k from 1 to n do\n \+
total := total + evalf( subs(x=a+i*stepx-stepx/2,\n \+
y=c+j*stepy-stepy/2,\n \+
z=e+k*stepz-stepz/2,g));\n od; od; od;\n total := evalf( tot
al*stepx*stepy*stepz );\n end:\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT
-1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 262 "Let's use the command to appr
oximate the integral of the constant function g(x,y,z)=x+y+z\nover t
he cube [0,1] x [0,2] x [0,3] . Note that setting n=4 here reall
y amounts\nto using 4^3 = 64 subdivisions. (Setting n=10 would invo
lve 1000 subdivisions!)\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 54 "triple
midpointsum( x+y+z, x=0..1, y=0..2, z=0..3, 4);" }}}{EXCHG {PARA 0 "
" 0 "" {TEXT -1 121 "\nThat number can't readily be interpreted geomet
rically, but it does agree with what\nwe'd get by iterated integratio
n:\n\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "int( int( int( x+y+z,x=0.
.1), y=0..2), z=0..3);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 "\033" }}
}}{MARK "22 0 0" 1 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0
1 2 33 1 1 }