Create Your Own Meldelbrot Checker | Jason Zhu’s Personal Website
Create Your Own Meldelbrot Checker
Mendelbrot set is the subset of complex numbers. Let “c” be an arbitary complex number, and define the function: \(f_c(z) = z^2 + c\), where \(z\) start from \(0 + 0i\).
Then, for the complex number “c”, if \(f_c(z)\) won’t diverge (or go to infinity) after applying the function for infinite times, then this complex number “c” is in Mandelbrot Set.
Although the definition is pretty simple, it creates a fractal, which would give you unlimited details as long as you keep zooming in.
Before Coding
Still, there is a problem: how can we determine whether a certain point would diverge? Clearly computers cannot do calculations infinitely for infinite points, but we can apply these two strategies:
Indeed, we cannot apply \(f_c(z)\) for infinite times. Therefore, we set the max iteration count for the program. The larger maxIter is, the more precise the graph would be. We can adjust based on our needs.
We can prove that any points with absolute value greater than two (\(\sqrt{a^2 + b^2} > 2\)) will ultimately diverge. Here is the proof by induction from stackExchange:
Code Implementation with Video
Also, here is the full version of the code, and you can also check more related content in corresponding github repo: