The integer solutions to the equation $x^2 + y^2 = z^2$ are very well studied. I'm wondering if there's any literature about the integer solutions to the equation $ax^2 + by^2 = cz^2$ where a,b,c are non-zero integers. Here are some of my questions:

  1. Given a,b,c, is there an explicit way of writing all the solutions?

  2. If not, could you generate all the solutions given one of the solutions?

  3. If this is the case, are there any algorithms that are designed to look for one of these solutions?

  4. Are there any additional conditions that these solutions must satisfy?

  5. What happens when you're only given a and b?

  • 6
    $\begingroup$ I hope this doesn't start another 400 year long search. $\endgroup$
    – Guy
    Commented Apr 3, 2014 at 16:52
  • 2
    $\begingroup$ "Number Theory: Volume I: Tools and Diophantine Equations" By Henri Cohen, Chapter VI has some good material on this subject. $\endgroup$
    – Alan
    Commented Apr 3, 2014 at 17:32

4 Answers 4


Proof of Legendre's theorem on the ternary quadratic form

I like the discussion of Legendre's theorem in Cassels, Rational Quadratic Forms, Theorem 4.1, pages 80-82, as he is careful about pointing out that certain products must be quadratic residues for each prime dividing each entry $(a,b,c).$

Next, if $a,b,c$ are positive, and there is at least one nontrivial solution $(x_0,y_0,z_0)$ then we may find all rational points on the ellipse $a \alpha^2 + b \beta^2 = c$ by drawing all lines of rational slope through $(x_0/z_0, y_0/z_0).$ For each such line, there is a second rational point on the ellipse, with the slope $m$ as a parameter. Multiplying back through by the denominators gives a new integral solution to $a x^2 + b y^2 = c z^2.$ It is exactly this method that gives primitive Pythagorean triples $(2rs, s^2 - r^2, s^2 + r^2).$ I've done that a few times, i will try to find some of my answers on this site.

Found one anyway, Generating Pythagorean triples for $a^2+b^2=5c^2$?

Found another: note that more than one (two, here) recipe may be required to get all solutions. Pythagorean triples with additional parameters

Oh, for this few variables it is good enough to take lines with rational slope, but in general, such as $a x^2 + b y^2 + c z^2 = d w^2,$ it is better to find some rational point on the ellipsoid $(x_0/w_0, y_0/w_0, z_0/w_0)$ and then use a parameter $t$ and integers, call them $p,q,r,$ and find the other ellipsoid point $(x_0/w_0 + pt, y_0/w_0 + qt, z_0/w_0 +rt), $ where we can then eliminate $t.$

  • $\begingroup$ A quick question, Will. Is it true that if $x^2+y^2=nz^2$ has integer solutions, then $u^2+v^2=n$ has integer solutions as well? Also these are $n = 2, 5, 10, 13, 17, 26, 29, 34, 37,\dots$ as A020893. $\endgroup$ Commented Aug 14, 2017 at 12:07
  • 1
    $\begingroup$ @TitoPiezasIII yes. Your list is the squarefree $n.$ Let's see, we get $u^2 + v^2 = n$ precisely when the exponent of any prime $q \equiv 3 \pmod 4$ that divides $n$ is even. This includes $9$ for example. If you had some $n$ and such $q$ to an odd power, you would have $x^2 + y^2 = q^{odd} m,$ where $m$ is prime to $q,$ and this is impossible. $\endgroup$
    – Will Jagy
    Commented Aug 14, 2017 at 16:59
  • $\begingroup$ The reason is that I'm also looking at $x^3+y^3 = nz^3$ and solutions to this do not necessarily have $n=u^3+v^3$ with integer variables. For example, $x^3+y^3 = 6z^3$ is solvable. $\endgroup$ Commented Aug 16, 2017 at 2:17

Here are the formulas! Formula generally look like this: Do not like these formulas. But this does not mean that we should not draw them. To start this equation zayimemsya, well then, and others. $aX^2+bXY+cY^2=jZ^2$

Solutions can be written if even a single root.$\sqrt{j(a+b+c)}$ , $\sqrt{b^2 + 4a(j-c)}$ , $\sqrt{b^2+4c(j-a)}$

Then the solution can be written.

$X=(2j(b+2c)^2-(b^2+4c(j-a))(j\pm\sqrt{j(a+b+c)}))s^2+2(b+2c)(\sqrt{j(a+b+c)}\mp{j})sp+(j\mp \sqrt{j(a+b+c)})p^2$

$Y=(2j(2j-b-2a)(b+2c)-(b^2+4c(j-a))(j\pm\sqrt{j(a+b+c)}))s^2+ +2((2j-2a-b)\sqrt{j(a+b+c)}\mp{j(b+2c)})sp+(j\mp\sqrt{j(a+b+c)})p^2$

$Z=(2j(b+2c)^2-(b^2+4c(j-a))(a+b+c\pm\sqrt{j(a+b+c)}))s^2+ +2(b+2c) ( \sqrt{j(a+b+c)} \mp{j})sp + ( a + b + c \mp \sqrt{j(a+b+c)})p^2 $

In the case when the root $\sqrt{b^2+4c(j-a)}$ whole.

