Pythagorean Triples Generator

Given a leg of a right-angled triangle a, this formula gives the other leg b and the hypotenuse c by the usage of a pattern observed in Pythagorean triples. This is different as compared to Euclids method since Euclids method takes two arbitrary numbers as the input while this uses the side of the right-angled triangle as the input.


The Current Problem
The Euclid's formula is the most commonly used formula for generating Pythagorean triples given an arbitrary pair of integers m and n with m > n > 0. The limitation in this formula is that we have no control over the values of the sides of the triangle. For instance, if we want to find a Pythagorean triple with side length of 156, this is quite a challenge with Euclid's method. However, the basis of the method presented in this paper has complete control over the side length.

Alternate Methods
There have been various other methods besides Euclid's formula that have been devised for generating Pythagorean triples such as: • Fibonacci's Method -Fibonacci described a method for generating primitive triples for the sequence of odd natural numbers and the fact that the sum of the first n terms of this sequence is n 2 . The method shared in this paper uses Fibonacci's Method as a source of inspiration.
• Dickson's Method -If we find positive integers r, s, and t such that r 2 = 2st is a perfect square. Then x = r + s , y = r + t , z = r + s + t. where x, y, z are the side lengths and hypotenuse respectively.
In the odd series, they differ by 1 and in the even series, they differ by 2.

Analysing the Relation
Using the fact observed previously, we derive that, However, this pattern is not applicable to all Pythagorean triples since the next triple would be (28, 45, 53) which does not follow the pattern.
Therefore, this formula will generate infinite Pythagorean triples but does not generate all Pythagorean triples.

Derivation of the Formula
By plugging in the results developed previously into the Pythagoras theorem, we can derive the formulas.
For odd inputs, For even inputs,

Final Result
Hence the final formula would be, 2 where a = 2n + 1 and n ∈ Z b = a 2 4 − 1, c = a 2 4 + 1 where a = 2n and n ∈ Z

An Exploration
Now that the formula has been derived, we can try different inputs to receive interesting results.

The Base
Examples The triplet is (11,60,61) The triplet is (14,48,50) The above two exhibits show results as expected.

Few Special Cases
The triplet is (2,0,2) The triplet is (1,0,1) Exhibit 5 f (0) 0 can be represented as 2n where n = 0, the second set of formulas would be applied to it.
The triplet is (0,-1,1) Hence, we can conclude that, • Giving an input of 0,1 or 2 results in having one of the sides as a zero length.
• Zero is the only input thats able to produce a negative Hypotenuse.

The Negative Integers
Exhibit 6 f (−5) -5 can be written as 2(-3) + 1, the first set of formulas would be applied to it.
The triplet is (-5,12,13) Exhibit 7 f (−6) -6 can be written as 2(-3), the second set of formulas would be applied to it b = 9 − 1 = 8; c = 9 + 1 = 10 The triplet is (-6,8,10) Hence, the sign of the input does not play a role here as the input is squared in every formula.

The Code
Given below is the algorithm written in the programming language Python.
The following code can be executed without any installation in Google Collab or can be executed in Jupyter Notebook if installed.

The Graphs
A graphical representation can help us understand how the three quantities vary when compared to each other.
Therefore using the mypythagoreantripletchart() function shown before, we shall observe the a vs b, a vs c and b vs c graphs. We can observe the negligible difference between b and c.

Conclusion and the Way Forward
Prime numbers and Pythagorean Triples generation are a vital component in Cryptography. Developing methods that enable more flexibility in the generation process will benefit the Cryptography domain.
The Development of new methods of generating Pythagorean triples will not stop here. Although this paper showcases a method with flexible input values, The ability to generate all the Pythagorean triples is constrained.
Hence, methods that involve flexibility in input, ease of implementation and the ability to generate all Pythagorean Triples is the goal that we should try to achieve.