Sunday, April 30, 2017

Mathematical Discovery in Grade Two

   My original copy of Professor Seymour Papert’s book Mindstorms is packed away so I recently ordered a new copy from Amazon. I read the book when it first came out in the late 1970s and became an immediate convert to Papert’s vision for the computer as ‘an object to think with’. 
   As director of the MIT Artificial Intelligence Lab (now the MIT Media Lab) he and Wallace Feurzeig developed Logo, the first programming language designed with a entry level simple enough that kids could use it but robust enough for serious programming.
   Logo was available for the early Apple IIe and Atari 400/800 home computers. I used and taught several versions of Logo but I liked Atari Logo because it had a colorful ‘turtle’ as a cursor. 
   The Logo turtle is a mathematical object. In fact, it’s a vector object since it can be pushed or pulled in any direction. 

   Below is the simple code for drawing a square using Logo and the modern successor to Logo, Scratch.
   When home computers first became available I was a district math/science/computer coordinator with a limited amount of money to buy hardware and software. Just a handful of teachers were interested in ‘computers in the classroom’ and they were curious to learn what students could and would do if they had even limited access to a computer. Marty was one of those teachers and he pioneered Logo in his second grade classroom.
   Marty invited me to visit his class and observe students at the computer. Early one morning I arrived in his classroom as students were taking turns cycling through the single computer center. There they used the computer and Logo to draw squares, triangles, and hexagons and played with the color of the drawing pen.
   Marty had taught them that a ‘square corner’ was a turn of 90º and half of a square corner a turn of 45º. The students could then consult a chart that displayed turns as multiples of 45º. They also knew that a triangle needed a 120º turn and not a 60º turn.

   What follows is a description of what I observed one particular student do when given a turn at the computer. 
   To begin, the student typed clear to send the turtle (cursor) to the center of the screen, pointing North (see A in the diagram below).  The student then typed the first command, forward 100 right 90, followed by the return key, and the turtle moved and turned to the position shown in diagram B. The 90º angle indicated that the student was going to draw a square. The second command, forward 100 right 90, moved the turtle to the position shown in C. The third command moved the turtle to D and the fourth command to E, its starting point, with the turtle again facing North. The student had directed the turtle drawn a square.
   At this point I expected the student to clear the screen and draw another figure but the student hesitated. Why? What could the student be thinking? We cannot know what is going on inside another human’s head but, when the student commanded the turtle to right 45 (F) it flashed in my head that the student was thinking about crossing the square, from its lower left corner to its upper right corner. In other words, the student was pointing the turtle along the diagonal of the square!

   And the student's next command, forward 100, confirmed this as the turtle moved 100 units along the diagonal (G).
   But again, the student hesitated! Was the student surprised that the turtle didn’t make it to the upper right corner? All the previously drawn triangles, squares, and hexagons had formed closed, regular polygons.
   The student then typed forward 1 over and over until the turtle reached the upper right corner (H).
   The student then cleared the screen for the next student and returned to the student’s desk. 
   Clearing the computer’s screen had erased the history of this student’s discovery that the diagonal of a square is longer than the side of the square.
   During morning break I described for Marty how that one student had  ‘discovered’ that the diagonal of a square is longer than the side of the same square. We realized that we might be missing other examples of students using the turtle to ‘play’ with mathematics.  
   That afternoon we set up a video camera focused on the computer screen. Marty would turn on the camera any time students were in the computer center. Later, by reviewing the video, we could identify students that were not just practicing regular polygon construction but were using Logo as ‘an object to think with’.
   We found that several students would complete the computer center assignment and then use the remaining minutes to explore on their own. Marty and I were not researchers so we never wrote about the exciting mathematical learning experiences we captured on videotape.
   For Marty and myself, the experience amounted to an existence proof that Papert’s belief that students could use Logo as an ‘object to think with’ was true.
Chapter 3 of Mindstorms opens with the following:
“Turtle geometry is a different style of doing geometry, just as Euclid’s axiomatic style and Descarte’s analytic styles are different from one another. Euclid’s is a logical style. Descarte’s is an algebraic style. Turtle geometry is a computational style of geometry.”
Optional Challenge:
   Move and turn are primitives in both Logo and Scratch. These two primitives can be combined to program the turtle to draw a circle (actually a regular polygon with a large enough number of sides to make it look like a circle).
   To experience computational geometry, visit my Scratch blog by clicking on the following link 
and read a post that derives of a set of equations that use move and turn to draw any regular polygon. As the number of sides of the regular polygon increases, its perimeter approaches the circumference of the circumscribed circle.

Saturday, April 1, 2017

