18. Determinants and inverse matrices

Definition

In many applications we will use the notion of determinant of a matrix. The determinant of a matrix makes sense for square matrices only and is defined recursively:

  • \det[a]=a
  •     \[\det \left[\begin{array}{cccc}a_{1,1}&a_{1,2}&\ldots&a_{1,n}\\a_{2,1}&a_{2,2}&\ldots&a_{2,n}\\\ldots&\ldots&&\ldots\\ a_{n,1}&a_{n,2}&\ldots&a_{n,n}\end{array}\right]=\]

        \[=a_{1,1}\det A_{1,1}-a_{1,2}\det A_{1,2}+a_{1,3}\det A_{1,3}-\ldots\pm a_{1,n}\det A_{1,m},\]

where A_{i,j} is matrix A with i-th row and j-th column crossed out. So (the determinant is denoted by \det or by using absolute value style brackets around a matrix):

    \[\left|\begin{array}{cc}a&b\\c&d\end{array}\right|=ad-bc,\]

therefore:

    \[\left|\begin{array}{ccc}a&b&c\\k&l&m\\x&y&z\end{array}\right|=a\left|\begin{array}{cc}l&m\\y&z\end{array}\right|-b\left|\begin{array}{cc}k&m\\x&z\end{array}\right|+c\left|\begin{array}{cc}k&l\\x&y\end{array}\right|=\]

    \[=a(lz-my)-b(kz-mx)+c(ky-lx)=alz+bmx+cky-amy-bkz-clx.\]

And so on. E.g.:

    \[\left|\begin{array}{cccc}1&0&2&0\\2&3&0&-1\\3&-1&-1&0\\0&1&-1&-2\end{array}\right|=\]

    \[=1\left|\begin{array}{ccc}3&0&-1\\-1&-1&0\\1&-1&-2\end{array}\right|-0\left|\begin{array}{cccc}2&0&-1\\3&-1&0\\0&-1&-2\end{array}\right|+2\left|\begin{array}{cccc}2&3&-1\\3&-1&0\\0&1&-2\end{array}\right|-0\left|\begin{array}{cccc}2&3&0\\3&-1&-1\\0&1&-1\end{array}\right|=\]

    \[=1\cdot 4-0+2\cdot 19-0=42\]

Laplace expansion

The above definition is only a special case of a more general fact called Laplace expansion. Instead of using the first row we can use any row or column (choose always the one with most zeros). So:

    \[\det \left[\begin{array}{cccc}a_{1,1}&a_{1,2}&\ldots&a_{1,n}\\a_{2,1}&a_{2,2}&\ldots&a_{2,n}\\\ldots&\ldots&&\ldots\\ a_{n,1}&a_{n,2}&\ldots&a_{n,n}\end{array}\right]=\]

    \[=(-1)^{i-1}\left(a_{i,1}\det A_{i,1}-a_{i,2}\det A_{i,2}+a_{i,3}\det A_{i,3}-\ldots\pm a_{i,n}\det A_{i,m}\right),\]

for any row w_i. Analogical fact is true for any column.

E.g. for the below matrix it is easiest to use the third column:

    \[\left|\begin{array}{cccc}1&1&0&-1\\2&0&-1&-1\\3&-1&0&1\\0&1&0&-2\end{array}\right|=(-1)^3\cdot(-1)\cdot \left|\begin{array}{cccc}1&1&-1\\3&-1&1\\0&1&-2\end{array}\right|=10\]

Determinant and operations on a matrix

Notice first that from the Laplace expansion we easily get that if a matrix has a row of zeros (or column) its determinant equals zero.

Consider now different operations on rows of a matrix, which we use to calculate a ,,stair-like” form of a matrix. Using Laplace expansion we can prove that swapping two rows multiplies the determinant by -1 — indeed calculating the determinant using the first column we see that the signs in the sum may change, but also the rows in the minor matrices get swapped.

Immediately we can notice that multiplying a row by a number multiplies also the determinant by this number — you can see it easily calculating Laplace expansion using this row.

Therefore multiplying whole matrix by a number multiplies the determinant by this number many times, precisely:

    \[\det (aA)=a^n \det A, \]

where A is a matrix of size n\times n.

Notice also, that the determinant of a matrix with two identical rows equals zero, because swapping those rows does not change the matrix but multiplies the determinant by -1, so \det A=-\det A, therefore \det A=0. So because of the row multiplication rule, if two rows in a matrix are linearly dependent, then its determinant equals 0.

Also the Laplace expansion implies that if matrices A, B, C differ only by i-th row in the way that this row in matrix C is a sum of i-th rows in matrices B and C, then the determinant of C is the sum of determinants of A and B, e.g.:

    \[\left|\begin{array}{ccc}1&3&-1\\0&1&2\\0&3&3\end{array}\right|=\left|\begin{array}{ccc}0&1&4\\0&1&2\\0&3&3\end{array}\right|+\left|\begin{array}{ccc}1&2&-5\\0&1&2\\0&3&3\end{array}\right|.\]

