The conjugate gradient algorithm: conjugate_gradient

### 5.54.4 The conjugate gradient algorithm: conjugate_gradient

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

- conjugate_gradient takes two mandatory arguments and two optional arguments.
  - A, an n× n positive definite symmetric matrix.
  - y, a vector of length n.
  - Optionally, x0, a vector of length n, an initial approximation.
  - є, a positive number (by default epsilon, see Section 2.5.7, item 9).
- conjugate_gradient(A,y ⟨ x0,є⟩) returns the solution to Ax = y to within є.

#### Examples

- Input:
  conjugate_gradient([[2,1],[1,5]],[1,0])
  Output:

  ⎡ ⎢ ⎢ ⎣ |
  5
  9
  | ,− |
  1
  9
  | ⎤ ⎥ ⎥ ⎦

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

  ⎡ ⎣ | 0.555,−0.11 | ⎤ ⎦

- Input:
  conjugate_gradient([[2,1],[1,5]],[1,0],[0.55,-0.11],1e-10)
  Output:

  ⎡ ⎣ | 0.555555555556,−0.111111111111 | ⎤ ⎦