Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • $\begingroup$ thanks for the solution but the timing in my larger 2K numbers are the same as Solve $\endgroup$ Commented Dec 23, 2013 at 19:29
  • $\begingroup$ My machine still runs Cornacchia faster than Solve on the larger numbers but, as I said, your timings may vary. The FactorInteger method of @DanielLichtblau should not be dismissed so quickly; it is significantly faster than all so far. Perhaps if you could optimize the Cornacchia algorithm, since its inner workings are visible and not a black box like Solve, then we would all benefit. $\endgroup$ Commented Dec 23, 2013 at 20:16
  • $\begingroup$ I've added new findings $\endgroup$ Commented Dec 23, 2013 at 21:44
  • 1
    $\begingroup$ Here is a shorter variant. With[{r = PowerMod[-1, 1/2, p]}, GCD[p, r + I]]. But it's not any faster as far as I can tell. $\endgroup$ Commented Dec 23, 2013 at 22:43
  • $\begingroup$ @DanielLichtblau Thanks! Your PowerMod formulation is compact and much, much faster than the awkward JacobiSymbol equivalent I was using in another non-Cornacchia approach. $\endgroup$ Commented Jan 19, 2014 at 1:13