In [2]:
    
import numpy as np
    
In [ ]:
    
    
The mandelbrot set is defined as the set of complex numbers $c$ for which the iteration $z_{n+1} = (z_n)^2 + c$, with $z_0=0$ does not diverge. In this exercise we want to compute the Mandelbrot set within a certain range.
in_mandelbrot(real, comp) which computes whether a complex number (real = real part, comp=complex part) belongs to the mandelbrot set. Hint: the complex number 5+3i can be constructed in python as follows: c = 5 + 1j*3. Iterate N_max times and use the threshold thresh.1000x1000 zeros called MM.
In [1]:
    
N_max = 50 # number of iterations
thresh = 50 # threshold
def in_mandelbrot(real, comp):
    # computes whether a complex number (real = real part, comp=complex part) belongs to the mandelbrot set
    pass
    
In [ ]:
    
# plot the mandelbrot fractal
# assusmes M is a 2D array filled with boolean values
import matplotlib.pyplot as plt
plt.imshow(M)
plt.show()
    
In [ ]:
    
    
In [ ]: