# Can this matrix inverse be re-written?

I have a matrix inverse of the form $(\mathbf{AB}+\mathbf{C})^{-1}$, where each matrix is $2\times 2$ and each of the subelements below are known a priori.

$$\left( \left[ \begin{array}{cc} A_1&A_2\\ A_3&A_4\\ \end{array} \right]\mathbf{B}+ \left[ \begin{array}{cc} C_1&C_2\\ C_3&C_4\\ \end{array} \right] \right)^{-1}$$

$\mathbf{B}$ is also known, but it varies in each iteration, whereas $\mathbf{A}$ and $\mathbf{C}$ are fixed for all. When I implement the above in code, I run into instability issues with numerical matrix inverses.

I was wondering if it would be possible to re-write the above inverse using all the known terms so that the inverse is implemented as a series of matrix/scalar multiplications instead of finding the inverse numerically.

If you get $B$ that gives a singular matrix that you are trying to invert, there's no way around it, there's no inverse; similarly if $B$ gives a near singular matrix you are trying to invert, standard numerical inversion with floating point may run into problems.
It is indeed possible to write down the formula for the inverse in terms of the entries of $B$, if the entries of $A$ and $C$ are given. You can just use the formula for $2 \times 2$ inverse to get the formula. However, in the formula, you divide by the determinant; if this is too close to 0, then you can have numeric instability, and you'll basically need to use an arbitrary precision floating point library to do the computation so that you can estimate the determinant accurately even though it's a small number defined by the difference of two nearly equal numbers that are much larger (which is how the numeric instability arises, from lack of floating-point number accuracy when you subtract two numbers that are almost equal).
Similarly in your special $AB + C$ case, you can run into problems if all the numerator terms for entries in your inverse matrix are small numbers given as the difference of nearly equal much larger numbers, and an arbitrary precision floating point library will fix this as well. Alternatively, if all your matrix entries in $A,B,C$ can be expressed as fractions, you can get an exact fraction for the determinant using a rational number arbitrary precision library.