Numerical Linear Algebra: Direct Methods

why you rarely form the inverse

On paper the solution of A x = b is written x = A^{-1} b, so a natural reflex is to compute the inverse matrix A^{-1} and multiply it by b. Almost always, this is the wrong thing to do. In numerical linear algebra the inverse is a quantity you write down to reason about, not one you actually compute, and 'never invert the matrix to solve a system' is one of the field's firmest pieces of folk wisdom.

There are two solid reasons. First, cost: forming A^{-1} explicitly takes about 2 n^3 flops (it is like solving n systems at once, one for each column of the identity), and then x = A^{-1} b costs a further 2 n^2. Solving A x = b directly via an LU factorization costs only about 2 n^3 / 3 for the factorization plus n^2 for the solve — roughly three times cheaper, and far cheaper still when you reuse one factorization for many right-hand sides. Second, accuracy: solving with the factorization (forward and back substitution on L and U) is backward stable, whereas forming the inverse and multiplying introduces extra rounding and is measurably less accurate for the SAME problem. So the LU solve wins on both speed and precision.

The right mental model is: factor, then solve. Keep the LU (or Cholesky) factorization and apply it to each b; never materialize A^{-1}. The same principle generalizes — you do not form A^{-1} B to solve A X = B for a matrix B, you do triangular solves; you do not invert to get a determinant, you read it off the factorization. The rare legitimate exceptions are when the inverse itself is the genuine end-product you need (for instance certain entries of a covariance matrix in statistics), and even then specialized methods are usually better. If you catch yourself typing 'inv(A)*b', stop and use a solve instead.

To get x with A 1000x1000: an LU solve costs ~6.7e8 flops and is backward stable; forming A^{-1} then multiplying costs ~2e9 flops AND loses accuracy — strictly worse on both counts.

The factor-and-solve route is both cheaper and more accurate; the explicit inverse is almost never warranted.

The phrase x = A^{-1} b is mathematically correct but numerically a bad recipe: it tells you what x is, not how to compute it. Use a solve (forward/back substitution on the factorization), not a matrix inversion.

Also called
don't invert the matrixinverse avoidance避免求逆不要求逆矩陣