#### Note

To manipulate the demo in this post, you must have Wolfram CDF Player installed on your computer. It is available free from the Wolfram website.

The demo currently shows a banner that says "This file contains potentially unsafe dynamic content". You can view the diagram by clicking on the "Enable Dynamics" button. If and when I figure out how to get rid of the banner, this paragraph will disappear from the post!

### Riemann Sums

The Riemann Sum is a complicated idea. The integral \[\int_a^b f(x)\,dx\] involves three parameters: two numbers $a$ and $b$ and the function $x\mapsto f(x)$. *These are not freely varying parameters:* They are subject to the requirements

- The function $x\mapsto f(x)$ must be defined on the closed interval $[a,b]$ (let's pretend improper integrals don't exist).
- The function must be Riemann integrable (continuous will do).

A particular Riemann Sum for this integral looks like \[\sum_{i=1}^n f(p_i)(x_i-x_{i-1})\]

It has three more parameters, a number and *two* *lists of numbers *satisfying* *some complicated conditions:

- The
**number**$n$ of**subdivisions**. - The
**partition,**which- is a list of $n+1$ numbers $\{x_0,x_1,\ldots,x_n\}$
- satisfies the conditions
- $x_0<x_1<\ldots<x_n$
- $x_0=a$
- $x_n=b$

- The
**list of evaluation points**, which- is a list of $n$ numbers $\{p_1,\ldots,p_n\}$
- satisfies the condition $x_{i-1}\leq p_i \leq x_i$ for $i=1,\ldots,n$.

A Riemann sum may or may not have various important* properties*.

- The partition can be
- uniform
- random
- chosen by a rule (increase the number of points as the derivative increases, for example)

- The evaluation points can be chosen
- randomly
- at the midpoint
- at the left end
- at the right end
- at the lowest point
- at the highest point.

So the concept is complex, with several constituents and interrelationships to hold in your head all at once. Experienced math people learn concepts like this all the time. Math students have a harder time. Manipulable diagrams can help. Here is an example:

### The Demo

In a class where students use computers with CDF Player installed, you could give them this demo along with instructions about how to use it and a list of questions that they must answer.

**Examples of instructions**

- Click on the big plus sign in the upper right corner for some options.
- Move the slide labeled $n$ to make more or fewer subdivisions.
- Click on the little plus sign besides the slide for some options such as allowing $n$ to increase automatically.
- The buttons allow you to choose the type of partition, the type of evaluation points, and five functions to play with.

**Sample questions**

- Set $n=1$, uniform partition and midpoint and look at the results for each function. Explain what you see.
- Set $n=4$, uniform partition and midpoint and look at the results for each function. Explain each of the following by referring to the picture:
- For $x\mapsto x$, the estimate is exact.
- For $x\mapsto x^2$, the estimate is less than the value of the integral.
- For $x\mapsto x^5$, the error in the estimate is
*much worse*than for $x^2$. - For $x\mapsto \sqrt{1-x^2}$ , the estimate is greater than the value of the integral.

- Go through the examples in 2. and check that when you make $n$ bigger the properties stated continue to be true. Can you explain this?
- Starting with $n=4$, uniform and midpoint and then using bigger values, note that the error for $x\mapsto \sqrt{1-x^2}$ is always bigger than the error for $x\mapsto \sin \pi x$. Try to explain this. (Don't ask the students to prove it in freshman calculus).
- For $n=4$, uniform and midpoint (and then try bigger $n$), for $x\mapsto x^5$, the LeftSide error is always less than the RightSide error. Explain using the picture.
- For which curves is the LeftSide estimate always the Lower Sum? Always the Upper Sum? Neither? Does using Random instead of Uniform change these answers?

There are many other questions like this you can ask. After answering some of them, I claim (without proof) that the students will have a much better understanding of Riemann sums.

Note that teachers can use this Demo without knowing anything at all about Mathematica. There are hundreds of Demos available in the cloud that can be used in the same way; many of the best are on the Wolfram Demonstration Project.

If you can program some in Mathematica, you can take the source code for this demo and modify it, for example to use other functions, to provide functions with changeable parameters and to use partitions following dynamic rules.

You could also have this up on a screen in your classroom for class discussion. But I doubt that is the best use. For classroom demos you probably need *simple *on-off demos that you prepare ahead or even write on the spot. An example of a simple demo is in the post Offloading Abstraction. I will talk about simple demos more in a later post.

### Rant about why math teachers should use manipulable diagrams

A teacher in the past would draw an example of a RIemann sum on the blackboard and talk about a few features as they point at the board. Nowadays, teachers have slides with accurately drawn Riemann sums and books have pictures of them. This sort of thing gives the student a *picture *which (hopefully) stays in their head. That picture is a kind of *metaphor *which enables you to think of the sum in terms of something that you are familiar with, just as you can think of a function as position and its derivative as velocity. (Position and velocity are familiar from driving or any other kind of moving. The picture of a Riemann sum is not something you knew before you studied them, but your brain has remarkable abilities to absorb a picture and the relations between parts of the picture, so once you have seen it you can call it up whenever you think of Riemann sums.)

But there are a lot of aspects of Riemann sums that cannot be demonstrated by a still picture. When the mesh gets finer, the value of the sum tends to be closer to the exact value of the integral. You can stare at the still picture and *sort of *visualize this. Can you visualize a situation where changing to a finer mesh could make the error *worse? * If someone suggests a high-frequency sine wave, can you visualize *in your head* why a finer mesh might make it worse?

An elaborate demo with lots of push buttons is something for students to play with on their own time and thereby gain a better understanding of the topic. Before manipulable diagrams the only way you could do this was produce physical models. I don't know of anyone who produced a physical model of a Riemann sum. It is possible to do so with some parameters changeable but it would be difficult and not as flexible as the demo given here.

The world has more possibilities. Use them.

**Related posts**

An elaborate Riemann Sum Demo (Mathematica notebook, source of the demo in this post)

Freezing a family of functions (previous post)

Images and Metaphors (in abstractmath.org)

Offloading abstraction (previous post)

## One thought on “An Elaborate Riemann Sums Demo”