How to "inform" successive ContourPlot calculations?
Using NestWhile
seems to work well
z[n_, c_] := NestWhile[(#^2 + c) &, c, Abs[#] <= 2 &, 1, n];
ContourPlot[Abs[z[iter, x + I*y]] == 2, {x, -.00001, .00001}, {y, .99999, 1.00001},
MaxRecursion -> 5] // AbsoluteTiming
producing the plot in the question in about 10 seconds, as opposed to 180 seconds for the code in the question.
Many years of Lisp and Scheme programming has given me a fondness for recursive functions. They don't have to have poor performance if some care is taken when writing them. For your problem I would write z
as
z[n_, c0_] := z[n - 1, c0, c0^2 + c0]
z[0, _, c_] := c
z[n_, c0_, c_?(Abs[#] > 2 &)] := c
z[n_, c0_, c_] := z[n - 1, c0, c^2 + c0]
Note there is a cutoff for Abs[c] > 2
. That gives a pretty good performance boost.
ContourPlot[Abs[z[25, x + I*y]] == 2, {x, -.00001, .00001}, {y, .99999, 1.00001},
MaxRecursion -> 5] // AbsoluteTiming
Not as fast as bbgodfrey's NestWhile
solution, but not too shabby.