Conjugate gradient squared method
Background
A system of linear equations A ๐ฑ = ๐ consists of a known matrix A and a known vector ๐ . To solve the system is to find the value of the unknown vector ๐ฑ . A direct method for solving a system of linear equations is to take the inverse of the matrix A , then calculate ๐ฑ = A โ 1 ๐ . However, computing the inverse is computationally expensive. Hence, iterative methods are commonly used. Iterative methods begin with a guess ๐ฑ ( 0 ) , and on each iteration the guess is improved. Once the difference between successive guesses is sufficiently small, the method has converged to a solution.
As with the conjugate gradient method , biconjugate gradient method , and similar iterative methods for solving systems of linear equations, the CGS method can be used to find solutions to multi-variable optimisation problems , such as power-flow analysis , hyperparameter optimisation , and facial recognition .
Algorithm
The algorithm is as follows:
Choose an initial guess ๐ฑ ( 0 )
Compute the residual ๐ซ ( 0 ) = ๐ โ A ๐ฑ ( 0 )
Choose ๐ซ ~ = ๐ซ ( 0 )
For i = 1 , 2 , 3 , โฆ do:
ฯ ( i โ 1 ) = ๐ซ ~ T ๐ซ ( i โ 1 )
If ฯ ( i โ 1 ) = 0 , the method fails.
If i = 1 :
๐ฉ ( 1 ) = ๐ฎ ( 1 ) = ๐ซ ( 0 )
Else:
ฮฒ ( i โ 1 ) = ฯ ( i โ 1 ) / ฯ ( i โ 2 )
๐ฎ ( i ) = ๐ซ ( i โ 1 ) + ฮฒ i โ 1 ๐ช ( i โ 1 )
๐ฉ ( i ) = ๐ฎ ( i ) + ฮฒ ( i โ 1 ) ( ๐ช ( i โ 1 ) + ฮฒ ( i โ 1 ) ๐ฉ ( i โ 1 ) )
Solve M ๐ฉ ฬ = ๐ฉ ( i ) , where M is a pre-conditioner.
๐ฏ ฬ = A ๐ฉ ฬ
ฮฑ ( i ) = ฯ ( i โ 1 ) / ๐ซ ~ T ๐ฏ ฬ
๐ช ( i ) = ๐ฎ ( i ) โ ฮฑ ( i ) ๐ฏ ฬ
Solve M ๐ฎ ฬ = ๐ฎ ( i ) + ๐ช ( i )
๐ฑ ( i ) = ๐ฑ ( i โ 1 ) + ฮฑ ( i ) ๐ฎ ฬ
๐ช ฬ = A ๐ฎ ฬ
๐ซ ( i ) = ๐ซ ( i โ 1 ) โ ฮฑ ( i ) ๐ช ฬ
Check for convergence: if there is convergence, end the loop and return the result
References
โ Noel Black; Shirley Moore. "Conjugate Gradient Squared Method" . Wolfram Mathworld .
โ Mathworks . "cgs" . Matlab documentation .
1 2 Henk van der Vorst (2003). "Bi-Conjugate Gradients". Iterative Krylov Methods for Large Linear Systems . Cambridge University Press. ISBN ย 0-521-81828-1 .
โ Peter Sonneveld (1989). "CGS, A Fast Lanczos-Type Solver for Nonsymmetric Linear systems" . SIAM Journal on Scientific and Statistical Computing . 10 (1): 36โ 52. doi :10.1137/0910004 . ProQuest ย 921988114 .
โ "Linear equations" ( (PDF) ) , Matrix Analysis and Applied Linear Algebra , Philadelphia, PA: SIAM, 2000, pp.ย 1โ 40, doi :10.1137/1.9780898719512.ch1 (inactive 11 July 2025), ISBN ย 978-0-89871-454-8 , archived from the original on 2004-06-10, retrieved 2023-12-18 {{citation }}: CS1 maint: DOI inactive as of July 2025 (link )
โ "Iterative Methods for Linear Systems" . Mathworks .
โ Jean Gallier. "Iterative Methods for Solving Linear Systems" (PDF) . UPenn .
โ Alexandra Roberts; Anye Shi; Yue Sun. "Conjugate gradient methods" . Cornell University . Retrieved 2023-12-26 .
โ R. Barrett; M. Berry; T. F. Chan; J. Demmel; J. Donato; J. Dongarra; V. Eijkhout; R. Pozo; C. Romine; H. Van der Vorst (1994). Templates for the Solution of Linear Systems: Building Blocks for Iterative Methods, 2nd Edition . SIAM.