# Modified Pell equation: $x^2-D y^2 = m$, $m\neq1$.

How does one solve the Diophantine equation $$x^2-Dy^2=m,$$ where $m$ is some fixed arbitrary integer?

I understand that given the fundamental solution to $r^2-D s^2=1$, and any solution to the above I can generate an infinite sequence of solutions. But how do I find all fundamental solutions of the equation with $m\neq1$? Mathworld says it is complicated and several may exist. I have been unable to find a clear explanation of this, unfortunately.

What is the range $0<y\leq Y$ that all fundamental solutions are guaranteed to belong to?

• +1 Good question. For example, $x^2-10y^2 = 9$ has three fundamental solutions $S_0$. I wonder what's the maximum number of $S_0$ the generalized Pell equation can have? – Tito Piezas III Nov 28 '14 at 0:28

Here I analyse the equation $x^2 -D y^2 = z^2$.Generally these type of equations can have several solutions if x, y, D and z are particular function of a certain parameter like m.

Suppose $x=2m^2 + p$; plugging in equation we get:

$(2m^2 +p)^2 - z^2 = D y^2$ ⇒ $4 m^4 + 4p m^2+p^2 -z^2=Dy^2$

If $4m^2 | p^2 - z^2$ then we have:

$p^2 - z^2 = 4 k m^2$ or $4m^2(m^2 +p+k)=D y^2$

So we have following system of equations:

$y^2 = 4m^2$ ⇒ $y = ± 2m$

$D= m^2 +p+k$

Therefore with certain values for m, p, and k equation $x^2 -D y^2 = z^2$ is valid. In fact equation $p^2 = z^2 + 4 k m^2$ can have several solutions if $p^2$, $z^2$ and $4km^2$ make a Pythagorean triple$a^2 +b^2= c^2$ in which c and b are two consecutive numbers, that is $4km= p-1$ and $4km^2$is a perfect square. For example Consider triple $25^2 = 24^2 +7^2$ and compare it with above equation, we get:

$p=25$, $z=7$ and:

$4km^2=24^2= 4. 4. 6^2$ ⇒ $(k=4 , m=6)$ or $( k=36 , m=2)$

For example for $m=2, k=36, p=25 and z=7$ we have:

$x=2m^2 +p =2. 2^2 +25 = 33$

$y = 2m= 2.2=4$

$D=m^2 +p+k=2^2 +25+36=65$ and the equation has the form: $x^2 -65y^2=z^2$

Since there are infinitely many such triples, then there are infinitely many forms of equation$x^2 -D y^2 = z^2$, that is there are several solution. Using this algorithm you can analyse the equation when RHS of equation is not perfect square.