You are here

Mathematical Thinking through Web Programming - Real programming

Author(s): 
Dennis DeTurck

Phase IV: Output, random numbers, iterations, and simulations

Toward the end of the course, students begin to learn how to manipulate data in Javascript and to rewrite the webpage in order to display the results of their calculations. This is difficult for some students, while others get completely involved in trying to outdo one another with fancy output or programs that are browser-independent. A couple of fun examples of student-produced programs are Get an A (wich works only under Internet Explorer) and the Light Switch Game. Both of these are examples of using and manipulating tables of images.

In a more mathematical vein, we used our programming ability and Javascript’s random number generator to produce simulations and to display the results of iteration schemes. One of our simulations shows what happens when a stick is broken into three pieces by choosing two spots along the stick at random to cut it. The question is whether the three pieces can be assembled into a triangle -- so the criterion is that none of the three pieces should be more than half as long as the original stick. It is a nice problem to calculate the probability that the pieces can be so assembled, and the webpage contains a simulation of this, where the experiment is repeated in bunches of ten tries each, and the results are accumulated. An interesting variation on this problem is to cut the stick once at a random spot, and then cut the larger piece at a random spot along it.

Another simulation -- in response to a student question -- was to see why you divide by n - 1 instead of by n when you calculate the variance of a sample in statistics. To do this, we considered the experiment of flipping a coin over and over, getting one point for each head, and losing a point for each tail. Of course, the theoretical mean is zero points, and the standard deviation (in fact, every deviation) from the mean is 1. By taking modest-sized samples we could see that we got a better estimate of the theoretical variance by dividing by - 1.

Finally, one of the mathematics units we studied concerned iteration schemes for solving equations. The students discovered Newton’s method for calculating nth roots by experimenting, and eventually we looked at some examples of chaotic dynamics and fractals.

Dennis DeTurck, "Mathematical Thinking through Web Programming - Real programming," Loci (October 2004)

JOMA

Journal of Online Mathematics and its Applications

Dummy View - NOT TO BE DELETED