Recursive Scripting in Sketchpad

In The Geometer's Sketchpad, you can easily repeat an action again and again on the same figure. Repeatedly taking the result of a function and applying the function to that result again is called recursion. In this demonstration, a simple recursive script will be recorded to create the first few stages of a fractal called the Sierpinski gasket.

  1. To create the recursive script, close all open sketches and scripts and open a new sketch.

    If you do not have a copy of Sketchpad on your system, you can download a demo copy.

  2. Open a new script. Click REC to begin recording. Position the sketch and script side by side.

  3. In the sketch, construct triangle ABC, its interior, and midpoints of its sides.

  4. Select points AEF and click Loop in your script.

  5. Repeat step 3 for EBD and FDC.

  6. Hide points for F, E, D.

  7. Stop your script.
recursion Having trouble? Click here for an example of this recursive script.
This script constructs a triangle and the midpoints of its sides. The recursive step repeats the script in each corner of the triangle just constructed by the script. The fractal created when this process is repeated an infinite number of times is known as the Sierpinski Gasket.

Construct three points in a new sketch to serve as vertices of a large triangle. Play your script to a recursion depth of 2 or higher. An example of recursion depth 5 can be seen below. You will end up with several layers of triangles, all covered by the interior of of the largest, original triangle.

Experiment with recursive scripts to see what other figures you can create.

© 1996 Key Curriculum Press