# Conjugate gradient for nonsymmetric problem

• ihggin
In summary, the conjugate gradient method can be used to solve problems where the condition number of the matrix A is not symmetric, but it may be unstable. There is a practical stabilized version of the method called the BiCGSTAB algorithm, and it doesn't degrade the condition number.
ihggin
Hi, I was wondering if it is possible to adapt the conjugate gradient method (or if there's a variation of the method) for nonsymmetrical boundary value problems.

For example, I want to solve something like a 2D square grid, where $f(x)=0$ for all $x$ on the boundary of the square, $f(x_{i0,j0})=1$ and $f(x_{i1, j1})$ for specified interior points, and

$$f(x_{i,j})=.1f(x_{i-1,j})+.2f(x_{i+1,j})+.3f(x_{i,j-1})+.4f(x_{i,j+1})$$

for all other interior grid points $x_{i,j}$. If I change $f_{i,j}$ to a 1D vector $y_{k}$, and then write the system of eqs out, the matrix $A$ in the system I want to solve ($Ay=b$) is not symmetric.

From what I've read, the conjugate gradient method only works for symmetric $A$, so I was wondering if there is some way to adapt the method, or a different way of setting up the system. If not, what would be the fastest way to solve this problem? (The only reason I'm interested in conjugate gradient is b/c I heard it's fast.) I'm currently using successive over-relaxation (SOR). Is there anything faster?

ihggin said:
From what I've read, the conjugate gradient method only works for symmetric $A$, so I was wondering if there is some way to adapt the method, or a different way of setting up the system.

There are some traps here, because biconjugate gradient can be unstable. A practical stabilized version is the BiCGSTAB algorithm (also in Google!)

Another way the conjugate gradient method could be used is to solve
$$A^T A y = A^T b$$​

Hurkyl said:
Another way the conjugate gradient method could be used is to solve
$$A^T A y = A^T b$$​

True, provided it doesn't matter that the condition number of $A^T A$ is the square of the condition number of $A$, which may decrease the numerical precision.

The biconjugate gradient method also involves multiplyng vectors by $A^T$, but it doesn't degrade the condition number.

Anybody has Conjugate Gradient code snippet in C or C#?

## 1. What is the conjugate gradient method?

The conjugate gradient method is a popular iterative algorithm used to solve systems of linear equations. It is particularly useful for large, sparse, and nonsymmetric matrices. It uses an efficient approach to find the minimum of a quadratic function by minimizing the residual of the matrix equation.

## 2. How does the conjugate gradient method work for nonsymmetric problems?

The conjugate gradient method for nonsymmetric problems is a modified version of the classic conjugate gradient method. It uses a new search direction that is a combination of the residual and a preconditioned residual. This allows for efficient convergence even for nonsymmetric matrices.

## 3. What are the advantages of using the conjugate gradient method for nonsymmetric problems?

The conjugate gradient method has several advantages for solving nonsymmetric problems. These include faster convergence rates, better stability, and lower memory requirements compared to other methods. It also has the flexibility to handle a wide range of problem sizes and types.

## 4. Are there any limitations to using the conjugate gradient method for nonsymmetric problems?

While the conjugate gradient method is a powerful and efficient algorithm, it does have some limitations. It may not be suitable for very large or highly ill-conditioned matrices. Additionally, it may not converge if the matrix is not positive definite.

## 5. How can I implement the conjugate gradient method for nonsymmetric problems in my research?

There are many resources available for implementing the conjugate gradient method for nonsymmetric problems. Some popular options include using the built-in functions in programming languages like MATLAB or Python, or using open-source libraries like PETSc or Trilinos. It is important to carefully choose the implementation that best suits your specific problem and research goals.

• Programming and Computer Science
Replies
5
Views
969
• Calculus
Replies
1
Views
859
• Programming and Computer Science
Replies
2
Views
2K
• Programming and Computer Science
Replies
2
Views
1K
Replies
5
Views
928
• Programming and Computer Science
Replies
1
Views
1K
• General Math
Replies
36
Views
6K
• Introductory Physics Homework Help
Replies
3
Views
394
• General Math
Replies
6
Views
1K
• Topology and Analysis
Replies
3
Views
1K