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$.


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?

  • $\begingroup$ 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). $\endgroup$ Oct 22 '13 at 20:48

The determinant of the matrix A in this case is about 10^282

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$.

A typical example is finding the intersection between two almost parallel lines. Mathematica will give you the right intersection, but if equations of the lines are just a little of (e.g. due to rounding errors or measurement noise), it might not be the point you're looking for.

What is the best way to solve the equation $Ax=b$ when the matrix $A$ is large?

I think the best way is not to solve it at all. A "large" matrix (with large coefficients or large determinant) is perfectly ok, but a badly conditioned matrix is often a sign that something's wrong with the problem statement.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.