View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Conjugate Gradient Method

5.0 | 3 ratings Rate this file 41 Downloads (last 30 days) File Size: 1.49 KB File ID: #22494 Version: 1.3

Conjugate Gradient Method


Yi Cao (view profile)


18 Dec 2008 (Updated )

Conjugate Gradient Method to solve a system of linear equations

| Watch this File

File Information

The conjugate gradient method aims to solve a system of linear equations, Ax=b, where A is symmetric, without calculation of the inverse of A. It only requires a very small amount of membory, hence is particularly suitable for large scale systems.

It is faster than other approach such as Gaussian elimination if A is well-conditioned. For example,

A=U*diag(s+max(s))*U'; % to make A symmetric, well-contioned

Conjugate gradient is about two to three times faster than A\b, which uses the Gaissian elimination.

MATLAB release MATLAB 8.2 (R2013b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (5)
12 Sep 2016 Mehulkumar Dipakbhai Patel

02 Feb 2012 Kovács Sebestyén


05 Apr 2009 V. Poor

13 Jan 2009 Lei

Lei (view profile)

Could anybody tell me how to evaluate the time required by the SVD. Please kindly note the svd.m called directly by the workspace is a built-in function, which is much faster than the svd.m available on the Matlab website. So which one is more suitable to evaluate the required time?

Actually, I am trying to compare a new algorithm with the SVD in computational cost or time. I suppose the built-in SVD function might be faster than the source-code SVD function. Could anybody help me? Thanks a lot for your kindly helps in advance! My email address is

Comment only
04 Jan 2009 Luigi Giaccari

A\b uses cholesky factorization if A is simmetric. It swithes to gauss method when A is not simmetric and the factorization fails due to negative sqrt input.

I don't know if it is present in all version, but there already is a conjgrad method in matlab.


help pcg

Anyway thank to Cao, submissions that works are always usefull, in the worst case you can study the algorithm.

Comment only
22 Dec 2008 1.1

update description

05 Feb 2014 1.2

change initial value to x=b. slightly faster.

06 Feb 2014 1.3

To consider two trival cases.

Contact us