Improved clouds

In my post Riemann Clouds Improved I showed examples of clouds of values of Riemann sums in such a way that you could see the convergence to the value, the efficiency of the midpoint rule, and other things.  Here I include two Riemann sums that are shown

  • as manipulable graphs,
  • in clouds in an animated form.

To see and work with these demos, you must have Wolfram CDF Player installed on your computer. It is available free from the Wolfram website.

Each manipulable graph (see Elaborate Riemann Sums Demo) has a slider to choose the mesh (1/n) of the partitions.  The small plus sign besides the slider gives you additional options. The buttons allow you to choose the type of partition and the type of evaluation points.

Each cloud shows a collection of values of random Riemann sums of the function, plotted by size of mesh (an upper bound on the width of the largest subdivision) and the value of the sum.  The cloud shows how the sums converge to the value of the integral. 

Every dot represents a random partition.  The sums with blue dots have random valuation points, the green dots use the left side of the subdivision, the brown dots the right side, and the red dots the midpoint.  The clouds may be suitable for students to study.  Some possible questions they could be asked to do are listed at the end.

Pressing the starter shows many clouds in rapid succession.  I don't know how much educational value that has but I think it is fun, and fun is worthwhile in itself.

Quarter Circle

Manipulable graph:

Animated cloud

 

Sine wave

Manipulable graph:

Animated cloud

Questions

I am not sure of the answers to some of these myself.

  • Why is the accuracy generally better for the sine wave than for the quarter circle?  
  • Why are the green dots above all the others and the brown dots below all the others in the quarter circle?
  • Why are they mixed in with the others for the sine curve?  In fact why do they tend upward? (Going from right to left, in other words in the direction of more accuracy).
  • Why are the midpoint sums so much more accurate?
  • Why do they tend downward for the sine wave?
  • Is it an optical illusion or do they also tend downward for the quarter circle? 

Notes:

The source code for these demos is Animated Riemann.nb at my Mathematica site.

The animated clouds show two hundred precalculated clouds for each picture, so you get the same clouds each time you run the animation.  It would have taken too long to generate the random clouds on the fly.  Each list of two hundred took about seven minutes to create on my computer.

An Elaborate Riemann Sums Demo

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

  1. Set $n=1$, uniform partition and midpoint and look at the results for each function.  Explain what you see.
  2. 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.
  3. 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?
  4. 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).
  5. 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.
  6. 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)

Riemann clouds improved

In my post Playing with Riemann Sums I showed a couple of clouds of points, each representing a particular Riemann sum for a particular function.   I have extended the code in a couple of ways.

The new code is in the Mathematica notebook and CDF file called MoreRiemann in the Mathematica section of abstractmath.   The .nb form is a Mathematica Notebook, which requires Mathematica to run and allows you to manipulate the objects and change the code in the notebook as you wish.  In particular, you can rerun the commands generating the clouds to get a new random result.  The .cdf file contains the same material and can be viewed using Mathematica CDF Player, which is available free here.  Both files have several other examples besides the ones shown below.

As always, my code is one-time code to show the ideas, but it is available freely via the Creative Commons Attribution – ShareAlike 3.0 License. I hope people will feel free to develop it further for use in teaching or for their own purposes.

Below is a cloud for $latex \int_0^2 \sqrt{4-x^2} dx$, the area of a quarter circle of radius 2, which is $latex \pi$.  The blue dots are arbitrary random Riemann sums with mesh shown on the horizontal axis and value on the vertical axis.  The partitions and the point in each subinterval are both random.  The red dots are arbitrary Riemann sums with random partitions but using the midpoint for value.

The next cloud shows random blue dots with the same meaning as above.  The red dots are Riemann sums with uniform subintervals evaluated at midpoints.  Possible discussion question for both of the clouds above:

  • Why do the red dots trend upward?

The following cloud is like the cloud above  with the addition of green dots representing uniform partitions evaluated at the left endpoint or right endpoint. (But the mesh scale is extended, giving different proportions to the picture.)

Of course the left endpoint gives the upper sums and the right endpoint gives the lower sums.

  • Explain the slight downward curvature of both green streaks.
  • Explain the big gap between the blue dots and the green dots.  (Requires some machinations with probability.)
  • Would there be blue dots a lot nearer the green dots if I ran the command asking for many more blue dots?

(These are idle questions I haven't thought about myself, but I'll bet they could be turned into good projects in analysis classes.)

Here is a cloud for $latex \int_0^{\pi}\sin x dc$ with everything random for the blue dots and random partitions but midpoints for the red dots.

  • Why do these red dots trend upward?

The cloud below is for the same integral but uses uniform subintervals for the midpoint and adds green points for both the left endpoint and the right endpoint of uniform subinterval.

  • Why on earth do all the green dots trend downward???

This is a similar picture for $latex \int_0^1 x^2 dx$.  There are red dots but they are kind of drowned out.

And finally, here is $latex \int_{\frac{1}{2}}^2 \frac{1}{x} dx$: