[ Prev | Main | Next ]

RiemannSums Applet



The RiemannSums applet computes a Riemann sum for a given function and displays the sum and the rectangles that define the sum. In choosing the rectangles, it can use: Left endpoint rule, Midpoint rule, Right endpoint rule, Inscribed rectangles, Circumscribed rectangles, or the Trapezoid rule. (Yes, I know that the trapezoid rule is not exactly a Riemann sum.) The methods that use inscribed and circumscribed rectangles are shown in the menu as "~Inscribed" and "~Circumscribed". The "~" here means "approximate," and it's there since the minimum and maximum of a function on an interval is not always computed exactly. Here is the basic form of the applet, with no applet params:


Here is a version configured with some different colors and several loadable examples:

The applet tag for this version is as follows:

 <applet archive="webcompmath.jar" code="net.sourceforge.webcompmath.applets.RiemannSums" width=520 height=400>

<param name="TextBackground" value="lightGray">

<param name="CanvasColor" value="220 220 255">

<param name="RectColor" value="lightGray">

<param name="OutlineColor" value="gray">

<param name="GraphColor" value="red">

<param name="Example" value="Exactly answer is 1/3; x^2; 0 1 0 1 100; Midpoint">

<param name="Example1" value="Integral of e^(x^2) on [0,1]; e ^ (x^2); 0 1 -0.5 3 10; Midpoint">

<param name="Example2" value="Integral is about 1; 1/x; 1 2.71828 -0.5 1.5 25; Inscribed">

<param name="Example3" value="A discontinuous function; (x < 1)? x : 3 - x^2; 0 2 -2 2 5; Trapezoid">

<param name="Example4" value="Infinite limit -- bad idea; 1 / x^2; -1 1 0 100; Left">

</applet>


Many of the applet params are processed by the source code in the base class, GenericGraphApplet. See the list of params for that class for information about those parameters. Here is a table of applet parameters processed by the RiemannSums applet:

Param Name Type Default Description
GraphColor Color magenta The color used to draw the graphs.
RectColor Color 255 255 180 The color used to fill in the approximating rectangles.
OutlineColor Color 180 180 0 The color used to outline the approximating rectangles.
TextColor Color black The color for the text of the labels at the upper left and lower left of each graph (if present).
TextBackground Color white The background color for labels at the upper left and lower left of each graph (if present).
UseMethodInput yes/no yes If the value is yes, then there is a pop-up menu that can be used to choose the approximation method (left endpoint rule, midpoint rule, etc.)
Method String Left endpoint The initial approximation method. In fact, only the first letter of the string is examined. The legal values are: L, R, M, C, I, and T (upper or lower case), standing for Left endpoint, Right endpoint, Midpoint, Circumscribed, Inscribed, Trapezoid.
UseIntervalInput yes/no yes If the value is yes, then there is an input box where the user can enter the number of sub-intervals.
IntervalCount number 5 The initial number of sub-intervals. The value must be between 1 and 5000, or it is ignored.
Function String 1 / (1 + x^2) The initial function that is graphed. This is a change in the default value from GenericGraphApplet.
ComputeButtonName String Compute! The name of the button that the user can press to recompute and redraw. This is just a change in the default value from GenericGraphApplet. (This seems a better default than "New Function" because no other button is provided for the user to press after changing the number of intervals. Of course, the button is not really necessary anyway since it's enough to press return in the input box.)
Example,
Example1,
Example2,
...
String (none) These params, if present, define examples that appear in an Examples menu at the top of the applet. You can define "Example1" whether or not you define "Example". However, you can only have an "Example2" if you have an "Example1", you can only have "Example3" if you have "Example2", and so on. An example takes the following form: First, a descriptive title that will appear in the example menu, followed by a semicolon. Second, a function definition that will be graphed (and put in the function input box, if there is one). This can be optionally followed by another semicolon and a list of four or five numbers. The first four numbers in the list give the x- and y- limits for the graph. The fifth number gives the initial number of sub-intervals. Finally, there can be another semicolon followed by the initial method of integration: Left endpoint, Right endpoint, Midpoint, Circumscribed, Inscribed, and Trapezoid. (In fact, only the first character of the method name is examined.)


[ Prev | Main | Next ]