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$. 



A class of quadratic equations
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.