But it can be easily seen that in general \det(A+B)\neq \det A+\det B!

Finally, consider the most important operation of adding to a row another row multiplied by a number. Then we actually deal with the situation described above. The resulting matrix is matrix C, which differs from A and B only by the row we sum to. Matrix A is the original matrix and matrix C is matrix A, in which we substitute the row we sum to with the row we are summing multiplied by a number. Therefore \det A=\det B+\det C, but C has two linearly dependent rows, so \det C=0 and \det B=\det A. Therefore the operation of adding a row multiplied by a number to another row does not change the determinant of a matrix.

Finally, the matrix multiplication. All the above operations can be written as multiplication by a special matrix. E.g. swapping of 2-nd and 3-rd rows in a matrix of size 3\times 3, is actually the following:

    \[\left[\begin{array}{ccc}1&0&0\\0&0&1\\0&1&0\end{array}\right]\cdot\]

multiplication of the 3-rd row by scalar 4, is:

    \[\left[\begin{array}{ccc}1&0&0\\0&1&0\\0&0&4\end{array}\right]\cdot\]

adding to the third row the second multiplied by 2 is:

    \[\left[\begin{array}{ccc}1&0&0\\2&1&0\\0&0&1\end{array}\right]\cdot\]

It is relatively easy to see that even in the general case the matrix, which changes rows has determinant (-1), the matrix multiplying a row by scalar a, has determinant a, and matrix of adding to a row another row multiplied by a scalar has determinant 1. Therefore multiplying by those matrices (called the elementary matrices) multiplies the determinant of a matrix by their determinants. Moreover, every matrix can be created by multiplying elementary matrix, which gives the following important conclusion:

    \[\det (A\cdot B)=\det A\cdot \det B\]

Calculating the determinant via triangular form of matrix

If you look closely enough you will see that the Laplace expansion also implies that the determinant of a matrix in an echelon form (usually called triangular for square matrices) equals the product of elements on the diagonal of the matrix, so e.g.:

    \[\left|\begin{array}{ccc}-1&3&-1\\0&1&2\\0&0&3\end{array}\right|=(-1)\cdot 1\cdot 3=-3.\]

Because we know how the elementary operations change, to calculate the determinant of a matrix we can calculate a triangular form, calculate its determinant and recreate the determinant of the original matrix. This method is especially useful for large matrices, e.g.:

    \[\left[\begin{array}{ccccc}1&2&0&3&1\\2&6&2&0&2\\3&9&1&1&-1\\1&2&0&3&4\\1&2&0&1&1\end{array}\right]\underrightarrow{w_2-2w_1,w_3-3w_1,w_4-w_1,w_5-w_1}\]

    \[\left[\begin{array}{ccccc}1&2&0&3&1\\0&2&2&-6&0\\0&3&1&-8&-4\\0&0&0&0&3\\0&0&0&-2&0\end{array}\right]\underrightarrow{w_2\cdot\frac{1}{2}}\]

    \[\left[\begin{array}{ccccc}1&2&0&3&1\\0&1&1&-3&0\\0&3&1&-8&-4\\0&0&0&0&3\\0&0&0&-2&0\end{array}\right]\underrightarrow{w_3-3w_2, w_4\leftrightarrow w_5} \left[\begin{array}{ccccc}1&2&0&3&1\\0&1&1&-3&0\\0&0&-2&1&-4\\0&0&0&-2&0\\0&0&0&0&3\end{array}\right]\]

Therefore, the determinant of the last matrix is 1\cdot 1\cdot (-2)\cdot (-2)\cdot 3=12. On our way we have swapped rows once and we have multiplied one row by \frac{1}{2}, therefore the determinant of the first matrix equals \frac{12\cdot(-1)}{\frac{1}{2}}=-24.

The above fact also implies how to calculate the determinant of a matrix which is in the block form: \left[\begin{array}{cc}A&C\\0&B\end{array}\right] with left bottom block of zeros. The determinant of such a matrix equals \det A\cdot \det B, e.g.:

    \[\left|\begin{array}{ccccc}1&2&0&3&1\\2&6&2&0&2\\3&9&1&1&-1\\0&0&0&3&4\\0&0&0&1&1\end{array}\right|= \left|\begin{array}{ccc}1&2&0\\2&6&2\\3&9&1\end{array}\right|\cdot\left|\begin{array}{cc}3&4\\1&1\end{array}\right|.\]

Now we will make use of determinants and along the way introduce the notion of inverse matrix.

