Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
    
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). –  Daniel Lichtblau Oct 22 '13 at 20:48
add comment

1 Answer

up vote 7 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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