# Quick method in solving symmetric linear equation

10 visualizzazioni (ultimi 30 giorni)
Ziwen Gu il 22 Ott 2023
Commentato: Ziwen Gu il 23 Ott 2023
In simulation of PDE, I have to solve a linear equation: Ax = b for many times( with different b, iteratively ) .
The matrix A is symmetric with size of about 1e6*1e6 , and doesn't change in time. So I use cholesky decomposition
R = chol(A);
and solve two triangle equation
y = linsolve(R',b,opts.LT = true);
x = linsolve(R ,y,opts.UT = true);
at each iteration.
More detailed, matrix A is like:
A = M + S*inv(M)*S + S ;
where M is a diagonal matrix( lump mass matrix in finite element method ) , S is a symmetric stiff matrix.
My question is : is there a better way to solve this equation?( quick and stable ) All numerical method are acceptable, for example preconditioner, iterative method...
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Bruno Luong il 22 Ott 2023
Modificato: Bruno Luong il 22 Ott 2023
If your S is sparse you should look at iterative methods. For symmtric case it is recommended to use pcg. To take further advantage you might want to find a cheap preconditioner. The problem is you have to iterate for new rhs.
The cholesky decomposition will fill the entire half matrix, so it will not be cheap. I'm even surprised you can even do it with 1e6 matrix.
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Ziwen Gu il 22 Ott 2023
Yes it's very stupid, I find Matlab uses cholesky decomposition when I solve A\b, so I adapt this method...

Accedi per commentare.

### Più risposte (1)

Christine Tobler il 23 Ott 2023
You can definitely use iterative methods such as pcg. The success of this usually depends on how well-conditioned your matrix is, or how good of a preconditioner you can come up with.
In terms of direct methods, consider using permuted Cholesky (the three-output syntax). The permutation allows reduction of fill-in in a sparse direct factorization in many cases - meaning you need less storage and less computation for the factor R, as it contains fewer nonzero elements.
You can also try the decomposition object (which uses permuted Cholesky, and additionally stores the factorization of A in the same internal format used in backslash, instead of converting it to a generic sparse matrix):
dA = decomposition(A);
x = dA \ b;
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Ziwen Gu il 23 Ott 2023
Thanks a lot for your reply! I further study the structure of A, its condition number is about 10(very well-conditioned), and I use incomplete cholesky as preconditioner, it works well.
I will try another two methods in spare time. Thanks again for your help!

Accedi per commentare.

### Categorie

Scopri di più su Mathematics and Optimization in Help Center e File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by