Advertisement
Matthen

Julia Animation

Apr 15th, 2012
769
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. cjc = Compile[{{power, _Integer}, {c, _Complex}},
  2. Module[{imax = 1000, dzmax = 2500., maxpt = 10^5, z, dz, roots,
  3. branches, i = 2, res = 0. + 0. I, pt = 0},
  4. branches = Table[Exp[-2. N[Pi] I k/power], {k, 0, power - 1}];
  5. z = Table[0. + 0. I, {imax}];
  6. dz = Table[1., {imax}];
  7. roots = Table[1, {imax}];
  8. Map[{Re[#], Im[#]} &,
  9. NestWhileList[
  10. Function[
  11. z[[i]] = branches[[roots[[i]]]] (z[[i - 1]] - c)^(1/power);
  12. dz[[i]] = power Abs[z[[i]]]^(power - 1) dz[[i - 1]];
  13. res = z[[i]];
  14. If[i < imax && dz[[i]] < dzmax, i++;
  15. roots[[i]] = 1
  16. (*else*),
  17. While[i > 1 && roots[[i]] == power, roots[[i]] = 1; i--];
  18. roots[[i]]++]; res], 0. + 0. I,
  19. Function[(i > 1) && (pt++ < maxpt)]]]],
  20. CompilationTarget -> "C", RuntimeOptions -> "Speed"];
  21.  
  22. Manipulate[
  23. Graphics[{Darker[Red], Opacity[0.1], PointSize[0.0001],
  24. Point[cjc[
  25. 2, (Sin[\[Theta]] + Cos[\[Theta]] I) (1 +
  26. 0.3 Sin[3 \[Theta]])]]}, AspectRatio -> 1,
  27. Background -> White, PlotRange -> 2, ImageSize -> 300],
  28. {\[Theta], 0, 2 Pi}
  29. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement