Fractals and the Mandelbrot set

The Mandelbrot set
I have always liked the concept of fractal. They are very beautiful, they have a notion of infinity embedded in it, and they make no sense (seriously though, self-similarity?). How couldn't they be loved?

Despite being fond of fractals, I had never understood them because I didn't know how to mathematically define one. I knew how to draw some, for example the snowflake or the Sierpinski triangle, but drawing and mathematical definitions aren't quite the same thing.

Enlightenment struck after watching this video from Numberphile about the Mandelbrot set, the fractal I presented above. After all, a fractal like this was not but a simple formula and a check for a bound on a sequence! I recommend all of you to watch that video.

Simplifying it a lot, for each number you can create a sequence. After you do that, you check if the numbers in that sequence explode or remain small.

After learning how to create the Mandelbrot set I put that knowledge to practice, making use of my coding skills in Python. At first I wrote this piece of code, but I quickly realised it had a major flaw: as you zoomed in, the fractal became round, which is not supposed to happen. The problem lied in the way I tried to check if a pixel belonged to the set or not: I created the sequence as described in the video, and I would check if the 50th term had already exploded (i.e. surpassed the upper bound). As you zoom in around the border of the fractal, the points there take more iterations to start exploding, and thus after 50 iterations some points would be counted as pacific points, while they should actually be considered explosive points.

To try and fix that I created a second version of the script, which uses a bound on the number of iterations that has quadratic growth in the zoom level. I tried several different increasing bounds and was moderately happy with this one. A downside of this modification is that, as you zoom in, the image takes more time to be parsed.

The scripts were written in Python3 and make use of pygame, probably version 1.9.2, but I am not sure. For those who can't make the scripts work, I can't help more than providing this folder which, after unziping, has a windows executable that opens a 600x600 window with the fractal. The zipped folder contains a bunch of things inside, which are ought to be left as-is. Clicking the fractal once zooms it in, around the point you clicked. Don't click the image again while it is zooming in. Or else you will bend time.

[Pt] O Mundo dos fractais é uma coisa maravilhosa. Eu sugiro grandemente o vídeo do canal Numberphile sobre fractais, para quem quiser ver um exemplo de uma definição matemática de um fractal. Ou então que espere pelo vídeo da Mathgurl sobre fractais. Têm aqui e aqui os scripts que eu escrevi em Python3, com pygame, para fazer os fractais. O segundo é muito melhor mas é significativamente mais lento. Alternativamente, nesta pasta têm um executável.

Let me know what you think!

-RGS
Fractals and the Mandelbrot set Fractals and the Mandelbrot set Reviewed by Unknown on October 12, 2017 Rating: 5

No comments:

Powered by Blogger.