Saturday, May 3, 2008

GCDs of Pythagorean Triples

Euclid's formula for Pythagorean triples is used to generate triples from row and column numbers. Then the greatest common divisor (GCD) of the triple is calculated, using the Euclidean algorithm. Finally, a color is assigned the GCD.


seeking echo said...

I'd like to understand how that beautiful pattern is generated from the rows and columns. Are the rows and columns the ordinal numbers?

jb said...

I wrote the code for this over 3 years ago, but I think I've figured out what I did. I have assigned the numbers between 1 & about 40 (more than I need) to a color. In this case I may be simply cycling through the four colors. Then I cycle through the grid, generating three numbers from the row number and column number. Here I'm using Euclid's formulas for generating a triple from the row and column numbers for each cell of the grid. You can get these formulas from the Wikipedia page for "Pythagorean triple". In others words, I generate a, b, and c from the row and column number, m & n. Then I use Euclid's algorithm for finding the greatest common divisor of a, b, and c. The result is a number that I have assigned a color. I tried other ways of generating numbers from the row and column, and finding the greatest common divisor of the two (or three) numbers generated. You may be able to access some of my results here: I hope this helps you.

jb said...

These images are from the GCD of two numbers:
...and these images are from the GCD of three numbers, including Pythagorean triples: