# Fractals

I love fractals.

A simple rule, iterated multiple times, yields an impossibly complex and intricate geometry. The beauty that arises from these algorithmic geometries often emerges in nature and can be observed at every scale....

... from the cosmic web of hundreds of billions of galaxies in the universe...

... to the network of hundreds of billions of neurons in the human brain...

... somehow, impossibly, the same structures emerge! How can this possibly be?

Let's attempt to reproduce this beauty! The way I think about it, to create a fractal, we need a starting point and a simple rule:

**Start:**One line segment.**Rule:**Replace every line segment with 2 line segments, joined at a right angle.

Let's render it using Javascript canvases. What would applying this rule once look like?

One line becomes two...

What would applying this rule over and over and over look like?

This fractal is called the Lévy C curve.

What do you see? Circles? Tentacles? Curling? Nesting orbs?

We did not define any of this! Our simple rule does not, cannot, encode the complexity and intricacy of tentacles!

But tentacles emerge... What does this mean about the morphology of octopus tentacles? What if octopus DNA does not contain a full, detailed blueprint for making tentacles, but instead encodes a simple fractal ruleset that, when followed, 3D print octopus tentacles out of protein?

Marvelous. Here's the same animation, but this time previous generations are not cleared after every iteration.

One line becomes three becomes... how many?

What if this went on forever? Every little tiny circle we see is made of line segments. But if you zoom in on any one line segment, you would find that it isn't a line segment at all! It's just more of the same whole!

So how does this apply to the images at the beginning of this page? How do galaxies in the universe and neurons in the brain end up forming similar shapes?

Perhaps the physical laws governing the gravitational attraction of galaxies and the biological algorithms guiding the network optimization of neurons are not so different? Could it be that the uncanny resemblance of these emergent geometries arises from some shared logic in the patterns guiding their formation? Could a strange quirk of physics and reality exist as their common ancestor, despite the immense difference in scale?

Which leads me to wonder; could we learn more about neural networks by studying them as if they followed the laws of gravity and the cosmos? Could we learn more about the structure of the universe by studying it through the lens of procedural network optimization?

What a beautiful, remarkable universe...

Another fractal I'm particularly fond of is the Julia Set. If you want to learn about it, check out this Youtube video: Filled Julia Set - NumberPhile.

Below is an interactive Julia set render!

- You can change explore the fractal by moving your mouse over the image.
- Click the image to freeze it, so that mouse movement no longer modifies it.
- Click the "Save Render" button to save a large-scale image of the fractal at your chosen coordinates.
- Click again to unfreeze it and keep exploring!

This is how I generated the background image for this website! See if you can find the cursor position that produces the same render of the Julia set!

Enjoy!