<s>[INST] A problem about rational number for right triangles. If a right triangle has hypotenuse of length 5, and the remaining two sides $a, b$ have rational lengths, what can we say about $a$ and $b$? 
 [/INST] We want to generate the rational solutions of $u^2+v^2=25$. Equivalently, we 
generate the solutions of the equation $x^2+y^2=25z^2$ in integers, with $z\ne 0$, and set $u=x/z$, $v=y/z$. Ultimately the procedure we get is a close analogue of the standard way of generating primitive Pythagorean triples. The case where $5$ divides one (and therefore both) of $x$ and $y$ is not interesting, so assume that neither $x$ nor $y$ is divisible by $5$. 
The square $3+4i$ of the Gaussian prime $2+i$ must divide one of $x+iy$ or $x-iy$. By changing the sign of $y$ if necessary, suppose that $3+4i$ divides $x+iy$.
So $x+iy=(s+it)(3+4i)=(3s-4t)+(4s+3t)i$, and therefore $x=3s-4t$, $y=4s+3t$.
Squaring, we find that $x^2+y^2=25(s^2+t^2)=25z^2$, so we want $s^2+t^2=z^2$.
It is enough to consider primitive solutions of this equation. These are given by 
(i) $(a^2-b^2,2ab,a^2+b^2)$, and (ii) $(2ab, a^2-b^2, a^2+b^2)$, where $a$ and $b$ are relatively prime and of opposite parity. We have to consider both possibilities because of the lack of symmetry between $s$ and $t$ in $x=3s-4t$, $y=4s+3t$.
Case (i) gives us the solutions $x=3(a^2-b^2)-8ab$, $y=4(a^2-b^2)+6ab$, $z=a^2+b^2$, and therefore the rational solutions 
$$u=\frac{3(a^2-b^2)-8ab}{a^2+b^2},\qquad v=\frac{4(a^2-b^2)+6ab}{a^2+b^2}.$$
Case (ii) yields something similar.
Comment: The above procedure, with possibly changes of sign, generates all non-trivial rational solutions. There is undoubtedly a more attractive way of doing this. Furthermore, it seems likely that even though we are taking $a$ and $b$ relatively prime and of opposite parity, some rational solutions are generated more than once. 
For a more elementary way of getting at a parametric solution, rewrite the equation $x^2+y^2=25z^2$ as $x^2-9z^2=16z^2-y^2$, and imitate the analysis of Pythagorean triples. It is somewhat messy. 
</s>