Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)]]]],
- CompilationTarget -> "C", RuntimeOptions -> "Speed"];
- Manipulate[
- Graphics[{Darker[Red], Opacity[0.1], PointSize[0.0001],
- Point[cjc[
- 2, (Sin[\[Theta]] + Cos[\[Theta]] I) (1 +
- 0.3 Sin[3 \[Theta]])]]}, AspectRatio -> 1,
- Background -> White, PlotRange -> 2, ImageSize -> 300],
- {\[Theta], 0, 2 Pi}
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement