My problem is that the L2-Norm of the residual for the periodic Poisson matrix $P$ is initially decreasing but starts to blow up after a certain number of iterations. The blowup happens earlier the larger the matrix is.

On the other hand, the Poisson matrix $H$ with homogeneous Dirichlet boundary condition converges exponentially for many iterations without any notable oscillations.

For reference, I am using the CG algorithm presented here from Wikipedia.

The only criterion for convergence I came across seems to be the positive definiteness of the system matrix. What could possibly lead to the blowup with matrix $P$?


1 Answer 1


That type of behaviour usually happens when you matrix is poorly-conditioned. Reasons:

  • your iterative solve works fine for different matrices (less-likely to have a bug/bad memory access, etc)
  • the problem gets worse when you increase the matrix size (condition number would be proportional to the matrix size)

Suggested actions:

  • check condition number of your two matrices. If the first one is significantly worse (the larger it is, the more problems you will probably have during the iterative solve), you may have to opt for a better preconditioner or even to continue solving it iteratively.
  • check the preconditioning you are using in the first place. At least diagonal (Jacobi) preconditioner has to be used.
  • check if you can solve a smaller problem directly (to make sure you matrix assembly and other code pipelining works fine) using LU decomposition.
  • $\begingroup$ Thanks for the suggestions! P as well as H are both s.p.d. but the matrix H has negligible condition number compared to its periodic counterpart. I didn't know that the condition number itself determines if CG diverges, only that it determines its speed of convergence. Do you have a reference concerning this behavior? $\endgroup$
    – CoppaMan
    Jun 7, 2019 at 18:06
  • $\begingroup$ @CoppaMan The divergence happens because of inevitable floating-point errors happening. So, in theory, if your matrix has a finite condition number - the iterative solver converges, provided you have infinite precision. In practice, you are limited to double precision, thus large condition numbers would imply divergence\instability of iterative solvers in a lot of cases. It is a bit general fact, so even the aforementioned link to Wikipedia on condition number would suffice. $\endgroup$
    – Anton Menshov
    Jun 7, 2019 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.