Previous Up Next

15.6.4  Conjugate gradient algorithm

The conjugate_gradient command uses the conjugate gradient algorithm to solve a linear system of equations.

Examples

We can solve the system {

2x+y=1
x+5y=0

by entering one of the following commandlines.

conjugate_gradient([[2,1],[1,5]],[1,0])
     



5
9
,−
1
9



          
conjugate_gradient([[2,1],[1,5]],[1,0],[0.55,-0.11],1e-2)
     

0.555,−0.11
          
conjugate_gradient([[2,1],[1,5]],[1,0],[0.55,-0.11],1e-10)
     

0.555555555556,−0.111111111111
          

Previous Up Next