Conjugate gradient for nonsymmetric problem

AI Thread Summary
The discussion centers on adapting the conjugate gradient method for nonsymmetrical boundary value problems, particularly in a 2D square grid scenario. The user seeks to solve a system where the matrix A is not symmetric, which poses a challenge since the conjugate gradient method is typically applicable only to symmetric matrices. Suggestions include using the biconjugate gradient algorithm, with a caution about its potential instability. The BiCGSTAB algorithm is recommended as a stabilized version of the biconjugate gradient method. Additionally, an alternative approach involves transforming the problem to solve A^T A y = A^T b, though this may affect numerical precision due to the condition number. The discussion also touches on the need for efficient solutions, as the user currently employs successive over-relaxation (SOR) and is looking for faster methods. There is a request for code snippets in C or C# for the conjugate gradient method.
ihggin
Messages
14
Reaction score
0
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?
 
Technology news on Phys.org
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.

Google for "biconjugate gradient algorithm".

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#?
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top