3

I'm trying to find the smallest integer solution to

$$n^2 = 2d^2 - 2d + 1$$

Additional constraints: $$d > 10^{12}, n > 0$$

I wrote a computer program to bruteforce it, but that is too slow.

This page says that I can consider the equation modulo some prime to find whether it has solutions, but I already know that it has a solution, I just don't know what it is.

Bill Dubuque
  • 272,048
Nick ODell
  • 231
  • 1
  • 12

3 Answers3

4

It's $$n^2=d^2+(d-1)^2$$ and we got Pythagorean triples because we can assume that $d-1>0$,

otherwise it's or obvious or the same.

Since $gcd(d,d-1)=1$, we have two cases.

  1. $d=2mn$ and $d-1=m^2-n^2$, where $gcd(m,n)=1$, $m>n$ and $mn$ is even;

  2. $d=m^2-n^2$ and $d-1=2mn$.

We got two Pell's equations: $$(m+n)^2=1+2m^2$$ and $$(m-n)^2=1+2n^2.$$ They are $y^2=1+2x^2$ with a minimal solution $(2,3)$ and from here we can get all solutions.

2

We have $$n^2=2d^2+2d-1\implies d^2+(d-1)^2=n^2$$

which can translate to a Pythagorean triple $\qquad A^2+B^2=C^2=n^2\quad\text{where }\quad B=A\pm1$

The $(m,k)$ values for to generate these triples are adjacent Pell numbers which can be generated by a simple derivation of Euclid's formula $ \quad A=m^2-k^2,\quad B=2mk,\quad C=m^2+k^2\quad$ where each m-value generated is the k-value for the next iteration of the formula

\begin{equation}\quad m=k+\sqrt{2k^2+(-1)^k}\end{equation} Only $19$ can be generated with $15$-digit precision but it is simple and quick in a spreadsheet. It looks like the answer you seek, where $d>10^{12}$ is number $16$ in the list below.

\begin{equation} 0)\quad F(m,k)=(d,(d\pm1),n)\\ 1)\quad F(2,1)=(3,4,5)\\ 2)\quad F(5,2)=(21,20,29)\\ 3)\quad F(12,5)=(119,120,169)\\ 4)\quad F(29,12)=(697,696,985)\\ 5)\quad F(70,29)=(4059,4060,5741)\\ 6)\quad F(169,70)=(23661,23660,33461)\\ 7)\quad F(408,169)=(137903,137904,195025)\\ 8)\quad F(985,408)=(803761,803760,1136689)\\ 9)\quad F(2378,985)=(4684659,4684660,6625109)\\ 10)\quad F(5741,2378)=(27304197,27304196,38613965)\\ 11)\quad F(13860,5741)=(159140519,159140520,225058681)\\ 12)\quad F(33461,13860)=(927538921,927538920,1311738121)\\ 13)\quad F(80782,33461)=(5406093003,5406093004,7645370045)\\ 14)\quad F(195025,80782)=(31509019101,31509019100,44560482149)\\ 15)\quad F(470832,195025)=(183648021599,183648021600,259717522849)\\ 16)\quad F(1136689,470832)=(1070379110497,1070379110496,1513744654945)\\ 17)\quad F(2744210,1136689)=(6238626641379,6238626641380,8822750406821)\\ 18)\quad F(6625109,2744210)=(36361380737781,36361380737780,51422757785981)\\ 19)\quad F(15994428,6625109)=(211929657785303,211929657785304,299713796309065)\\ \end{equation}

poetasis
  • 6,338
-2

Found a solution.

Valid values of d have a ratio of approx 5.82842712474619 between them. (Is this ratio significant in some way? Damned if I know.)

In other words, if you know that 1235216565974041 is a valid value, then you can guess that 7199369738058942 is a valid value, which is only 2 away from 7199369738058940, which is correct.

This makes the problem bruteforceable, and solves my problem.

Nick ODell
  • 231
  • 1
  • 12