One more solution of the Mordell equation
[Update: Improved second code.]
There is a system limit on Solve
, which you can extend this way:
k = 1000000;
n = Ceiling[k^(3/2)];
With[{ropts = SystemOptions["ReduceOptions"]},
Internal`WithLocalSettings[
SetSystemOptions[
"ReduceOptions" -> "SolveDiscreteSolutionBound" -> n],
Solve[x^3 - y^2 == 307 && -k < x < k && 0 < y < n, {x, y},
Integers],
SetSystemOptions[ropts]
]] // AbsoluteTiming
(*
{143.664,
{{x -> 7, y -> 6}, {x -> 11, y -> 32},
{x -> 71, y -> 598}, {x -> 939787, y -> 911054064}}}
*)
For speed using an exhaustive search over x
: The code will work efficiently for machine integers (for solutions with x^3
less than 2^53
, the limit on double-precision floating-point numbers to exactly represent an integer).
Block[{Part},
With[{x = #[[1]] + 1, y = #[[2]]},
Hold[
Pick[#[[All, 1 ;; 2]], #[[All, -1]], 0] &@
NestList[
With[{n = Sqrt[x^3 - 307.]},
If[FractionalPart@n == 0,
{x, Round[n], 0},
{x, y, 1}]
] &,
{Floor@CubeRoot@307., 1, 1},
1000000
]
]
]
] // ReleaseHold // AbsoluteTiming
(* {0.36922, {{7, 6}, {11, 32}, {71, 598}, {939787, 911054064}}} *)
If you want a brute-force approach to check the rectangular {x, y}
space, keep in mind that for 0 <= x <= 10^6
, the space has 10^15
pairs, which would take a long time for a GHz processor, or even a few thousand of them.
I used this code to find one. In every iteration I looked up 200k range.
m = 100000;
Total@Boole[IntegerQ /@ Sqrt[Range[8 m, 10 m]^3 - 307]]
1
And extracted the solution using
Position[IntegerQ /@ Sqrt[Range[8 m, 10 m]^3 - 307], True]
{{139788}}
This implies that
x=139788 - 1 + 8 m=939787
is a solution.
{x,y}={939787,911054064}
Since I used Brute-Force, next solution must be $x>10,000,000$