This could very well be a duplicate, so please close if similar. Working through old preliminary exams.
Edit: The original question is stated as follows.
Let $A$ be Hermitian $n\times n$ matrix. Suppose $B$ is an arbitrary $n\times n$ matrix. Prove that if
$A^3B=BA^3$
Then in fact
$AB=BA$.
I'm trying to prove a generalization.
Suppose $A$ is Hermitian, and let suppose there exists a $k\in\mathbb{N}$ such that
$A^kB=BA^k$
Prove that $AB=BA$.
It's easy to show from the assumption that if $p(x)$ is a polynomial then in fact
$p(A^k)B=Bp(A^k)$
So that it's sufficient to find some polynomial $p$ that $p(A^k)=A$. To that end, $A$ Hermitian implies that $\sigma(A)\subset\mathbb{R}$. The spectral mapping theorem implies that the eigenvalues of $A^k$ are $\lambda^k$ for $\lambda$ an eigenvalue of $A$. If $\{\lambda_i\}_{i=1}^{n}$ are the eigenvales of $A$, let $q$ be the interpolation polynomial of degree $n-1$ satisfying
$q(\lambda_i^k)=\lambda_i$.
Here's where I'm stuck. I want to conclude that $q(A^k)=A$. Is there a way to do that? Or is the interpolation polynomial the completely wrong approach.
Hints are appreciated if possible instead of answers!
The statement is false: take a self-adjoint projection $P$ and any matrix $B$ which does not commute with $P$. Then $B$ does not commute with $$ A= 2P-1 $$ either. However $A^2=1$, so clearly $A^2$ and $B$ commute.
On the other hand the statement becomes true if $A$ is assumed positive.