Polygon Pi

   As the number of sides of a regular polygon inscribed in a circle increases, the polygon gets closer and closer to the shape of a circle. This fact is widely used in video games because the human eye will accept a shape as being a circle even when the number of sides in the regular polygon is as small as 20. The wheels of a car in a video game can be rendered as 20-sided polygons. 
   The sum of the lengths of the sides in any regular polygon is called its perimeter.
   A regular polygon of n sides with side length p has a Perimeter
P = np units.
   As you know, the perimeter of a circle is called its circumference.
The ratio of the circumference to the diameter of any circle is that famous, irrational number, Pi.
π = C/D
   One could gain an approximation for Pi by measuring the circumference and diameter of a circle to as high a degree of accuracy as current measurement technology allows and then evaluate the ratio of circumference to diameter. But mathematics and access to Scratch give us an easier and cheaper (no need to buy expensive measuring tools) way to evaluate Pi.
   We need to determine the relationship between the number of sides in a regular polygon, its radius, and the central angle subtended by one of its sides.
   For any regular polygon, we would like to know how to compute the length of one of the equal sides given the radius of the circumscribed circle.
   Consider the seven-sided regular polygon (heptagon or septagon) shown in the figure below.
   The central angle in any regular polygon of n sides can be computed by dividing 360º by n
central angle = 360º/n
   Construct the line from the center of a regular polygon at right angles to any of its sides. This line is called the apothem.
   The hypotenuse–leg theorem states that any two right triangles that have a congruent hypotenuse and a corresponding, congruent leg, are congruent triangles. Therefore, the apothem bisects the central angle.
   Let s equal the length of a side in a regular polygon and ø the angle between the apothem and the radius as shown in the following diagram.
   Then ø = half the central angle. This gives ø in terms of n, the number of sides.
ø = 360º/2n
ø = 180/n   [Equation 1.]

   In the right triangle,  sing = (s/2)/r and solving for s
