TITLE: If $A^kX=B^kY$ for all $k$, is $X=Y$?
QUESTION [6 upvotes]: This one is more general than the one I asked before.
Given invertible matrices $A,B$ and matrices $X,Y$ all with size $n$, such that $A^k X = B^k Y$ for $k=1,2,...,2n$. Does it follow that $X = Y$?
I have no idea where to work. Thanks for any help.

REPLY [11 votes]: Let $$C= \begin{pmatrix} A & 0 \\0 & B \\
\end{pmatrix} \,.$$
Then $C$ is invertible with inverse $C^{-1}= \begin{pmatrix} A^{-1} & 0 \\0 & B^{-1} \\
\end{pmatrix} \,.$
Let $P(x)=x^{2n}+a_{2n-1}x^{2n-1}+....+a_0$ be the Characteristic Polynomial of $C$. The, since $C$ is invertible we have $a_0 \neq 0$.
Thus
$$I_{2n}=-\frac{1}{a_0} [ C^{2n}+a_{2n-1}C^{2n-1}+....+a_1C] \,.$$
Let $Q(x)=-\frac{1}{a_0} [ x^{2n}+a_{2n-1}x^{2n-1}+....+a_1x] \,.$
Since $Q(C)=I_{2n}$ from the definition of $C$ we get $Q(A)=Q(B)=I_n$. 
From $A^kX=B^kY, \forall 1 \leq k \leq 2n$ we get $Q(A)X=Q(B)Y$, thus $X=Y$:
$$X=I_nX=Q(A)X=-\frac{1}{a_0} [ A^{2n}X+a_{2n-1}A^{2n-1}X+....+a_1AX]=-\frac{1}{a_0} [ B^{2n}Y+a_{2n-1}B^{2n-1}Y+....+a_1BY]=Q(B)Y=I_nY=Y \,.$$