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$. Let $A$ and $B$ be $n×n$ matrices such that $AB = BA$. 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$.
My Try: From the fact that $A$ has distinct eigen values, we can say that $A$ is diagonalizable. And from the fact fact that $AB = BA$, I have shown the fact that $B$ also have distinct eigen values and hence also Diagonalizable.
It is also noticed that the matrix $P$ for which $P^{-1}AP = C$, the same matrix $P$ also satisfies $P^{-1}BP = D$, where $C,D$ are resp diagonal matrices.
I have also arrived the fact that if $D$ can be expressed uniquely expressed as a polynomial in $C$ with degree no more than $n − 1$, then $B$ can be expressed uniquely as a polynomial in $A$ with degree no more than $n − 1$.
Having Problem to show that $D$ can be expressed uniquely expressed as a polynomial in $C$ with degree no more than $n − 1$.
Thanks in Advance..
 A: You have reduced it to the case where $C,D$ are diagonal matrices, and $C$ has $n$ different eigenvalues. That means that the minimal polynomial of $C$ is the same as the characteristic polynomial. That is, no polynomial of degree smaller than $n$ annihilates $C.$ Or,
$$ I,C,C^2, C^3, \ldots, C^{n-1} $$ are linearly independent in the vector space of square matrices.The span of these is a dimension $n$ space consisting entirely of diagonal matrices. On the other hand, the space of diagonal matrices is dimension $n,$ meaning that all diagonal matrices are in the span, and all diagonal matrices $D$ can be written as a polynomial in $C$
A: Hint:
Since, you have reduced it to the diagonal case, we can consider $A$ and $B$ to be diagonal matrices without loss of generality. Let $x=[x_1,\dots,x_N]$ be a vector containing the diagonal elements of $A$ which are distinct. Consider the $N\times N$ vandermonde matrix
\begin{align}
V=\begin{bmatrix}
1 & x_1 & x_1^2 & \dots & x_1^{N-1} \\
1 & x_2 & x_2^2 & \dots & x_2^{N-1} \\
1 & x_3 & x_3^2 & \dots & x_3^{N-1} \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
1 & x_N & x_N^2 & \dots & x_N^{N-1}
\end{bmatrix}
\end{align} Thus the columns of the vandermonde matrix are actually equivalent to the vectors containing diagonal elements of the matrices $I,A,A^2,\dots,A^{N-1}$. Thus, if the columns of $V$ are linearly independent, then any vector $y$ can be expressed in terms of columns of $V$ which directly implies that your requirement.
Now note that $$\det(V)=\prod_{1\leq i < j \leq N}(x_i-x_j)$$
