Are iterative methods always better than direct methods for solving large linear systems?
Show older comments
I am trying to solve a very sparse linear system Ax = b. A is very sparse - if A is of size N^2 x N^2, all nontrivial elements for any row k are located in between (k-2N, k+2N). The overall the number of nontrivial elements in A is bounded by 13*N^2 (for a matrix with N^4 elements)
Now back to the original question: Currently I am using mldivide to solve the system. On a 1e6 x 1e6 matrix, the program takes around 60-75s 64 bit machine. Now it is possible to beat this performance using iterative methods? The ones I have tried (built into MATLAB) do not seem to offer any advantages; however, I think that may be due to the fact that I am not using a preconditioner. The problem is, how do I effectively get a preconditioner? I tried using ilu, but that is also pretty slow (and there is no guarantee that it will do the trick).
Thanks, Peter
Accepted Answer
More Answers (2)
John D'Errico
on 12 Jan 2026
Edited: John D'Errico
on 12 Jan 2026
The use case which some may miss here, is the very large array, where a dense solver fails due to memory, but even the sparse one fails due to fill-in, BUT, the problem is solvable using an iterative solver. This may require a sufficiently well-posed array that the iterative solver has no problem in converging. In this example, I'll make up a case where the matrix is extremely well-posed, just so I can solve it trivially online.
A = sprandn(1e5,1e5,0.001)*0.001 + speye(1e5);
max(sum(abs(A),2))
Clearly A is moderately sparse, but it is far too non-sparse that a sparse solver would fail miserably due to fill-in. And a dense solver would be a complete waste of time. As well, I've constructed A to be quite well-posed. Any iterative solver worth its salt will converge easily enough.
X0 = ones(1e5,1);
b = A*X0;
tic,X = lsqr(A,b); toc
norm(X - X0)
On a somewhat worse system, now we could employ an incomplete preconditioner,
Have I ever had a real world case where the sparse solvers were the only recourse, and I needed to employ a preconditioner? YES.
Wolfgang Schwanghart
on 9 May 2011
1 vote
Why is performance a problem? Do you have to solve the system repeatedly or do you want to solve larger systems? If former is the case, then take a look at Tim Davis' factorize
If latter is the case, then I hope someone else will be able to provide an answer.
HTH, W.
Categories
Find more on Sparse Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!