Evaluate $\int_0^\infty {\rm Tr}\left( {\bf A}^{-1} (x \,{\bf A}+{\bf I})^{-1} -\frac{1}{2+x} {\bf I} \right) dx$ I would like to evaluate the following integral.
\begin{align}
\int_0^\infty {\rm Tr}\left( {\bf A}^{-1} (x \,{\bf A}+{\bf I})^{-1} -\frac{1}{2+x} {\bf I} \right) dx
\end{align}
where ${\bf A} \in \mathbb{R}^{n \times n}$ is a real positive definte matrix and ${\bf I}\in \mathbb{R}^{n \times n}$  is an identity.  
Unfortunately, my matrix calculus is very weak.  So, any reference where I can look up this would also be great. 
For the scalar case, the integral is equal to 
\begin{align}
\int_0^\infty  \frac{\frac{1}{a}}{ax+1}-\frac{1}{2+x} dx=\log(2)-\log(a).
\end{align}
Thanks.
 A: Write $D = P AP^{-1}$ where $D = \operatorname{diag}(\lambda_1,\dots,\lambda_n)$ is diagonal with $\lambda_i > 0$. Then
$$ P (A(xA + I))^{-1} P^{-1} = (P A(xA + I) P^{-1})^{-1} = (x PA^2 P^{-1} + PAP^{-1})^{-1} = (xD^2 + D)^{-1}.$$
Using the invariance of trace under conjugation, we have
$$ \operatorname{Tr} \left( (A(xA + I))^{-1} - \frac{I}{2 + x} \right) = \operatorname{Tr} \left( P \left((A(xA + I))^{-1} - \frac{I}{2 + x} \right) P^{-1} \right) =\\
\operatorname{Tr} \left( (xD^2 + D)^{-1} - \frac{I}{2 + x} \right) = \sum_{i=1}^n \frac{1}{x \lambda_i^2 + \lambda_i} - \frac{1}{2 + x} = \sum_{i=1}^n \frac{x(1 - \lambda_i)^2 + 2 - \lambda_i}{(2 + x) \lambda_i(x\lambda_i + 1)}.$$
This is a rational function whose integral you can calculate explicitly.
A: As requested in the comments, here is a by-hand evaluation of the scalar integral.
The indefinite integral of the scalar integrand is:
$$I(x) := \int \left(\frac{\frac{1}{a}}{ax+1} - \frac{1}{2+x}\right)dx = \frac{\log(ax+1)}{a^2} - \log(x+2) + C.$$
The definite integral is:
$$\int_0^\infty \left(\frac{1/a}{ax+1} - \frac{1}{2+x}\right)dx = I(\infty)-I(0).$$
Now $I(0) = -\log(2) + C$. To compute $I(\infty)$, we use the rules of logarithms to further combine terms:
$$\frac{\log(ax+1)}{a^2} - \log(x+2) = \log\left(\frac{(ax+1)^{1/a^2}}{x+2}\right).$$
Asymptotically the numerator within the logatirhm acts as $x^{1/a^2}$ as $x \rightarrow \infty$, and the denominator acts as $x$ in the same limit. So the ratio within the logarithm approaches zero if $1/a^2 < 1$ and infinity if $1/a^2 > 1$. Outside the logarithm this corresponds to values for $I(\infty)$ of $-\infty$ and $+\infty$, respectively.
Hence
$$\int_0^\infty \left(\frac{1/a}{ax+1} - \frac{1}{2+x}\right)dx = \begin{cases}
-\infty, & \quad a > 1 \\
+\infty, & \quad a < 1.
\end{cases}$$
