Formulas for generating Pythagorean triples


Besides Euclid's formula, many other formulas for generating Pythagorean triples have been developed.

Euclid's, Pythagoras', and Plato's formulas

Euclid's, Pythagoras' and Plato's formulas for calculating triples have been described here:
The methods below appear in various sources, often without attribution as to their origin.

Fibonacci's method

described this method for generating primitive triples using the sequence of consecutive odd integers and the fact that the sum of the first terms of this sequence is. If is the -th member of this sequence then.
Choose any odd square number from this sequence and let this square be the -th term of the sequence. Also, let be the sum of the previous terms, and let be the sum of all terms. Then we have established that and we have generated the primitive triple. This method produces an infinite number of primitive triples, but not all of them.
EXAMPLE:
Choose. This odd square number is the fifth term of the sequence, because. The sum of the previous 4 terms is and the sum of all terms is giving us and the primitive triple.

Sequences of mixed numbers

published the following method in 1544. Consider the sequence of mixed numbers with. To calculate a Pythagorean triple, take any term of this sequence and convert it to an improper fraction. Then its numerator and denominator are the sides, and, of a right triangle, and the hypotenuse is. For example:
Jacques Ozanam republished Stifel's sequence in 1694 and added the similar sequence with. As before, to produce a triple from this sequence, take any term and convert it to an improper fraction. Then its numerator and denominator are the sides, and, of a right triangle, and the hypotenuse is. For example:
With the shorter and the longer legs of a triangle and its hypotenuse, the Pythagoras family of triplets is defined by, the Plato family by, and the Fermat family by. The Stifel sequence produces all primitive triplets of the Pythagoras family, and the Ozanam sequence produces all primitive triples of the Plato family. The triplets of the Fermat family must be found by other means.

Dickson's method

attributes to himself the following method for generating Pythagorean triples. To find integer solutions to, find positive integers,, and such that is a perfect square. Then:
From this we see that is any even integer and that and are factors of. This method does not yield all Pythagorean triples. When and are coprime, the triple will be primitive. A simple proof of Dickson's method has been presented by Josef Rukavicka, J. .
Example: Choose. Then. The three factor-pairs of 18 are,, and. All three factor pairs will produce triples using the above equations.

Generalized Fibonacci sequence

Method I

For Fibonacci numbers starting with and and with each succeeding Fibonacci number being the sum of the preceding two, one can generate a sequence of Pythagorean triples starting from via
for.

Method II

A Pythagorean triple can be generated using any two positive integers by the following procedures using generalized Fibonacci sequences.
For initial positive integers and, if and, then
is a Pythagorean triple.

Method III

The following is a matrix-based approach to generating primitive triples with generalized Fibonacci sequences. Start with a 2 × 2 array and insert two coprime positive integers in the top row. Place the even integer in the column.
Now apply the following "Fibonacci rule" to get the entries in the bottom row:
Such an array may be called a "Fibonacci Box". Note that is a generalized Fibonacci sequence. Taking column, row, and diagonal products we obtain the sides of triangle, its area, and its perimeter, as well as the radii of its incircle and three excircles as follows:
The half-angle tangents at the acute angles are and.
EXAMPLE:
Using coprime integers 9 and 2.
The column, row, and diagonal products are:,,, so
The half-angle tangents at the acute angles are 2/11 and 9/13. Note that if the chosen integers and are not coprime, then the same procedure leads to a non-primitive triple.

Pythagorean triples and Descartes' circle equation

This method of generating primitive Pythagorean triples also provides integer solutions to Descartes' Circle Equation,
where integer curvatures are obtained by multiplying the reciprocal of each radius by the area. The result is, ,, . Here, the largest circle is taken as having negative curvature with respect to the other three. The largest circle may also be replaced by a smaller circle with positive curvature.
EXAMPLE:
Using the area and four radii obtained above for primitive triple, we obtain the following integer solutions to Descartes' Equation: ,,,, and.

A Ternary Tree: Generating All Primitive Pythagorean Triples

