# Chaos and Randomness to Generate IFS

As we have seen from the section on Iterated Function Systems, the Barnsley Fern is impossible to generate by drawing triangles. There are too many triangles to draw and too many transformation to be applied. There must be another way!

Instead of using and transforming triangles, let us transform points. It is computationally much easier to draw and transform a point than a triangle.

To best describe this, let us use the Sierpinski Gasket as our example again. We begin with an imaginary triangle and label its vertices 1, 2, & 3. Pick a random point. Now, generate a random integer between 1 and 3. The next point is the midpoint between the first point and the generated random number vertex. Continue generating random integers and plotting the midpoints. After a thousand or so iterations, we will see a Sierpinski Gasket!

A more algorithmic approach to this would be

1. Pick the total number of iterations to perform and call it i.
2. Set the total number of transformations possible to n.
3. Label each transformation an integer from 1 to n.
4. Pick a random point and call it a.
5. Generate a random integer from 1 to n.
6. Apply the transition labeled by that random number to a, generating a new point a.
7. Plot a.
8. Go to step #5, repeating i times.

Applying this to the Barnsley fern, we get

This allows us to decode fractals with much easier computations.

To the Next Page