Step by step Gauss-Jordan reduction of a matrix

### 15.7.5 Step by step Gauss-Jordan reduction of a matrix

One step of Gauss-Jordan elimination involves taking a non-zero element of a matrix (the pivot) and adding multiples of its row to the other rows to get zeros above and below the pivot. The pivot command performs this operation.

- pivot takes three arguments:
  - A, a a matrix with n rows and p columns.
  - l and c, two integers such that l is the index of a row of A and c is an index of column of A, and the element of A in row l and column c is non-zero.
- pivot(A,l,c) returns the result of performing one step of the Gauss-Jordan method using the element of A in row l, column c as pivot.

#### Examples

pivot([[1,2],[3,4],[5,6]],1,1)

⎡ ⎢ ⎢ ⎣ |
−2 | 0
3 | 4
2 | 0
| ⎤ ⎥ ⎥ ⎦

pivot([[1,2],[3,4],[5,6]],0,1)

⎡ ⎢ ⎢ ⎣ |
1 | 2
2 | 0
4 | 0
| ⎤ ⎥ ⎥ ⎦