# solving the equation $X^2-nY^2=d$ [duplicate]

This question already has an answer here:

we know that equations of the form $X^2-dY^2=Z^2$ have parameter solutions in $\mathbb{Z}$

see here

but what about equations of the form $X^2-nY^2=d$ where $x,y,z,d \in \mathbb{Z}$ ($X$ and $Y$ are variables)

do they have solutions in general? what about special case below:

$X^2-17Y^2=14$

## marked as duplicate by Adam Hughes, Rohan, John B, Namaste, ShaileshDec 31 '16 at 0:40

• – Rohan Dec 30 '16 at 13:48
• do you mean a Pell equation? – Dr. Sonnhard Graubner Dec 30 '16 at 13:55

Your particular equation has no integral solutions.

First of all, if $7\mid X$ then $7\mid (X^2 - 14) = 17Y^2$ which implies that $7\mid Y$, but then $7^2\mid (X^2 - 17Y^2) = 14$ but that is false. A similar deduction can be made if $7\mid Y$.

Then $X^2$ is congruent to $1$, $2$ or $4$ $\text{(mod) } 7$ and $-17Y^2$ is congruent to $4Y^2$, so also to $1$, $2$ or $4$ $\text{(mod) } 7$.

That means that $X^2 -17Y^2$ can be congruent to one of the following:

$$\begin{array}{c|ccc} + & 1 & 2 & 4 \\ \hline 1 & 2 & 3 & 5 \\ 2 & 3 & 4 & 6 \\ 4 & 5 & 6 & 1 \\ \end{array}$$

So $X^2 -17Y^2 \not\equiv 0 \pmod 7$ but $14 \equiv 0 \pmod 7$.

Dickson gives the complete integer solution in this paper.

• Doesn't that solve $X^2 -nY^2 = ZW$ with $X,Y,Z,W$ as variables? @OP's question asks about $X^2 -nY^2 = d$ where only $X$ and $Y$ are variables. – Darth Geek Dec 30 '16 at 14:23
• The OP can use Dickson's parameterization and the known $n$ and $d=ZW$ to solve for the variables that comprise $X$ and $Y$. – Kieren MacMillan Dec 30 '16 at 16:15
• So you are saying that the only values of $d$ for which the equation has solutions are the ones where $d = (el^2 + 2flq + gq^2)(en^2 - 2fnr + gr^2)$ for some integral parameters $e,f,g,l,n,q,r$. – Darth Geek Dec 30 '16 at 16:21
• Sort of… In the OP's specific example, we have $n=17$. Using Dickson's parameterization, we can solve (for example) $e=(f^2-17)/g$. Substituting back in, we have $ZW=d=14$, with only four integral possibilities (factorizations) to consider — we can quickly determine [as you did, using other means] that there are no solutions. – Kieren MacMillan Dec 30 '16 at 16:30