Fractal Explorations
Use Compile to significantly speed up numerical computations.
cjc = Compile[{{power, _Integer}, {c, _Complex}}, Module[{imax = 1000, dzmax = 2500., maxpt = 10 ^ 5, z, dz, roots, branches, i = 2, res = 0. + 0. I, pt = 0},
branches = Table[Exp[-2. N[Pi] I k / power], {k, 0, power - 1}];
z = Table[0. + 0.I, {imax}];
dz = Table[1. , {imax}];
roots = Table[1, {imax}];
Map[{Re[#], Im[#]}&, NestWhileList[
Function[
z[[i]] = branches[[roots[[i]]]](z[[i - 1]] - c) ^ (1 / power);dz[[i]] = power Abs[z[[i]]] ^ (power - 1)dz[[i - 1]];
res = z[[i]];
If[i < imax && dz[[i]] < dzmax,
i++;
roots[[i]] = 1
(* else *),
While[i > 1 && roots[[i]] == power,
roots[[i]] = 1;i--];
roots[[i]]++];res],
0. + 0.I , Function[(i > 1) && (pt++ < maxpt)]]]], RuntimeOptions -> "Speed"];
Graphics[{PointSize[0.0001], Point[cjc[3, -0.04 + I * -0.78]]}, AspectRatio -> 1]Use Manipulate to explore the Julia set and discover interesting points:
Manipulate[Graphics[{PointSize[0.0001], Point[cjc[p, d[[1]] + I d[[2]]]]}, AspectRatio -> 1], {{p, 3}, Range[10]}, {{d, {-.5, -.05}}, {-2, -2}, {2, 2}}, SaveDefinitions -> True]