Finding Pythagorean triples

150 Views Asked by At

I've encountered the following problem in a programming textbook . Let x,y denote two real variables and k a fixed parameter (real as well) . Find (efficiently) all the possible values for x,y such that :

$x^2+y^2=k^2$.

The problem itself is easy to solve through simple lines of code, but I'm much more interested in a mathematical approach that can be translated into code without much effort.

1

There are 1 best solutions below

0
On

I don't know how familiar with abstract algebra you are, but Hilbert's Theorem 90 provides a very elegant characterization of the rational points on the unit circle (which are precisely the Pythagorean triples). Wikipedia has some of the details here.