Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

If I have a quadratic form like $y^2 - x^2 - x = k$ none of the techniques I know work because of the nasty $x$. Note that homogenizing doesn't work because a solution of $Y^2 - X^2 - X Z = k Z^{(2)}$ does not lead to a solution of the original equation in integers, at least as far as I have been able to determine.

How does one understand the solution set of these equation? How can I solve them?

share|improve this question

3 Answers 3

up vote 11 down vote accepted

Over 200 years ago Lagrange solved the general binary quadratic Diophatine equation

$$\rm a\ x^2 + b\ xy + c\ y^2 + d\ x + e\ y + f = 0 $$

It reduces to a Pell equation: put $\rm\ D = b^2-4ac,\ E = bd-2ae,\ F = d^2-4af\:.\ $ Then

$$\rm D\ Y^2\ =\ (D\ y + E)^2 + D\ F - E^2,\quad\quad Y\ =\ 2ax + by + d $$

Therefore if we put $\rm\quad\ \ X = D\ y + E,\quad\ \ N = E^2 - D\ F\quad\ \ $ we have the Pell equation

$$\rm X^2 - D\ Y^2\ =\ N $$

Dario Alpern has a web page Quadratic two integer variable equation solver that will solve any such equation - with complete descriptions of the methods involved. For some recent optimizations of Lagrange's algorithm see this paper H. C. Williams et al. A new look at an old equation

share|improve this answer

These all reduce to equations $$f(x,y)=k$$ where $x$ and $y$ are integers, possibly satisfying some congruence conditions, and $f$ is a homogeneous quadratic form. In two variables this basically comes down to solving norm equations in the rings of integers in quadratic fields. For your example you get $$4y^2-4x^2-4x-1=4k-1$$ that is $$y'^2-x'^2=4k-1$$ where $x'=2x-1$ is odd and $y'=2y$ is even. This is atypically easy, since it factorizes as $(y'-x')(y'+x')=4k-1$. More typically you'd get a Pell-type equation.

share|improve this answer
"atypically easy" - :D –  J. M. Nov 7 '10 at 13:58
Thanks for this answer. Why/how would I get $4y^2-4x^4-4x-1=4k-1$! –  anon Nov 7 '10 at 14:00
@muad: multiply by 4 and subtract 1 from both sides. That lets you factor 4x^2 + 4x + 1 to get rid of the linear term. –  Qiaochu Yuan Nov 7 '10 at 15:00

The idea is to write the original equation and then try to match coefficients. The method is not perfect but it may work in a number of cases.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.