Illustrating the Mandelbrot Set using Julia and Iteration
Mandelbrot?
The Mandelbrot set is an equation which, when supplied with numbers and iterated over, will return a number in an escape-based format. If you're interested in the equation and how it is iterated, look at it's Wikipedia page.
meaning the length of the number allows us to index an array of colours by amount of characters to colour the Mandelbrot fractal in.
The history of the Mandelbrot equation is interesting as it was first investigated at the beginning of the 20th century by French mathematicians Pierre Fatou and Gaston Julia, the Mandelbrot Fractal was first defined and drawn in 1978 by Robert W. Brooks and Peter Matelski as part of a study of Kleinian groups. At IBM's Thomas J. Watson Research Centre in Yorktown Heights, New York, the Mandelbrot fractal was visualised on the first of March, 1980.
Overview
This post will focus on my implementation of this equation and how other parts of this work. I have implemented this fractal in both programming languages which are called Julia and Python. We will focus on the Julia version as my Python version is, well... let's say 'a bit rough around the edges'.
What is Julia?
Julia is a programming language, namely a 'scientific programming language' which is optimised for iterating equations or large banks of memory, mainly for scientific or mathematic or probability-based simulations. Julia also has libraries for machine-learning and other intensive algorithms.
Mandelbrot Fractal Overview
Onto The Code
All of the code is stored in my
GitHub repository.
By varying the amount of iterations per pixel you can have more precise values
which allow a higher accuracy when zoomed in.
To be 100% honest, it's been around 7 and 1/2 months since I looked at this
code so the explanation might be a bit crude.
The Mandelbrot program shown here uses the CUDA on a NVIDIA GPU to store and
retrieve data extremely fast as to run the algorithm faster, using standard
arrays in memory [RAM] is much slower than using VRAM [CUDA] as VRAM runs at
higher clock speeds to calculate graphics, basically, we're using the CUDA
cores for doing CUDA things (graphics).
This program saves to BMP files by using the 'colorview' function to convert
my escape values in the array, which is 1:1 to the pixels of the image, to RGB
values which are correct to be written to a BMP file, PNGs or JPEGs/JPGs would
be much harder.
The way I calculate the escape values for the array is by using an
O2 loop (seen on lines
91->98
of
Mandelbrot.jl), O2 refers to a loop with another inside. This
O-to-the-2 loop iterates through an array of predetermined zeros made by a
function named 'zeros' which is a default function in Julia to make 'empty'
arrays using amount of items vertically and amount of items horizontally,
meaning the array looks something like this.
[ ], [ ], [ ], [ ], [ ]
[0], [0],
[0], [0], [0], Y⬇ 0
[0],
[0], [0], [0], [0],
[0],
[0], [0], [0], [0],
[0], [0], [0], [0], [0],
[0], [0], [0], [0], [0],
[0], [0], [0], [0], [0],
[0], [0], [0], [0], [0],
[0], [0], [0], [0], [0],
[0], [0], [0], [0], [0],
[0] [0] [0] [0] [0] 9
Comments
Post a Comment