# Integer Solutions to $x^2+y^2=5z^2$

I'm looking for a formula to generate all solutions $x$, $y$, $z$ for $x^2 + y^2 = 5z^2$.

• Consider the easier question of finding all integer solutions to $x^2 + y^2 = z^2$. There are two standard ways of doing this. One way is to rewrite it as $x^2 = (z + y)(z - y)$ and compare the prime factorizations of both sides. But that method doesn't work so well for the present equation, where when you try to do this you get $x^2 = (\sqrt{5} \cdot z - y)(\sqrt{5} \cdot z - y)$ and have to work in a number system other than the integers... – Jonah Sinick Oct 31 '12 at 5:41
• The other standard way to find all integer solutions to $x^2 + y^2 = z^2$ is to recast the problem as that of finding all rational solutions to $X^2 + Y^2 = 1$. See, e.g. ux1.eiu.edu/~cfdmb/4900/rational.pdf (but note that this document omits the geometric picture). This method is more promising for finding all integer solutions to the equation that you wrote down above. Just curious - in what context did this question come up? – Jonah Sinick Oct 31 '12 at 5:45

Ok, so I am assuming rational solutions. This method can yield a parametrization of all integer solutions without too much work.

Note that $(1,2)$ lie on the circle $x^2 + y^2 = 5$. Let $x_0 = 1, y_0 = 2$. Now suppose $x^2 + y^2 = 5$. Let $m = x - x_0, n = y - y_0$, then we have $$m^2 + 2mx_0 + x_0^2 + n^2 + 2ny_0 + y_0^2 = 5$$ And thus $m^2 + 2mx_0 + n^2 + 2ny_0 = 0$. Let $\lambda = \frac{m}{n}$. Then we have: $$n^2\lambda^2 + 2n\lambda x_0 + n^2 + 2ny_0 = 0$$ $$n\lambda^2 + 2\lambda x_0 + n + 2y_0 = 0$$ $$n = \frac{-2y_0 - 2\lambda x_0}{1 + \lambda^2}$$ Plugging in $x_0 = 1, y_0 = 2$: $$n = \frac{-4 - 2 \lambda}{1 + \lambda^2}$$ Thus it follows $$(x,y) = \left (1 + \frac{-4\lambda - 2\lambda^2}{1 + \lambda^2}, 2 + \frac{-4 - 2 \lambda}{1 + \lambda^2} \right )$$ where $\lambda$ is an arbitrary number in $\mathbb{Q}$. Now for $x^2 + y^2 = 5z^2$, we simply need: $$(x,y,z) = \left (z + \frac{-4z\lambda - 2z\lambda^2}{1 + \lambda^2}, 2z + \frac{-4z - 2z \lambda}{1 + \lambda^2},z \right )$$ If you want solutions in $\mathbb{Z}$, it takes only a little more work to finish.

EDIT: So either I made a massive reading failure or the author changed the title. So here's how to finish.

A slightly neater form to work with is $$(x,y,z) = \left (1 + \lambda^2 -4\lambda - 2\lambda^2, 2 + 2\lambda^2 -4 - 2\lambda, 1 + \lambda^2 \right )$$ Letting $\lambda = \frac{m}{n}$, we see that: $$(x,y,z) = \left (m^2 - n^2 -4mn, 2n^2 -2m^2 - 2mn, m^2 + n^2 \right )$$

• Yes, it should be the latter. Thanks for pointing out the error, I'll correct it. – dinoboy Oct 31 '12 at 4:51
• This answer would benefit from the inclusion of more motivational material. (How would someone have thought of this solution?) – Jonah Sinick Oct 31 '12 at 5:53
• Someone would have thought of this solution by having seen someone else do something like this previously. – Gerry Myerson Oct 31 '12 at 12:24
• The motivation for this solution came from doing this problem many times. I am extremely experienced in solving olympiad style problems and have done this problem at least a dozen times. The first time I solved this problem my motivation was essentially this. By using Lubin's method of Gaussian integers we can generate infinitely many solutions from 1. This motivates taking (2,1). The equation we have is inhomogenous, so this motivates us to define $m,n$. Now finally, we note that if we define $\lambda$ we can solve for $n$ in terms of it. – dinoboy Oct 31 '12 at 15:54
• The idea here is that once you have one rational point on a conic section, you can get to all the others by specifying the (rational) slope between your first point and the point to be found. I think that in general, this method has lots of advantages over the method I used, which depends on the arithmetic of a particular quadratic imaginary field. – Lubin Nov 2 '12 at 0:15

