Let $f(x,y) = ax^2 + bxy + cy^2$ be an indefinite irreducible binary quadratic form with integer coefficients with non-zero discriminant. We can assume, without loss of generality, that $a \geq 1$. Can one categorize the solutions to the equation $$\displaystyle f(x,y) = c, x,y \in \mathbb{Z} $$

as cleanly as in the case of Pell's equation?

In the case when $a = 1, b = 0, c = -D$, then we have a Pell's equation, i.e.,

$$\displaystyle x^2 - Dy^2 = -D.$$

If $(x,y)$ is a solution, then $D | x$, say $x = Dz$. Then the equation becomes $D^2 z^2 - Dy^2 = -D$, and one sees that this is equivalent to the Pell equation $y^2 - Dz^2 = 1$.

  • $\begingroup$ Solving $f(x,y)=N$ is in general difficult, because integrally there is no Hasse principle, there are delicate issues involving factorization. But let me rephrase your question in a more conceptual way. For representability questions we can replace your form $f$ with an equivalent form, but it's not hard to check that an arbitrary quad form $g$ represents an integer $N$ primitively iff $g$ is equiv to something of form $ax^2+bxy+Ny^2$. So a far nicer way of asking your question is "if an indefinite form $f$ represents $N$ primitively can we find all solutions to $f(x,y)=N$? $\endgroup$
    – znt
    Commented Mar 20, 2016 at 21:16
  • $\begingroup$ Aah and now of course the question is easy because we can now use the usual unit trick for getting new solutions to old in Pell and we're done. So the answer is yes -- with respect to some basis they're just elements of some explicit principal ideal. $\endgroup$
    – znt
    Commented Mar 20, 2016 at 21:19
  • $\begingroup$ Why $D|x$? Do we assume that $D$ is squarefree? $\endgroup$ Commented Mar 20, 2016 at 21:28
  • $\begingroup$ Aie Fedor's comment has alerted me to a problem with my sketch: the solutions are the elements of a finite set of principal ideals of norm $N$, and given that one of them is principal there are still subtleties figuring out whether the others are principal. So this aspect of the problem is as hard as the usual problems one has with generalised Pellian equations of this form. In short, looks like you're going to have to factor $c$ in an order of a real quadratic field and then identify which ideals of norm $c$ are principal (and you know one of them is but there may be others). $\endgroup$
    – znt
    Commented Mar 20, 2016 at 22:23

2 Answers 2


One could argue that this question is vague -- I mean, one can "categorise" the solutions as being the numbers that make the equation work, right? But let me give some sort of an idea as to what one would have to deal with in order to "categorise" the solutions to this sort of equation.

Let's start with $X^2-401Y^2$, because the class group of $\mathbf{Q}(\sqrt{401})$ is cyclic of order 5 (according to pari) which is a random prime large enough to make things fun. Now let's take some odd split primes -- $5,7,11,29,41,43$ will do (again according to pari these are all squares mod 401) and now let's multiply them all together and cross our fingers...yes :-) The product is $19683895$ which is $5508^2-401\times163^2$. So $19683895$ is representable by $X^2-401Y^2$.

Now let's change coordinates, to deal with this specific MO question. I want new coordinates $x$ and $y$ such that if $x=0$ and $y=1$ then $X=5508$ and $Y=163$. A solution to $163\lambda-5508\mu=1$ is $\lambda=811$ and $\mu=24$, so the matrix $\begin{pmatrix}811&5508\\24&163\end{pmatrix}$ has determinant 1 and moves us from the $(x,y)$ coordinates to the the $(X,Y)$ coordinates; we have $X=811x+5508y$ and $Y=24x+163y$. Now we're ready to find $f$!

I want to set $f(x,y)=X^2-401Y^2=(811x+5508y)^2-401(24x+163y)^2$ so

$f(x,y)=426745x^2 + 5796552xy + 19683895y^2$.

Now we can forget all the thoughts above and just wonder what the question is asking in this particular case.

What I am suggesting is that this is the sort of example of an $f$ for which it's hard to categorise the solutions to $f(x,y)=c$ -- indeed it is impossible to characterise them just using formulae, so this answer is some sort of explicit counterexample to individ's hope that it's all about formulae. Formulae might give you one family of solutions, but below is an explanation of why it won't give all of them.

