If all the eigenvalues of $A$ are distinct, then $B$ can be expressed uniquely as a polynomial in $A$ with degree no more than $n − 1$.
If matrices $A$ and $B$ commute, $A$ with distinct eigenvalues, then $B$ is a polynomial in $A$