[Numerical] Why is it better to solve Ax=b instead of calculating inv(A)

  • Context: Undergrad 
  • Thread starter Thread starter nonequilibrium
  • Start date Start date
  • Tags Tags
    Numerical
Click For Summary

Discussion Overview

The discussion revolves around the numerical methods for solving the equation Ax=b, particularly in the context of iterative solutions where the matrix A is reused. Participants explore the implications of using matrix inversion versus alternative methods like Gaussian elimination and LU decomposition.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant suggests that while calculating the inverse of A could solve Ax_{i+1}=x_i, there may be better methods like Gaussian elimination.
  • Another participant argues against using the inverse due to concerns about stability, accuracy, and time, especially when the matrix A is reused in iterative solutions.
  • A suggestion is made to compute the LU decomposition as a more efficient alternative, which is cheaper than Gaussian elimination or matrix inversion and retains similar stability and accuracy advantages.
  • One participant notes that if the iteration only takes a few steps, the efficiency of using the inverse may not be evident compared to Gaussian elimination.
  • Another participant points out that calculating the inverse through LU decomposition can be inefficient if only a few solves are needed, especially if the matrix A is sparse, as the inverse tends to be fully populated.
  • A "rule of thumb" is proposed that explicitly inverting a matrix numerically is generally not advisable unless there is a strong justification for it.

Areas of Agreement / Disagreement

Participants express differing views on the efficiency and appropriateness of using matrix inversion versus other methods like Gaussian elimination and LU decomposition. There is no consensus on the best approach, as various factors such as the number of iterations and the properties of the matrix A are considered.

Contextual Notes

Participants highlight limitations related to the sparsity of matrix A, the computational overhead of LU decomposition, and the potential numerical conditioning issues when using the inverse.

nonequilibrium
Messages
1,412
Reaction score
2
Hello,

So I'm using a numerical method where I iteratively have to solve [itex]Ax_{i+1}=x_i[/itex] which can of course be done by calculating the inverse matrix, but something in the back of my mind is telling me that it is better to solve the equation using Gaussian elimination and substitution.

However, what is the reason for this? And is the difference relevant, or is merely a difference "in principle".
 
Physics news on Phys.org
There are lots of reasons not to use the inverse. Stability, accuracy, time. However, some of these reasons apply to a one-time solution of [itex]Ax=b[/itex]. Here you are apparently reusing the A matrix, iteratively solving [itex]Ax_{i+1} = x_i[/itex]. If you reuse A, timing considerations suggest you should compute the inverse of A instead of using Gaussian elimination.

There's an even better approach to using either of the techniques you mentioned. Compute the LU decomposition. It's cheaper to compute the LU decomposition than it is to use Gaussian elimination or the matrix inverse. LU backsubstitution is fast, faster than the matrix * vector computation, and the same stability and accuracy advantages that pertain to Gaussian elimination apply to LU decomposition.
 
Last edited:
The iteration usually takes only three steps though, so maybe it is not evident that the inverse is optimal relative to solving it by Gaussian elimination?

Interesting what you say about the LU decomposition...
 
Calculating the inverse efficiently (i.e. by doing an LU decomposition and then solving N right hand sides each containng one 1 and the rest of the entries 0) is an overhead of about N solves. So if you are only doing 3 solves anyway, you will lose unless N is very small.

In addition to D.H's points, often A is sparse and the LU decomposition has a similar amount of sparsity, but the inverse matrix is almost always fully populated. In that situation, multiplying by the inverse can be orders of magnitude more expensive than solving using the sparse matrices, quite apart from the numerical conditoning issues and the amount of storage that may be required for the inverse matrix.

My "rule of thumb" here is that explicitly inverting a matrix numerically is NEVER the right thing to do, unless you can make a very good argument in favor of it. Even when it appears to be "no worse" than equation solving, straightforward equation solving (based on LU decomoposition for example) is usually not the only alternative.
 
Thank you both for the good advice.
 

Similar threads

  • · Replies 16 ·
Replies
16
Views
5K
  • · Replies 8 ·
Replies
8
Views
12K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K