Gauss Jordan is a variant of the Gauss elimination method in which **row reduction operations are done to find out the inverse of the matrix**. Here also the row reduced echelon form of the matrix is formed.

__DERIVATION__

**Then we write the augmented matrix as**

**Then the first step will be,**

** **Where

And

**The second step will be**

**The third and ultimate step:**

__INPUT:__

A matrix

__OUTPUT:__

The inverse of the given matrix

__PROCESS:__

```
Step 1: [taking the inputs from the user]
Read n [the order of the matrix]
for i = 1 to n repeat
for j = 1 to n repeat
Read a[i][j]
[End of ‘for’ loop]
[End of ‘for’ loop]
Step 2: [Gauss Jordan Inverse]
Set c ← n + 1
for i = 1 to n repeat
for j = n + 1 to 2n repeat
If c = j then
Set a[i][j] ← 1.0
else
Set a[i][j] ← 0.0
[End of ‘if’]
[End of ‘for’ loop]
Set c ← c + 1
[End of ‘for’ loop]
for i = 1 to n repeat
for j = 1 to 2n repeat
Print a[i][j]
[End of ‘for’ loop]
Move to next line
[End of ‘for’ loop]
for k = 1 to n repeat
for j = 1 to 2n repeat
Set a[k][j] ← a[k][j]/a[k][k]
[End of ‘for’ loop]
for i = 1 to n repeat
If i = k then
Continue
[End of ‘if’]
Set r ← a[i][k]
for j = 1 to 2n repeat
Set a[i][j] ← a[i][j] - (a[k][j] * r)
[End of ‘for’ loop]
[End of ‘for’ loop]
for i = 1 to n repeat
for j = 1 to 2n repeat
Print a[i][j]
[End of ‘for’ loop]
Move to the next line
[End of ‘for’ loop]
[End of ‘for’ loop]
[Printing the matrix after inversion]
for i = 1 to n repeat
for j = n + 1 to 2n repeat
Print a[i][j]
[End of ‘fot’ loop]
Move to the next line
[End of ‘for’ loop]
[End of Gauss Jordan Inverse Method]
```

__ADVANTAGES__

**1.** It is a stable algorithm when pivoted.

**2.** It puts a matrix in a reduced row echelon form.

**3.** For a small system, it is more convenient to use Gauss Jordan Method.

__DISADVANTAGES__

**1.** It requires three times the number of operations than the Gauss Elimination method.

**2.** It is slower than LU or Gauss Elimination method.

__APPLICATION__

**1.** It is used to reduce a matrix into the echelon form.

**2.** It is also used to find the inverse of a matrix.

Contributed by