Of course using the change of basis matrix above we may as well solve $X^2-401Y^2=c=19683895$ and this is equivalent to finding all the elements of norm $19683895$ in $\mathbf{Z}[\sqrt{401}]$. Now finding all the ideals of norm $19683895$ in this ring isn't hard; it has index 2 in the full ring of integers of $K:=\mathbf{Q}(\sqrt{401})$ so it suffices to factorize $19683895$ in the full ring of integers (because $19683895$ is odd). But we know how to factor this: each of $5,7,11,29,41,43$ splits into two primes in $K$, so there are 64 ideals of norm $19683895$. However -- how many are principal? Well this is is a far more subtle problem! As far as I can see there are two ways of going about it.

Here's the first way. If $P_i$ is a fixed prime ideal of $K$ above the rational prime $i\in\{5,7,11,29,31,43\}$ and $Q_i$ is the other, then in the class group $\langle a\rangle$ of $K$ (which has order 5 recall) we have $P_5=a^{d(5)}$, $P_7=a^{d(7)}$ etc, with $d(5),d(7),d(11),d(29),d(31),d(43)$ all in $\mathbf{Z}/5\mathbf{Z}$. We could try and work out what all of these are (using a computer I guess), and then for each choice of sign $\pm d(5)\pm d(7)\pm d(11)\cdots\pm d(43)$ we could see if the result is zero mod 5. For each zero we get, we have a principal ideal (the product of the $P_i$ for the $i$s for which we used a plus sign andthe $Q_i$ for which we used a minus sign), and its generator will give us one and hence infinitely many (using units) solutions to the equation $f(x,y)=c$.

Computationally a far more effective method, I should imagine, is the second method, which is to use the general fact that every principal ideal of norm $c$ will contain an element $X+Y\sqrt{401}$ with $X$ and $Y$ bounded above by some explicit upper bound depending on the size of the fundamental unit (the trick being that if we have a solution wih $X$ and $Y$ huge compared to the size of the fundamental unit then multiplying it by the inverse of the fundamental unit decreases the size of both $X$ and $Y$). So one can just do an explicit computer search for small solutions and one is then guaranteed to run into each ideal before too long (and also make a rigorous proof that we've found them all).

Once one has found a generator for each of the principal ideals one just multiplies them by units of the appropriate sign to "categorise" the solutions to the original equation.

The reason I typed all this up is because it seems to come up again and again on MO/math.stackexchange and no-one ever seems to come up with an explicit reference for the sorts of problems one has to deal with, this being one (the most awkward one really). Hence one cannot really hope to deal with this sort of equation with "explicit" formulae.


The equations you're talking about are all curves of genus zero with two points at infinity, defined over a real quadratic extension. This means that any set of integral points on this curve will be acted on by some finite index subgroup of the unit group of the ring of integers of that quadratic extension. In other words, your curves are homogeneous spaces for $\mathbb{G}_m$ (albeit over $\mathbb{Q}$).

This means that the set of integer solutions is either empty or infinite.

More than this is hard to say, because, as has already been pointed out by ${\bf znt}$, the existence of a solution depends sensitively on splitting behaviour of rational primes in the quadratic field, and on the class number of that field. So in particular there's no nice formula for anything (except in particular cases). I guess the action of $\mathbb{G}_m$ tells you something about how the solutions are related in the infinite case.

  • $\begingroup$ The set of solutions is infinite in this case because $(x,y)=(0,1)$ is a solution here. The $G_m$ action integrally becomes an action of the units in an order of the real quadratic field, so we see that the set of solutions is a union of orbits. It's deeper but still not hard that there are finitely many orbits. The hard part is finding all of them -- that's the point of my answer -- because it involves computing which primes of a certain norm are principal. $\endgroup$
    – znt
    Commented Mar 22, 2016 at 20:32
  • $\begingroup$ Oh! I feel dumb for having missed the obvious trivial solution there -- I didn't notice that the coefficient on $y^2$ was the same as the constant on the RHS. Absolutely agree with all you say here. $\endgroup$ Commented Mar 23, 2016 at 16:10

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.