Commutative Semigroup Let $S$ be a Semigroup with the two following properties,
$(1):$ for all $x$ in $S$ we have $x^3=x$
$(2):$ for any $x,y$ in $S$ we have $xy^2x=yx^2y$.
   Then prove that this Semigroup $S$ is commutative.
I have found the following identities for any $x,y$ in $S$


*

*$(xy)^3=xy=x^3y^3$

*$xy^2x=y^2(xy^2x)$

*$(xy)^2=y(xy)^2y$

*$xy^2x^2x=yx^2yx^2$
 A: $$yxy=yxyyxyyxy=yxy^2xy^2xy=yyx^2yy^2xy=y^2x^2yxy=$$
$$=yxy^2xxy=yxy^2x^2y=yxyxy^2x,$$
which gives $$yxy^2=yxyxy^2xy.$$
In another hand,
$$xyxy=xyy^2xy=y(xy)^2y=yxyxy^2,$$
which gives
$$xy=(xy)^3=yxyxy^2xy.$$
Thus,
$$xy=yxy^2$$ and also,
$$yx=xyx^2$$ or
$$xy^2=yxy$$ and
$$yx^2=xyx.$$
Now,
$$x^2yx^2y=x^2yy^2x^2y=y(x^2y)^2y=yx^2yx^2yy=yx^2yx^2y^2.$$
Thus, $$x^2y=(x^2y)^3=yx^2yx^2y^2x^2y=xy^2xx^2y^2x^2y=$$
$$=xy^2xy^2x^2y=yx^2y^3x^2y=yx^2yx^2y,$$
Which gives
$$xy=x(x^2y)=(xyx^2)(yx^2y)=(yx)(xy^2x)=yx^2y^2x=x^2yx.$$
Id est,
$$x^2y=xyx=yx^2$$ and
$$xy=x(x^2y)=xyx^2=yx.$$
A: Suppose $S$ is a semigroup such that
\begin{align*}
x^3&=x,\;\text{for all}\;x\in S\tag{1}\\[4pt]
xy^2x&=yx^2y,\;\text{for all}\;x,y\in S\tag{2}\\[4pt]
\end{align*}
Our goal is to show $xy=yx$, for all $x,y\in S$.

We can recast $(2)$ as
$$(xy)(yx)=(yx)(xy),\;\text{for all}\;x,y\in S\tag{3}$$
so $xy$ commutes with $yx$, for all $x,y\in S$.

Next, working on $y^2x^2y^2$, we get
\begin{align*}
y^2x^2y^2&=(y^2x)(xy^2)\\[4pt]
&=(xy^2)(y^2x)&&\text{[by $(3)$]}\\[4pt]
&=xy^4x\\[4pt]
&=xy^2x&&\text{[by $(1)$]}\\[4pt]
\end{align*}
Thus we have
$$y^2x^2y^2=xy^2x,\;\text{for all}\;x,y\in S\tag{4}$$
Next, working on $x^2y^2$, we get
\begin{align*}
x^2y^2&=(x^2y^2)^3\\[4pt]
&=(x^2y^2)(x^2y^2)(x^2y^2)\\[4pt]
&=x^2(y^2x^2y^2)x^2y^2\\[4pt]
&=x^2(xy^2x)x^2y^2&&\text{[by $(4)$]}\\[4pt]
&=x^3y^2x^3y^2\\[4pt]
&=xy^2xy^2&&\text{[by $(1)$]}\\[4pt]
&=(xy^2x)y^2\\[4pt]
&=(yx^2y)y^2&&\text{[by $(2)$]}\\[4pt]
&=yx^2y^3\\[4pt]
&=yx^2y&&\text{[by $(1)$]}\\[4pt]
&=xy^2x&&\text{[by $(2)$]}\\[4pt]
\end{align*}
Thus we have
$$x^2y^2=yx^2y=xy^2x,\;\text{for all}\;x,y\in S$$
hence, by symmetry, we get
$$x^2y^2=y^2x^2,\;\text{for all}\;x,y\in S\tag{5}$$
so $x^2$ commutes with $y^2$, for all $x,y\in S$.

Next, working on $x^2y$, we get
\begin{align*}
x^2y&=(x^2y)^3&&\text{[by $(1)$]}\\[4pt] 
&=x^2(yx^2y)x^2y\\[4pt]
&=x^2(xy^2x)x^2y&&\text{[by $(2)$]}\\[4pt]
&=x^3y^2x^3y\\[4pt]
&=xy^2xy&&\text{[by $(1)$]}\\[4pt]
&=(xy^2x)y\\[4pt]
&=(yx^2y)y&&\text{[by $(2)$]}\\[4pt]
&=y(x^2y^2)\\[4pt]
&=y(y^2x^2)&&\text{[by $(5)$]}\\[4pt]
&=y^3x^2\\[4pt]
&=yx^2&&\text{[by $(1)$]}\\[4pt] 
\end{align*}

Thus we have
$$x^2y=yx^2,\;\text{for all}\;x,y\in S\tag{6}$$
so squares commute with everything.

Finally, working on $xy$, we get
\begin{align*}
xy&=(xy)^3&&\text{[by $(1)$]}\\[4pt]
&=x(yx)^2y\\[4pt]
&=(yx)^2xy&&\text{[by $(6)$]}\\[4pt]
&=yx(yx^2y)\\[4pt]
&=yx(xy^2x)&&\text{[by $(2)$]}\\[4pt]
&=yx^2y^2x\\[4pt]
&=y(x^2y^2)x\\[4pt]
&=y(y^2x^2)x&&\text{[by $(5)$]}\\[4pt]
&=y^3x^3\\[4pt]
&=yx&&\text{[by $(1)$]}\\[4pt]
\end{align*}
Thus we have
$$xy=yx,\;\text{for all}\;x,y\in S$$
as was to be shown.
