This applet will graph a given function on an interval [a, b], display various graphs that arise in the numerical evaluation of integrals, and evaluate the associated sums.

The graphing screen is large and you will have to move from this text screen to the graphing screen by means of the mouse while learning how to use the applet.

After the applet window is loaded you will see: a graphing area at the top, left of the screen; a text area at the top, right, and three text fields labeled f(x), a b, and M at the bottom left. The default value of f(x) is sin(1/x). It is being graphed on the interval [1, 2]. The graph is constructed by plotting f(x) at M = 80 equally spaced x values in [a, b], and then connecting the 80 points (x, f(x)) by straight lines.

The f(x) field is where the function under consideration is to be entered. The usual syntax rules apply here: the variable has the name x; the carat, ^, is used for exponentiation; multiplication must be denoted by the symbol *; all the functions you would see in a ordinary calculus course sin(x), tan(x), exp(x), ln(x), etc may be used; function arguments must be included within a pair of parentheses. Further details on syntax are given below.

The domain is any pair of real numbers a b with a < b. The entry M is assumed to be a positive integer.

To start, click on the "graph f(x)" button; this produces the graph of the function. The function is graphed in black. The x-axis, and the two lines from the x-axis to the function at the end points appear in purple.

Moving to the right, the Partition with N = text field specifies the number of subintervals in which to divide the interval [a, b]. The default value is 6. The subintervals all have the same length, (b -a)/N.

Continuing, if you press the button labeled "right" the applet will display the 6 rectangles whose height is the value of the function at the right hand endpoint of each subinterval. The type, the integer N, and the numerical value of the associated riemann sum are printed in the text area. Analogous actions occur when left, mid-point, and random buttons are pressed.

When the trapezoid button is pressed, the trapezoid rule is applied. It may be difficult to see the straight lines connecting the successive function lines. To confirm that straight lines are used replace f(x) by sin(x), a b by 0 3.14159, press "graph f(x)", reset N to 4, and then press "trapezoid" again.

Pressing the "Simpson" button yields an approximation of the "area under the curve" by parabolas. Again, unless N is small, say N = 2 or N = 4, it will be difficult to distinguish the graph of f(x) from the graph oof the approximating polynomial. However, the numerical values of the trapezoidal sums and the simpson sums illustrate the relative accuracy of the simpson algorithm.

Incidentally, in Simpson's method, the integer N must be an even integer. If N is odd when you click on the simpson button, the program will let you know.

Built-In Functions

If you click on "Examples" at the top of the Riemann screen, and then click on Example1 the program will load the function
f(x)= abs(x) + sqrt(x) + ln(1+x) + exp(x)+ arcsin(x/3). (It may be necessary to scroll across the text field to see all of them)

The main point here is that the program the usual elementary functions (polynomials, the trigonometric functions, the absolute value function, the logarithm to the base e, the exponential function ex, and the inverse trigonometric functions) may be used in the program.

The functions ln(x) must be defined on a positive domain; sqrt(x) must be defined for x >= 0.

Exponents and Negative Domains

Click on Examples|Example2 , click on Example2, and then click on "graph f(x)". This graph illustrates, in part, how exponents are handled in the applet.

First of all, an exponent must be an integer, a decimal, or a rational number. Functions of x are not allowed. (You can handle, say, xx, by entering it as exp(x*ln(x))).

Second, if the domain consists of positive numbers there are no problems with the evaluation of the functions. If the domain contains negative numbers then two cases can occur:

  1. If a number to be plotted is real, as in the case x^(2/3) of Example 2, it will be calculated.
  2. If the expression is imaginary, as in the cases x^(1/2) or x^(0.333) where x is negative, then the action depends on your browser.


If (in case (b)) you are using the Netscape browser no graph will appear, but question remarks will appear on the left side of the graphing area. A brief description of the error can then be found by clicking on Netscape's

Communicator|Tools|Java Counsel


menu entries. If you are using Microsoft's Internet Explorer, all imaginary numbers are graphed as +1.


The program will produce error messages when some common errors are made.

If you click on Examples|Syntax1 and then click on "graph f(x)" an error message will appear on the graphing screen. It will say that the number of left parenthesis is not equal to the number of right ones. So correct the error (by erasing the extra parenthesis at the end of the definition of f(x)) and click again.

You will get another error message: the 2x needs to have a multiplication sign between the 2 and the x. Insert one and click again.

Another error: A multiplication sign is needed between a closing and opening parenthesis. Insert one. This time the program works.

To continue click on Examples|Syntax2 and then click on "graph f(x)". You will learn that you can enter on two distinct numbers for the domain. Erase the last "3" and click again. You will find you still don't have exactly two numbers. The problem this time is the space between the minus sign and the 1. Erase an click. A graph will appear.