Using matrix inverses, and matrix determinants
Contents
Using matrix inverses, and matrix determinants#
Using the inverse of A to solve a system of linear equations#
If you have the inverse of a matrix \(\arr{A}\) representative of a linear system of equations, you can use it to find \(\vec{x}\):
now \(\vec{x}\) is just the product.
Fun fact: An n\(\times\)n system \(\arr{A}\vec{x}=\vec{b}\) has a unique solution if and only if \(\arr{A}\) is nonsingular (i.e. has an inverse). *Other properties:
Be careful:
if \(\arr{A}=\begin{bmatrix}1&0&-2\\ 2&-1&3\\ 4&0&2\end{bmatrix}\) then \(\arr{A}^{-1}=\begin{bmatrix}2/10&0&2/10\\ -8/10&-1&7/10\\ \bf{-4/10}&\bf{0}&\bf{1/10}\end{bmatrix}\)
if \(\arr{B}=\begin{bmatrix}1&0&-2\\ 4&0&2\\ 2&-1&3\end{bmatrix}\)(switched rows), then \(\arr{B}^{-1}\neq\begin{bmatrix}2/10&0&2/10\\ \bf{-4/10}&\bf{0}&\bf{1/10}\\ -8/10&-1&7/10\end{bmatrix}\) but \(\arr{B}^{-1}=\begin{bmatrix}2/10&2/10&0\\ -8/10&7/10&-1\\ -4/10&1/10&0\end{bmatrix}\)
Notice the columns were switched here.
Determinants#
Every square matrix is associated with a real number (a scalar) called the determinant.
The value of the determinant will tell us whether or not the matrix is singular.
Generalized definition:
where \(A_{1k} = (-1)^{1+k} \det(\arr{M_{1k}})\), for \(k=1,2,...n\)
Here, \(A_{1k}\) is a “cofactor” and \(\det(\arr{M_{1k}})\) is the “minor” of \(a_{1k}\).
Also, \(\arr{M_{1k}}\) = submatrix formed from \(\arr{A}\) when deleting row \(1\) and column \(k\).
OK, so this makes no sense without some examples. Let’s consider matrices of different sizes.
Case 1: 1\(\times\)1 Matrix#
\(|A| = a_{11}=a\)
\(\arr{A}\) is non-singular if \(a\neq0\) and singular if \(a=0\).
Ex: \(\arr{A}=[5] \hspace{0.5cm} \rightarrow{} \det(\arr{A})=5\) (non singular)
\(\hspace{0.6cm} \arr{B}=[0] \hspace{0.5cm} \rightarrow{} \det(\arr{B})=0\) (singular)
Let’s think about a physical system \(ax=5\). If \(a\) is zero, we have a problem! If it’s non-zero, we can solve.
Case 2: 2\(\times\)2 matrix#
Let \(\arr{A} = \begin{bmatrix}a_{11} & a_{12}\\ a_{21} & a_{22}\end{bmatrix}\)
\(\arr{A}\) will be non-singular only if we can convert it to \(\arr{I}\) using elementary row operations. This property is called “row equivalence”.
Let’s consider how we would convert \(\arr{A}\) to \(\arr{I}\).
If \(a_{11}\neq0\) then we can perform the following row operations:
Multiply the second row of \(\arr{A}\) by \(a_{11}\) \((R_2=a_{11}R_2)\)
Subtract \(a_{21} \times \)Row 1 from Row 2 \((R_2 = R_2 - a_{21} R_1)\)\
Since \(a_{11}\neq0\), \(\arr{A}\) will be row equivalent to \(\arr{I}\) IFF:\
If \(a_{11}=0\), then we can switch the two rows:
Now, \(\arr{A}\) will be row equivalent to \(\arr{I}\) if \(a_{21}\neq0\) and \(a_{12}\neq0\)
This is the same as saying \(a_{11}a_{21} \neq 0\) which is equivalent to (*) for \(a_{11}=0\):
Great! These cases of \(a_{11}\neq0\) and \(a_{11}=0\) are consistent and we can define
\(det(\arr{A}) = |\arr{A}| = a_{11}a_{22} - a_{12} a_{21}\)
Case 3: 3\(\times\) 3 Matrix#
We will not derive the determinant for a 3 \(\times\) 3 matrix in class (see text).
How to find it?
Working with Row 1, decompose as follows:
Looks complicated but it’s just a number. Each determinant is a “minor” determinant of the submatrix formed by eliminating row \(j\) and column \(k\).\
Example#
\(Ex: \arr{A} = \left|\begin{array}{} 2&5&4\\ 3&1&2\\ 5&4&6\end{array}\right|\)
What is \(\det(\arr{A})\)?
Row choice for determinants#
You don’t need to work with Row 1. You can use any column or row you’d like but must switch signs for even number rows or columns.
Ex: Choose column 2
\(\arr{A} = \left|\begin{array}{}
2&5&4\\
3&1&2\\
5&4&6\end{array}\right|\)
In-class problem#
Calculate the determinant of
General definition of the determinant (any size matrix)#
OK, so let’s revisit the general determinant definition:
where \(A_{1k} = (-1)^{1+k} \det(\arr{M_{1k}})\), for \(k=1,2,...n\)
So, for a 3 \(\times\)3 matrix, this would be
This generalized definition is for when we work off of Row 1 only.
We can further generalize
where \(A_{jk} = (-1)^{j+k}\det(\arr{M_{jk}})\) (careful with the signs!)
\(A_{jk}\) is the “cofactor” and \(\det(\arr{M_{jk}})\) is the “minor”
An n \(\times\) n matrix has \(n^2\) cofactors and \(n^2\) minors.
Note the “checker board” of the signs:
\begin{array}{}
& - & +\
& + & -\
& - & + \end{array}
In general, working with Row 1 is easiest, but the super-generalized formula (allowing you to work with any row or column) can be useful depending on the matrix.
Ex: \begin{bmatrix} 9 & 2 & \bf{4}\ 5 & 3 & \bf{0}\ 1 & 6 & \bf{0} \end{bmatrix}
Which column or row to choose? Column 3, which has most zeros.
Question: What if you have a row or column of all zeros?#
\(\underline{ANS}:\) Determinant is zero. We can “choose” all-zero row or column and then all \(a_{jk}\)’s will be zero.
Makes sense right? When \(|\arr{A}|=0, \arr{A}\) is singular, or not invertible i.e. we can’t convert the matrix to \(\arr{I}\) if there is a row or column of all zeros.
Use of determinant in solving systems of equations#
We will use the determinant a lot next class. Let’s clarify a couple of uses now.
We’re interested in a solution to the system \(\arr{A}\vec{x}=\vec{b}\). There are two situations:
Non-homogeneous system of equations (\(\vec{b}\neq\vec{0}\))
If \(\det(\arr{A})\neq 0\) or
rank(\(\arr{A}\))=n, or
\(\arr{A}\) is invertible,
THEN a unique solution exists
Homogeneous system of equations (\(\vec{b}=\vec{0}\))
If \(\det(\arr{A})\neq 0\)
There is only the trivial solution \(\vec{x}=\vec{0}\)
If \(\det(\arr{A})= 0\)
There is both the trivial solution \(\vec{x}=\vec{0}\) AND a series of non-trivial solutions
Numerical calculation of determinant#
Easy! np.linalg.det
Calculate the determinant of
import numpy as np
A = np.array([[-1,2,3],[0,5,3],[3,1,1]])
np.linalg.det(A)
-28.99999999999999