If you’re doing a lot of simulations, optimizations or other muckity-muck, it’s easy to start writing down equations with matrices like \(A^{-1}B\) inside of them. And, depending on the application, it might be a really good idea to precompute this matrix. But there’s that pesky inverse operation, and generally inverting a matrix is a no-no since it can easily land you in trouble when that matrix isn’t really very stable.
So, here’s a trick you can use in these situations to avoid explicitly inverting the matrix \(A\). It turns out that instead we can just solve the system \(Ax=b\) a bunch of times in order to explicitly compute the product matrix \(A^{-1}B\).
It’s pretty straightforward. If we want to extract the \(i\)th column from \(A^{-1}B\), we need to solve the equation \(x = A^{-1}B e_i\), where \(e_i\) is the indicator vector with \(0\)s everywhere except the \(i\)th entry, which is \(1\). If we just massage this equation a bit, we get \(Ax = Be_i = b_i\) where \(b_i\) is the \( i\)th column of \( B\). Sweet! If we have a good way to pre-factor \( A\) or otherwise prepare it for repeated solves, we can also keep this solution method pretty efficient.



