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?


Solution 1:

Let $r\in[0,\infty)$. The problem posed is equivalent to finding $m\geq n\in\mathbb N$ such that $r\sim\frac{2mn}{m^2-n^2}$.

Thus, we want $$rm^2-2mn-rn^2\sim0$$Now suppose $r,n$ is given and we want to find $m$ that satisfies the equation above (not necessarily natural).

Thus, $$m=\frac{n\left(1+\sqrt{1+r^2}\right)}r$$So, we want to find a choice of $n$ that makes the expression above arbitrarily close to an integer.

But that's relatively easy. Let $c=\frac r{1+\sqrt{1+r^2}}$. Thus, $n=mc$. So, we just want to find a fraction $\frac nm$ close to $c$. Easy!

Summary:

Given $\theta$, compute $$c=\frac{\sin\theta}{1+\cos\theta} = \tan\frac\theta2$$Then, find a fraction $\frac nm$ arbitrarily close to $c$. Substitute $m,n$ into your formula and voila!

Solution 2:

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

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

  2. Solve the tangent function for $k$

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

  4. 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 $$

Solution 3:

For any positive integer $m>n$, \begin{gather} z=m+ni= r\angle \phi\\ z^2=(m+ni)^2=(m^2-n^2)+2mni=r^2\angle 2\phi \end{gather} where $r=\sqrt{m^2+n^2}$ and $\tan \phi=\frac{n}{m}$.

Thus $\{m^2+n^2,m^2-n^2,2mn\}$ is a Pythagorean triplet.

In your case $2\phi=56.25^\circ$ or $\phi=28.125^\circ$.

Find the simplest $m>n$ such that $\tan 28.125^\circ=\frac{n}{m}$.

\begin{align} \tan 28.125^\circ&=\frac{n}{m}\\ 0.5&\approx\frac{n}{m}\\ \end{align}

$m=2$ and $n=1$.

Solution 4:

My "other" answer used Euclid's formula, found triples for Cotangent instead of Tangent, and required using $(90-\theta)$ for angles above $45^\circ.\quad$ This answer uses a formula I developed in $2009$ and finds triples for $0\lt \theta \lt 90^\circ$ with an error of (usually) $5$ arc seconds or less–– and extreme fractions of a second as angles approach zero of ninety degrees.

\begin{align*} \\ A&=\space \big(2n-1+k)^2-k^2 &=(2n-1)^2+&2(2n-1)k \\ B&=2(2n-1+k)k &=&2(2n-1)k+2k^2\\ C&=\space (2n-1+k)^2+k^2 & =(2n-1)^2+&2(2n-1)k+2k^2\\ \end{align*} We begin with $\dfrac{B}{A}$ and solve for $k$ testing a defined range of $n$-values to see which is closest to any integer greater than zero. The values of $A$ and $B$ are the fractional equivalent of tangent with a denominator $(A)$ of up to three digits. \begin{align*} \frac{B}{A} &=\frac{2(2n-1)k +2k^2}{(2n-1)^2 + 2(2n-1)k} \\ \\ B((2n-1)^2 + 2(2n-1)k) &=A(2(2n-1)k +2k^2)\\ \\k &= \frac{(2n-1)\big(B-A +\sqrt{A^2 + B^2}\big)}{2 A}\\ \quad \text{for} \quad 2+ \bigg\lfloor\frac{1}{\tan\theta}\bigg\rfloor\le &n\le 100 +\bigg\lfloor\frac{1}{\tan\theta}\bigg\rfloor \quad 0 \lt\theta\lt 90^\circ \end{align*}

Using the $39^\circ$ example, $\tan\theta\approx 0.80978403,\space A=184,\space B=149$

\begin{align*} k&=\bigg[ \frac{(2n-1)\big(149-184 +\sqrt{184^2 + 149^2}\big)}{2 (184)}\bigg] \\ \\ \quad \text{for} \quad &2+ \bigg\lfloor\frac{1}{\ 0.80978403}\bigg\rfloor\le n\le 100 +\bigg\lfloor\frac{1}{0.80978403}\bigg\rfloor\\ \\\\ \implies f(n,k)&=f(16,17)=(2015,1632,2593)\quad \approx 39.00489701^\circ \end{align*}

For other examples we have

\begin{align*} 0.01^\circ\rightarrow & f(5731,1)=(131377443,22924,131377445)\\ &\approx 0.009997519^\circ \\ 30^\circ\rightarrow & f(77,56)=(40545,23408,46817)\space \approx 29.9992934272601^\circ \\ 45^\circ\rightarrow & f(50,70)=(23661,23660,33461)\space \approx 44.9987892102977^\circ \\ 56.25^\circ\rightarrow & f(14,31)=(2403,3596,4325)\space \approx 56.2474707665776^\circ \\ 60^\circ\rightarrow & f(77,209)=(87363,151316,174725)\space \approx 59.9998106752595^\circ \\ 89.99^\circ\rightarrow & f(39,441139)=(67941335,389275170048,389275175977)\\ &\approx 89.9899999999744^\circ \end{align*}

Solution 5:

For an angle $\theta$ you can find a Pythagorean triple $(2mn, |m^2-n^2|, m^2+n^2)$ corresponding to a right triangle containing an angle about $\theta$ by find a rational approximation $$\frac{m}{n} \approx \tan\frac{\theta}{2}$$ You can find a "good" rational approximation to $\tan\frac{\theta}{2}$ using techniques from this Q&A post. Note that Don Thousands' answer is the inspiration for this realization; I wanted to express it compactly.