s=2r(sin(ø)   [Equation 2.]
   Substitute Equation 1 for ø in Equation 2.
s=2rsin(180/n)  [Equation 3.]
   The perimeter is P = ns or 
P=n2rsin(180/n)   [Equation 4.]
   The ratio of the perimeter of the polygon to 2r gives an approximation to Pi.
   Given a radius of 100 units, Equation 3 and the approximation to Pi is coded in the following, short, Scratch script.
   The Scratch program was run to generate the data in the following table.
   A polygon with just 12 sides and a radius of 100 approximates the first two digits of Pi, 3.1.
   Equation 3 with r = 100 units can be used to write a Scratch script that draws the polygon for any given number of sides.
   I leave it to you to key in the above code and verify that is does indeed draw the regular polygon specified by the number of sides variable.

Saturday, December 24, 2016

Diffusion Limited Aggregation

   Diffusion-limited aggregation (DLA) is the process whereby particles perform random walks (Brownian motion) and aggregate (stick) together. DLA can be observed in many systems such as electrode position (see picture below), mineral deposits, and the breakdown of an electrical conductor when the voltage exceeds the breakdown voltage of the conductor.
   The picture shows the aggregation of copper crystals emanating from the center of a thin cell filled with copper soleplate. The center of the cell is a cathode (–) and the thinness of the cell
limits the growth to essentially two dimensions.
Thomas Witten (1944 – ), an American theoretical physicist, pioneered the study of diffusion limited aggregation.
Here is a screen shot of the Scratch project after a run. Scratch has a 300 clone limit so there are not enough particles to create fully developed DLA like the one shown in the photograph but even 300 agents reveal the structure associated with DLA.
You can view and download this project from the Scratch web site by clicking on the following link.
 If you view the project on the web site or download it Click on the green flag and be patient. It takes less than 3 minutes for the project to finish.  All processes in nature take time. Some take a few billionths of a second, others, millions of years. 
   A document detailing the programming of this project is available on request. Send an email to grandadscience@gmail.com.
   For a high level treatment of DLA see:

Saturday, July 23, 2016

Random Numbers in Scratch

   Every programming language has a method for generating random numbers and Scratch is no exception. 
   Load Scratch, look in the green Operators menu, and you will find a pick random block. Drag a (pick random) block into the scripting section. 

   Continually click on the block and it will report a string of numbers, 1 though 10. 
   Change the 10 to 6, click on the block several times and note that the numerical results are similar to what you would obtain by rolling a single die. 
   The pick random block actually generates pseudo-random numbers. Since every operation in every programming language has to be based on algorithms, Scratch, like every other language, must contain an algorithm (the antithesis of a random process) that generates numbers that 'look like' random numbers. Hence, the term pseudo-random numbers. A popular class of algorithms that generate pseudo-random numbers are called linear congruential generators and constitute a major topic in contemporary mathematics.
   If you are interested, request the Linear Congruential Generator.pdf, a four-page document that works through the mathematics and provides a Scratch script that implements the Park-Miller parameter set. 
   Psuedo-random numbers, hereafter called random numbers, are fun to play with and Scratch (or any other programming or scripting language) provide students the opportunity to develop dynamic solutions to many types of mathematical problems. Here's a problem in geometrical probability.
   Consider a square is divided into four smaller, congruent squares. The square in the upper right has been shaded.
  The following Scratch block, used in a Repeat block, can be used to generate 100 random points in the above square.
    How many of the 100 points would you expect to fall in the shaded square?
One could argue that since the four smaller squares are congruent, the area of the shaded square is one-fourth the area of the large square. Since the probability of picking any point is equal to the probability of picking any other point, the expectation is that 25 of the100 points, or one-fourth, would fall in the shaded area.
  As you readily see in the graphic shown below, this problem is easily modeled in Scratch. The red circular sprite, sprite 1, is used to plot each random (x, y) point.
  A yellow sprite, sprite 2, is a square with one-quarter the area of the large square (see left screenshot below). Since the yellow square is a sprite, you can click on it and move the yellow square around (see screenshot on right) within (or even outside of) the larger square. This makes the problem dynamic, as compared to the static example given at the beginning of this lecture.  
    When the program is executed (click on the green flag) 100 trials of 100 random points are computed and averaged. As you can see in the left screenshot, the average for the 100 trials is 25.27. The average for the screenshot on the right is 24.62. Both averages are close to the theoretical value of 25.
   This project can be viewed and downloaded by clicking on this link:

Sunday, July 10, 2016

Where Do Random Numbers Come From?


   The random numbers generated in a computer or calculator are not truly random. They are not produced by sampling a physical process that contains a random process, such as flipping a coin or monitoring radioactive decay.

   Computer and calculator-generated random numbers are produced by computing an algorithm. An algorithm, by its very nature, contains no random processes. Still, these computer-generated random numbers pass most statistical tests and are, for most (but not all) practical purposes, random. Random numbers produced by an algorithm are more accurately called pseudo-random numbers.           

   The most commonly used algorithm for generating psuedo-random numbers is the linear congruential generator (LCG). The defining equation for a LCG is

xn+1 = (axn + c )mod m

where xn is called the seed, a is an integer constant called the multiplier, c (also an integer constant) is called the increment, and m is the modulus.
   The project can be viewed and downloaded by clicking on this link:
    A four-page pdf document takes you through a paper and pencil exercise that explains the mathematics of a linear congruential generator and is available, free, on request. Send a request to grandadscience@gmail.com.

Wednesday, July 6, 2016

Ask Fibonacci


  During the Fall of 1998 I was researching the algorithms computer scientists use to generate random numbers (called pseudorandom numbers). One of the references I came across was this brief statement in Ivars Peterson's book, The Jungles of Randomness: A Mathematical Safari.

“At the heart of the Marsaglia-Zaman method of generating random numbers is the so-called Fibonacci sequence…"


   While waiting to see my bone doctor one morning, I remembered this statement and began to explore the patterns exhibited by the one's digit of the Fibonacci sequence. The question in my mind was, What is there about the one’s digit of the Fibonacci sequence that would interest two research mathematicians?


   Using only pencil and paper I soon made two startling discoveries (known to others but unknown to me, and probably you) about the 1's digit of any Fibonacci number. My first discovery made it possible for me to write an algorithm that computes the 1’s digit of the nth Fibonacci number.
   The project can be viewed and downloaded by clicking on this link:


Tuesday, July 5, 2016

What is iteration?


   Many of my Scratch projects are about fractals and mathematical chaos. Examples are given below. 
   Both topics are products of the computer age and are powered by a mathematical method known as iteration. Iteration is sometimes confused with looping but it is a much deeper and more mathematically powerful tool than looping.
   I have written a document that carefully, step-by-step, compares the process of graphing y = f(x) with the iteration of y = f(x). This information is basic for developing an understanding of the mathematics that underlie fractals and chaos.
   In the graphic shown below, the image on the left is the graph of the function given in the center of the graphic with the parameter c varying from 0 to 8 in increments of one.


      The image to the right is the iteration of the same function with c starting at -0.5 and varying to -2.0 in 0.005 increments

   For your free copy of this document send an email to www.grandadscience@gmail.com.

A Sample of My Fractal and Chaos Projects

Langton's Ant – Random Squares Experiment 

Koch Snowflake

x^2+ c Plots

Chaos Game - Midpoint Formula

Mandelbrot Set [Featured Project – 4656 views]