# Define the three types of elementary row transformations, their matrix form and their inverse.

The three types of row operations are:

1) switching two rows

2) multiplying a row by a constant

3) adding a multiple of one row to another row

To switch two rows, say row 1 and row 2, the matrix you want is the one with a 1 in the `a_(12)` spot and the `a_(21)` spot. All the other 1s go in the `a_(33)` , `a_(44)`, etc. So for a 3x3 matrix, switching the first and second rows we would have:

`[[0,1,0],[1,0,0],[0,0,1]] [[a,b,c],[d,e,f],[g,h,i]] = [[d,e,f],[a,b,c],[g,h,i]]`

To invert that, switch the rows back by using the same matrix:

`[[0,1,0],[1,0,0],[0,0,1]]`

To multiply a row by a constant, say row 1 by the number 3, the matrix you want has a 3 in the `a_(11)` spot, and 1s in the `a_(22)` , `a_(33)` , `a_(44)`, etc. So for a 3x3 matrix, we would have:

`[[3,0,0],[0,1,0],[0,0,1]] [[a,b,c],[d,e,f],[g,h,i]] = [[3a,3b,3c],[d,e,f],[g,h,i]]`

The matrix to invert this has a `(1)/(3)` where the previous matrix had a 3:

`[[1/3,0,0],[0,1,0],[0,0,1]]`

Finally, to add a multiple of a row to another row:

Say we want to add 2 of row 3 to row 2 (replacing the old row 2):

The matrix that does this has 1s in the `a_(11)` , `a_(22)` , `a_(33)` etc spots, but in addition, it has a 2 in the `a_(23)` spot:

`[[1,0,0],[0,1,2],[0,0,1]] [[a,b,c],[d,e,f],[g,h,i]] = [[a,b,c],[d+2g,e+2h,f+2i],[g,h,i]]`

The matrix to invert this is:

`[[1,0,0],[0,1,-2],[0,0,1]]`

That is, it is the same matrix, but with a negative 2 where before we had a positive 2