SHAD UBC 2018: Make Your Own Fractal with Kyle Blaney

  1. Learn the mathematical concept of fractals (and particularly the Mandelbrot Set) by watching this presentation.
  2. After installing required software, learn the Python programming language by watching prerecorded lessons and doing the exercises after each lesson. Compare your answers to my answers, remembering that there are many ways to correctly do each exercise.
  3. Write a program in Python that draws the Mandelbrot Set. One such program appears below.
  4. Customize the program to make your own fractal! There are many ways to customize. Here are a few, ordered from easy to difficult:
    • Use a different color map. (Modify cmap="hot". Learn more about color maps.)
    • Zoom in on a particular region. (Modify min_real, max_real, min_imag and max_imag to specify the portion of the complex plane that the program displays. Try some of these interesting regions.)
    • Instead of drawing the Mandelbrot Set, draw the Julia Set for a particular complex number.

Python Program that Draws Mandelbrot Set

import numpy
import matplotlib.pyplot

def mandel(c):
    max_num_iterations = 125
    z = 0
    for i in range(max_num_iterations):
        z = (z*z) + c
        if abs(z) > 2:
    return i

min_real = -2.25
max_real = 0.75
min_imag = -1.25
max_imag = 1.25
num_intervals = 1000
real_values = numpy.linspace(min_real, max_real, num_intervals)
imag_values = numpy.linspace(min_imag, max_imag, num_intervals)

atlas = numpy.empty([num_intervals, num_intervals])
for x in range(num_intervals):
    for y in range(num_intervals):
        c = complex(real_values[x], imag_values[y])
        atlas[x, y] = mandel(c)

matplotlib.pyplot.imshow(atlas.T, aspect="auto", cmap="hot")

Other Resources

Online Mandelbrot Set Viewer
GNU XaoS - Fast Interactive Fractal Explorer
Video - Deepest Mandelbrot Set Zoom Ever