Let $\text{NPE}_d$ denote the negative Pell equation: $$ x^2-dy^2=-1$$ Where $d$ is a given positive nonsquare integer and integer solutions are sought for x and y.

we know that (in this paper archive):

Theorem : The equation $\text{NPE}_d$ has integer solutions if and only if there exist two integers $a(d)=a$ and $b(d)=b$ such that $d=a^2+b^2$ and there exists a Pythagorean triplet $(A,B,C)$ such that $|aA-bB|=1$ and in this case $(Aa+Bb,C)$ is a solution.

Obviously if $\text{NPE}_d$ has integer solutions then $d$ cannot be divisible by any prime $p$ such that $p=3\mod 4$.

My question: Is there any characterization for the integers $d$ for which $\text{NPE}_d$ and $\text{NPE}_{2d}$ have both integer solutions.

I used the characterization above, but I can't link the couple $(a(d),b(d))$ to $(a(2d),b(2d))$ because the theorem doesn't give us much information

The sequence of the elements $d$ for which $\text{NPE}_d$ is soluble is OEIS A031396.

I posted this question in math.exchange and does not receive any answer


2 Answers 2


I know the question is old, but is possible to give an exact characterization to $d$, at least if it's a prime number:

It is known that considering a prime $p \equiv 1\mod 4$, there is always a solution to $x^2 - py^2 = -1$ in integers, the proof is from Mordell "Diophantine Equations" pages 55-56 (thanks to @Will Jagy for pointing that out).

Furthermore Dirichlet proved that if the prime $p \equiv 1 \mod 4$ and $p \equiv 5 \mod 8$ or $p \equiv 9 \mod 16$, the equation $x^2 - 2py^2 = -1$ has still integer solutions (reference: https://www.forgottenbooks.com/en/download/ThePellEquation_10024828.pdf pag. 80)

So you can say that if $p$ is a prime and $p \equiv 5 \mod 8$ or $p \equiv 9 \mod 16$ both NPEₚ NPE₂ₚ have integer solutions

  • 1
    $\begingroup$ Note that Mordell's proof can be easily adapted to this: primes $p,q \equiv 1 \pmod 4$ but mutual quadratic non-residues, that is Legendre symbol $(p,q) = -1$ then there are integer solutions to $x^2 - pq y^2 = -1$ The first two semiprimes where impossibility is a surprise are $205 = 5 \cdot 41$ and $221 = 13 \cdot 17$ both times mutual residues. $\endgroup$
    – Will Jagy
    Commented Jun 22 at 18:36
  • $\begingroup$ It appears Whitford skips over that one. However, on page 80 he lists conditions 1,2,3,4, but the refers to conditions 3,4,5 . Perhaps he meant to include a condition 5 with the simple $(p,q) = -1,$ or meant that as condition 4 and the one with quartic residues moved to condition 5. $\endgroup$
    – Will Jagy
    Commented Jun 22 at 18:57

(Too long for a comment.)

The sequence of integers such that $x^2-py^2=-1$ is solvable is given by,

$$p = 1, 2, 5, 10, 13, 17, 26, 29, 37, 41, 50, 53, 58, 61, 65, 73, 74, 82, 85, 89, 97, 101,\dots$$

which is A031396, while that of $x^2-2q y^2 = -1$ is (if I did my code right),

$$q = 1, 5, 13, 25, 29, 37, 41, 53, 61, 65, 85, 101, \dots$$

and is not yet in the OEIS.

Point 1: The sequence $p$ does not contain non-square $q$ as a subset.

With limited data, it seems to be the case. But the first missing value is $q=221$, since $x^2-221y^2=-1$ is not solvable, while $x^2-2\cdot221y^2=-1$ is.

Point 2: There is an infinite number of intersections between $p$ and $q$.

Proof: We use the identities,

$$m^2-(m^2+1)\cdot 1^2 = -1$$

$$(2n+1)^2-2\cdot(2n^2+2n+1)\cdot 1^2 = -1$$


$$m^2+1 = 2n^2+2n+1$$

and turns out to be a well-known Pell equation in disguise,

$$(2n+1)^2-2m^2 = 1$$


with solutions $(u,v) = (3,2),\,(17,12),\,(99,70),\dots$ and proves there is an infinite number of $d$ such that

$$x^2-dy^2 = -1$$

$$x^2-2dy^2 = -1$$

is both solvable.

P.S. However, to characterize all $d$ seems to be difficult.

  • $\begingroup$ The number 25 is in your list of values of $q$, so that is the first missing value. $\endgroup$
    – KConrad
    Commented May 16, 2015 at 16:16
  • $\begingroup$ @KConrad: Oops, I was not being precise. I was focusing on whether there were missing non-square $q$. $\endgroup$ Commented May 17, 2015 at 1:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.