Pell equations upper bound

479 Views Asked by At

Consider the Pell equation $x^2-p_n y^2=1$, where $p_n$ is the $n$th prime. Is $n^{2 \sqrt{n}}$ a reasonable upper bound for the smallest integer solution for $y$?

enter image description here

Above is a plot of $\log x$ (smallest solution for $y$) against $2 \sqrt{n} \log (n)$, plotted with

PellSolve[(m_Integer)?Positive] := Module[{cf, n, s}, cf = 
ContinuedFraction[Sqrt[m]]; n = Length[Last[cf]]; If[OddQ[n], n = 2*n]; 
s = FromContinuedFraction[ContinuedFraction[Sqrt[m], n]];

With[{n = 10^4}, Show[ListPlot[Log@(PellSolve[#] & /@ 
Prime@Range@n)[[All, 2]], PlotRange -> All], Plot[{2 Log@x Sqrt@x},
{x, 0, n}], PlotRange -> All]]

and

enter image description here

ListPlot[With[{n = 3*10^4}, ((Log@(PellSolve[#] & /@ 
Prime@Range[3, n])[[All, 2]])/(2 Log@# Sqrt@# & /@ Range[3, n]))], 
PlotRange -> All]

Update

Using @WillJagy's data produces the following plot:

enter image description here

(N@With[{a=PrimePi@#},Log[PellSolve[#]][[2]]/(2Log@aSqrt@a)]&/@{5,13,29,53,61,109,181,277,397,409,421,541,661,1021,1069,1381,1549,1621,2389,3061,3469,4621,4789,4909,5581,6301,6829,8269,8941,9949,12541,13381,16069,17341,24049,24229,25309,29269,30781,32341,36061,39901,40429,43261,56149,58909,60589,63781,74869,82021,92821,107101,115021,125101,136189,140221,144589,145861,169789,199021,202981,216661,219829,226669,231709,245389,259429,266029,271021,300301,330229,379549,395509,448309,451669,455701,492781,548461,596821,602221,611389,617269,664381,679669,731509,759301,774229,799621,952429})//ListPlot

Added

Following up from @GregMartin's comment below, I add a plot coloured orange for primes congruent to $1 \!\!\mod 4$ and blue for primes congruent to $3 \!\!\mod 4$:

enter image description here

2

There are 2 best solutions below

2
On

I ran some numbers using the prime itself and using the smaller number, $y,$ from $x^2 - p y^2 = 1.$ Oh, I only printed out $p$ when $y$ increased. Also $x \approx y \sqrt p.$

5 decimal digits 1 approx log_p(y) 1.43068   Y 4
13 decimal digits 3 approx log_p(y) 2.69314   Y 180
29 decimal digits 4 approx log_p(y) 2.73523   Y 1820
53 decimal digits 4 approx log_p(y) 2.31981   Y 9100
61 decimal digits 9 approx log_p(y) 5.04109   Y 226153980
109 decimal digits 14 approx log_p(y) 6.87141   Y 15140424455100
181 decimal digits 18 approx log_p(y) 7.97279   Y 183567298683461940
277 decimal digits 19 approx log_p(y) 7.77898   Y 9562401173878027020
397 decimal digits 20 approx log_p(y) 7.69589   Y 42094239791738433660
409 decimal digits 22 approx log_p(y) 8.42356   Y 1238789998647218582160
421 decimal digits 33 approx log_p(y) 12.5749   Y 189073995951839020880499780706260
541 decimal digits 36 approx log_p(y) 13.1714   Y 159395869721270110077187138775196900
661 decimal digits 36 approx log_p(y) 12.765   Y 638728478116949861246791167518480580

================================

Without printing $y$ itself, it gets very long:

5 decimal digits 1 approx log_p(y) 1.43068   Y 
13 decimal digits 3 approx log_p(y) 2.69314   Y 
29 decimal digits 4 approx log_p(y) 2.73523   Y 
53 decimal digits 4 approx log_p(y) 2.31981   Y 
61 decimal digits 9 approx log_p(y) 5.04109   Y 
109 decimal digits 14 approx log_p(y) 6.87141   Y 
181 decimal digits 18 approx log_p(y) 7.97279   Y 
277 decimal digits 19 approx log_p(y) 7.77898   Y 
397 decimal digits 20 approx log_p(y) 7.69589   Y 
409 decimal digits 22 approx log_p(y) 8.42356   Y 
421 decimal digits 33 approx log_p(y) 12.5749   Y 
541 decimal digits 36 approx log_p(y) 13.1714   Y 
661 decimal digits 36 approx log_p(y) 12.765   Y 
1021 decimal digits 46 approx log_p(y) 15.2873   Y 
1069 decimal digits 47 approx log_p(y) 15.5168   Y 
1381 decimal digits 64 approx log_p(y) 20.3809   Y 
1549 decimal digits 70 approx log_p(y) 21.9432   Y 
1621 decimal digits 75 approx log_p(y) 23.3661   Y 
2389 decimal digits 85 approx log_p(y) 25.1612   Y 
3061 decimal digits 103 approx log_p(y) 29.5479   Y 
3469 decimal digits 112 approx log_p(y) 31.6366   Y 
4621 decimal digits 123 approx log_p(y) 33.5631   Y 
4789 decimal digits 127 approx log_p(y) 34.5086   Y 
4909 decimal digits 132 approx log_p(y) 35.7627   Y 
5581 decimal digits 143 approx log_p(y) 38.1668   Y 
6301 decimal digits 152 approx log_p(y) 40.0062   Y 
6829 decimal digits 160 approx log_p(y) 41.728   Y 
8269 decimal digits 168 approx log_p(y) 42.885   Y 
8941 decimal digits 200 approx log_p(y) 50.6152   Y 
9949 decimal digits 210 approx log_p(y) 52.5292   Y 
12541 decimal digits 234 approx log_p(y) 57.0964   Y 
13381 decimal digits 254 approx log_p(y) 61.5535   Y 
16069 decimal digits 259 approx log_p(y) 61.5789   Y 
17341 decimal digits 276 approx log_p(y) 65.1086   Y 
24049 decimal digits 279 approx log_p(y) 63.6827   Y 
24229 decimal digits 301 approx log_p(y) 68.6535   Y 
25309 decimal digits 325 approx log_p(y) 73.8087   Y 
29269 decimal digits 328 approx log_p(y) 73.4371   Y 
30781 decimal digits 358 approx log_p(y) 79.7632   Y 
32341 decimal digits 391 approx log_p(y) 86.701   Y 
36061 decimal digits 394 approx log_p(y) 86.4597   Y 
39901 decimal digits 446 approx log_p(y) 96.9358   Y 
40429 decimal digits 449 approx log_p(y) 97.4669   Y 
43261 decimal digits 476 approx log_p(y) 102.673   Y 
56149 decimal digits 508 approx log_p(y) 106.962   Y 
58909 decimal digits 523 approx log_p(y) 109.639   Y 
60589 decimal digits 551 approx log_p(y) 115.214   Y 
63781 decimal digits 560 approx log_p(y) 116.553   Y 
74869 decimal digits 597 approx log_p(y) 122.479   Y 
82021 decimal digits 680 approx log_p(y) 138.382   Y 
92821 decimal digits 722 approx log_p(y) 145.34   Y 
107101 decimal digits 723 approx log_p(y) 143.743   Y 
115021 decimal digits 768 approx log_p(y) 151.755   Y 
125101 decimal digits 815 approx log_p(y) 159.89   Y 
136189 decimal digits 863 approx log_p(y) 168.09   Y 
140221 decimal digits 884 approx log_p(y) 171.757   Y 
144589 decimal digits 890 approx log_p(y) 172.476   Y 
145861 decimal digits 910 approx log_p(y) 176.222   Y 
169789 decimal digits 999 approx log_p(y) 191.017   Y 
199021 decimal digits 1066 approx log_p(y) 201.174   Y 
202981 decimal digits 1109 approx log_p(y) 208.951   Y 
216661 decimal digits 1118 approx log_p(y) 209.529   Y 
219829 decimal digits 1133 approx log_p(y) 212.089   Y 
226669 decimal digits 1148 approx log_p(y) 214.363   Y 
231709 decimal digits 1155 approx log_p(y) 215.287   Y 
245389 decimal digits 1162 approx log_p(y) 215.59   Y 
259429 decimal digits 1164 approx log_p(y) 214.997   Y 
266029 decimal digits 1190 approx log_p(y) 219.358   Y 
271021 decimal digits 1234 approx log_p(y) 227.13   Y 
300301 decimal digits 1386 approx log_p(y) 253.033   Y 
330229 decimal digits 1433 approx log_p(y) 259.657   Y 
379549 decimal digits 1452 approx log_p(y) 260.249   Y 
395509 decimal digits 1610 approx log_p(y) 287.646   Y 
448309 decimal digits 1615 approx log_p(y) 285.761   Y 
451669 decimal digits 1697 approx log_p(y) 300.098   Y 
455701 decimal digits 1754 approx log_p(y) 309.966   Y 
492781 decimal digits 1790 approx log_p(y) 314.44   Y 
548461 decimal digits 1826 approx log_p(y) 318.166   Y 
596821 decimal digits 1836 approx log_p(y) 317.876   Y 
602221 decimal digits 1931 approx log_p(y) 334.097   Y 
611389 decimal digits 1997 approx log_p(y) 345.125   Y 
617269 decimal digits 2025 approx log_p(y) 349.712   Y 
664381 decimal digits 2045 approx log_p(y) 351.229   Y 
679669 decimal digits 2101 approx log_p(y) 360.235   Y 
731509 decimal digits 2132 approx log_p(y) 363.561   Y 
759301 decimal digits 2245 approx log_p(y) 381.776   Y 
774229 decimal digits 2285 approx log_p(y) 388.02   Y 
799621 decimal digits 2395 approx log_p(y) 405.734   Y 
952429 decimal digits 2472 approx log_p(y) 413.459   Y 

========================================

0
On

Worked nicely, got accurate logarithms. The evident conjecture would be $$ \log_p \log_p y < \frac{1}{2}, $$ so $$ y < p^{\sqrt p} $$ Recall $x \approx y \sqrt p.$

Now that I have everything working, I am running it much higher. So far, the output says $$ \require{enclose} \enclose{horizontalstrike,updiagonalstrike}{y < p^{\left( p^{4/9} \right)}} $$ No, spoke too soon, eventually got

  3462229  log_p(y)  806.243   log_p(log_p(y)) 0.444458   Y 
  6810301  log_p(y) 1100.57    log_p(log_p(y)) 0.445126   Y 
 21030109  log_p(y) 1823.34    log_p(log_p(y)) 0.445301   Y 
 23493661  log_p(y) 1938.6     log_p(log_p(y)) 0.446006   Y
 25959781  log_p(y) 2036.55    log_p(log_p(y)) 0.446285   Y 

I repeat that methods based on continued fractions with no explicit control of the precision may easily give wrong and essentially random results. There are intricate modern methods for solving Pell; I implemented the Lagrange method of reduced indefinite binary quadratic forms, which is elementary, requires no decimal accuracy at all, and requires zero memory and no cycle detection, as the point when it concludes is unmistakeable.

jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$ ./Pell_Y
    5 approx log_p(y) 0.861353   Y 4
    13 approx log_p(y) 2.02458   Y 180
    29 approx log_p(y) 2.22926   Y 1820
    53 approx log_p(y) 2.29606   Y 9100
    61 approx log_p(y) 4.67947   Y 226153980
    109 approx log_p(y) 6.46901   Y 15140424455100
    181 approx log_p(y) 7.6467   Y 183567298683461940
    277 approx log_p(y) 7.77102   Y 9562401173878027020
    397 approx log_p(y) 7.55129   Y 42094239791738433660
    409 approx log_p(y) 8.07628   Y 1238789998647218582160
    421 approx log_p(y) 12.2992   Y 189073995951839020880499780706260
    541 approx log_p(y) 12.8796   Y 159395869721270110077187138775196900
    661 approx log_p(y) 12.696   Y 638728478116949861246791167518480580
    1021 approx log_p(y) 15.2188   Y 6219237759214762827187409503019432615976684540
    1069 approx log_p(y) 15.3043   Y 22722526912283010072320240710785462723519145740
    1381 approx log_p(y) 20.1877   Y 2472690352775053537868141555978544119564691977342423075952738420
    1549 approx log_p(y) 21.6571   Y 1222309542826747495934242683346380508818076263178681966098672827963220
    1621 approx log_p(y) 23.1151   Y 156429324369979112128445583345098338627552043874824108399177922442751050500
    jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$



jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$ ./Pell_Y
    5  log_p(y) 0.861353   log_p(log_p(y)) -0.0927347   Y 
    13  log_p(y) 2.02458   log_p(log_p(y)) 0.275001   Y 
    29  log_p(y) 2.22926   log_p(log_p(y)) 0.238076   Y 
    53  log_p(y) 2.29606   log_p(log_p(y)) 0.209354   Y 
    61  log_p(y) 4.67947   log_p(log_p(y)) 0.375391   Y 
    109  log_p(y) 6.46901   log_p(log_p(y)) 0.397972   Y 
    181  log_p(y) 7.6467   log_p(log_p(y)) 0.39132   Y 
    277  log_p(y) 7.77102   log_p(log_p(y)) 0.36458   Y 
    397  log_p(y) 7.55129   log_p(log_p(y)) 0.337858   Y 
    409  log_p(y) 8.07628   log_p(log_p(y)) 0.347361   Y 
    421  log_p(y) 12.2992   log_p(log_p(y)) 0.415305   Y 
    541  log_p(y) 12.8796   log_p(log_p(y)) 0.406082   Y 
    661  log_p(y) 12.696   log_p(log_p(y)) 0.391343   Y 
    1021  log_p(y) 15.2188   log_p(log_p(y)) 0.392945   Y 
    1069  log_p(y) 15.3043   log_p(log_p(y)) 0.39116   Y 
    1381  log_p(y) 20.1877   log_p(log_p(y)) 0.415607   Y 
    1549  log_p(y) 21.6571   log_p(log_p(y)) 0.418677   Y 
    1621  log_p(y) 23.1151   log_p(log_p(y)) 0.424918   Y 
    2389  log_p(y) 25.1011   log_p(log_p(y)) 0.414329   Y 
    3061  log_p(y) 29.3495   log_p(log_p(y)) 0.421015   Y 
    3469  log_p(y) 31.3737   log_p(log_p(y)) 0.422734   Y 
    4621  log_p(y) 33.3206   log_p(log_p(y)) 0.415504   Y 
    4789  log_p(y) 34.4361   log_p(log_p(y)) 0.417639   Y 
    4909  log_p(y) 35.5567   log_p(log_p(y)) 0.420191   Y 
    5581  log_p(y) 38.1218   log_p(log_p(y)) 0.422016   Y 
    6301  log_p(y) 39.805   log_p(log_p(y)) 0.421102   Y 
    6829  log_p(y) 41.6237   log_p(log_p(y)) 0.422324   Y 
    8269  log_p(y) 42.7728   log_p(log_p(y)) 0.416385   Y 
    8941  log_p(y) 50.4718   log_p(log_p(y)) 0.431   Y 
    9949  log_p(y) 52.3724   log_p(log_p(y)) 0.430014   Y 
    12541  log_p(y) 56.9013   log_p(log_p(y)) 0.428253   Y 
    13381  log_p(y) 61.4047   log_p(log_p(y)) 0.433347   Y 
    16069  log_p(y) 61.5531   log_p(log_p(y)) 0.425405   Y 
    17341  log_p(y) 65.0599   log_p(log_p(y)) 0.427762   Y 
    24049  log_p(y) 63.4789   log_p(log_p(y)) 0.411456   Y 
    24229  log_p(y) 68.5042   log_p(log_p(y)) 0.418699   Y 
    25309  log_p(y) 73.7992   log_p(log_p(y)) 0.424241   Y 
    29269  log_p(y) 73.3186   log_p(log_p(y)) 0.417609   Y 
    30781  log_p(y) 79.7233   log_p(log_p(y)) 0.423678   Y 
    32341  log_p(y) 86.678   log_p(log_p(y)) 0.429715   Y 
    36061  log_p(y) 86.2591   log_p(log_p(y)) 0.424795   Y 
    39901  log_p(y) 96.8796   log_p(log_p(y)) 0.431697   Y 
    40429  log_p(y) 97.3489   log_p(log_p(y)) 0.431618   Y 
    43261  log_p(y) 102.508   log_p(log_p(y)) 0.433718   Y 
    56149  log_p(y) 106.832   log_p(log_p(y)) 0.427154   Y 
    58909  log_p(y) 109.458   log_p(log_p(y)) 0.427499   Y 
    60589  log_p(y) 115.187   log_p(log_p(y)) 0.43104   Y 
    63781  log_p(y) 116.501   log_p(log_p(y)) 0.430065   Y 
    74869  log_p(y) 122.279   log_p(log_p(y)) 0.428236   Y 
    82021  log_p(y) 138.278   log_p(log_p(y)) 0.43565   Y 
    92821  log_p(y) 145.235   log_p(log_p(y)) 0.435231   Y 
    107101  log_p(y) 143.738   log_p(log_p(y)) 0.428958   Y 
    115021  log_p(y) 151.66   log_p(log_p(y)) 0.430936   Y 
    125101  log_p(y) 159.854   log_p(log_p(y)) 0.432335   Y 
    136189  log_p(y) 167.978   log_p(log_p(y)) 0.433422   Y 
    140221  log_p(y) 171.612   log_p(log_p(y)) 0.434161   Y 
    144589  log_p(y) 172.339   log_p(log_p(y)) 0.433397   Y 
    145861  log_p(y) 176.19   log_p(log_p(y)) 0.434935   Y 
    169789  log_p(y) 190.953   log_p(log_p(y)) 0.436131   Y 
    199021  log_p(y) 201.171   log_p(log_p(y)) 0.434725   Y 
    202981  log_p(y) 208.893   log_p(log_p(y)) 0.437107   Y 
    216661  log_p(y) 209.434   log_p(log_p(y)) 0.434997   Y 
    219829  log_p(y) 211.923   log_p(log_p(y)) 0.435444   Y 
    226669  log_p(y) 214.183   log_p(log_p(y)) 0.435222   Y 
    231709  log_p(y) 215.202   log_p(log_p(y)) 0.434832   Y 
    245389  log_p(y) 215.537   log_p(log_p(y)) 0.432947   Y 
    259429  log_p(y) 214.83   log_p(log_p(y)) 0.430751   Y 
    266029  log_p(y) 219.301   log_p(log_p(y)) 0.431534   Y 
    271021  log_p(y) 226.96   log_p(log_p(y)) 0.433637   Y 
    300301  log_p(y) 252.924   log_p(log_p(y)) 0.438697   Y 
    330229  log_p(y) 259.537   log_p(log_p(y)) 0.437449   Y 
    379549  log_p(y) 260.128   log_p(log_p(y)) 0.432886   Y 
    395509  log_p(y) 287.529   log_p(log_p(y)) 0.439273   Y 
    448309  log_p(y) 285.66   log_p(log_p(y)) 0.434542   Y 
    451669  log_p(y) 300.008   log_p(log_p(y)) 0.438057   Y 
    455701  log_p(y) 309.934   log_p(log_p(y)) 0.440256   Y 
    492781  log_p(y) 314.412   log_p(log_p(y)) 0.438723   Y 
    548461  log_p(y) 317.999   log_p(log_p(y)) 0.436028   Y 
    596821  log_p(y) 317.846   log_p(log_p(y)) 0.433221   Y 
    602221  log_p(y) 334.081   log_p(log_p(y)) 0.436671   Y 
    611389  log_p(y) 345.064   log_p(log_p(y)) 0.438604   Y 
    617269  log_p(y) 349.704   log_p(log_p(y)) 0.43929   Y 
    664381  log_p(y) 351.122   log_p(log_p(y)) 0.437182   Y 
    679669  log_p(y) 360.23   log_p(log_p(y)) 0.438349   Y 
    731509  log_p(y) 363.548   log_p(log_p(y)) 0.436642   Y 
    759301  log_p(y) 381.733   log_p(log_p(y)) 0.439044   Y 
    774229  log_p(y) 387.86   log_p(log_p(y)) 0.439588   Y 
    799621  log_p(y) 405.661   log_p(log_p(y)) 0.441846   Y 
    952429  log_p(y) 413.317   log_p(log_p(y)) 0.437591   Y 
    1026061  log_p(y) 424.428   log_p(log_p(y)) 0.437153   Y 
    1027261  log_p(y) 438.245   log_p(log_p(y)) 0.439431   Y 
    1047589  log_p(y) 439.753   log_p(log_p(y)) 0.439057   Y  
    1053061  log_p(y) 439.665   log_p(log_p(y)) 0.438878   Y 
    1094461  log_p(y) 439.882   log_p(log_p(y)) 0.437696   Y 
    1117741  log_p(y) 446.678   log_p(log_p(y)) 0.438136   Y 
    1130581  log_p(y) 446.514   log_p(log_p(y)) 0.43775   Y 
    1167709  log_p(y) 457.613   log_p(log_p(y)) 0.438495   Y 
    1261549  log_p(y) 467.872   log_p(log_p(y)) 0.437661   Y 
    1331269  log_p(y) 469.769   log_p(log_p(y)) 0.436278   Y 
    1336141  log_p(y) 515.986   log_p(log_p(y)) 0.442818   Y 
    1404181  log_p(y) 516.672   log_p(log_p(y)) 0.441358   Y 
    jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$