# Is LinearSolve the most robust way to solve the equation $Ax=b$?

I want to solve the equation $Ax=b$, where $A$ is an $n\times n$ matrix, and $x$ and $b$ are $n\times 1$ column vectors. Here $n=124$.

LinearSolve[A,b]

I got the following warning message:

LinearSolve::luc: Result for LinearSolve of badly conditioned matrix {{2075.28,-2527.91,633.713,-282.942,160.179,-103.364,72.5099,-53.9143,41.8539,-33.5945,27.6963,-23.3423,20.0412,-17.4831,15.4647,-13.8482,12.5376,<<17>>,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,<<74>>},<<49>>,<<74>>} may contain significant numerical errors. >>

The determinant of the matrix $A$ in this case is about $10^{282}$. I also used MATLAB to solve the same problem; there is no warning massage and the result is consistent with the Mathematica result. This is only a small part of a program, and it can be checked that the final result is correct despite the warning message. But it is disturbing that the precision may not be good enough.

What is the best way to solve the equation $Ax=b$ when the matrix $A$ is large? How can we increase the precision or control the precision?

• You could try using the singular values decomposition. Better though might be to opt for a least-squares solution. As for the determinant, it is not the determining (if you will) factor. The condition number is what actually matters. (I gave an upvote to a response that says pretty similar things but wanted to also raise the possibility of a least squares approach). Oct 22 '13 at 20:48

The determinant isn't very useful, but the condition number is: You can use SingularValuesList to get the largest and the smallest singular value. If the ratio between the two is too large, the matrix is ill-conditioned.
Solving an ill-conditioned linear system will still give "exact" results (the same as Matlab), but you'll get wildly different results for small perturbations of $A$ or $b$.
What is the best way to solve the equation $Ax=b$ when the matrix $A$ is large?