Let $A $ and $B$ be real symmetric matrices of order $n$, satisfying $A^2B=ABA.$ Proof that $AB=BA.$ Let $A $ and $B$ be real symmetric matrices of order $n$, satisfying $A^2B=ABA.$ Proof that $AB=BA.$
I only find that $A^2B=BA^2=ABA.$ Then I don't know what to do next.Can you help me solve this puzzle?

If $A$ is invertible or $A=0$ then it is obvious. Assume now that $A\ne 0$ and $\det A=0$.
$A$ is symmetric and hence diagonalizabe by an orthnormal matrix $U$. Set $A=U^{-1}LU$, where$L$ is diagonal. Expressing $L$ and $\hat B=UBU^{-1}$ (which is also symmetric) in block form,
$$
L=\left(
\begin{array}{cc}D & 0 \\ 0 & 0\end{array}
\right),\qquad
UBU^{-1}=\left(
\begin{array}{cc}B_1 & B_2 \\ B_3 & B_4\end{array}
\right)=\hat B,
$$
where $D$ is diagonal and invertible, we have
$$
U^{-1}L^2\hat B U=U^{-1}L^2UB=A^2B=ABA=U^{-1}LUBU^{-1}LU=U^{-1}L\hat BLU
$$
or
$$
L^2\hat B=L\hat BL
$$
or
$$
\left(
\begin{array}{cc}D^2 & 0 \\ 0 & 0\end{array}
\right)\left(
\begin{array}{cc}B_1 & B_2 \\ B_3 & B_4\end{array}
\right)=\left(
\begin{array}{cc}D & 0 \\ 0 & 0\end{array}
\right)\left(
\begin{array}{cc}B_1 & B_2 \\ B_3 & B_4\end{array}
\right)\left(
\begin{array}{cc}D & 0 \\ 0 & 0\end{array}
\right)
$$
or
$$
\left(
\begin{array}{cc}D^2B_1 & D^2B_2 \\ 0 & 0\end{array}
\right)=\left(
\begin{array}{cc}DB_1D & 0 \\ 0 & 0\end{array}
\right).
$$
Hence $B_2=0$ and $DB_1=B_1D$, and also $B_3=B_1^T=0$, in which case
$$
BA=U^{-1}\hat BUU^{-1}\left(
\begin{array}{cc}D & 0 \\ 0 & 0\end{array}
\right)U=
U^{-1}\hat B\left(
\begin{array}{cc}D & 0 \\ 0 & 0\end{array}
\right)U=U^{-1}\left(
\begin{array}{cc}B_1 & 0 \\ 0 & B_4\end{array}
\right)\left(
\begin{array}{cc}D & 0 \\ 0 & 0\end{array}
\right)U=U^{-1}\left(
\begin{array}{cc}B_1D & 0 \\ 0 & 0\end{array}
\right)U=U^{-1}\left(
\begin{array}{cc}DB_1 & 0 \\ 0 & 0\end{array}
\right)U=U^{-1}\left(
\begin{array}{cc}D & 0 \\ 0 & 0\end{array}
\right)\left(
\begin{array}{cc}B_1 & 0 \\ 0 & B_4\end{array}
\right)U=U^{-1}\left(
\begin{array}{cc}D & 0 \\ 0 & 0\end{array}
\right)\hat BU=U^{-1}\left(
\begin{array}{cc}D & 0 \\ 0 & 0\end{array}
\right)UBU^{-1}U=AB
$$
