Let $A,B$ are similar matrices. Then, under what condition on matrix $Q$, we have $tr(AQ)=tr(BQ)$
$A$ and $B$ are similar matrices, so there exist an invertible matrix $P$ such that $$A=P^{-1}BP\\ AQ=P^{-1}BPQ\quad \text {(taking $Q$ invertible matrix)}\\ tr(AQ)=tr(P^{-1}BPQ)$$ But unable to reach at result.What will happen if $Q$ is singular matrix?
I know that similar matrices have same eigenvalues but not getting a way to use this. Any help is appreciated. Thank you.
The linear functional $\phi: Q \mapsto \text{tr}(AQ) - \text{tr}(BQ)$ on $n \times n$ matrices is nonzero if $A \ne B$, and so those $Q$ for which $\phi(Q) = 0$ form a linear subspace of the $n \times n$ matrices with codimension $1$. For any $n \times n$ matrix $X$, there is a scalar $z$ such that $X + z (A-B)^*$ is in this subspace. Here ${}^*$ denotes the Hermitian transpose (or the transpose in the real case).