Which rational slopes have angle bisectors with rational slopes?

This question was inspired by the following question in quora:

The lines $$y = 1/3 x$$ and $$y = 13/9 x$$ are drawn in the coordinate plane. What is the slope of the line that bisects the angle these lines make?

It turns out that the slope of the bisector is 3/4 (and, of course, -4/3).

This suggested the question:

Which rational slopes have angle bisectors with rational slopes?

There are a number of related questions, but I have not seen this particular variation.

Here's what I have so far.

If the slopes are $$a$$ and $$b$$, by using $$\tan(u-v) = (\tan(u)-\tan(v))/(1+\tan(u)\tan(v))$$, we can show that the slope $$x$$ of the bisector satisfies $$x^2+2rx-1 = 0$$ where $$r = (1-ab)/(a+b)$$.

From this, $$x =-r \pm \sqrt{1+r^2}$$.

For this to be rational, $$\sqrt{1+r^2}$$ must be rational.

It turns out that $$1+r^2 =\dfrac{(1+a^2)(1+b^2)}{(a+b)^2}$$ so a necessary and sufficient condition is that $$(1+a^2)(1+b^2)$$ is a rational square.

If $$a = \dfrac{s}{t}, b=\dfrac{u}{v}$$, this is equivalent to $$(s^2+t^2)(u^2+v^2)$$ beinga square, or, using the standard identity, $$(su\pm tv)^2+(sv\mp tu)^2$$ is a square.

What I do not know is necessary and sufficiaent conditions on $$s, t, u, v$$ which make $$(s^2+t^2)(u^2+v^2) =(su\pm tv)^2+(sv\mp tu)^2$$ a square.

In the original problen, $$a = 1/3, b = 13/9$$, so $$s^2+t^2 = 10, u^2+v^2 = 250$$ and $$(su\pm tv)^2+(sv\mp tu)^2 =(13\pm27)^2+(9\mp 39)^2 =40^2+30^2 =50^2$$ or $$14^2+48^2 =4(7^2+24^2) =4(25^2) =(50)^2$$.

I haven't been able to take this any further.

The tags could use improving, too.

• Reduce to the case $a=0$, so $u^2+v^2$ is a square, which is of course the classification of primitive pythagorean triples $u=A^2-B^2, v=2AB$ or the other way depending on which one is even. – user10354138 Aug 5 at 5:27