I couldn't but notice the pattern $x^2 + y^2 = 5 z^2 = z^2 + (2z)^2$; owing to

$(am+bn)^2 + (an-bm)^2 = (an+bm)^2 + (am-bn)^2$, and so if we let $x=am+bn , y=an-bm , z=am-bn$ , we need $an + bm = 2(am-bn)$ , i.e. $a(n - 2m) + b(m+2n) =0$ which is possible by

$a = (m+2n) k , b=(2m-n)k$ , where $a,b,m,n,k$ $∈$ $\Bbb Z$

So, the solutions are :- $x = k( m^2 + 4mn - n^2 )$ ; $y = 2k(mn + n^2 - m^2 )$ ; $z = k( m^2 + n^2 )$ these are same as what "dinoboy" seems to have obtained by comparatively more effort.

• As we say, byapok korechis! – Soham Chowdhury May 27 '13 at 8:27
• @SohamChowdhury: It appears that you are a pure "Bangali" , $\ tai$$\ na ?$ – Souvik Dey May 29 '13 at 6:05
• Ekkebare tai. OK, this is enough :) – Soham Chowdhury Jun 11 '13 at 8:35

Presumably you’re looking for solutions from $\mathbb Z$. When you have such a solution, you can divide the equation through by $z^2$ to find rational numbers $\lambda$ and $\mu$ such that $\lambda^2+\mu^2=5$. So far so good. Now you can think of $(\lambda,\mu)$ as the complex number $\lambda+\mu i\in{\mathbb{Q}}(i)$, the field of Gaussian numbers. And, when we call $z=\lambda+\mu i$, the condition is that $\mathbf{N}(z)=5$, where $\mathbf N$ is the norm map, $z\mapsto z\bar z$, which you see is multiplicative. Now, in case $\mathbf{N}(z)=5$ and $\mathbf{N}(u)=1$, you see that $zu$ is another point on your circle of radius $\sqrt5$, just the kind of number you’re looking for.

But we know all the Gaussian numbers of norm $1$, they correspond to Pythagorean triples, just as $5/13 + 12i/13$ corresponds to the Pythagorean triple $(5,12,13)$, and there are various ways of describing these triples, in other words the appropriate Gaussian numbers of norm $1$. Here’s one way of describing all the P-triples:

The Gaussian numbers of norm $1$ are an infinitely generated abelian group. The torsion subgroup is $\{\pm1,\pm i\}$, and, modulo these, the group is free-abelian, generators indexed by the primes congruent to $1$ modulo $4$. For each such prime $p$, you write $p=m^2+n^2$, and the corresponding generator of the above-mentioned free-abelian group is $(m+ni)/(m-ni)$. The upshot is that once you've made your choices of these generators $\{g_p\}$, every Gaussian number of norm $1$ is uniquely writable as $\varepsilon\prod_p g_p^{e_p}$. Here the product must be finite, that is all but finitely many of the exponents $e_p$ must be zero, and the $\varepsilon$ is $\pm1$ or $\pm i$.

Example: take $g_5=(2+i)/(2-i)=(3+4i)/5$. Then, using the fixed Gaussian number $2+i$ for your $z$, if you use $u=g_5^2=(-7+24i)/25$, you get $uz=(-38+41i)/25$. This yields the solution $x=-38$, $y=41$, $z=25$ to your original equation.

• Good. This is a way to generate as many examples as you'd like. It's not quite a formula generating all solutions, as in dinoboy's answer. – Gerry Myerson Oct 31 '12 at 4:42
• Can you say why you recast the problem as one involving Gaussian numbers instead of remaining in the field of rational numbers? – Jonah Sinick Oct 31 '12 at 5:54
• @JonahSinick, this is the quickest way of approaching the situation as a set (the pairs of rationals $(x,y)$ with $x^2+y^2=5$) operated on by a group (those pairs with $x^2+y^2=1$). To get the generators of the aforementioned group, it’s almost obligatory to go to the Gaussian numbers, where you know the generators of the multiplicative group. – Lubin Nov 2 '12 at 0:08