[Math] Graphing Fractals With Equations

fractalsfunctionsgraphing-functions

The Sierpinski Triangle is what interests me most in this question. Would there be equations for self-similar fractals (or any fractal types) which would work on a graphing calculator such as Desmos?

Best Answer

Let me describe what the functions on this Desmos page do. Try to go through the steps with me and play around with the equations and buttons to select equations, this will make everything clear.

First, deselect everything except for the equation for $(T(t),S(t))$. Clearly, that is a parametric equation for this red triangle. Now, the equation just below gives an inverted rescaled version of that triangle. This is just an affine transformation of the first triangle. As you can see by the formula which is: $\left(2T\left(t\right)-\frac{1}{2},-2S\left(t\right)+2\frac{\sqrt{3}}{4}\right)$.

The next step is to create many rescaled versions of these triangles. This is what the functions $A_x$ and $A_y$ do. To help you visualise this, make a duplicate of the ninth equation, but drop the summation terms. you should get something like this

$$\left(A_x\left(Nt,\operatorname{ceil}\left(Nt\right)\right),A_y\left(Nt,\operatorname{ceil}\left(Nt\right)\right)\right)$$

The plot of this is a series of rescaled versions of the triangle represented by $(T(t),S(t))$. The sidelengths of successive rescaled version scale as $1/2$. But that's not all. You also see this modulo function: $\operatorname{mod}\left(3^kx,1\right)$. This makes you actually traverse the triangle several times. For every rescaled version you traverse it 3 times more. You don't see it because at this stage, the triangles overlap. But this is important, because the next step is to position each traversal of the copies in different positions. That's what the summation term we dropped is used for.

Copy the following part in a separate line

$$\sum_{n=1}^{\operatorname{ceil}\left(Nx\right)}\left(\frac{1}{2}\right)^nF\left(p\left(Nx,n\right)\right)$$

Set the slide ruler in the first equation on $N=1$. When you do that, what you will see for the interval $[0,1]$ is actually just the function $F(x)$ that is defined on the second line, which is just a step function. To be more precise, it's a discrete function, but when combined with $p(x,k)$ it becomes a step function. But if you know add this to the $A_x$ from before, this will shift the x-coordinates of all the little triangles to the positions you want to have them. The clever trick is now that again using the modulo and rescaling, you can also out of $F$ construct the positions for the triangles at smaller scales. So that's what that part does. Do the same for the y-coordinates and now putting everything together and you have constructed the Sierpinski triangle.

Hope this sets you on your way. Try playing around with it to understand how it works. Another suggestion: try first making a one dimensional fractal like a Cantor set. This makes the construction a bit simpler and let's you accomodate to the way Desmos can be used to make this kind of fractals.