I have been writing a python program to generate integers that satisfy the perfect root of $a^2 + b^2$ over large ranges of values using brute force loops. Are there direct generating equations to solve this problem?
Just to be clear, for example, $a = 16$ and $b=30$ form a perfect square, since $\sqrt{16^2+30^2}=34$. So is $a=1308$ and $b=3815$, and so on.
In my searching, I read how Euclid solved the Diophantine equations for pythagorean triples and I thought the method would apply to my situation.
I thought that if $a$, $b$, and $c$ satisfied the triple $a^2+b^2=c^2$, then $a^2+b^2$ is a perfect square and would be given by the same equations of Euclid. Namely, $a=m^2-n^2$, $b=2mn$. And indeed, this is the case for $a=16$ and $b=30$ where $m=5$ and $n=3$. Success, I thought! But there is no rational solution for $a=1308$ and $b=3815$ or any of the other $a,b$ pairs as per some fiddling on wolframalpha.
The structure of Pythagorean triples is well-known. Let us consider the circle $x^2+y^2=1$ and a line with rational slope through $(1,0)$: by Vieta's theorem the second intersection with the circle is a point with rational coordinates, and if $P(x,y)\neq(1,0)$ is a point on the unit circle with rational coordinates the line joining $P$ with $(1,0)$ has a rational slope. By computing in a explicit way the non-trivial intersection between $x^2+y^2=1$ and a line through $(1,0)$ with slope $t\in\mathbb{Q}$ we get that
Every rational point on $x^2+y^2=1$ is associated with a Pythagorean triple by $$ \left(\frac{a}{c},\frac{b}{c}\right)\in S^1 \mapsto (a,b,c)\in\mathbb{Z}^3, a^2+b^2=c^2.$$ In particular:
This generates the whole set of Pythagorean triples, and the constraint $d=1$ gives the primitive pythagorean triples.