MATLAB: Updating inverse of a lower triangular matrix

lower triangular matrixupdating inverse

Dear All,
I need to solve a matrix equation Ax=b, where the matrix A is a lower triangular matrix and its dimension is very big (could be 10000 by 10000). Now I need to change a row of A and solve Ax=b again (this change will be many times). In order to speed up the calculation, a good approach is to calculate the inverse of matrix A and use the substitution to solve x. But when a row of matrix A is changed, I need to update the inverse of A. Is there a good idea to update the inverse of matrix A?

Best Answer

NO. Computing the inverse of A, if it is lower triangular is a BAD idea.
Solving the problem x = A\b is a forward substitution, so fast as hell. On the order of a matrix*vector multiply in terms of the computational load. I.e., essentially an O(n^2) operation.
Wasting the time to do do an update of an inverse matrix, so that you can then do a matrix multiply is just silly.
A = tril(rand(10000));
b = rand(10000,1);
timeit(@() A*b)
ans =
0.067386
timeit(@() A\b)
ans =
0.090263
So the backslash took only slightly more time than a multiply. The update of a matrix inverse would take way more time than that. And for no good reason at all, only to still need to do a matrix*vector multiply.
For example, one can compute the change to a matrix inverse under a rank 1 update. (which is exactly what you want to do.) The classic solution is due to Sherman & Morrison. (I remember Woodbury in the name when I learned about it a zillion years ago, but Sherman-Morrison is a special case.)
https://en.wikipedia.org/wiki/Sherman–Morrison_formula
Now, look carefully at the computations in the formula shown. While you could do them, you need to recognize that they would involve more work than a simple matrix*vector multiply would entail. And since the forward substitution itself is trivial, you cannot possibly gain here.