How do you find Pythagorean triples that approximately correspond to a right triangle with a given angle? Given an angle $\theta$, can I find a Pythagorean triple $(A,B,C)$ such that the corresponding right triangle contains an angle that is as close to $\theta$ as I want? And if so, how? For example suppose $\theta = 56.25^\circ$. How do I find Pythagorean triples $(A,B,C)$ such that $\tan(56.25^\circ) \approx B/A$? Looking at Euclid's formula this is the same as asking for coprime not-both-odd integers $m$ and $n$ such that $$\tan(56.25^\circ) \approx \frac{2mn}{m^2-n^2}\,$$ but this only makes a brute-force search easier. Is there a procedural way to generate such arbitrarily precise triples?

This works for
$\quad 0.01 \lt \tan\theta\lt 1\quad$
being limited to decimals expressible as $3$-digit fractions.
For  $\tan\theta>1,\space \tan\space (90-\theta)\space$ should be used.
For $\tan\theta=1,\space$ the best triples are where $A^2+(A\pm1)^2=C^2.\quad$
We begin with Euclid's formula
$$ A=m^2-k^2\qquad B=2mk \qquad C=m^2+k^2$$
For $\tan\theta = 1,\space$ the values for
$A^2 +(A\pm1)^2=C^2\space$ triples (to feed $(m,k)$-values to Euclid's formula) may be generated sequentially with
$k_{n+1}=k_n+\sqrt{2k_n^2+(-1)^{k_n}}.$ These are pell numbers $\{1,2,5,12,\cdots\}$ to be used in pairs like $\space(2,1),\space (5,2),\space (12,5)\cdots.\space$ For $\tan\theta<1,\space$ we use these steps

*

*Convert tangent to a $1$-to-$3$ digit fraction to identify the A:B ratio.


*Solve the tangent function for $k$


*Test a range of $m$-values to see which yields a
$k$-value closest to an integer,


*Use $m$ and the rounded value of $k$ to generate the triple with Euclid's formula.
\begin{equation}
\tan\theta=\dfrac{A}{B} 
= \dfrac{m^2-k^2}{2mk}\\
\\ 2mkA=(m^2-k^2)B\\
\\ B k^2+2 A k m  - B m^2 = 0
\\
\implies 
k = \dfrac{\sqrt{A^2 m^2 + B^2 m^2} - A m}{B}\\
 \quad \text{ for }\quad
2
\le m \le 
50
\end{equation}
This range is chosen to accommodate fractions up to $3$ digits.
Example
$$\tan39^\circ\approx 0.80978\approx \dfrac{149}{184} 
\implies A=149\quad B=184$$
$$k = \dfrac{\sqrt{149^2 m^2 + 184^2 m^2} - 149 m}{184}
 \quad \text{ for } 2\le m \le 30
\\\text{and we find the best fit is }
\quad m=21\quad k\approx 10.016\approx 10
 \\ 
f(21,10)=(341,420,541)\\ 
\tan\theta\approx\dfrac{341}{420}\approx 0.81190476 
\\ \tan^{-1} 0.81190476\approx 39.07^\circ
$$
