<s>[INST] Trying to find Pythagorean triples for a given ratio of $\frac{C}{A}$ I want to solve a ratio equation for $n$ in terms of $m$ and $R$ hoping, given a Ratio and a range of $m$ values, that finding an integer $n$ will give me the $m,n$ needed to generate a Pythagrean triple where $\frac{C}{A}$ has that ratio.
Given $A=m^2-n^2\qquad C=m^2+n^2$
$$\frac{C}{A}=\frac{m^2+n^2}{m^2-n^2}=R\implies Rm^2-Rn^2=m^2+n^2\implies (R+1)n^2+0n-m^2(R-1)=0$$
$$n=\frac{-b\pm\sqrt{b^2-4ac}}{2a}=\frac{\pm\sqrt{4*(R+1)*m^2(R-1)}}{2(R+1)}=\frac{2m\sqrt{R^2-1}}{2(R^2-1)}=\frac{m\sqrt{R^2-1}}{R^2-1}$$
If I take the example of $f(2,1)=3,4,5$, $R=\frac{5}{3}$ and $\frac{2\sqrt{\frac{25}{9}-1}}{\frac{25}{9}-1}=\frac{2\sqrt{\frac{16}{9}}}{\frac{16}{9}}=\frac{\frac{8}{3}}{\frac{16}{9}}=\frac{8*9}{3*16}=\frac{72}{48}=1.5$
Where is my mistake?
 [/INST] In
$$\frac{-b\pm\sqrt{b^2-4ac}}{2a}=\frac{\pm\sqrt{4*(R+1)*m^2(R-1)}}{2(R+1)}=\frac{2m\sqrt{R^2-1}}{2(R^2-1)}=\frac{m\sqrt{R^2-1}}{R^2-1}$$
Going from the second to the third part, you introduced an extra factor of $R-1$ into the denominator, i.e., it went from $2(R+1)$ to $2(R^2-1)$. Thus, with handling for both both positive & negative radicals, the correct result is
$$n = \pm\frac{m\sqrt{R^2-1}}{R+1} \tag{1}\label{eq1}$$
As such, with your example, using $m = 2$, $R = \frac{5}{3}$ in \eqref{eq1} gives $n = \pm 1$. Also, with your calculated results, multiplying $1.5 = \frac{3}{2}$ by $R - 1 = \frac{5}{3} - 1 = \frac{2}{3}$ (to undo dividing by $R-1$ in your calculations) gives $1$, i.e., the correct value of $n$.
</s>