deriving the formulas for Pythagorean triples A Pythagorean triple is a triple $(a,b.c)$ of positive integers for which $a^2+b^2=c^2$;it is called primitive if the $\gcd(a,b.c)=1$.


*

*Consider a complex number $z=q+pi$, where $q>p$ are positive integers.
prove that $(q^2-p^2,2pq,q^2+p^2)$ is a Pythagorean triple, and whether it is primitive?

*prove that every primitive triple $(a,b,c)$ is of this type.
 A: The first one is quite easy. It's obvious that $(q^2-p^2,2pq,q^2+p^2)$ is a Pythagorean triple because:
$(q^2-p^2)^2+(2pq)^2=(q^2+p^2)^2 \iff q^4 + p^4 - 2p^2q^2 + 4p^2q^2=q^4+p^4+2p^2q^2$
as I said in the comments, the condition that $q>p$ is not sufficient. I believe the following conditions are sufficient to prove $\gcd(q^2-p^2,2pq,q^2+p^2)=1$:


*

*$\gcd(p,q)=1$

*$p$ and $q$ must have different parities. In other words, one of them must be odd and the other one must be even.
To prove that part, notice that if we set $d=\gcd(q^2-p^2,2pq,q^2+p^2)$ and suppose $d>1$ then there must be a prime number $m$ such that $m \mid d$ by prime factorization theorem. Remember that $m$ is a prime number and we use all theorems about prime numbers for $m$.
Now, since $m \mid d$ then $m \mid q^2-p^2$ and $m \mid q^2+p^2$. so, we have:
$m \mid (q^2-p^2)+(q^2+p^2)=2q^2$ and $m \mid (q^2+p^2)-(q^2-p^2)=2p^2$. 
If $m \neq 2$ then since $\gcd(m,2)=1$ we can see that:
$m \mid 2q^2 \implies m \mid q^2 \implies m \mid q$ 
$m \mid 2p^2 \implies m \mid p^2 \implies m \mid p$.
That means $m \mid \gcd(p,q)$, but by our hypothesis, $\gcd(p,q)=1$ therefore $m \mid 1$ and since $m$ has been assumed to be a prime number that is a contradiction.
To check that the case where $m=2$ doesn't happen notice that $p$ and $q$ have different parities. So, one of them is even and the other one is odd. In this case $q-p$ and $p+q$ will be odd and their product $(q-p)(p+q)=q^2-p^2$ will be odd as well.Therefore $2 \not\mid q^2-p^2$ and hence $d \neq 2$.
To prove the second one, what I have in mind is a geometric argument which is based on the fact that all Pythagorean triples actually come from the rational parametrization of the unit circle. I have talked about this before on another question, I'll try to find it. The fact that all Pythagorean triples are obtained by this way is actually is equivalent to the surjectivity of the map which is obtained from parametrization. I can't think of any better reasons for now, but I'll edit my post to give a good proof of the second statement.