Each primitive Pythagorean triple corresponds uniquely to a Fibonacci Box. Conversely, each Fibonacci Box corresponds to a unique and primitive Pythagorean triple. In this section we shall use the Fibonacci Box in place of the primitive triple it represents. An infinite ternary tree containing all primitive Pythagorean triples/Fibonacci Boxes can be constructed by the following procedure.
Consider a Fibonacci Box containing two, odd, coprime integers and in the right-hand column.
It may be seen that these integers can also be placed as follows:
resulting in three more valid Fibonacci boxes containing and. We may think of the first Box as the "parent" of the next three. For example, if and we have:
Moreover, each "child" is itself the parent of three more children which can be obtained by the same procedure. Continuing this process at each node leads to an infinite ternary tree containing all possible Fibonacci Boxes, or equivalently, to a ternary tree containing all possible primitive triples. Compare: "Classic Tree". See also Tree of primitive Pythagorean triples.

Generating all Pythagorean triples using a predetermined positive integer

There is a method to construct all Pythagorean triples that contain a given positive integer as one of the legs of the right-angled triangle associated with the triple. It means finding all right triangles whose sides have integer measures, with one leg predetermined as a given cathetus. The formulas read as follows.
with
where
and if is even with,, and odd fixed, with
That is, regarding, must be even and such that is still divisible by.
Moreover, is a primitive Pythagorean triple if both of the following conditions are verified:
EXAMPLES

for primitive
for
for
for primitive
for trivial



for primitive
for
for
for primitive
for trivial



We remember that the Euclid's formulas do not give all Pythagorean triples that involves a predetermined positive integer, for example, the triples,, and. Moreover, it can be laborious to find and such that. Meanwhile, when using, it is enough to find all the to obtain all Pythagorean triples. In particular, if we need to find all primitive Pythagorean triples that involve a predetermined positive integer, then now we can use only the that satisfy the conditions.

Generating triples using quadratic equations

There are several methods for defining quadratic equations for calculating each leg of a Pythagorean triple. A simple method is to modify the standard Euclid equation by adding a variable to each and pair. The pair is treated as a constant while the value of is varied to produce a "family" of triples based on the selected triple. An arbitrary coefficient can be placed in front of the -value on either or, which causes the resulting equation to systematically "skip" through the triples. For example, consider the triple, which can be calculated from the Euclid equations with values and. Also, arbitrarily put the coefficient of 4 in front of the in the term.
Let, and let.
Hence, substituting the values of and :
The original triple comprises the constant term in each of the respective quadratic equations. Below is a sample output from these equations. The effect of these equations is to cause the -value in the Euclid equations to increment in steps of 4, while the -value increments by 1.
side side side
020212952
154729093
2104153185134
3170264314175
4252405477216

Generating all primitive Pythagorean triples using half-angle tangents

A primitive Pythagorean triple can be reconstructed from a half-angle tangent. Choose, a positive rational number in, to be for the interior angle that is opposite the side of length. Using tangent half-angle formulas, it follows immediately that
are both rational and that. Multiplying up by the smallest integer that clears the denominators of and recovers the original primitive Pythagorean triple. Note that if is desired, then should be chosen to be less than.
The interior angle that is opposite the side of length will be the complementary angle of. We can calculate
from the formula for the tangent of the difference of angles. Using instead of in the above formulas will give the same primitive Pythagorean triple but with and swapped.
Note that and can be reconstructed from,, and using and.

Pythagorean triples by use of matrices and linear transformations

Let be a primitive triple with odd. Then 3 new triples, , may be produced from using matrix multiplication and Berggren's three matrices,,. Triple is termed the parent of the three new triples. Each child is itself the parent of 3 more children, and so on. If one begins with primitive triple, then all primitive triples will eventually be produced by application of these matrices. The result can be graphically represented as an infinite ternary tree with at the root node. An equivalent result may be obtained using Berggrens's three linear transformations shown below.
Berggren's three linear transformations are:
Alternatively, one may also use 3 different matrices found by Price. These matrices and their corresponding linear transformations are shown below.
Price's three linear transformations are
The 3 children produced by each of the two sets of matrices are not the same, but each set separately produces all primitive triples.
For example, using as the parent yields two sets of three children:

Area proportional to sums of squares

All primitive triples with and with odd can be generated as follows:
Pythagorean tripleSemi-perimeterAreaIncircle radiusCircumcircle radius
1
2
3

Height-excess enumeration theorem

Wade and Wade first introduced the categorization of Pythagorean triples by their height, defined as, linking 3,4,5 to 5,12,13 and 7,24,25 and so on.
McCullough and Wade extended this approach, which produces all Pythagorean triples when : Write a positive integer as with square-free and positive. Set if is odd, or if is even. For all pairs of positive integers, the triples are given by
The primitive triples occur when and either with odd or.