# Is there a way to update the inverse of a sum of two matrices following a rescaling of one of them?

Suppose I have two matrices $A$ and $B$ (let's assume that both $A$ and $B$ are invertible, as is their sum), and a scalar $g$.

I am interested in the matrix

$$M^{-1} = (A + gB)^{-1}$$

I am aware of various expressions for computing this inverse in general, but I am interested in whether, if I calculate $M^{-1}$ for some value of $g$, is there a way to quickly update $M^{-1}$ following an update to the value of $g$?

I am specifically interested in whether this can be done without performing any additional inversions after updating $g$, i.e. if I can just store $A$, $B$, $A^{-1}$, $B^{-1}$ (or some factorizations of them) and the previous value of $g$ in memory, and then somehow update $M^{-1}$ as a function of these?

I've just found this, which suggests a solution if $B=I$, but I fear I may be out of luck for the more general case where $B\neq I$. I would also potentially be interested in solutions which rely on sparsity of either $A$ or $B$, as I may have some cases in which this is true.

• You can use the following : $(A + gB)^{-1} = ((AB^{-1} + gI)B)^{-1} = B^{-1} (AB^{-1} + gI)^{-1}$
– user44092
Commented Apr 11, 2016 at 22:57
• Ah, that does look handy. Thanks! Commented Apr 11, 2016 at 23:02

$$(A+gB)^{-1} = B^{-1}(AB^{-1} + gI)^{-1}$$
and let $$AB^{-1}=PDP^{-1}$$ where $P$ gives the eigenvectors and $D$ the eigenvalues of $C=AB^{-1}$, which allows us to apply this previous answer to get
$$(A+gB)^{-1} =B^{-1}P(D + gI)^{-1}P^{-1}$$
$P$ and $B^{-1}P$ can be pre-computed once, and $(D+gI)^{-1}$ is easy to invert quickly because it is diagonal. Neat!