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

by nonequilibrium
Tags: inva, numerical, solve
 P: 1,416 Hello, So I'm using a numerical method where I iteratively have to solve $Ax_{i+1}=x_i$ 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".
 Mentor P: 15,147 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 $Ax=b$. Here you are apparently reusing the A matrix, iteratively solving $Ax_{i+1} = x_i$. 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.