Sierpinski's Triangle
Sierpinski's Triangle is a very famous fractal that's been seen by most advanced math students.
This fractal consists of one large triangle, which contains an infinite amount of smaller triangles
within. The infinite amount of triangles is easily understood if the fractal is zoomed in many
levels. Each zoom will show yet more previously unseen triangles embedded in the visible ones.
Creating the fractal requires little computational power. Even simple graphing calculators can easily
make this image. The fractal is created pixel by pixel, using random numbers; the fractal will
be slightly different each time due to this. Although, if you were to run the program repeatedly,
and allow each to use an infinite amount of time, the results would be always identical.
No one has an infinite amount of time, but the differences in the finite versions are very small.
To generate this fractal, a few steps are involved. First, initial X and Y values should be chosen, either
by the program or the user. The values used have little effect on the fractal. Regardless of what's
chosen, the same triangle will be created. Next, the program must create a random number,
between 0 and 1. Then, three possible routes can be taken.
- If the random number is less then 1/3, then the following equations should be applied to X and Y.
- xn = 0.5 * (xn-1 + 1)
- yn = 0.5 * yn-1
- If the random number is between 1/3 and 2/3, then these equations should be used.
- xn = xn-1 * 0.5
- yn = yn-1 * 0.5
- If the number is greater than 2/3, the the following equations should be applied.
- xn = 0.5 * (xn-1 + 0.5)
- yn = 0.5 * (yn-1 + 1)
Now that X and Y have changed, the point should be plotted on the screen. Finally, loop back to
the random number generation and start over again.
Only a few hundred iterations are needed to begin to see the triangles. A few thousand pixels
will produce a good image.
The image on this page was created with a QBasic program, which can run on any PC. The source code
is available for download.
A Java applet is also available that will create this triangle on your computer.
And finally, here's a Tcl script to draw Sierpinski's triangle.