# [seqfan] Re: x^2 + Dy^2 = N

hv at crypt.org hv at crypt.org
Thu Jun 3 19:01:46 CEST 2021

```Ah, I had missed the linked wiki page "Binary Quadratic Forms and OEIS",

Hugo

I wrote:
:I'm working on code to solve as completely as possible the generalized
:second order 2-variable Diophantine equation:
:  ax^2 + bxy + cy^2 + dx + ey + f = 0
:
:The subset I'm now now looking at is a kind of "anti-Pell" equation:
:x^2 + Dy^2 = N. When D = 1 we have the sum of two squares, for which
:good algorithms have been published (eg [1]). For D > 0 not a square
:I have not yet found anything, so I started looking at the next case,
:D = 2.
:
:Counting the number of solutions, S, for N < 101^2 (with x, y >= 0) I find:
:
:S >= 1: 0 1 2 3 4 6 8 9 11 12 16 17 18 19 22 ... (A002479)
:S  = 1: 0 1 2 3 4 6 8 11 12 16 17 19 22 24 ... (A034034)
:
:S >= 2: 9 18 27 33 36 51 54 57 66 72 81 99 ...
:S  = 2: 9 18 27 33 36 51 54 57 66 72 102 108 ...
:
:S >= 3: 81 99 153 162 171 198 243 297 306 ...
:S  = 3: 81 99 153 162 171 198 243 306 324 342 ...
:
:S >= 4: 297 459 513 561 594 627 729 891 918 ...
:S  = 4: 297 459 513 561 594 627 729 918 969 ...
:
:S >= 5: 891 1089 1377 1539 1683 1782 1881 2178 ...
:S  = 5: 891 1089 1377 1539 1782 2178 2601 2754 ...
:
:S >= 6: 1683 1881 2673 2907 3267 3366 3762 ...
:S  = 6: 1683 1881 2673 2907 3267 3366 3762 ...
:
:S >= 7: 5049 5643 8019 8721 9801 10098
:S  = 7: 8019
:
:S >= 8: 5049 5643 8721 9801 10098
:S  = 8: 5049 5643 8721 9801 10098
:
:Least k with at least n representations: 0 9 81 297 891 1683 5049 5049
:
:Only the first pair of these sequences are in the OEIS; should more of
:them be? If so, how many of them?
:
:If anyone is aware of prior investigation of this, and in particular of
:algorithms to find solutions of x^2 + Dy^2 = N either for specific
:non-square D or more generally, I'd appreciate any references you have.
:
:Hugo
:
:[1] https://www.ams.org/journals/mcom/1972-26-120/S0025-5718-1972-0314745-6/S0025-5718-1972-0314745-6.pdf
```