Solutions have the form.



$Z=((b+2a)(8ac+2b(2j-b))-(b^2+4a(j-c))(b+2c\mp\sqrt{b^2+4c(j-a)}))s^2++2(4ac+b(2j-b)\pm {(b+2a)}\sqrt{b^2+4c(j-a)})sp+(b+2c\pm\sqrt{b^2+4c(j-a)})p^2$

In the case when the root $\sqrt{b^2+4a(j-c)}$ whole.

Solutions have the form.

$X=(2j^2(b+2a)-j(a+b+c)(2j-2c-b\pm\sqrt{b^2+4a(j-c)}))p^2+ +2j(\sqrt{b^2+4a(j-c)}\mp{(b+2a)})ps+(2j-2c-b\mp\sqrt{b^2+4a(j-c)})s^2$

$Y=(2j^2(b+2a)-j(a+b+c)(b+2a\pm\sqrt{b^2+4a(j-c)}))p^2+ +2j(\sqrt{b^2+4a(j-c)}\mp{(b+2a)})ps+(b+2a\mp\sqrt{b^2+4a(j-c)})s^2$

$Z=j(a+b+c)(b+2a\mp\sqrt{b^2+4a(j-c)})p^2+ +2((a+b+c)\sqrt{b^2+4a(j-c)}\mp{j(b+2a)})ps+ (b+2a\mp\sqrt{b^2+4a(j-c)})s^2$

Since these formulas are written in general terms, require a certain specificity calculations.If, after a permutation of the coefficients, no root is not an integer. You need to check whether there is an equivalent quadratic form in which, at least one root of a whole. Is usually sufficient to make the substitution $X\longrightarrow{X+kY}$ or more $Y\longrightarrow{Y+kX}$ In fact, this reduces to determining the existence of solutions in certain Pell's equation. Of course with such an idea can solve more complex equations. If I will not disturb anybody, slowly formula will draw. number $p,s$ integers and set us. I understand that these formulas do not like. And when they draw - or try to ignore or delete.

Formulas but there are no bad or good. They either are or they are not. In equation $aX^2+bY^2+cZ^2=qXY+dXZ+tYZ$

$a,b,c,q,d,t$ integer coefficients which specify the conditions of the problem.

For a more compact notation, we introduce a replacement.




Then the formula in the general form is:


$Y=(2n(2c-d-t)+j(2(a+c-d)-q-t\pm\sqrt{k}))p^2+2((d+t-2c)\sqrt{k}\mp{ n })ps++(q+t+2(d-a-c)\pm\sqrt{k})s^2$


And more.




$p,s$ are integers and are given us. Since formulas are written in general terms, in the case where neither the root is not an integer, it is necessary to check whether there is such an equivalent quadratic form in which at least one root of a whole. If not, then the solution in integers of the equation have not.

  • 1
    $\begingroup$ Could you fix a gibberish in the introductory text left after machine translation from Russian to English? I won’t guess how was it expressed originally (although could translate it). $\endgroup$ Commented Nov 11, 2014 at 19:27

I do not understand! What is the point? Then try to guess the solution to solve the equation on it and build solutions.

Here's an example equation: $X^2+Y^2=5Z^2$

Many difficulties in the calculation. What's the point? When substituting into the formula we get solutions immediately.
















When numerical coefficients little else can guess the first solution, but when there are large number guessing does not help. Do not we want, but still have to use the formula. And the formula is easier - we immediately obtain the formula for the solution.

  • $\begingroup$ Did you give all the solutions of the equation $X^2+Y^2=5Z^2$, or they are only examples? Moreover where did you take them from (what book or article?) $\endgroup$
    – joaopa
    Commented Jul 23, 2015 at 16:43
  • $\begingroup$ Substitute in the above formula and get these formulas. If the coefficient is the sum of the squares, you can use this formula. math.stackexchange.com/questions/1177661/… $\endgroup$
    – individ
    Commented Jul 23, 2015 at 16:49
  • $\begingroup$ I susbstituted in the equation and (Maple !!) confirms that the given quantities are solutions. But my questions remain: Where did you extract these formulas from? And are they all the solutions or there exist other ones? $\endgroup$
    – joaopa
    Commented Jul 23, 2015 at 16:56
  • $\begingroup$ I'm more interested in equations of the form. $aX^2+bXY+cY^2=jZ^2$ Formula these I brought. On my Blog there are many. $\endgroup$
    – individ
    Commented Jul 23, 2015 at 17:03
  • $\begingroup$ Can you give the internet address of your blog? Do you have formulas for the equation $aX^2+bXY+cY^2+dZ^2=k$ where $k\in\mathbb Z$ (not necessarily $0$)? $\endgroup$
    – joaopa
    Commented Jul 23, 2015 at 17:10

Above mentioned equation is shown below:

$ax^2 + by^2 = cz^2$

The above equation has parametric solution for $(a,b,c)=(35,10,3)$




For $k=1$ we get:


  • $\begingroup$ What is the point of writing these numbers? You want to find the General formula! $\endgroup$
    – individ
    Commented Jul 9, 2017 at 5:27

You must log in to answer this question.