Learning Scientific Programming with Python (2nd edition)

P7.5.4: The Julia set

Question P7.5.4

The Julia set associated with the complex function $f(z) = z^2 + c$ may be depicted using the following algorithm.$\renewcommand\Re{\operatorname{Re}}\renewcommand\Im{\operatorname{Im}}$

For each point, $z_0$, in the complex plane such that $-1.5 \le \Re[z_0] \le 1.5$ and $-1.5 \le \Im[z_0] \le 1.5$, iterate according to $z_{n+1} = z_n^2 + c$ where $c$ is a some (complex) constant. Colour the pixel in an image corresponding to this region of the complex plane according to the number of iterations required for $|z|$ to exceed some critical value, $|z|_\mathrm{max}$ (or black if this does not happen before a certain maxmimum number of iterations $n_\mathrm{max}$).

Write a program to plot the Julia set for $c = -0.1 + 0.65j$, using $|z|_\mathrm{max}=10$ and $n_\mathrm{max}=500$.