[Math] Given hypotenuse, find the other two sides.

pythagorean triples

Note that we are only interested in integral pythagorean triplets, we are given the hypotenuse $c$, how can I efficiently find the other two sides of the right angled triangle. I need something better than the bruteforce approach of iterating over all lengths $a$ below $c$, and checking perfect square for $b = \sqrt{c^2-a^2}$.
For multiple solutions, I need one with the smallest $a$ possible.

Best Answer

You cannot, because there exist infinitely many right angled triangles with the same hypotenuse length.

For example, if the length of the hypotenuse is $1$, then for every $x\in(0,1)$, $(x, \sqrt{1-x^2})$ are possible lengths of the other two sides.