Example of a non-abelian group $(G,.)$ where $a^2b=ba^2\Rightarrow ab=ba $ Give and example of a non-abelian group $(G,.)$ where $a^2b=ba^2\Rightarrow ab=ba$ for all $a,b\in G$. Can somebody give me some tips, please? Moreover how did you think to get there.
I've found that $C(a^2) \subset C(a)=C(a^{|G|+1}) $
Edit: The answer sheet gives the solution the group of matrices of the form
$$\begin{pmatrix} 
\hat 1 & a & b \\ 
\hat 0& \hat 1 & c \\ 
\hat 0 & \hat 0 & \hat 1  
\end{pmatrix}\qquad\text{ with }\ a,b,c \in  \Bbb{Z}/3\Bbb{Z}.$$
Then $A^3=I_3$ for all such matrices.
I wanted to know if there are some easier groups to find. It's pretty hard to find matrices.
 A: My thought process:


*

*The relation $a^2b=ba^2$ can be read as stating that $a^2$ is in the centralizer of $b$, or that $b$ is in the centralizer of $a^2$. Can't tell which is more useful, yet.

*The relation $ab=ba$ similarly states that $a$ is in the centralizer of $b$, or that $b$ is in the centralizer of $a$.

*Centralizers of $b$ are involved in both, so the implication can be conveniently rephrased: $$\text{for all $a,b\in G$ we have:}\ a^2\in C_G(b)\implies a\in C_G(b).$$
How to make that implication true in a non-abelian group? Remember that $C_G(b)$ is a subgroup. If it contains the element $a^2$ it will contain all the powers $(a^2)^k=a^{2k}$, $k\in\Bbb{Z}$. Can we make sure that $a$ is among those powers? Yes, we can! Simply insist that for all $a$ we have $a^{2k-1}=1$ for some integer $k$.

Any non-abelian group $G$ of odd order will work. This is because, by Lagrange, every element then has an odd order as well.

See here for an explicit construction of the smallest non-abelian group of odd order.
A: One example of such a group is the subgroup of $\operatorname{GL}_3(\Bbb{F}_3)$ of matrices of the form
$$\begin{pmatrix}1&a&b\\0&1&c\\0&0&1\end{pmatrix}.$$
My thought process; if $a^2=a^{-1}$ for all $a\in G$ then the implication is immediate. So I'd like a group in which the order of every element divides $3$. Then the order of this group is $3^k$ for some $k$, because I'd like the group to be finite. Now I know that if the order of a group is either $p$ or $p^2$ for a prime $p$, then it is abelian. So I'd like a group of order $p^3$. This is the first one that came to mind.
It isn't hard to check that this group is non-abelian, and if you have a little patience it isn't even that hard to check explicitly that the relation $a^2b=ba^2\implies ab=ba$ holds.
