I've recently started to try working on exercises from this book on Diophantine equations before I need to return it to the library. This one has me slightly stumped. It asks to show that the cosine of an angle of a rational triangle can be written in one of the forms $f(\alpha,\beta)=\dfrac{\alpha^2-\beta^2}{\alpha^2+\beta^2}$ or $g(\alpha,\beta)=\dfrac{2\alpha\beta}{\alpha^2+\beta^2}$ where $\alpha$ and $\beta$ are coprime positive integers.
The first form I can get. Following logic similar to previous examples, draw in the height of the triangle, making a right triangle. The hypoteneuse is one side of the rational triangle and the height is opposite one of the angles of the rational triangle (or $180^o$ minus it, the book doesn't seem to consider this case). The book makes a quick reference that the length of the other leg must be rational since the cosine must be rational due to the law of cosines. Let's call the length of the hypoteneuse $x$, the height is of course $h$, and the other leg has length $z$. Then we have
$h^2=x^2-z^2=(x+z)(x-z)$
Following the book's example, there exists a rational $m$ such that
$x+z=m,x-z=\frac {h^2}m$
This system can be solved for $x$ and $z$. Then we get our cosine is $\frac zx=\frac{m^2-h^2}{m^2+h^2}$. (Of course if the angle of the rational triangle is obtuse,we found the cosine of the supplementary angle and the cosine of the angle we actually want is $\frac{h^2-m^2}{h^2+m^2}$.) Multiply top and bottom by the square of the lowest common denominator of $h$ and $m$ and divide by the square of the gcd of their numerators to get the first form.
This seems to imply that the cosine of any angle of a rational triangle can be written in this form. I have no idea how to obtain the $g(\alpha,\beta)$ form unless we deal with pythagorean triples, in which knowing the form makes it rather trivial. So first of all, how do I obtain the form $g(\alpha,\beta)?$
It also seems that these forms are not mutually exclusive. For example, $f(3,1)=g(2,1)=\frac45$. If we ignore the requirement that $\alpha$ and $\beta$ are positive, are there values that can be written in one form, but not the other?