Finding $\det(f(A))$, given the eigenvalues of $A$. Consider a matrix $A$ with given eigenvalues. Given any expression involving $A$ and its inverse as $f(A)$. If I wish to find $\det(f(A))$, is there any algorithmic approach  that may be followed to achieve the result. For example, consider the problem below:

Eigenvalues of $A$ are $1,2,-1$, $B=f(A)=I+A-A^{-1}+A^{2}$. Find $\det(B)$.

I do not have any idea on how to come up with a generalised approach for solving this kind of problem. It is absolutely clear that Cayley Hamilton theorem has to be used somehow, but how exactly is not clear. Any hints are appreciated. Thanks.
 A: According to the Spectral Mapping Theorem, the eigenvalues of $f(A)$ are precisely
$$f(1), f(2), f(-1)$$
and therefore since the determinant is the product of eigenvalues
$$\det f(A) = f(1)f(2)f(-1).$$
In general we have
$$\det f(A) = \prod_{\lambda \in \sigma(A)} f(\lambda)$$
where the eigenvalues are taken with multiplicity.
A: $\DeclareMathOperator{\Spec}{Spec}$If $A$ has all distinct eigenvalues, then it is of the form $S\Lambda S^{-1}$ where $S$ is the matrix of its eigenvectors and $\Lambda$ is the diagonal matrix of its eigenvalues --- this is the diagonalisation of $A$. If $f$ is a rational function, then you can easily show yourself that $f(S\Lambda S^{-1}) = S f(\Lambda) S^{-1}$, and consequently that the eigenvalues of $f(A)$ are precisely just $f(\lambda)$ where $\lambda$ is an eigenvalue of $A$. Then, use the fact that the determinant is a product of the eigenvalues to get, as also mentioned in the other answer, $$\det f(A) = \prod_{\lambda}f(\lambda)$$ where the product runs over all eigenvalues $\lambda$ of $A$.
This also holds even if $A$ doesn't have distinct eigenvalues. This is because all matrices (over $\mathbb C$) admit a Jordan canonical form, which can be used similarly to the diagonalisation idea to solve the problem. In particular, we only need to solve it for each Jordan block of the form $$J=\begin{bmatrix}\lambda&1&&&\\&\lambda&1&&\\&&\ddots&&\\ &&&\lambda&1\\ &&&&\lambda\end{bmatrix}$$
which has eigenvalue $\lambda$, and you can check for yourself that $J^n$ indeed has eigenvalues $\lambda^n$ for all $n$. (Just work out $J^n$ explicitly and read off the diagonal elements.)
The conclusion can be summarised succinctly as $f(\Spec A) = \Spec f(A)$, where $\Spec$ (also written $\sigma$) denotes the "spectrum" of $A$, i.e. its set of eigenvalues counted with multiplicity. This solves your problem as the determinant is just the product over the spectrum of the matrix.
