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.
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.
- 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
- Open a new script. Click REC to begin recording. Position the sketch and script side by side.
- In the sketch, construct triangle ABC, its interior, and midpoints of its sides.
- Select points AEF and click Loop in your script.
- Repeat step 3 for EBD and FDC.
- Hide points for F, E, D.
- Stop your script.
Having trouble? Click here for an example of this recursive script.
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