Riemann Sums:
A Symbolic and Graphical Approach

This Maple worksheet allows investigation of the definite integral of y = f(x) on [a,b] as a limit of Riemann Sums from a symbolic and graphical point of view. The Riemann sums for the right and left hand endpoints are computed and the convergence to the common limit is illustrated using an animation.

The approach taken in this worksheet is to define the Riemann sums as functions of the increment in x and plot the Riemann sums as a function of the increment. As the increment approaches 0, the Riemann sums approach a common limit.

Change the function, f(x), interval [a,b] by re-defining. Enter each command, select the graphics box and use the animation tools in the toolbar. The number of frames in the animation may be changed by changing the value of numframes.

> restart:with(plots):with(student):

```Warning, the name changecoords has been redefined

> f:=x->-3*x^4-4*x^3+x^2-x+10;```

> a:=0;b:=2;

> LS :=leftsum(f, x=a..b, n);

> n:=(b-a)/deltax;

> LHE:=expand(value(LS));

Define the left hand endpoint function.

> lefthand:=t->-218/15+39*t-35/3*t^2+1/5*t^4;

> leftplot:=plot(lefthand(deltax),deltax=-1..1,color=blue,thickness=3):

> unassign('n');

> RS := rightsum(f, x=a..b, n);

> n:=(b-a)/deltax;

> RHE:=expand(value(RS));

Define the right hand sum function.

> righthand:=t->-218/15-39*t-35/3*t^2+1/5*t^4;

> rightplot:=plot(righthand(deltax),deltax=-1..1,color=red,thickness=3):

> display(leftplot,rightplot);

Set up the animation. For a left approach use h:=k->-((1-a)-(1-a)*k/numframes);

> numframes:=50;

> h:=k->(1-a)-(1-a)*k/numframes;

> plot_animate:=[seq(plot([righthand(deltax),
[[h(k),righthand(h(k))]],lefthand(deltax),
[[h(k),lefthand(h(k))]]],deltax=-1..1,
y=-70..20,color=[red,red,blue,blue],
style=[line,point,line,point],
symbol=circle,symbolsize=20,thickness=3),
k=0..numframes-1)]:

> display(plot_animate,insequence=true);

We now construct a more general Riemann sum where the points at which the function is evaluated are chosen in a consistent manner.

> unassign('n');

> rs:=(deltax,s)->expand(value(sum(f(a+(m-s)*deltax)*deltax,m=1..n)));

> n:=(b-a)/deltax;

> rs(deltax,1/2);

> mp:=t->-218/15+35/6*t^2-7/40*t^4;

> mpplot:=plot(mp(deltax),deltax=-1..1,color=green,thickness=3):

Define the trapezoid approximation.

> trap:=t->1/2*(lefthand(t)+righthand(t));

> trapplot:=plot(trap(deltax),deltax=-1..1,color=yellow,thickness=3):

Plot right hand, left hand, midpoint, and trapezoid approximations concurrently, then animate the motion of a point on each of the graphs. For a left-hand approach, use h:=k->-((1-a)-(1-a)*k/numframes) ;

> display(leftplot,rightplot,mpplot,trapplot);

> plot_animate2:=[seq(plot([righthand(deltax),
[[h(k),righthand(h(k))]],lefthand(deltax),
[[h(k),lefthand(h(k))]],mp(deltax),
[[h(k),mp(h(k))]],trap(deltax),
[[h(k),trap(h(k))]]],deltax=-1..1,
y=-70..20,
color=[red,red,blue,blue,green,green,yellow,yellow],
style=[line,point,line,point,line,point,line,point],
symbol=circle,symbolsize=20,thickness=3),
k=0..numframes-1)]:

> display(plot_animate2,insequence=true);

Another approximation is Simpson's Rule.

> simp:=t->1/3*(2*mp(t)+trap(t));

> simp_plot:=plot(simp(deltax),deltax=-1..1,color=black,thickness=3):

> display(mpplot,trapplot,rightplot,leftplot,simp_plot);

This Maple 6 worksheet was based on the ideas discussed in
"Symbolic and Graphical Investigations of Riemann Sums with a Computer Algebra System",
PRIMUS , VI, No.4 (December 1996), 366-380 by Dr. Lawrence H. Riddle from Agnes Scott College.

The Maple 6 worksheet was developed by
Lila F. Roberts
Department of Mathematics and Computer Science
Georgia College & State University
Milledgeville, GA  31061
lila.roberts@gcsu.edu