# extract constant from inverse of sum of symmetric matrices

I need to take the derivative with respect to p of an inverse of the sum of two symmetric matrices, where p is part of a constant in front of one of the matrices. That is, I have:

$$\left[\frac{1}{p^2}A+B\right]^{-1}$$

where $A$ is symmetric and $B$ is a diagonal matrix. I would like to be able to get the $\frac{1}{p^2}$ outside the inverse of the sum, similar to the Sherman-Morrison decomposition (which doesn't work because $B$ is a diagonal matrix).

If $B$ is invertible and $AB^{-1}$ has spectral radius $R$, then for $|p^2|>R$ we can write \eqalign{ \left(\dfrac{A}{p^2} + B\right)^{-1} &= \left(\left(\dfrac{AB^{-1}}{p^2} + I\right)B\right)^{-1} = B^{-1} \left(\dfrac{AB^{-1}}{p^2} + I\right)^{-1}\cr&= \sum_{j=0}^{\infty} \dfrac{(-1)^j}{p^{2j}} B^{-1}(AB^{-1})^j\cr &= B^{-1} - \dfrac{1}{p^2} B^{-1}AB^{-1} + \dfrac{1}{p^4} B^{-1}AB^{-1}AB^{-1} + \ldots} Similarly, if $A$ is invertible and $AB^{-1}$ has spectral radius $S$ there is a series expansion in positive powers of $p^2$, convergent for $|p^2| < 1/S$: \eqalign{p^2 A^{-1} &- p^4 A^{-1} B A^{-1} + p^4 A^{-1}BA^{-1}BA^{-1} + \ldots\cr &= \sum_{j=0}^\infty (-1)^j p^{2j+2} A^{-1} (BA^{-1})^j}