Laboratory 6
Double Integrals and Riemann Sums
Name:

Code

showRiemannSum[f_,{a1_,b1_},{a2_,b2_},max_]:=Module[
{g,n,sampleX,sampleY,Δx,Δy,p1,p2,riemannSum},
g[x_,y_]=f[x,y];
Manipulate[
Δx=(b1-a1)/n;Δy=(b2-a2)/n;
sampleX=Table[a1+i*Δx+RandomInteger[{1,7}]*Δx/8,{i,0,n-1},{j,0,n-1}];
sampleY=Table[a2+j*Δy+RandomInteger[{1,7}]*Δy/8,{i,0,n-1},{j,0,n-1}];
p1=Table[
Graphics3D[
{PointSize[.02],
Point[{sampleX[[i]][[j]],sampleY[[i]][[j]],g[sampleX[[i]][[j]],sampleY[[i]][[j]]]}]
}],
{i,1,n},{j,1,n}];
p2=Table[
Graphics3D[
{Boxed->False,
Cuboid[{a1+(i-1)*Δx,a2+(j-1)*Δy,0},{a1+i*Δx,a2+j*Δy,g[sampleX[[i]][[j]],sampleY[[i]][[j]]]}]}],
{i,1,n},{j,1,n}];
riemannSum=N[Sum[g[sampleX[[i]][[j]],sampleY[[i]][[j]]],{i,1,n},{j,1,n}]*Δx*Δy,10];
Show[p1,p2,PlotLabel->Style[riemannSum,Blue]],
{{n,max,"n"},1,max,1,Appearance->"Labeled"}]]

Exercises

Exercise 1

Use the module showRiemannSum above, to obtain Riemann sum approximations to the volumes determined by the following functions. In each case, start with n=100 and adjust this value up or down until the values of the Riemann sums vary by not more than 2%. Once you have found an acceptable value of n, use the dynamic feature of showRiemannSum to compute 5 different Riemann sums with that value of n and approximate the double integral ∫(∫_R)f(x,y) dA by their average. You are to turn in only one plot, but you should write as your answer the values of all five Riemann sums and of their average. 

(a) f(x,y)=x sin(x y), on the rectangle [0,π]×[0,π]
(b) f(x,y)=(y^2)(e^(-(x+y))), on the rectangle [0,1]×[0,1]. 
(c) f(x,y)=y+sin(x y), on the rectangle [0,π]×[0,π].
(d) f(x,y)=(1/5)sin(x+y) (e^(Sqrt[x+y])), on the rectangle [0,π]×[0,π]. 
(e) f(x,y)=y(x^2)cosx+xsin y, on the rectangle [1,2]×[0,3].
(f) f(x,y)=(x^3)(y^2)+x y, on the rectangle [0,1]×[1,2].

Credits

These laboratories were created by Raouf Boules, Geoffrey Goodson, Ohoe Kim, Alexei Kolesnikov, and Michael O'Leary for use in the Calculus courses of Towson University. Commercial use is prohibited without permission of the authors. Non-commercial use is permitted, provided this credit section is retained.