Sunday, June 23, 2013

Preparing to Teach a Fractals and Chaos Course

   I will soon be teaching (for the fifteenth time) an introductory course called Fractals and Chaos. The students are middle and secondary school math and science teachers. As part of the course, they are required to do a certain amount of programming and I have been converting the program assignments from another language to Scratch. Below are just three of the conversions that have been uploaded to My Stuff on Scratch. 
   The first two projects are examples of what are called strange attractors. The first really famous strange attractor was the Lorenz attractor (already in My Stuff).  Before attempting to understand strange attractors, we study the concept of a mathematical attractor using a simple linear equation and iteration.

The Hénon Attractor

The Rössler Attractor

   One of the curves that forced mathematicians to redefine the definition of 'curve' was the Koch snowflake. The snowflake curve is an example of a similarity fractal. It's mathematical properties are counter-intuitive. For example, it's perimeter is infinite in length but it bounds a finite area. Students are assigned the task of constructing their own similarity fractal.
The Koch Snowflake

   Additional information about each of these projects (in the form of PDF files) can be had by sending an email request to

Saturday, June 15, 2013

The Circle Squared

   x2 + y2 = 1 is the equation of the unit circle. Most of us go through school mathematics without ever wondering what
xn + yn = 1 looks like for different n. We learn the 'equation for a circle', and move on.
   The French mathematician Gabriel Lamé (1795-1870) first explored the xn + yn = 1 equation. The Danish scientist, mathematician, architect, and poet (polymath) popularized a specific shape he called a Superellipse. His superellipse is drawn for n = 2.5. Piet Hein also invented the famous 27-cube puzzle, the Soma cube. The lower left corner of the Scratch project displays his drawing of his cube and his profound statement about problem-solving, well understood by Scratchers.
   Here is a shot of the Scratch project screen. The project is interactive and can be seen and downloaded at this link,

   As you can see above, n is set in the slider at n = 2 and the algorithm draws the familiar circle (I filled the circle to make the shape stand out more).
   The value of n can be set in the slider from n= 1 to n = 20. As is shown below, at n = 20, the equation draws a square with rounded corners!
   What does the shape look like for n = 2.5, n-4, and n=1?
   This script uses the logarithm definition of basepower = answer to compute exponentiation.
   bp = a
   log bp = log a
   p log b = log a, and by the definition of a logarithm,
   10p log b = a
   The above equation is used to perform exponentiation.

   Programming Outline
   This project looks at the equation xn + yn = 1.
   First, solve the equation for y;
   yn = 1 - xn, take the nth root of both sides,
   y = (1- xn)1/n    [as in √2 = 21/2]

   In the computation loop, the script performs these steps in order:
(1) compute xn,
(2) compute (1 - xn), and
(3) compute  (1 - xn)1/n
   The script actually computes y from x = 0 to x =1 to draw the right half and then uses symmetry to draw the left  half of the shape.
   If you would like to learn about the Soma cube puzzle, go to my other blog at and search on Soma. I have written several posts about making and using the Soma puzzle with kids.

Friday, June 7, 2013

The Mandelbrot Set in Scratch

   Colorful images of the complex Mandelbrot set have been seen and liked by millions of people that have no interest at all in the mathematics that defines members of the set.
   I recently uploaded to Scratch a Mandelbrot Set in Scratch project that steps back from the colorful images and computes the set in black and white. In the picture below, members of the set are those complex numbers painted white and nonmembers are in the black.
   The Mandelbrot set lives in the complex number plane and the computation starts with the complex number in the lower corner of the screen that displays the image. Input the complex number (-2, -1i), real part first, imaginary part second, with a scan size of 2.5, and the full set is computed.
   Input the numbers in the Try These list in the lower right corner and view a more detailed portion around the two o’clock position of the large, heart-shaped bulge.
   Since the complex numbers are infinitely dense, there is no limit as to how deep one can zoom into the set. Practically, our computers have limited precision when it comes to representing numbers and our screens have a finite resolution so we will never see the complete Mandelbrot set. That’s why the set is sometimes called the most complicated object in mathematics.

   To view this project and play with it or to download it to your computer, click on this link.
   I did include documentation in the project notes section but nowhere near enough information to help anyone interested in really understanding the mathematics underlying the set and how to code the mathematics in Scratch. For example, Scratch does not contain prebuilt blocks for computing with complex numbers. I coded subroutines in Scratch to do the necessary complex number arithmetic.
   Something as mathematically profound as the Mandelbrot set cannot be explained within the 134 characters of a tweet so I’m writing three documents to break up the task of explaining the set itself and the coding. The first document in the following list is finished and the other two will be ready within a week.

Introduction to the Mandelbrot Set.pdf
The Paper and Pencil Part.pdf
Developing the Scratch Script for the Mandelbrot Set.pdf

   Any or all of the above documents can be had—free—by sending a request to my email address.
   By the way, this project was selected as a Featured Project on the Scratch home page.

Tuesday, June 4, 2013


   I have been posting mostly math-based Scratch projects so this is the first of several science-based Scratch projects that I will be posting in the near future.
   You may well think the simple movement strategy of moving forward until an object is struck, backing up a short distance, turning left or right through a small angle, and then moving forward again, is too simple to be of much use. But in nature, exactly this behavior can be found in simple organisms like the single-celled paramecium. This mode of motion is called kinesis kinesis (a movement that is a response to a stimulus but is not oriented with respect to the source of stimulation).
    Small hairs called cilia cover the outer body of a paramecium. These hairs act like tiny oars to propel the organism through water and also help the organism gather food.
    When a paramecium strikes an object in its environment, the cilia reverse direction moving the paramecium backwards.  The organism then turns left or right through a small angle, and moves forward. By continually repeating this process the paramecium is able to move around obstacles in it path.
   In this Scratch simulation, the paramecium is swimming though a thin layer of water containing a grain of sand. The sprite 1 script models kinesis.
   I have on my ‘to do’ list to model a euglena that propels itself with a single, long cilia and an amoeba that 'flows' pseudopodia (false feet) to move.
    You can view, run, and download this project by clicking on this link.