# `3x + 2y - z + w = 0, x - y + 4z + 2w = 25, ``-2x + y + 2z - w = 2, x + y + z + w =6`Use matricies to solve the system of equations. Use Gaussian elimination with back-substitution.

`3x+2y-z+w=0`

`x-y+4z+2w=25`

`-2x+y+2z-w=2`

`x+y+z+w=6`

The above system of equations can be represented by the coefficient matrix A and right hand side vector b as follows:

`A=[[3,2,-1,1],[1,-1,4,2],[-2,1,2,-1],[1,1,1,1]]`

`b=[[0],[25],[2],[6]]`

The augmented matrix can be written as:

`[A b]=[[3,2,-1,1,0],[1,-1,4,2,25],[-2,1,2,-1,2],[1,1,1,1,6]]`

Now let's bring the above matrix in row-echelon form by performing various row operations,

Rewrite the 1st Row`(R_1)` as `(R_1+R_3)`

`[[1,3,1,0,2],[1,-1,4,2,25],[-2,1,2,-1,2],[1,1,1,1,6]]`

Rewrite the 2nd Row`(R_2)` as `(R_2-R_4)`

`[[1,3,1,0,2],[0,-2,3,1,19],[-2,1,2,-1,2],[1,1,1,1,6]]`

Rewrite the 3rd Row`(R_3)` as`(R_3+2R_4)`

`[[1,3,1,0,2],[0,-2,3,1,19],[0,3,4,1,14],[1,1,1,1,6]]`

Rewrite the 4th Row as `(R_4-R_1)`

`[[1,3,1,0,2],[0,-2,3,1,19],[0,3,4,1,14],[0,-2,0,1,4]]`

Rewrite the 2nd Row as `(R_2+R_3)`

`[[1,3,1,0,2],[0,1,7,2,33],[0,3,4,1,14],[0,-2,0,1,4]]`

Rewrite the 3rd Row as `(R_3-3R_2)`

`[[1,3,1,0,2],[0,1,7,2,33],[0,0,-17,-5,-85],[0,-2,0,1,4]]`

Rewrite the 4th Row as `(R_4+2R_2)`

`[[1,3,1,0,2],[0,1,7,2,33],[0,0,-17,-5,-85],[0,0,14,5,70]]`

Rewrite the 3rd Row as `(R_3+R_4)`

`[[1,3,1,0,2],[0,1,7,2,33],[0,0,-3,0,-15],[0,0,14,5,70]]`

Rewrite the 3rd Row by dividing it with -3,

`[[1,3,1,0,2],[0,1,7,2,33],[0,0,1,0,5],[0,0,14,5,70]]`

Rewrite the 4th Row as`(R_4-14R_3)`

`[[1,3,1,0,2],[0,1,7,2,33],[0,0,1,0,5],[0,0,0,5,0]]`

Rewrite the 4th Row by dividing it with 5,

`[[1,3,1,0,2],[0,1,7,2,33],[0,0,1,0,5],[0,0,0,1,0]]`

Now the above matrix is row-echelon form and we can perform back substitution on the corresponding system,

`x+3y+z=2`     ----- Eq:1

`y+7z+2w=33`    ------ Eq:2

`z=5`

`w=0`

Substitute back the value of z and w in Eq:2,

`y+7(5)+2(0)=33`

`y+35=33`

`y=33-35=-2`

Substitute back the value of y and z in Eq:1,

`x+3(-2)+5=2`

`x-6+5=2`

`x-1=2`

`x=3`

So the solutions are x=3,y=-2,z=5 and w=0