编译出错原因是ArcTan的问题,试试:ArcTan
@@@ Tuples[{0, 0.}, 2]
下面编译后运行时间约2.5s.
cf = Compile[{},
Do[With[{r = Sqrt[x^2 + y^2], th = ArcTan[x + 10^-9, y]},
If[(Cos[th - r] - Sin[th]) (r^4 - 2 r^2 Cos[2 th + 2.4] + 0.9) +
(0.62 r)^1000 < 0, Sow@{x, y}];
],
{x, -2, 2, 0.005}, {y, -2, 2, 0.005}]
];
{$, {data}} = cf[] // Reap;