Lesson 12 of 15

Julia Sets

Julia Sets

For every complex constant c, the Julia set J_c is the boundary between starting points z that escape to infinity and those that remain bounded under repeated application of f(z) = z² + c.

Unlike the Mandelbrot set — where c varies and z starts at 0 — for a Julia set we fix c and vary the starting point z. This gives a different fractal for every value of c.

A key theorem connects Julia sets to the Mandelbrot set:

  • If c is inside the Mandelbrot set, then J_c is connected (one piece)
  • If c is outside the Mandelbrot set, then J_c is a Cantor dust (infinitely disconnected)

The filled Julia set K_c consists of all z that do not escape — the interior plus the boundary. Computing the fraction of a grid that lies in K_c gives a measure of the "filled" area.

Implement the following functions:

  • julia_iter(zr, zi, cr, ci, max_iter) — return the escape time for starting point (zr, zi) with constant c = (cr, ci)
  • julia_connected(cr, ci, max_iter) — return True if the Julia set is connected (c is in the Mandelbrot set)
  • julia_fill_ratio(cr, ci, zr_min, zr_max, zi_min, zi_max, n, max_iter) — fraction of n×n grid points that do not escape
Python runtime loading...
Loading...
Click "Run" to execute your code.