TITLE: Show that $f$ is a homomorphism.
QUESTION [5 upvotes]: There is a group $G$ of order $p^3$, where $p>2$. Show that $f:G\rightarrow Z(G) $ with $f(x)=x^p$ is a homomorphism.
My attempt:
Case a):
Suppose $|Z(G)|=p^3$. Then $G=Z(G)$, so $G$ is abelian, and $(x_1x_2)^p=x_1^px_2^p$ is obvious.
Case b):
Suppose $|Z(G)|=p^2$. Then  $|G/Z(G)|=p$ and is cyclic, so $G$ itself is abelian, which implies that $|G|=|Z(G)|=p^3$. Contradiction.
Case c):
Suppose $|Z(G)|=p$. Then $|G/Z(G)|=p^2$, so $G/Z(G)\cong\mathbb{Z_p}\times\mathbb{Z_p}$(otherwise $G/Z(G)$ is cyclic and $G$ is abelian. So...
I don't even think that it is possible to finish my solution. It seems that there is better one, but this is just my unlucky try.

REPLY [2 votes]: For any $a,b\in G$
$$
[a,b] := aba^{-1}b^{-1}
$$
Since $G/Z(G)$ is abelian, one can see that
$$
[a,b] \in Z(G) \quad\forall a,b\in G
$$
Hence, $[a,b]^p = e$ for all $a,b\in G$. Now for any $x,y\in G$, note that
$$
(xy)^p = x^py^p[x,y^{-1}]^{p(p-1)/2} = x^p y^p ([x,y^{-1}]^p)^{(p-1)/2} = x^py^p
$$

REPLY [2 votes]: Since $G/Z(G)$ is abelian, for any $x,y \in G$, the commutator $[x,y]=x^{-1}y^{-1}xy$ is in $Z(G)$.
Now $yx=xy[y,x]$. To transform $(xy)^p$ to $x^py^p$ we have to carry out this transformation a total of $p(p-1)/2$ times, which is a multiple of $p$ because $p$ is odd.. So, using $[y,x] \in Z(P)$, we get
$$(xy)^p = x^py^p[y,x]^{p(p-1)/2} = x^py^p,$$
which proves the result.