Eigenvalues of composition of functions I am trying to do the following exercise:
Let $V$ be a $K$-finite dimensional vector space and let $f,g \in Hom(V,V)$. Define $Spec(f)=\{\alpha \in K / \alpha \space \text{is an eigenvalue of f}\}$. Prove that $Spec(f \circ g)=Spec(g \circ f)$. 
Suppose one of the two linear transformations is an isomorphism, w.l.g., suppose $g$ is an isomorphism, then if $|f|_{\mathcal B}=A, |g|_{\mathcal B}=B$ for some basis $\mathcal B$ of $V$, then the characteristic polynomial of $AB$ is $$\mathcal X_{AB}=det(\alpha I_n - AB)$$$$=det(B(\alpha I_n - AB)B^{-1})$$$$=det(\alpha I_n - BA)=\mathcal X_{BA}$$
From here it follows $\alpha$ is an eigenvalue of $f \circ g$ if and only if it is an eigenvalue of $g \circ f$. 
I don't know what to do for the general case. Any help would be appreciated.
 A: A more direct proof would be:
Assume $\lambda$ is a non-zero eigenvalue of $f\circ g$, i.e. 
$$ (f\circ g)v=\lambda v$$ for some $0\neq v\in V$.
Application of $g$ on both sides shows
$ (g\circ f) (g(v)) =\lambda g(v)$
which shows that $\lambda$ is also an eigenvalue of $g\circ f$ (with eigenvetor $g(v)$, which is not equal to $0$, otherwise $(f\circ g)v=\lambda v$ would be zero, a contradiction to $\lambda,v\neq 0$). 
If $\lambda=0$ is an eigenvalue of $f\circ g$, then $\text{det}(f\circ g)=0$, but then also $\text{det}(g\circ f)=0$ so $g\circ f$ is also not-injective, i.e. has eigenvalue $0$.
This shows that every eigenvalue of $f\circ g$ is also one of $g\circ f$. The other inclusion works the same way.
A: This works not just for square matrices but all matrices where the product makes sense. A reference is Godsil and Royle's book Algebraic graph theory, Lemma 8.2.4. Their ingenious proof is to note that
$$
\det\left(\begin{bmatrix}I & A \\ B & I\end{bmatrix}
\begin{bmatrix}I & 0 \\ -B & I\end{bmatrix}\right)
= \det\left(\begin{bmatrix}I & 0 \\ -B & I\end{bmatrix}
\begin{bmatrix}I & A \\ B & I\end{bmatrix}\right).
$$
The multiplicities of the eigenvalues will, in general, be different.
The result is used in graph theory to relate the number of spanning trees of a graph to that of its line graph.
