On the complete solution to $x^2+y^2=z^k$ for odd $k$? While trying to answer this question, I was looking at a computer output of solutions to $x^2+y^2 = z^k$ for odd $k$ and noticed certain patterns. For example, for $k=5$ we have $x,y,z$,
$$10, 55, 5\\25, 50, 5\\38, 41, 5\\117, 598, 13\\122, 597, 13\\338, 507, 13\\799, 884, 17$$
Question: Is it true that all integer solutions to $x^2+y^2=z^k$ for odd $k>1$ are given by just two formulas, namely,


*

*Primitives $\gcd(x,y)=1$:
$$A^2+B^2 = (a^2+b^2)^k\tag1$$
where $A,B$ is the expansion of $(a+bi)^k = A+Bi$. Example, $$(a+bi)^3 =(a^3 - 3 a b^2)+ (3 a^2 b - b^3)i$$ hence, $$(a^3 - 3 a b^2)^2+ (3 a^2 b - b^3)^2 = (a^2+b^2)^3$$ and so on for other $k$.

*Non-primitives $\gcd(x,y)\neq1$:
$$a^2(a^2+b^2)^{k-1}+b^2(a^2+b^2)^{k-1} = (a^2+b^2)^k\tag2$$
where, for both Forms $1$ and $2$, we use some rational $a,b$?


Example. The first three solutions for $k=5$ above use:
$$a,b = 2/5,\;11/5\quad \text{Form 2}$$
$$a,b = 1,\;2\quad \text{Form 2}$$
$$a,b = -2,\;1\quad \text{Form 1}$$
 A: If $x^2+y^2=z^k$, then $(x+iy)(x-iy)=z^k$. The Gaussians are a UFD, so if $\gcd(x+iy,x-iy)=1$ then this forces $x+iy=(r+si)^k$ for some integers $r$ and $s$. I think this is your form 1. 
If there exists $d$ dividing both $x+iy$ and $x-iy$, then $d$ must divide their sum, $2x$, and their difference, $2iy$. So if $x$ and $y$ are relatively prime, then $d$ is nontrivial if and only if $x$ and $y$ are both odd, and $d=1+i$. But if $x$ and $y$ are odd, then $x^2+y^2\equiv2\bmod4$, while $z^k\equiv0\bmod4$, contradiction. 
So we're left with the case where there is an integer $d>1$ dividing both $x$ and $y$. To be continued....
A: Good news: the answer is Yes. Moreover, all integer solutions are given by just one formula - the second one. It covers both primitive and non-primitive solutions. That is, for every solution $(x,y,z)$ to $x^2+y^2=z^k$  there exist rational numbers $a,b$ such that $x=a(a^2+b^2)^{(k-1)/2}$, $y=b(a^2+b^2)^{(k-1)/2}$ and $z=a^2+b^2$.
Bad news: This formula is quite useless. The reason is that you use rational parameters to describe integer solutions, and the question for which rational parameters the corresponding values of $x,y,z$ are integers is as difficult as solving the equation.
Now the proof. Take $a=\frac{x}{z^{(k-1)/2}}$, $b=\frac{y}{z^{(k-1)/2}}$. Then $a^2+b^2=(x^2+y^2)/z^{k-1} = z^k/z^{k-1}=z$, $a(a^2+b^2)^{(k-1)/2}=\frac{x}{z^{(k-1)/2}}z^{(k-1)/2}=x$ and $b(a^2+b^2)^{(k-1)/2}=y$.
A: Must write more correctly. $Z$ representation as a sum of squares gives the standard approach.
$$X^2+Y^2=Z^{k}$$
Uses the standard formula of the Brahmaputra. View the sum of the squares piece.
$$X^2+Y^2=(ab+cd)^2+(cb-ad)^2=(a^2+c^2)(b^2+d^2)$$
So the sum of squares is converted until
$$(b_1^2+d_1^2)...(b_{k}^2+d_{k}^2)=Z^{2k}$$
$$Z^2=b_1^2+d_1^2=...=b_{k}^2+d_{k}^2$$
Odd.
$$(a^2+b^2)(b_1^2+d_1^2).....(b_{k}^2+d_{k}^2)=Z*Z^{2k}$$
$$Z^2=b_1^2+d_1^2=...=b_{k}^2+d_{k}^2$$
$$Z=a^2+b^2$$
$$b_1=b_2=...=b_{k}=a^2-b^2$$
$$d_1=d_2=...=d_{k}=2ab$$
Will as an example this equation.
$$X^2+Y^2=Z^5$$
$$(xb+yd)^2+(yb-xd)^2=(x^2+y^2)(b^2+d^2)=(a^2+c^2)(b^2+d^2)(b^2+d^2)=Z*Z^2*Z^2$$
$$Z=a^2+c^2$$
$$x=ab+cd$$
$$y=cb-ad$$
$$d=a^2-c^2$$
$$b=2ac$$
And then the decision on the record.
$$X=a^5-10c^2a^3+5ac^4$$
$$Y=c^5-10a^2c^3+5ca^4$$
So these numbers are multiples of each its option.
