Let $G$ be a $p$-group of nilpotency class at most 2, where $p$ is an odd prime. Then ${\{x^p| x \in G\}}$ is a subgroup of $G$.

Let $$G$$ be a $$p$$-group of nilpotency class at most 2, where $$p$$ is an odd prime.Then $$A=\{{x^p| x \in G}\}$$ is a subgroup of $$G$$.

As $$G$$ is a group of nilpotency class at most 2, if the nilpotency class of $$G$$ equal 1 then $$G$$ is an abelian group and the result is obvious.

Now we consider the nilpotency class equal 2. Then we have $$G^\prime \leq Z(G)$$.

Also as a result for every natural number like $$n$$ and every $$x,y$$ in $$G$$ we have $$(xy)^n= x^ny^n[y,x]^{n\frac{n-1}{2}}.$$

Now I consider $$x^p, y^p$$ in $$A$$ where $$x,y$$ are in $$G$$. I want to show $$x^py^p$$ in $$A$$. According to the above fact we have $$(xy)^p= x^py^p[y,x]^{p\frac{p-1}{2}}.$$

I want to show $$[y,x]^{p\frac{p-1}{2}}=1$$, but I don't know how.

• You don't need to show it is trivial! You need to show that the product of two $p$th powers is a $p$th power, and what you have shows that $x^py^p = (xy)^p([x,y]^{(p-1)/2})^p \in G^p$. Or you can note that $[y,x]^{p(p-1)/2} = [y^p,x^{(p-1)/2}] = y^{-p} (y^p)^{x^{(p-1)/2}}$, so it is a product of $p$-th powers. Thus, the product of two elements in $G^p$ is in $G^p$. – Arturo Magidin Mar 22 at 18:32
• @ArturoMagidin We define $G^p =\langle x^p|x \in G\rangle$ and it is obviously a subgroup of $G$. But here $A=\{x^p|x \in G\}$. We want to show the procut of two $p$-power elements is in $A$ not in $G^p$. Thanks for your complete answer. – Yasmin Mar 23 at 4:05
• Well, as you see in the answer, the comment is incomplete; the point is that one of the factors is central, and a product of two $p$-th powers, one of which is central, is a $p$th power. P.S. Use \langle rather than <, and \rangle rather than >. – Arturo Magidin Mar 23 at 4:07
• @ArturoMagidin yes, I see the answer, I only wanted to say that the way you said in comment dosen't complete. Thanks for your help. – Yasmin Mar 23 at 4:14

Consider the multiplicative group of upper triangular $$3\times 3$$ matrices with entries in $$\mathbb{Z}/p^n\mathbb{Z}$$ with $$1$$s in the diagonal. Multiplication is given by $$\left(\begin{array}{ccc} 1&a&c\\ 0 & 1 & b\\ 0 & 0 & 1\end{array}\right) \left(\begin{array}{ccc} 1 & \alpha & \gamma\\ 0 & 1 & \beta\\ 0 & 0 & 1 \end{array}\right) = \left(\begin{array}{ccc} 1 & a+\alpha & c + \gamma + a\beta\\ 0 &1 & b+\beta\\ 0 & 0 & 1\end{array}\right).$$ This is a nilpotent group of order $$p^{3n}$$ and class $$2$$. The commutator subgroup is generated by the matricx with $$a=b=0$$, $$c=1$$.
If you let $$x$$ be the matrix corresponding to $$a=1$$, $$b=c=0$$; and $$y$$ the matrix corresponding to $$a=c=0$$, $$b=1$$, then $$[x,y]=x^{-1}y^{-1}xy$$ is the matrix with $$a=b=0$$, $$c=1$$, which has order $$p^n$$. In particular, if $$n\gt 1$$, then $$[x,y]^{p(p-1)/2}\neq e$$.
However, it is not necessary to show the commutator is trivial. As you already computed, in a nilpotent group of class at most $$2$$, we have $$(xy)^n = x^n y^n [y,x]^{n(n-1)/2}.$$
So, to show that $$A$$ is a subgroup, we note that $$e^p=e\in A$$; that if $$x^p\in$$, then $$(x^p)^{-1} = (x^{-1})^p\in A$$. And then the hard one: showing that the product of two $$p$$th powers is a $$p$$th power. Suppose $$x^p,y^p\in A$$. Then, as previously computed we have: \begin{align*} (xy)^p &= x^py^p[y,x]^{p(p-1)/2}\\ (xy)^p[x,y]^{p(p-1)/2} &= x^py^p\\ (xy)^p\left([x,y]^{(p-1)/2}\right) &= x^py^p. \end{align*} To finish off, we note that since $$[x,y]^{(p-1)/2}$$ commutes with $$xy$$ (in fact, it is central), then $$\left( (xy)[x,y]^{(p-1)/2}\right)^p = (xy)^p[x,y]^{p(p-1)/2} = x^py^p.$$ Thus, $$x^py^p$$ is equal to a $$p$$th power, and hence lies in $$A$$. Thus, $$A$$ is closed under products, and we are done.