Integral of function depending on positive definite matrix Consider a positive definite matrix $M$, and consider the integral
$$\int_{-\infty}^{\infty}dx(x^2I+M^2)^{-1}$$
If $v_n$ is an eigenvector of $M$ with eigenvalue $\lambda_n$, then the integral when applied to $v_n$ is
$$\int_{-\infty}^{\infty}dx(x^2I+M^2)^{-1}v_n=\int_{-\infty}^{\infty}dx(x^2+\lambda_n^2)^{-1}v_n=\pi\lambda_n^{-1}v_n$$
And since this is true for all $v_n$, I'd like to claim that this integral is equal to $\pi M^{-1}$. Is this true? Can this be done with other integrals?
 A: As $M$ psd, we can decompose $M$ as
$$M=PDP^{-1}$$
with $D$ a diagonal matrix with positive elements $\{\lambda_i\}_{i=1,...,n}$.
Then
$$\begin{align}
(x^2I+M^2)^{-1} &=(x^2I+PD^2P^{-1})^{-1}\\
&=(x^2P^2P^{-2}+PD^2P^{-1})^{-1}\\
&=\left(P(x^2I+D^2)P^{-1}\right)^{-1}\\
&=P(x^2I+D^2)^{-1}P^{-1} \tag{1}\\
\end{align}
$$
$(x^2I+D^2)^{-1}$ is a diagonal matrix with elements $\frac{1}{x^2+\lambda_i^2}$ for $i=1,...,n$ and
$$\int_{-\infty}^{+\infty}\frac{1}{x^2+\lambda_i^2}dx =\frac{\pi}{\lambda_i}$$
Then  $\int_{-\infty}^{+\infty}(x^2I+D^2)^{-1}dx$ is a diagonal matrix with elements equal to $$\frac{\pi}{\lambda_i}  \qquad \text{for } i=1,...,n$$
or $$\int_{-\infty}^{+\infty}(x^2I+D^2)^{-1}dx = \pi D^{-1}$$
Finally, from $(1)$ we have
$$\begin{align}
\int_{-\infty}^{+\infty}(x^2I+M^2)^{-1}dx &=P\left(\int_{-\infty}^{+\infty}(x^2I+D^2)^{-1}dx \right)P^{-1}\\
&=P\left(\pi D^{-1}\right)P^{-1}\\
&=\pi M^{-1}\\
\end{align}
$$
Remark: the integral only works with psd matrices. If the matrix $M$ has a non-positve eigenvalue, the integral diverges.
A: Another way to express the proof provided by NN2 is recall that the normalized eigenvectors $\{v_k\}_{k=1}^n$ of an $n$-dimensional matrix $M$ generate the resolution of the identity $I=\sum_{k=1}^n v_k v_k^\top$. Then the idea of the OP yields
\begin{align}
 \int_{-\infty}^{\infty}dx(x^2I+M^2)^{-1}
&= \int_{-\infty}^{\infty}dx(x^2I+M^2)^{-1}I\\
&= \int_{-\infty}^{\infty}dx(x^2I+M^2)^{-1} \sum_{k=1}^nv_k v_k^\top\\
&= \sum_{k=1}^n\int_{-\infty}^{\infty}dx(x^2+\lambda_k^2)^{-1} v_k v_k^\top\\
&= \sum_{k=1}^n \pi \lambda_k^{-1} v_k v_k^\top\\
&= \sum_{k=1}^n \pi M^{-1} v_k v_k^\top\\
&=\pi M^{-1}.
\end{align}
