Let's take a look at some examples of visualizing arrays as images. The following function will create a matrix of color values for the Mandelbrot fractal, see also [20]. Here, we consider a fixed-point iteration, which depends on a complex parameter,
:

Depending on the choice of this parameter, it may or may not create a bounded sequence of complex values,
.
For every value of
, we check whether
exceeds a prescribed bound. If it remains below the bound within maxit iterations, we assume the sequence to be bounded.
Note how, in the following piece of code,meshgrid is used to generate a matrix of complex parameter values,
:
def mandelbrot(h,w, maxit=20):
X,Y = meshgrid(linspace(-2, 0.8, w), linspace(-1.4, 1.4, h))
c = X + Y*1j
z = c
exceeds = zeros(z.shape, dtype=bool)
for iteration in range(maxit):
z = z**2 + c
exceeded = abs(z) > 4
exceeds_now...