Non cyclic group of order $p^3$ satisfies $G \simeq H \rtimes_{\theta}K$

Let $$G$$ be a non-cyclic group of order $$p^3$$ for an odd prime $$p$$. Prove that $$G \simeq H \rtimes_{\theta}K$$, where $$H$$ is a normal subgroup of $$G$$ of order $$p^2$$, $$K$$ is a subgroup of order $$p$$, and $$\theta : K \to Aut(H)$$ is a homomorphism.

I managed to prove that there exists a normal subgroup $$H$$ of order $$p^2$$. Then I took some $$g \in G-H$$. If $$g$$ is of order $$p$$, I am done since $$G \simeq H \rtimes \langle g \rangle$$. But what if all $$g \in G - H$$ are of order $$p^2$$?

• Impossible that all the non-trivial elements in $\;G\;$ are of order $\;p^2\;$ since there exists a subgroup of order $\;p\;$ ... – DonAntonio Dec 23 '18 at 22:10
• Sorry, I meant all $g \in G - H$. I edited my question – user401516 Dec 23 '18 at 22:18
• Observe that the conclusion would be false when $p=2$. The quaternion group $Q_8$. In other words, the fact that $p$ is odd must come into play somehow. – Jyrki Lahtonen Dec 24 '18 at 6:36
• The claim seems to follow from the observations made by the OP and the argument given in this old answer by Arturo Magidin. – Jyrki Lahtonen Dec 24 '18 at 7:21

The result follows immediately if all elements of $$G$$ have order $$1$$ or $$p$$, so we can assume that there exists an element of order $$p^2$$. This generates a cyclic subgroup of index $$p$$, which is normal in $$G$$, so we can assume that $$H$$ is cyclic of order $$p^2$$.
So let $$g \in G \setminus H$$, and assume that $$g$$ has order $$p^2$$ (if it has order $$p$$ then we are done). So $$g^p = h^p$$ for some $$h \in H$$. We claim that $$(gh^{-1})^p=1$$, and hence $$gh^{-1}$$ has order $$p$$ and we are done.
This is immediate if $$G$$ is abelian, so suppose not. Then $$[G,G]=Z(G)$$ has order $$p$$, so commutators are central, and $$(xy^{-1})^p = x^py^{-p}[y^{-1},x]^{p(p-1)/2}$$ (where $$[a,b]$$ denotes the commutator $$a^{-1}b^{-1}ab$$).
Then, since $$p$$ is odd and $$[y^{-1},x]$$ has order $$p$$, we get $$[y^{-1},x]^{p(p-1)/2}=1$$ and the claim follows. (Note that this result is false when $$p=2$$, and the quaternion group $$Q_8$$ is a counterexample.)
• Thank you for your answer. Can you please explain why $(xy^{-1})^p=x^py^{-p}[y^{-1},x]^{p(p-1)/2}$ ? – user401516 Dec 24 '18 at 12:30
• If $[G,G] \le Z(G)$ then $(ab)^k = a^kb^k[b,a]^{k(k-1)/2}$ for all $a,b \in G$ and all $k \ge 0$. Prove it by induction on $k$, using $ba = ab[b,a]$. – Derek Holt Dec 24 '18 at 15:24
• Where did you use the fact that $H$ is cyclic? – user401516 Dec 24 '18 at 21:45
• The existence of $h \in H$ such that $g^p=h^p$. – Derek Holt Dec 24 '18 at 22:45