Back
Close

How to plot the Mandelbrot set

[CG]Maxime
10.5K views
Previous: Adding some colors

Julia Sets

Julia Sets also offer great fractals. The definition of the Julia sets is very similar to the mandelbrot set. As a reminder, the Mandelbrot set is the set of the complex numbers c for which the sequence zn+1=zn2+c is bounded (z0 is set to 0). While, the definition of the Julia sets is the numbers z0 for which the sequence is bounded, with c a constant value.

from math import log, log2
MAX_ITER = 80
def julia(c, z0):
z = z0
n = 0
while abs(z) <= 2 and n < MAX_ITER:
z = z*z + c
n += 1
if n == MAX_ITER:
return MAX_ITER
return n + 1 - log(log2(abs(z)))
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I hope you liked this playground. Please leave a comment below!

Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants