Mandelbrot Set
Prerequisite Knowledge
Mandelbrot Set is a famous fractal. It is generated by a recursive function . Given a value of , is in the Mandelbrot Set if and only if does not go to infinity as increases.
Make Mandelbrot Set in Grapycal
This tutorial goes with the example file “mandelbrot.grapycal”. To open the file, you need grapycal_torch extension installed.
Initialize
First, we generate a complex plane and store it into both variable z0 and z. The complex plane include all complex numbers in a certain range (with limited resolution), so we can iterate them all together.
Iterate z
The program repeats 50 times: take z, calculate the new z, store the value back to z.
The outcome is a plain image of Mandelbrot Set.
Iterate z (With Better Rendering)
To make it prettier, we introduce a variable c
to record the time abs(z) exceeds 2.
What’s Next?
Zoom in to the details of Mandelbrot Set by adjusting the GridNode’s parameters.
Tip: Iterate more than 50 times to get finer result.
These are some examples:
Try other rendering techniques for Mandelbrot Set. A good technique is that instead of render from , render from . The make the color map periodic. The make the color map distribute evenly w.r.t scaling.
Make other kinds of fractals such as Julia Set. See https://en.wikipedia.org/wiki/Mandelbrot_set#See_also.