An n-by-n matrix A is the inverse of n-by-n matrix B (and B the inverse of A) if BA = AB = I,
where I is an identity matrix.
The inverse of an n-by-n matrix can be calculated by creating an n-by-2n matrix which has the original matrix on the left and the identity matrix on the right. Row reduce this matrix and the right half will be the inverse. If the matrix does not row reduce completely (i.e., a row is formed with all zeroes as its entries), it does not have an inverse.
We begin by expanding and partitioning A to include the identity matrix, and then proceed to row reduce A until we reach the identity matrix on the left-hand side.
The matrix is then the inverse of the original matrix A.