In any right triangle, the square of hypothenuse is the sum of the squares of the two other sides (legs).

The reciprocal is also true : if in a triangle the sum of the squares of two sides equals the square of the 3rd, this triangle is a right triangle.

We can search for sides being integers,
that is x² + y² = z².

The smallest is 3² + 4² = 5² giving the "rope square"
in the problem.

Such "Pythagorean triples" were known by Babylonians, thousand years before Pythagora !

If x and y are both odd, x = 2m + 1, y = 2n + 1,
z² = x² + y² =4(m² + n² + m + n) + 2
can't be a square, as a square must be a multiple of 4, or a multiple of 4 plus 1.

Hence at least one of x or y is even : let x = 2m and then y and z have same parity.

x² = 4m² = z² - y² = (z + y)(z - y),
z + y and z - y being each even, let z + y = 2p and z - y = 2q,
y = p - q, z = p + q, m² = pq.
Let p = kr², q = k's² with k and k' square free.
kk' should be a square, hence k = k' and m = krs.

Then we must have :

x = 2krs
y = k(r² - s²) z = k(r² + s²) |

The solutions are said to be primitive if x,y and z have no commun divisor.

This requires k = 1, r and s of opposite parity
(else r² + s² and r² - s² would be even).

If p is a prime dividing both r and s, p divides r² and s²
hence x, y and z. So r and s must then be coprime.

Reciprocally (if r and s coprime) let p a prime dividing rs,
If it divides r then it doesn't divide s, hence neither r² + s²
nor r² - s²

Then GCD(x,y,z) = 1 if and only if :

k = 1, GCD(r,s) = 1, r and s of opposite parity |

If we vary r and s as said above, with r > s > 0,
every triple is given only once (prove that).

We can then easily get tables of Pythagorean triples.

**Note** :

Studying ternary quadratic forms gives another method to get all Pythagorean triples

Starting from the "trivial" solution X_{0} = (1,0,1),
and multiplying by each of the matrices

U = | (1,2,2) (2,1,2) (2,2,3) | V = | (-1,-2,-2) ( 2, 1, 2) ( 2, 2, 3) | W = | ( 1, 2, 2) (-2,-1,-2) ( 2, 2, 3) |

gives 3 new solutions. Multiplying each of these by U, V and W give 9
new solutions etc...

The first step gives just (1,0,1)×U = (3,4,5) (X_{0}×V = X_{0}, X_{0}×W = X_{0}×U)

The next steps give :

(3,4,5)×U = (21,20,29) (3,4,5)×V = (15,8,17) (3,4,5)×W = (5,12,13)

then each one multiplied by U, V, W give :

(55,48,73), (45,28,53), (7,24,25)

(119,120,169), (77,36,85), (39,80,89)

(65,72,98), (35,12,37), (33,56,65)
and so on...

Roberts proved in 1977 that all primitive solutions are given by
(x,y,z) = (1,0,1)×L

where L is some product of U,V,W matrices.

- Find if a given number can be an hypothenuse of a right triangle with integer sides
- In case yes, in how many ways.
- How many Pythagorean triples with hypothenuse less than a given number.

z = k(r² + s²) with r > s > 0 should have a divisor which is a sum of two squares.

We can prove (Fermat-Girard theorem) that the only numbers which are sum of two squares are :

- Number 2
- Primes of the form 4k + 1
- Squares of primes of the form 4k + 3
- Product of those numbers

As we want r > s > 0, 2 = 1² + 1² is not suitable. A square of a prime a = 4k + 3 is sum of square only as a² + 0², and is not suitable either. Finally :

A number is the hypothenuse of a right triangle with integer sides if and only if it has at least one prime factor of the form 4k + 1. |

To count how many triples have this hypothenuse, we deal with the problem of decomposition into a sum of squares.

- Pythagorean triangles whose hypotenuse as well as the sum of the two legs are perfect squares.

Solution - Pythagorean triangles whose area is a square

Solution

Even more for primitive triangles :

If hypothenuse is not multiple of 5, area is multiple of 30 |