Double Integrals over Rectangles

Code

graphicsInitial := (
definiteIntegral=NIntegrate[f[x,y],{x,xLeft,xRight},{y,yLeft,yRight}];
surface=If[showSurface,Plot3D[f[x,y],{x,xLeft,xRight},{y,yLeft,yRight},Mesh->None,PlotStyle->{Red,Opacity[0.5]}],{}];

)

graphicsFinal[xSubdivisions_,ySubdivisions_]:=(
deltaX=(xRight-xLeft)/xSubdivisions;
deltaY=(yRight-yLeft)/ySubdivisions;

points=Join@@Table[{x,y,f[x,y]},{x,xLeft+deltaX*xPoint,xRight,deltaX},{y,yLeft+deltaY*yPoint,yRight,deltaY}];
riemannSum=Total[#[[3]]&/@points]*deltaX*deltaY;
riemannPlot=DiscretePlot3D[f[x,y],{x,xLeft+deltaX*xPoint,xRight,deltaX},{y,yLeft+deltaY*yPoint,yRight,deltaY},ExtentSize->{{deltaX*xPoint,deltaX*(1-xPoint)},{deltaY*yPoint,deltaY*(1-yPoint)}},PlotStyle->Opacity[0.75]];
pointsPlot=If[showPoints,Graphics3D[{Green,PointSize[0.02],Point[points]}],{}];

Show[riemannPlot,surface,pointsPlot,Axes->Automatic,Ticks->axisTicks,AxesLabel->{x,y,z},BoxRatios->boxRatios,ViewPoint->{20,4,8},PlotRange->{{xLeft,xRight},{yLeft,yRight},Automatic},PlotLabel->Style[Row[{"Riemann Sum: ",NumberForm[N[riemannSum],{6,3}],"\nDouble Integral: ",definiteIntegral}],FontSize->16]])

graphics[xSubdivisions_,ySubdivisions_]:=(
graphicsInitial;
graphicsFinal[xSubdivisions,ySubdivisions]
)

animation:=(
Table[Image[graphics[t,t]],{t,startingSubdivisions,endingSubdivisions,1}]
)

Graphics

Modify the function and options below to change the Riemann sum.
xPoint specifies where in each x interval to take the sample point; a left sum corresponds to xPoint=0, a right sum to xPoint=1, and a midpoint to xPoint=0.5.  (And similarly for yPoint.)
showPoints specifies whether to draw the sample points on the surface.

f[x_,y_]:=(3-x) (3-y)^2
xSubdivisions=2;
ySubdivisions=4;
xPoint=.5;
yPoint=.5;
xLeft=1;
xRight=2;
yLeft=0;
yRight=2;
showSurface=True;
showPoints=True;
graphics[xSubdivisions,ySubdivisions]

(*Display parameters*)
axisTicks=Automatic;
boxRatios={1,2,3};

Animation

This animation shows the Riemann sum as the number of subdivisions in each direction increases from startingSubdivions to endingSubdivisions.
All options except xSubdivisions and ySubdivions are taken from the Graphics section above.
It may take some time to run this command, as all frames of the animation are precomputed so that it can run smoothly.

startingSubdivisions=1;
endingSubdivisions=16;

ListAnimate[animation,DefaultDuration->4]