Sierpinski Triangle | Lab Report |

**Purpose
**The purpose of this project is to show how to create a
Sierpinksi gasket, a "holey" triangle, by recursively cutting holes in a
triangle.

**Mathematical Background**

Polish mathematician Waclaw Sierpinski introduced the "Sierpinski Gasket" in 1915. Starting with a triangle, recursively cut the triangle formed by the midpoints of each side:

0 |

1 |

The single equilateral triangle in Step 0, is divided into four equal-area equilateral triangles in Step 2. The "middle" triangle is colored differently to indicate it has been "cut" from the object. This same "rule" is applied an infinite number of times.

Here are the next two steps:

2 |

3 |

Let's analyze what's happening. Consider the perimeter of the red triangles:

Step |
Triangles |
3 sides/triangle |
Length of Side |
Total Length |

0 | 1 | a | 3a | |

1 | 3 | a/2 | 9a/2 | |

2 | 9 | a/4 | 27a/4 | |

k | 3^{k} |
a/2^{k} |
3^{k+1}a/2^{k} |

As k approaches infinity, the perimeter of all the red triangles approaches infinity.

The area of an equilateral triangle with each side length a is . (See the von
Koch Curve Lab Report for details.) For further computations here, we'll make
computations as a fraction of A_{0}.

Step |
Area Subtracted |
Total Area |

1 | A_{0}/4 |
A_{0} [1 - 1/4] |

2 | 3A_{0}/16 |
A_{0}[1 - 1/4 - 3/16] |

3 | 9A_{0}/64 |
A_{0}[1 - 1/4 - 3/16 - 9/64] |

4 | 27A_{0}/256 |
A_{0}[1 - 1/4 - 3/16 - 9/64 - 27/256] |

k | 3^{k-1}A_{0}/2^{2k} |
A_{0}[1 - 1/4 - 3/16 - 9/64 - ... - 3^{k-1}/2^{2k}] |

Like the von Koch Snowflake, the area of the triangles in the Sierpinkski gasket is finite but the perimeter of all the triangles is infinite.

A Sierpinski triangle has a self-similarity, Hausdorff dimension D = 1.585. (A line is 1D and a square is 2D).

Also see *Experiments
in Computing: Laboratories for Introductory Computer Science in Turbo
Pascal* by Kenneth Abernethy and J. Thomas Allen, Jr., PWS-Kent
Publishing, Boston, 1993, Chapter 20, Recursion in Fractal Geometry.
Constructing Sierpinski's Carpet, pp. 351-352.

**Materials and Equipment**

Software RequirementsWindows 98

Delphi 4/5 (to recompile)

SierpinksiTriangle.EXE

Hardware RequirementsVGA display with 640-by-480 screen in high/true color display mode

**Procedure**

- Double click on the
*SierpinskiTriangle.EXE*icon to start the program. - Select various values in the spinboxes at the left and immediately observe a new Sierpinski Gasket on the screen. Click on the colored boxes to change colors via a color dialog.
- Select the
*Print*button to print the currently displayed Sierpinksi triangle (perhaps in greater detail since many printers have many more dots than a display screen does). - To write a file to disk, select the bitmap size, and the press the
*Write to File*button. A save dialog will let you write this file anywhere you want.

**Discussion**

(Outline for now)

ScreenSierpinskiTriangle unit and form:

- DrawSierpinski method

- ButtonPrintSierpinskiClick

- ButtonSierpinksiFileClick

- ShapeTColorMouseDown (to change color of TShape)

- ShellExecute to link to web site

SierpinskiTriangleLibrary unit (separates computations from user
interface):

- TSierpinskiTriangle Class with method Draw (draws on any canvas: screen, printer,
or bitmap)

- SierpinskiTriangle (Local routine to Draw, which is called recursively. Since
Sierpinksi works with any triangle, the points making up the triangle are rotated before
this routine is ever called.)

MapWorldToPixel unit:

- TRealPoint, RealPoint

- TRealRect, RealRect

- TDigitalPantograph [for mapping real (x,y) to integer (i,j); "corrects"
direction of y-dimension]

A Sierpinski Triangle can be formed in a variety of other ways. In the "Chaos Game," you can start at the vertex of a triangle, and throw dice to choose the corner to move to. But you only move half way to the selected vertex and draw a point. After a large number of such random selections, a Sierpinksi triangle is formed. Eventually this method will be described in a separate Lab Report. At this time an old DOS version of this technique is available in the "Language of Patterns" program, which was originally written for the Maryland Science Center.

**Conclusions
**Tell your friends: the Sierpinski "gasket" has an infinite
perimeter with all its triangles, but a finite area! What does that really mean?

**Keywords**

Sierpinski triangle, Sierpinski gasket, fractals, self-similarity, Hausdorff
dimension, digital pantograph, world-to-pixel mapping, recursion

**Download
**Delphi 4/5 Source and EXE: Sierpinksi.ZIP
(201 KB)

**Related Downloads
**

Turbo Pascal 7 LangPatt.ZIP Turbo Pascal 7 Source: TP7LP.ZIP

Related DOS program: Triangle.EXE

Note: If you have a fast machine (233 MHz Pentium II or faster),
you'll likely need a patch to run these TP 7 programs.

See this fix for
"Runtime Error 200" for Turbo Pascal.

**Future**

Add *FormResize *handler.

**Links: **(Also see Fractals and Chaos Section of *efg's* Mathematics
Reference page)

Images of Mathematicians on Postage Stamps http://jeff560.tripod.com |

**References: **

[Mandelbrot83] | Benoit B. MandelbrotThe Fractal
Geometry of NatureSierpinski pyramid, pp. 142-143; Sierpinksi Carpet, Menger Sponge (pp. 144-145) W. H Freeman and Company, 1983 (updated and augmented) |

**Thanks to L****auren D'Elia**,
Mathematics Department, North Carolina State University, for pointing out an
error in the *Background *section. (28 Nov 2001)

Updated | 14 Jun 2009 |

Since | 9 Apr 2000 |