Generating Pythagorean Triples

The Pythagorean Theorem famously states that$$a^2 +b^2 = c^2$$for any right triangle where $a$ and $b$ are the legs of the triangle and $c$ is the hypotenuse.This relationship never fails for a right triangle, and so depending on what two of the values are, when you solve for the third you may or may not get an integer answer.Any three integers that satisfy the Pythagorean Theorem are called Pythagorean Triples. You've probably encountered a few of these in passing, since teachers and textbooks love to use them.One can verify a triple by calculating its sum of squares of the smaller two sides and verifying that it is equal to the square of the largest side. We do not need to draw a triangle to do this, since the longest side is necessarily the hypotenuse (the $c$ in the equation).Here are some other Pythagorean Triples6-8-107-24-259-40-4111-60-61There are not only infinitely many Pythagorean Triples, but there also exists a formulaic way to find them!

Generating Triples

Pythagorean Triples are either primitive or non-primitive. Primitive ones like 3-4-5 have no common factor among them. Non-primitive ones like 6-8-10 do have a common factor. Let's start with the formula for generating primitive triples, since any non-primitive triple is simply a multiple of a primitive one.Because we seek to stick with whole numbers, consider the following.If $a^2 + b^2 = c^2$, then $c^2 - a^2 = b^2$, and we can define$$a=u^2-v^2$$$$b=2uv$$$$c=u^2+v^2$$Where $u$ and $v$ are positive integers with $u \gt v$ so that $a$ is positive. We can verify that this definition gives us the two things we want to be true:1. $a$, $b$, and $c$ will each be an integer2. $a^2 + b^2 = c^2$ because$$ \begin{array}{rl} a^2+b^2 & = (u^2-v^2)^2 + (2uv)^2 \\ & =u^4 -2u^2v^2 +v^4 + 4u^2v^2 \\ & =u^4 + 2u^2v^2 +v^4 \\ & =(u^2 +v^2)^2 \\ & =c^2 \end{array} $$Finally, we must require two additional restrictions on $u$ and $v$ beside $u \gt v$ and that they are both positive. First, that $u$ and $v$ need to be relatively prime - that is, they do not have any common factors. If they did, then $a$, $b$, and $c$ would have a common factor, meaning we would not get a primitive triple. Second, they must be opposite in terms of even / odd. If they are both even, or if they are both odd, then $a$, $b$, and $c$ would each be even numbers, which means the triple would not be primitive.I found a really nice algebraic proof of why all primitive Pythagorean Triples must take on this form from UConn's math dept here » (external link) (direct file link »).However, only primitive Pythagorean Triples need to fit this form. Triple like 6-8-10 which have a GCF do not need to fit this form for integer values of $u$ and $v$. Therefore, if we want to generalize our result to make a formulaic approach for finding any Pythagorean Triple, we need to include an integer multiplier.The final generating formula, including the multiplier ($m$) to create non-primitive triples, is$$ \begin{array}{l} a = m(u^2-v^2) \\ b = 2muv \\ c = m(u^2+v^2) \end{array} $$All you have to do to use this formula is pick integer values of $m$, $u$, and $v$, following the guidelines (positive choices, $u$ bigger than $v$, and relatively prime $u$ and $v$, each different odd vs even for $u$ and $v$).Here are some results, obtained by selecting $m$, $u$, and $v$ systematically.For $m=1$:$$ \begin{array}{rl} & u=2, \,\,\,\, v=1 \\ \longrightarrow & a=3, \,\,\,\, b=4, \,\,\,\, c=5 \end{array} $$$$ \begin{array}{rl} & u=3, \,\,\,\, v=2 \\ \longrightarrow & a=5, \,\,\,\, b=12, \,\,\,\, c=13 \end{array} $$$$ \begin{array}{rl} & u=4, \,\,\,\, v=1 \\ \longrightarrow & a=15, \,\,\,\, b=8, \,\,\,\, c=17 \end{array} $$$$ \begin{array}{rl} & u=4, \,\,\,\, v=3 \\ \longrightarrow & a=7, \,\,\,\, b=24, \,\,\,\, c=25 \end{array} $$Note that we couldn't select the combinations $u=3$, $v=1$ because they are both odd, and we couldn't select $u=4$, $v=2$ because they are both even and furthermore are not relatively prime.Now, if we let $m=2$ and make the same choices, we will get 6-8-10, 10-24-26, 16-30-34, and 14-48-50.If we picked some larger random values of $m$, $u$, and $v$, we can instantly find very large triples! Let $m=1$, $u=21$, $v=10$:$$a=341, \,\,\,\, b=420, \,\,\,\, c=541$$$$341^2 + 420^2 = 292681$$$$541^2 = 292681$$

Pythag Triple Calculator

Try it out! Pick values of $m$, $u$, and $v$ below and see what triple you get!
First, enter the multiplier $m$ (make it $1$ if you want primitive triples).m:Then pick $u$ and $v$. Remember that they should have no GCF, and not both be odd nor both be even.u:v:Result: