# rational triangles and cosines

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?

-
Have you considered what happens when the foot of the height you draw falls outside the triangle? –  Arturo Magidin Apr 1 '12 at 3:23
@Arturo Haven't I? The right triangle is exterior to the rational triangle, so the adjacent angle in the right triangle is supplementary to the angle in the rational triangle. For a 13-13-24 triangle I get the cosine of the obtuse angle is $-\frac{119}{169}=\frac{5^2-12^2}{5^2+12^2}$ –  Mike Apr 1 '12 at 5:43
I did however fail to mention I may need to reduce further to make the 2 integers coprime. For the above example, I got $h=\frac{120}{13}$ and $m=\frac{288}{13}$. So I had to multiply top and bottom by $13^2$ and divide by $24^2$. I've edited to correct this oversight. –  Mike Apr 1 '12 at 5:53
There are two situations that I can think of: the foot of the height falls outside the triangle, and the foot of the height falls inside the triangle. Whether this changes the conditions or not, I haven't thought it through. –  Arturo Magidin Apr 1 '12 at 17:43
Those remind me awfully of Weierstrass' $\tan x/2 = t$, $\cos x = (1-t^2)/(1+t^2)$ and $\sin x = 2t/(1+t^2)$ –  Pedro Tamaroff May 2 '12 at 2:35

Looks like I may have to answer my own question. At least the second part. I can show that the 2 forms are equivalent. Let's show that $f(\alpha_1,\beta_1)=g(\alpha_2,\beta_2)$. Let $a=\alpha_1+\beta_1$ and $b=\alpha_1-\beta_1$. Then

$f(\alpha_1,\beta_1)=\dfrac{\alpha_1^2-\beta_1^2}{\alpha_1^2+\beta_1^2}=\dfrac{ab}{(\frac{a+b}2)^2+(\frac{a-b}2)^2}=\dfrac{ab}{\frac{a^2}2+\frac{b^2}2}=\dfrac{2ab}{a^2+b^2}$.

If either $\alpha_1$ or $\beta_1$ is even, we're done. Otherwise, $a$ and $b$ are even so we must divide top and bottom by $4$, giving $\alpha_2=\frac a2$ and $\beta_2=\frac b2$.

The other direction is similar. Of course, if we don't ignore the condition that $\alpha$ and $\beta$ are positive, the $g(\alpha,\beta)$ form can't represent negative cosines while the other form has no such problem.

So I've shown if it can be represented as the first form, it can be represented as the second, which kind of solves the problem in a roundabout way. Still, I wonder how the book intended the second form to be achieved.

-

Let us start from the fact that the cosine of an angle in a rational triangle can be written in the form $$\frac{\alpha^2-\beta^2}{\alpha^2+\beta^2},$$ where $\alpha$ and $\beta$ are rational (and of course not both $0$). You have given an argument for this. We deal with the other form the question asks for.

Let $x=\alpha+\beta$ and $y=\alpha-\beta$. Take the sum of the squares and add. We get $2(\alpha^2+\beta^2)=x^2+y^2$. It follows that $$\frac{\alpha^2-\beta^2}{\alpha^2+\beta^2}=\frac{2xy}{x^2+y^2}.$$ Express the rationals $x$ and $y$ as $\frac{m}{q}$ and $\frac{n}{q}$, where $m$, $n$, and $q$ are integers. Then $$\frac{\alpha^2-\beta^2}{\alpha^2+\beta^2}=\frac{2mn}{m^2+n^2}.$$ (If $m$ and $n$ are not relatively prime, let $d=\gcd(m,n)$ and divide each of $m$ and $n$ by $d$.)

We can arrange things so that at least one of $m$ and $n$ is non-negative. It is not in general possible to make both non-negative, since the cosine of an obtuse angle is negative.

-