Inverse matrix

A matrix B is inverse to matrix A, if A\cdot B=I, where I is the identity matrix (the matrix with ones on the diagonal and zeros everywhere else). The inverse matrix is denoted as A^{-1}. Since \det A\cdot B=\det A\cdot \det B and \det I=1, we see that \det A^{-1}=\frac{1}{\det A}. This implies that only matrices with non-zero determinants can have their inverses. Therefore we call such matrices invertible.

How to calculate the inverse of a given matrix? We have mentioned recently that the operations on rows of a matrix leading to the reduced “stair-like” for is actually multiplication by a matrix. Imagine that we transform the matrix [A|I] consisting of matrix A along with the identity matrix into the reduced “stair-like” form. Since A is a square matrix with non-zero determinant, we will get identity matrix on the left side: [I|B]. But notice that if C is the matrix of rows operations, then C\cdot [A|I]=[I|B]. Therefore C\cdot A=I and C\cdot I=B. The first equation implies that C=A^{-1}. The second that B=C=A^{-1}. So we get the inverse matrix on the right after those operations!

E.g. let us calculate the inverse of the following matrix:

    \[A=\left[\begin{array}{ccc}1&2&1\\2&5&2\\-1&-2&0\end{array}\right]\]

So:

    \[\left[\begin{array}{ccc|ccc}1&2&1&1&0&0\\2&5&2&0&1&0\\-1&-2&0&0&0&1\end{array}\right]\overrightarrow{w_2-2w_1,w_3+w_1} \left[\begin{array}{ccc|ccc}1&2&1&1&0&0\\0&1&0&-2&1&0\\0&0&1&1&0&1\end{array}\right]\overrightarrow{w_1-w_3}\]

    \[\left[\begin{array}{ccc|ccc}1&2&0&0&0&-1\\0&1&0&-2&1&0\\0&0&1&1&0&1\end{array}\right]\overrightarrow{w_1-2w_2} \left[\begin{array}{ccc|ccc}1&0&0&4&-2&-1\\0&1&0&-2&1&0\\0&0&1&1&0&1\end{array}\right]\]

And therefore:

    \[A^{-1}=\left[\begin{array}{ccc}4&-2&-1\\-2&1&0\\1&0&1\end{array}\right]\]

Determining one element of the inverse matrix

If you do not need the whole matrix but some elements only, the following method seems useful. It uses the adjugate matrix to the given one. The adjugate matrix is a matrix in which in j-th row and i-th column we have the determinant of matrix A_{i,j} (matrix A without i-th row and j-th column, there is no mistake there, a transposition plays a role here) multiplied by (-1)^{i+j}. The following equation holds:

    \[A^{-1}=\frac{A^{D}}{\det A}.\]

Therefore if we would like to calculate the value in the second row and first column of A^{-1} from the previous example we cross out the second column an the first row of A and calculate the determinants, and get:

    \[(-1)^{2+1}\frac{\left|\begin{array}{cc}2&2\\-1&0\end{array}\right|}{\left|\begin{array}{ccc}1&2&1\\2&5&2\\-1&-2&0\end{array}\right|}=(-1)\frac{2}{1}=-2\]

which agrees with the result obtained by the first method!

Cramer’s rule

Given a system of n equations with n variables we may try to solve it with Cramer’s rule. Let A be the matrix of this system without the column of free coefficients. Let A_{i} be the matrix A, in which instead of i-th column we put the column of free coefficients. Then:

  • if \det A\neq 0, the system has exactly one solution. The solution is given by the following formula: x_{i}=\frac{\det A_i}{\det A},
  • if \det A=0, and at least one of \det A_{i} is not equal to 0, the system has no solutions,
  • if \det A=0 and for every i, \det A_{i}=0, there can be zero or infinitely many solutions — Cramer’s method does not give any precise answer.

E.g. let us solve the following system of equations:

    \[\begin{cases} x+2y+z=1\\2x+5y+2z=-1\\-x-2y=0\end{cases}\]

Therefore:

    \[A=\left[\begin{array}{ccc}1&2&1\\2&5&2\\-1&-2&0\end{array}\right]\]

Since \det A=1, this system has exactly one solution. To determine it we calculate the other determinants:

    \[\det A_1= \left|\begin{array}{ccc}1&2&1\\-1&5&2\\0&-2&0\end{array}\right|=6\]

    \[\det A_2= \left|\begin{array}{ccc}1&1&1\\2&-1&2\\-1&0&0\end{array}\right|=-3\]

    \[\det A_3= \left|\begin{array}{ccc}1&2&1\\2&5&-1\\-1&-2&0\end{array}\right|=1\]

And so x=\frac{6}{1}=6, y=\frac{-3}{1}=-3, z=\frac{1}{1}=1.