Wednesday, 25 March 2015

Sierpinski Triangle: An implementation with the Wolfram Language

Wow, this is my first ever blog article. I am going to make it memorable for me and my readers.
This is what I believe, all the current mind-blowing technologies has a lot to do with Mathematics, everything in the universe is Mathematical in nature, even beauty itself is Mathematical in nature. Thus, it suffice to talk about a renowned Mathematician called Waclaw Franciszek Sierpinski and the implementation of one of his work (Sierpinski triangle) using the Wolfram Language; he contributed to the beauty of Mathematics, the aspect of Mathematics called Fractals Geometry.
A Fractal is a natural phenomenon or a mathematical set that exhibits a repeating pattern that displays at every scale. If the replication is exactly the same at every scale, it is called a self-similar pattern. An example is the Sierpinski triangle. Fractals can also be nearly the same at different levels. Fractals also include the idea of a detailed pattern that repeats itself.
Waclaw Franciszek Sierpinski was a Polish mathematician. He was known for outstanding contributions to set theory, number theory, theory of functions and topology. Three well-known fractals are named after him; the Sierpinski triangle, the Sierpinski carpet and the Sierpinski curve.
The Sierpinski triangle is a fractal and attractive fixed set with the overall shape of an equilateral triangle subdivided recursively into smaller equilateral triangles.This is one of the basic examples of self-similar sets, i.e. it is a mathematically generated pattern that can be reproducible at any magnification or reduction.
Without wasting much time and space (because that's what football is all about. Just kidding), let's implement the pseudo-code that constructs the Sierpinski triangle using the Wolfram Language. You will find this interesting, trust me.

Sierpinski triangle Pseudocode


The Sierpinski triangle may be constructed from an equilateral triangle by repeated removal of triangular subsets:

      1. Start with an equilateral triangle.
      2. Subdivide it into four smaller congruent equilateral triangles and remove the central one.
      3. Repeat step 2 with each of the remaining smaller triangles

Using the Wolfram Language


First we create the vertices of the Equilateral triangle
We can view the Equilateral triangle using the Polygon wrapper with the Graphics function
Subdividing it into four smaller congruent equilateral triangles and removing the
central one. We use the Translate and Scale function. The Translate takes a second argument, which we will denote as "vec"
Finally, we iterate the previous step 7 times using one of the most important iterative function in the Wolfram language, Nest, to get our beautiful
Sierpinski triangle.
Wow, isn't she beautiful?. I love Fractals.

Fractals are beautiful. I hope you will take out some time to study this implementation.
Happy Reading.
Cheers.

6 comments: