## Calculating the integral points of an elliptic curve

7

4

I asked this question on Math stachexchange. The question I have is:

Can I use Mathematica to find the (integral points on the following elliptic curve) or can I find when the number $$\text{n}$$ is a perfect square?

$$\text{n}=9+108x^2(1+x)$$

Probably not, but magma and sage can https://mathoverflow.net/questions/6676/integer-points-of-an-elliptic-curve . There is a free calculator here http://magma.maths.usyd.edu.au/calc/ Try IntegralPoints(EllipticCurve([0,0,1,-3,4]))

– yarchik – 2020-01-05T17:01:29.803

8

You can find the integer points with Solve:

With[{s = 10^5},
Solve[n == 9 + 108 x^2 (1 + x) && -s <= n <= s && -s <= x <= s,
{n, x}, Integers]]

(*    {{n -> -97191, x -> -10}, {n -> -69975, x -> -9}, {n -> -48375, x -> -8},
{n -> -31743, x -> -7}, {n -> -19431, x -> -6}, {n -> -10791, x -> -5},
{n -> -5175, x -> -4}, {n -> -1935, x -> -3}, {n -> -423, x -> -2},
{n -> 9, x -> -1}, {n -> 9, x -> 0}, {n -> 225, x -> 1},
{n -> 1305, x -> 2}, {n -> 3897, x -> 3}, {n -> 8649, x -> 4},
{n -> 16209, x -> 5}, {n -> 27225, x -> 6}, {n -> 42345, x -> 7},
{n -> 62217, x -> 8}, {n -> 87489, x -> 9}}    *)


Thanks to @MichaelE2: if you want only square values for $$n=y^2$$,

Solve[y^2 == 9 + 108 x^2 (1 + x) && 0 <= y <= 10^6, {y, x}, Integers]

(*    {{y -> 3, x -> -1}, {y -> 3, x -> 0}, {y -> 15, x -> 1},
{y -> 93, x -> 4}, {y -> 165, x -> 6}}    *)


This takes 0.7 seconds. The same calculation up to $$y\le10^9$$ gives the same solutions but takes 29 seconds.

For much larger search spaces you can adapt the 128-bit-integer C code from this solution.

Is there a way to start at a certain value of $s$. So that it checks the values between to certain values for $s$. So for example: I want to know if there is a solution between $s=10^6$ and $s=10^9$? – Jan – 2020-01-05T14:41:42.077

1Solve[n == 9 + 108 x^2 (1 + x) && 10^6 <= n <= 10^9, {n, x}, Integers] would do that. There are 189 solutions. – Roman – 2020-01-05T14:44:04.040

1You could use y^2 in place of n to get just the solutions with perfect squares on the lid – Michael E2 – 2020-01-05T16:21:44.813

@MichaelE2 I don't think there are any solutions that satisfy both the curve and the perfect square. These seem to be two separate questions by the OP, as far as I can tell. Specifically, FindInstance[y^2 == 9 + 108 x^2 (1 + x), {n, x}, Integers] gives no answers. – Roman – 2020-01-05T16:30:35.497

I got five for y below 10^6 with Solve[] – Michael E2 – 2020-01-05T16:34:52.477

Sorry, my mistake. Typo in FindInstance. Thanks @MichaelE2 ! – Roman – 2020-01-05T17:08:05.333

@MichaelE2 when you state you got 5 where y>0, did you use Solve or other technique? 3 were fortuitously visible on inspection: x=0, x=-1, x=1. My answer was just silliness and play but used the curve to generate rational solutions. Solve does the job... – ubpdqn – 2020-01-06T06:47:04.430

@ubpdqn Solve[y^2 == 9=108x^2(X+1) && 0<=y<=10^6, {x, y}, Integers] is what I remember (using the wolframcloud app on an iPhone I couldn't copy-paste from the app into the SE app) – Michael E2 – 2020-01-06T09:47:11.077

@MichaelE2 thank you. I have not used Wolfram Cloud app ...I have it. Have you been able to copy and paste before? Anyway, Solve with bounds was the best way. I was just having fun and the integer solutions sifted out of rationals...happy New Year and thanks for kindness of reply. :) – ubpdqn – 2020-01-06T09:50:40.710

@ubpdqn No the app is almost useless but I'm traveling without access to a real computer at times. I thought of a way similar to yours that generate rational solutions but it's also much more complicated than Solve[]. – Michael E2 – 2020-01-06T10:00:37.260

5

You see a number of integral points by inspection: e.g. {1,15},{1,-15},{0,3},{0,-3},{-1,3},{-1,-3}.

You can pick a "generator point" and scalar multiply and filter rational solutions to get other integers. For example:

f[x_] := 9 + 108 x^2 (x + 1)
fun[{xa_, ya_}, {"O", "O"}] := {xa, ya}
fun[{"O", "O"}, {xa_, ya_}] := {xa, ya}
fun[{xp_, yp_}, {xq_, yq_}] :=
Module[{s, res},
If[{xp, yp} == {xq, yq}, s = (324 xp^2 + 216 xp)/(2 yp),
If[xp - xq == 0, Return[{"O", "O"}],
s = (yp - yq)/(xp - xq)]];
res = Simplify[{x, (s (x - xp) + yp)}] /.
Solve[ (s (x - xp) + yp)^2 == f[x], x, Reals];
Complement[res, {{xp, yp}, {xq, yq}}][] {1, -1}
]


Iterating:

pts = NestList[fun[#, {1, 15}] &, {1, 15}, 30];
ip = Cases[pts, {_?IntegerQ, _?IntegerQ}];
ContourPlot[y^2 == f[x], {x, -2, 7}, {y, -200, 200},
Epilog -> {{Red, PointSize[0.02],
Point[ip~Join~(# {1, -1} & /@ ip)]},
Arrow /@ Partition[pts, 2, 1]}]
Column[ip~Join~(# {1, -1} & /@ ip)] This is not systematic or comprehensive. Perhaps you can play around.

4

Here is a brute force approach using NumberTheoryPowersRepresentationsDumpProbablePerfectSquareQ, which I got from this comment by JM on a question asking for the Fastest square number test.

Quiet@PowersRepresentations[];(* Just to load the necessary context *)

nums =
Table[{x, NumberTheoryPowersRepresentationsDumpProbablePerfectSquareQ[9 + 108 x^2 (1 + x)]},
{x, 1, 1000000}];
(candidates = Cases[nums, {n_, True} :> n]) // Length

(* Out: 98132 *)


So this approach found close to 100,000 tentative values of $$x$$ for which that expression may be a perfect square. That should be followed up with an exact check:

Select[candidates, IntegerQ@Sqrt@(9 + 108 #^2 (1 + #)) &]

(* Out: {1, 4, 6} *)


Well that is strange because between -10^6 and 10^6 there only exists 5 solutions. – Jan – 2019-12-25T23:41:24.637

@Jan Note the name starts with Probable. It quickly filters out most of the non-squares, but one should follow it up with an actual square test. – Michael E2 – 2019-12-26T00:54:39.447