Generalized minimal residual method
In mathematics, the generalized minimal residual method (GMRES) is an iterative method for the numerical solution of an indefinite nonsymmetric system of linear equations. The method approximates the solution by the vector in a Krylov subspace with minimal residual. The Arnoldi iteration is used to find this vector. The GMRES method was developed by Yousef Saad and Martin H. Schultz in 1986.[1] It is a generalization and improvement of the MINRES method due to Paige and Saunders in 1975.[2][3] The MINRES method requires that the matrix is symmetric, but has the advantage that it only requires handling of three vectors. GMRES is a special case of the DIIS method developed by Peter Pulay in 1980. DIIS is applicable to non-linear systems.
The method
Denote the Euclidean norm of any vector v by [math]\displaystyle{ \|v\| }[/math]. Denote the (square) system of linear equations to be solved by [math]\displaystyle{ Ax = b. }[/math] The matrix A is assumed to be invertible of size m-by-m. Furthermore, it is assumed that b is normalized, i.e., that [math]\displaystyle{ \|b\| = 1 }[/math].
The n-th Krylov subspace for this problem is [math]\displaystyle{ K_n = K_n(A,r_0) = \operatorname{span} \, \{ r_0, Ar_0, A^2r_0, \ldots, A^{n-1}r_0 \}. \, }[/math] where [math]\displaystyle{ r_0 = b - A x_0 }[/math] is the initial error given an initial guess [math]\displaystyle{ x_0 \ne 0 }[/math]. Clearly [math]\displaystyle{ r_0 = b }[/math] if [math]\displaystyle{ x_0 = 0 }[/math].
GMRES approximates the exact solution of [math]\displaystyle{ Ax = b }[/math] by the vector [math]\displaystyle{ x_n \in x_0 + K_n }[/math] that minimizes the Euclidean norm of the residual [math]\displaystyle{ r_n= b - Ax_n }[/math].
The vectors [math]\displaystyle{ r_0,Ar_0,\ldots A^{n-1}r_0 }[/math] might be close to linearly dependent, so instead of this basis, the Arnoldi iteration is used to find orthonormal vectors [math]\displaystyle{ q_1, q_2, \ldots, q_n \, }[/math] which form a basis for [math]\displaystyle{ K_n }[/math]. In particular, [math]\displaystyle{ q_1=\|r_0\|_2^{-1}r_0 }[/math].
Therefore, the vector [math]\displaystyle{ x_n \in x_0 + K_n }[/math] can be written as [math]\displaystyle{ x_n = x_0 + Q_n y_n }[/math] with [math]\displaystyle{ y_n \in \mathbb{R}^n }[/math], where [math]\displaystyle{ Q_n }[/math] is the m-by-n matrix formed by [math]\displaystyle{ q_1,\ldots,q_n }[/math]. In other words, finding the n-th approximation of the solution (i.e., [math]\displaystyle{ x_n }[/math]) is reduced to finding the vector [math]\displaystyle{ y_n }[/math], which is determined via minimizing the residue as described below.
The Arnoldi process also constructs [math]\displaystyle{ \tilde{H}_n }[/math], an ([math]\displaystyle{ n+1 }[/math])-by-[math]\displaystyle{ n }[/math] upper Hessenberg matrix which satisfies [math]\displaystyle{ AQ_n = Q_{n+1} \tilde{H}_n \, }[/math] an equality which is used to simplify the calculation of [math]\displaystyle{ y_n }[/math] (see below). Note that, for symmetric matrices, a symmetric tri-diagonal matrix is actually achieved, resulting in the MINRES method.
Because columns of [math]\displaystyle{ Q_n }[/math] are orthonormal, we have [math]\displaystyle{ \begin{align} \| r_n \| &= \| b - A x_n \| \\ &= \| b - A(x_0 + Q_n y_n) \| \\ &= \| r_0 - A Q_n y_n \| \\ &= \| \beta q_1 - A Q_n y_n \| \\ &= \| \beta q_1 - Q_{n+1} \tilde{H}_n y_n \| \\ &= \| Q_{n+1} (\beta e_1 - \tilde{H}_n y_n) \| \\ &= \| \beta e_1 - \tilde{H}_n y_n \| \end{align} }[/math] where [math]\displaystyle{ e_1 = (1,0,0,\ldots,0)^T \, }[/math] is the first vector in the standard basis of [math]\displaystyle{ \mathbb{R}^{n+1} }[/math], and [math]\displaystyle{ \beta = \|r_0\| \, , }[/math] [math]\displaystyle{ r_0 }[/math] being the first trial residual vector (usually [math]\displaystyle{ b }[/math]). Hence, [math]\displaystyle{ x_n }[/math] can be found by minimizing the Euclidean norm of the residual [math]\displaystyle{ r_n = \tilde{H}_n y_n - \beta e_1. }[/math] This is a linear least squares problem of size n.
This yields the GMRES method. On the [math]\displaystyle{ n }[/math]-th iteration:
- calculate [math]\displaystyle{ q_n }[/math] with the Arnoldi method;
- find the [math]\displaystyle{ y_n }[/math] which minimizes [math]\displaystyle{ \|r_n\| }[/math];
- compute [math]\displaystyle{ x_n = x_0 + Q_n y_n }[/math];
- repeat if the residual is not yet small enough.
At every iteration, a matrix-vector product [math]\displaystyle{ A q_n }[/math] must be computed. This costs about [math]\displaystyle{ 2m^2 }[/math] floating-point operations for general dense matrices of size [math]\displaystyle{ m }[/math], but the cost can decrease to [math]\displaystyle{ O(m) }[/math] for sparse matrices. In addition to the matrix-vector product, [math]\displaystyle{ O(nm) }[/math] floating-point operations must be computed at the n -th iteration.
Convergence
The nth iterate minimizes the residual in the Krylov subspace [math]\displaystyle{ K_n }[/math]. Since every subspace is contained in the next subspace, the residual does not increase. After m iterations, where m is the size of the matrix A, the Krylov space Km is the whole of Rm and hence the GMRES method arrives at the exact solution. However, the idea is that after a small number of iterations (relative to m), the vector xn is already a good approximation to the exact solution.
This does not happen in general. Indeed, a theorem of Greenbaum, Pták and Strakoš states that for every nonincreasing sequence a1, ..., am−1, am = 0, one can find a matrix A such that the ||rn|| = an for all n, where rn is the residual defined above. In particular, it is possible to find a matrix for which the residual stays constant for m − 1 iterations, and only drops to zero at the last iteration.
In practice, though, GMRES often performs well. This can be proven in specific situations. If the symmetric part of A, that is [math]\displaystyle{ (A^T + A)/2 }[/math], is positive definite, then [math]\displaystyle{ \|r_n\| \leq \left( 1-\frac{\lambda_{\min}^2(1/2(A^T + A))}{ \lambda_{\max}(A^T A)} \right)^{n/2} \|r_0\|, }[/math] where [math]\displaystyle{ \lambda_{\mathrm{min}}(M) }[/math] and [math]\displaystyle{ \lambda_{\mathrm{max}}(M) }[/math] denote the smallest and largest eigenvalue of the matrix [math]\displaystyle{ M }[/math], respectively.[4]
If A is symmetric and positive definite, then we even have [math]\displaystyle{ \|r_n\| \leq \left( \frac{\kappa_2(A)^2-1}{\kappa_2(A)^2} \right)^{n/2} \|r_0\|. }[/math] where [math]\displaystyle{ \kappa_2(A) }[/math] denotes the condition number of A in the Euclidean norm.
In the general case, where A is not positive definite, we have [math]\displaystyle{ \frac{\|r_n\|}{\|b\|} \le \inf_{p \in P_n} \|p(A)\| \le \kappa_2(V) \inf_{p \in P_n} \max_{\lambda \in \sigma(A)} |p(\lambda)|, \, }[/math] where Pn denotes the set of polynomials of degree at most n with p(0) = 1, V is the matrix appearing in the spectral decomposition of A, and σ(A) is the spectrum of A. Roughly speaking, this says that fast convergence occurs when the eigenvalues of A are clustered away from the origin and A is not too far from normality.[5]
All these inequalities bound only the residuals instead of the actual error, that is, the distance between the current iterate xn and the exact solution.
Extensions of the method
Like other iterative methods, GMRES is usually combined with a preconditioning method in order to speed up convergence.
The cost of the iterations grow as O(n2), where n is the iteration number. Therefore, the method is sometimes restarted after a number, say k, of iterations, with xk as initial guess. The resulting method is called GMRES(k) or Restarted GMRES. For non-positive definite matrices, this method may suffer from stagnation in convergence as the restarted subspace is often close to the earlier subspace.
The shortcomings of GMRES and restarted GMRES are addressed by the recycling of Krylov subspace in the GCRO type methods such as GCROT and GCRODR.[6] Recycling of Krylov subspaces in GMRES can also speed up convergence when sequences of linear systems need to be solved.[7]
Comparison with other solvers
The Arnoldi iteration reduces to the Lanczos iteration for symmetric matrices. The corresponding Krylov subspace method is the minimal residual method (MinRes) of Paige and Saunders. Unlike the unsymmetric case, the MinRes method is given by a three-term recurrence relation. It can be shown that there is no Krylov subspace method for general matrices, which is given by a short recurrence relation and yet minimizes the norms of the residuals, as GMRES does.
Another class of methods builds on the unsymmetric Lanczos iteration, in particular the BiCG method. These use a three-term recurrence relation, but they do not attain the minimum residual, and hence the residual does not decrease monotonically for these methods. Convergence is not even guaranteed.
The third class is formed by methods like CGS and BiCGSTAB. These also work with a three-term recurrence relation (hence, without optimality) and they can even terminate prematurely without achieving convergence. The idea behind these methods is to choose the generating polynomials of the iteration sequence suitably.
None of these three classes is the best for all matrices; there are always examples in which one class outperforms the other. Therefore, multiple solvers are tried in practice to see which one is the best for a given problem.
Solving the least squares problem
One part of the GMRES method is to find the vector [math]\displaystyle{ y_n }[/math] which minimizes [math]\displaystyle{ \left\| \tilde{H}_n y_n - \beta e_1 \right\|. }[/math] Note that [math]\displaystyle{ \tilde{H}_n }[/math] is an (n + 1)-by-n matrix, hence it gives an over-constrained linear system of n+1 equations for n unknowns.
The minimum can be computed using a QR decomposition: find an (n + 1)-by-(n + 1) orthogonal matrix Ωn and an (n + 1)-by-n upper triangular matrix [math]\displaystyle{ \tilde{R}_n }[/math] such that [math]\displaystyle{ \Omega_n \tilde{H}_n = \tilde{R}_n. }[/math] The triangular matrix has one more row than it has columns, so its bottom row consists of zero. Hence, it can be decomposed as [math]\displaystyle{ \tilde{R}_n = \begin{bmatrix} R_n \\ 0 \end{bmatrix}, }[/math] where [math]\displaystyle{ R_n }[/math] is an n-by-n (thus square) triangular matrix.
The QR decomposition can be updated cheaply from one iteration to the next, because the Hessenberg matrices differ only by a row of zeros and a column: [math]\displaystyle{ \tilde{H}_{n+1} = \begin{bmatrix} \tilde{H}_n & h_{n+1} \\ 0 & h_{n+2,n+1} \end{bmatrix}, }[/math] where hn+1 = (h1,n+1, ..., hn+1,n+1)T. This implies that premultiplying the Hessenberg matrix with Ωn, augmented with zeroes and a row with multiplicative identity, yields almost a triangular matrix: [math]\displaystyle{ \begin{bmatrix} \Omega_n & 0 \\ 0 & 1 \end{bmatrix} \tilde{H}_{n+1} = \begin{bmatrix} R_n & r_{n+1} \\ 0 & \rho \\ 0 & \sigma \end{bmatrix} }[/math] This would be triangular if σ is zero. To remedy this, one needs the Givens rotation [math]\displaystyle{ G_n = \begin{bmatrix} I_{n} & 0 & 0 \\ 0 & c_n & s_n \\ 0 & -s_n & c_n \end{bmatrix} }[/math] where [math]\displaystyle{ c_n = \frac{\rho}{\sqrt{\rho^2+\sigma^2}} \quad\text{and}\quad s_n = \frac{\sigma}{\sqrt{\rho^2+\sigma^2}}. }[/math] With this Givens rotation, we form [math]\displaystyle{ \Omega_{n+1} = G_n \begin{bmatrix} \Omega_n & 0 \\ 0 & 1 \end{bmatrix}. }[/math] Indeed, [math]\displaystyle{ \Omega_{n+1} \tilde{H}_{n+1} = \begin{bmatrix} R_n & r_{n+1} \\ 0 & r_{n+1,n+1} \\ 0 & 0 \end{bmatrix} }[/math] is a triangular matrix with [math]\displaystyle{ r_{n+1,n+1} = \sqrt{\rho^2+\sigma^2} }[/math].
Given the QR decomposition, the minimization problem is easily solved by noting that [math]\displaystyle{ \begin{align} \left\| \tilde{H}_n y_n - \beta e_1 \right\| &= \left\| \Omega_n (\tilde{H}_n y_n - \beta e_1) \right\| \\ &= \left\| \tilde{R}_n y_n - \beta \Omega_n e_1 \right\|. \end{align} }[/math] Denoting the vector [math]\displaystyle{ \beta\Omega_ne_1 }[/math] by [math]\displaystyle{ \tilde{g}_n = \begin{bmatrix} g_n \\ \gamma_n \end{bmatrix} }[/math] with gn ∈ Rn and γn ∈ R, this is [math]\displaystyle{ \begin{align} \left\| \tilde{H}_n y_n - \beta e_1 \right\| &= \left\| \tilde{R}_n y_n - \beta \Omega_n e_1 \right\| \\ &= \left\| \begin{bmatrix} R_n \\ 0 \end{bmatrix} y_n - \begin{bmatrix} g_n \\ \gamma_n \end{bmatrix} \right\|. \end{align} }[/math] The vector y that minimizes this expression is given by [math]\displaystyle{ y_n = R_n^{-1} g_n. }[/math] Again, the vectors [math]\displaystyle{ g_n }[/math] are easy to update.[8]
Example code
Regular GMRES (MATLAB / GNU Octave)
function [x, e] = gmres( A, b, x, max_iterations, threshold) n = length(A); m = max_iterations; % use x as the initial vector r = b - A * x; b_norm = norm(b); error = norm(r) / b_norm; % initialize the 1D vectors sn = zeros(m, 1); cs = zeros(m, 1); %e1 = zeros(n, 1); e1 = zeros(m+1, 1); e1(1) = 1; e = [error]; r_norm = norm(r); Q(:,1) = r / r_norm; % Note: this is not the beta scalar in section "The method" above but % the beta scalar multiplied by e1 beta = r_norm * e1; for k = 1:m % run arnoldi [H(1:k+1, k), Q(:, k+1)] = arnoldi(A, Q, k); % eliminate the last element in H ith row and update the rotation matrix [H(1:k+1, k), cs(k), sn(k)] = apply_givens_rotation(H(1:k+1,k), cs, sn, k); % update the residual vector beta(k + 1) = -sn(k) * beta(k); beta(k) = cs(k) * beta(k); error = abs(beta(k + 1)) / b_norm; % save the error e = [e; error]; if (error <= threshold) break; end end % if threshold is not reached, k = m at this point (and not m+1) % calculate the result y = H(1:k, 1:k) \ beta(1:k); x = x + Q(:, 1:k) * y; end %----------------------------------------------------% % Arnoldi Function % %----------------------------------------------------% function [h, q] = arnoldi(A, Q, k) q = A*Q(:,k); % Krylov Vector for i = 1:k % Modified Gram-Schmidt, keeping the Hessenberg matrix h(i) = q' * Q(:, i); q = q - h(i) * Q(:, i); end h(k + 1) = norm(q); q = q / h(k + 1); end %---------------------------------------------------------------------% % Applying Givens Rotation to H col % %---------------------------------------------------------------------% function [h, cs_k, sn_k] = apply_givens_rotation(h, cs, sn, k) % apply for ith column for i = 1:k-1 temp = cs(i) * h(i) + sn(i) * h(i + 1); h(i+1) = -sn(i) * h(i) + cs(i) * h(i + 1); h(i) = temp; end % update the next sin cos values for rotation [cs_k, sn_k] = givens_rotation(h(k), h(k + 1)); % eliminate H(i + 1, i) h(k) = cs_k * h(k) + sn_k * h(k + 1); h(k + 1) = 0.0; end %%----Calculate the Givens rotation matrix----%% function [cs, sn] = givens_rotation(v1, v2) % if (v1 == 0) % cs = 0; % sn = 1; % else t = sqrt(v1^2 + v2^2); % cs = abs(v1) / t; % sn = cs * v2 / v1; cs = v1 / t; % see http://www.netlib.org/eispack/comqr.f sn = v2 / t; % end end
See also
References
- ↑ Y. Saad and M.H. Schultz
- ↑ Paige and Saunders, "Solution of Sparse Indefinite Systems of Linear Equations", SIAM J. Numer. Anal., vol 12, page 617 (1975) https://doi.org/10.1137/0712047
- ↑ N.Nifa. "Doctoral Thesis". https://www.theses.fr/2017SACLC066.pdf.
- ↑ Eisenstat, Elman & Schultz, Thm 3.3. NB all results for GCR also hold for GMRES, cf. Saad & Schultz
- ↑ Trefethen & Bau, Thm 35.2
- ↑ Amritkar, Amit; de Sturler, Eric; Świrydowicz, Katarzyna; Tafti, Danesh; Ahuja, Kapil (2015). "Recycling Krylov subspaces for CFD applications and a new hybrid recycling solver". Journal of Computational Physics 303: 222. doi:10.1016/j.jcp.2015.09.040. Bibcode: 2015JCoPh.303..222A.
- ↑ Gaul, André (2014). Recycling Krylov subspace methods for sequences of linear systems (Ph.D.). TU Berlin. doi:10.14279/depositonce-4147.
- ↑ Stoer and Bulirsch, §8.7.2
Notes
- A. Meister, Numerik linearer Gleichungssysteme, 2nd edition, Vieweg 2005, ISBN:978-3-528-13135-7.
- Y. Saad, Iterative Methods for Sparse Linear Systems, 2nd edition, Society for Industrial and Applied Mathematics, 2003. ISBN:978-0-89871-534-7.
- Y. Saad and M.H. Schultz, "GMRES: A generalized minimal residual algorithm for solving nonsymmetric linear systems", SIAM J. Sci. Stat. Comput., 7:856–869, 1986. doi:10.1137/0907058.
- S. C. Eisenstat, H.C. Elman and M.H. Schultz, "Variational iterative methods for nonsymmetric systems of linear equations", SIAM Journal on Numerical Analysis, 20(2), 345–357, 1983.
- J. Stoer and R. Bulirsch, Introduction to numerical analysis, 3rd edition, Springer, New York, 2002. ISBN:978-0-387-95452-3.
- Lloyd N. Trefethen and David Bau, III, Numerical Linear Algebra, Society for Industrial and Applied Mathematics, 1997. ISBN:978-0-89871-361-9.
- Dongarra et al., Templates for the Solution of Linear Systems: Building Blocks for Iterative Methods, 2nd Edition, SIAM, Philadelphia, 1994
- Amritkar, Amit; de Sturler, Eric; Świrydowicz, Katarzyna; Tafti, Danesh; Ahuja, Kapil (2015). "Recycling Krylov subspaces for CFD applications and a new hybrid recycling solver". Journal of Computational Physics 303: 222. doi:10.1016/j.jcp.2015.09.040
- Imankulov T, Lebedev D, Matkerim B, Daribayev B, Kassymbek N. Numerical Simulation of Multiphase Multicomponent Flow in Porous Media: Efficiency Analysis of Newton-Based Method. Fluids. 2021; 6(10):355. https://doi.org/10.3390/fluids6100355
Original source: https://en.wikipedia.org/wiki/Generalized minimal residual method.
Read more |