Primitive Pythagorean Codes

In this paper, we shall define a simple generating matrix which produces all the primitive Pythagorean triples. Then we define classes of codes with primitive Pythagorean triples. These classes are very simple to encode and decode messages. They also have a very good data compression quality.


Introduction
A Pythagorean triple, is a triple of positive integers a , b, and c such that a right angle triangle exists with legs a , b and hypotenuse c .By the Pythagorean theorem, this is equivalent to finding positive integers a , b , and c , satisfying If a and b are relatively prime, then the Pythagorean triple is called primitive.The smallest and best-known Pythagorean triple is (3 , 4 , 5).The triangle generated by a Pythagorean triple is called a Pythagorean triangle.In all that follows we denote the primitive Pythagorean triple or triangle by PPT.
A more general formula for obtaining all triples was given by Euclid in c. 300 B.C. Lemma 1.For positive integers m and n , where 1 ≤ m < n, the triple is Pythagorean.Moreover, if m and n are relatively prime of opposite parity, then they generate a primitive triple.

Basic Properties of Primitive Pythagorean Triangles
In a primitive Pythagorean triangle T = (a, b, c), the following conditions hold: • The hypotenuse and one of the legs are always odd and the other leg is divisible by 4.
• The hypotenuse of every PPT exceeds the odd leg by twice the square of an integer r and the even leg by the square of an odd integer s,

Generating Matrix
Proposition 1.Let P be the set of all PPTs.For fixed positive integers m 0 and n 0 , , where m 0 is odd, define the following sets of PPTs: and c m − a m = 2 n 0 2 ; and finally for i 1 = i 2 and j 1 = j 2 , Moreover, R 1 contains all the PPTs, where the hypotenuse exceeds its even leg by one; and S 1 contains all the PPTs, where the hypotenuse exceeds its odd leg by two.
Proof.The identity u [m, n] G = < n, m + n> and Lemma 1 imply that any PPT can be obtained from the product of the vector u [m, n] and the generating matrix G. Thus We also conclude that if gcd (m 0 , n 0 ) = 1, then R m 0 ∩ S n 0 contains only one PPT, which is u[m 0 , n 0 ] G.
From the definitions of u [r, s] G, we obtain Notice that c − b = r 2 and c − a = 2 s 2 .Thus for the same a , b , and c ; r and s must be unique.Hence for i 1 = i 2 and j 1 = j 2 , Hence only R 1 contains all the PPTs, where the hypotenuse exceeds its even leg by one; and only S 1 contains all the PPTs, where the hypotenuse exceeds its odd leg by two.
Proof.(i) If T ∈ R m 0 ; then there exists a positive integer n with gcd (m 0 , n) = 1 such that (ii) If T ∈ S n 0 ; then there exists an odd number m with gcd (m, n 0 ) = 1 such that By solving the quadratic equation a = m 2 + 2 m n 0 for a positive m , we obtain From the fact that the last digit of any integer, could not be different from 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9 ; we conclude that any R m 0 and S n 0 may be partitioned into a finite number of disjoint classes, based on the last digits of a , b , and c , of T = (a, b, c).The above table shows that the set of T n , is partitioned into five disjoint classes, with coset leaders:
one may readily show the following identities which appear in the above table: , and a 12 k+1 is divisible by 3.

Application to Coding Theory
Primitive Pythagorean triple can lend itself to Coding Theory.There are infinitely many ways to encode letters of alphabet with PPTs.
To define a class of codewords, first we select either R m 0 or S n 0 .Suppose, we choose R m 0 , where m 0 is a prime odd number; then we assign a positive integer k with gcd (m 0 , k) = 1 to each letter of the alphabet.Finally, we create a Pythagorean alphabet using the generating matrix G.
The Pythagorean alphabet is as follows:

Error Detection
The fact that R 7 is partitioned into five disjoint classes; the received codeword must be in one of those five classes.If the last digits of a , b , or c do not match the digits of any of the coset leaders, the received codeword may be corrupted.Once the error is detected, it could eventually be corrected either directly or by a retransmission.It is customary that all codewords have the same length.We could achieve this task by adding some digits, such as zeros or ones at the beginning or the end of the shorter codewords.

Data Compression
Sometimes, it is necessary to shorten the length of the codewords without compromising the integrity of the message.According to Proposition 1, R m 0 contains all the PPTs, where the hypotenuse exceeds its even leg by m 2 0 ; and S n 0 contains all the PPTs, where the hypotenuse exceeds its odd leg by 2 n 2 0 .Removing the hypotenuse of the encrypted code in these sets, would not alter the message and its integrity.
Notice that in R 7 , c − b = 49 = 7 2 , for all c's and b's; so the alphabet could be shorten, by removing all the hypotenuses.According to Proposition 2, from the odd leg a of the codeword, we obtain k = a − 49 14 , the number assigned to the letter which was encoded with the generating matrix G. Therefore we could also remove the even leg b .
In order to be able to detect some transmission errors, we should add the last two digits of the coset leader of the class which contains the codeword.Here is the short form of the alphabet with parity-check digits: Although the generating matrix G is needed to encode a message; the received codeword by itself may decode the message without the need of the inverse of the generating matrix G.We could recreate the message, using 7, k = a − 49 14 , and G.
One could obviously generate a Pythagorean alphabet, using S n 0 .To decode the message, k = − n 0 + n 2 0 + a must be used.
In order to increase the probability of correcting errors, one could assign for example, three PPTs to each letter in the following way: "Choose the odd leg of the first PPT, the even leg of the second PPT, and the hypotenuse of the third PPT."This way, if one of the legs is error-free, then the codeword may be identified.
Finally, another way of increasing the probability of correcting errors and decreasing the number of retransmission; is to choose k's with large gaps between them.This way, it is most likely that the closest codeword to the received codeword is the codeword sent.
Clearly, all codewords must be converted to binary codewords, before transmission.