+ This notebook is part of lecture 18 *Properties of determinants* in the OCW MIT course 18.06 by Prof Gilbert Strang [1]
+ Created by me, Dr Juan H Klopper
    + Head of Acute Care Surgery
    + Groote Schuur Hospital
    + University Cape Town
    + <a href="mailto:juan.klopper@uct.ac.za">Email me with your thoughts, comments, suggestions and corrections</a> 
<a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/"></a><br /><span xmlns:dct="http://purl.org/dc/terms/" href="http://purl.org/dc/dcmitype/InteractiveResource" property="dct:title" rel="dct:type">Linear Algebra OCW MIT18.06</span> <span xmlns:cc="http://creativecommons.org/ns#" property="cc:attributionName">IPython notebook [2] study notes by Dr Juan H Klopper</span> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/">Creative Commons Attribution-NonCommercial 4.0 International License</a>.

+ [1] <a href="http://ocw.mit.edu/courses/mathematics/18-06sc-linear-algebra-fall-2011/index.htm">OCW MIT 18.06</a>
+ [2] Fernando Pérez, Brian E. Granger, IPython: A System for Interactive Scientific Computing, Computing in Science and Engineering, vol. 9, no. 3, pp. 21-29, May/June 2007, doi:10.1109/MCSE.2007.53. URL: http://ipython.org


```python
from IPython.core.display import HTML, Image
css_file = 'style.css'
HTML(open(css_file, 'r').read())
```




<link href='http://fonts.googleapis.com/css?family=Alegreya+Sans:100,300,400,500,700,800,900,100italic,300italic,400italic,500italic,700italic,800italic,900italic' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Arvo:400,700,400italic' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=PT+Mono' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Shadows+Into+Light' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Philosopher:400,700,400italic,700italic' rel='stylesheet' type='text/css'>

<style>

@font-face {
    font-family: "Computer Modern";
    src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunss.otf');
}

#notebook_panel { /* main background */
    background: #ddd;
    color: #000000;
}



/* Formatting for header cells */
.text_cell_render h1 {
    font-family: 'Philosopher', sans-serif;
    font-weight: 400;
    font-size: 2.2em;
    line-height: 100%;
    color: rgb(0, 80, 120);
    margin-bottom: 0.1em;
    margin-top: 0.1em;
    display: block;
}	
.text_cell_render h2 {
    font-family: 'Philosopher', serif;
    font-weight: 400;
    font-size: 1.9em;
    line-height: 100%;
    color: rgb(200,100,0);
    margin-bottom: 0.1em;
    margin-top: 0.1em;
    display: block;
}	

.text_cell_render h3 {
    font-family: 'Philosopher', serif;
    margin-top:12px;
    margin-bottom: 3px;
    font-style: italic;
    color: rgb(94,127,192);
}

.text_cell_render h4 {
    font-family: 'Philosopher', serif;
}

.text_cell_render h5 {
    font-family: 'Alegreya Sans', sans-serif;
    font-weight: 300;
    font-size: 16pt;
    color: grey;
    font-style: italic;
    margin-bottom: .1em;
    margin-top: 0.1em;
    display: block;
}

.text_cell_render h6 {
    font-family: 'PT Mono', sans-serif;
    font-weight: 300;
    font-size: 10pt;
    color: grey;
    margin-bottom: 1px;
    margin-top: 1px;
}

.CodeMirror{
        font-family: "PT Mono";
        font-size: 100%;
}

</style>






```python
from sympy import init_printing, Matrix, symbols
from IPython.display import HTML
from warnings import filterwarnings
```


```python
init_printing(use_latex = 'mathjax')
filterwarnings('ignore')
```


```python
a, b, c = symbols('a b c')
```

# Properties of the determinant

## Notation

* The determinant of a matrix A is written as det(A) or |A|

## Main properties

* There are three main properties (first three listed below) and seven that follow from them

* det(I)=1
* A row exchange changes the sign of the determinant
    * We now know the determinant of every permutation matrix
* Multiplying any row with a constant results in the determinant also being multiplied by that constant
        * Only works when altering a single row (the determinant is a linear function of each row separately)
        * An alternate way of seeing this is
$$ \begin{vmatrix} a+a' & b+b' \\ c & d \end{vmatrix}=\begin{vmatrix} a & b \\ c & d \end{vmatrix}+\begin{vmatrix} a' & b' \\ c & d \end{vmatrix} $$
* If two rows are equal then the determinant is zero
    * This follows from property number two, where if we interchange rows the sign must change
    * This only works for zero, since row exchange leaves the matrix unchanged, which now can't have a different determinant (opposite sign)
* Subtracting a constant multiple of one row from another leaves the determinant unchanged
    * This flows from property three above
$$ \begin{vmatrix} a & b \\ c-la & d-lb \end{vmatrix}=\begin{vmatrix} a & b \\ c & d \end{vmatrix}+\begin{vmatrix} a & b \\ -la & -lb \end{vmatrix} $$
    * From property four (determinant of matrix with two similar rows equal zero) we now have the following
$$ =\begin{vmatrix} a & b \\ c & d \end{vmatrix}+\left( -l \right) \begin{vmatrix} a & b \\ a & b \end{vmatrix}\\ =\begin{vmatrix} a & b \\ c & d \end{vmatrix}+0\\ =\begin{vmatrix} a & b \\ c & d \end{vmatrix} $$
* The determinant of a matrix with a complete row (or columns) of zero is zero
    * This also follows from property three above, but multiplying a row by zero
* The determinant of an upper triangular matrix is the product of the elements of the main diagonal (the pivots)
    * Same goes for a diagonal matrix
        * This helps us to develop the expression for the determinant of a 2&#215;2 matrix
$$ \begin{bmatrix} a & b \\ c & d \end{bmatrix}\\ \begin{bmatrix} \frac { c }{ a } a & \frac { c }{ a } b \\ c & d \end{bmatrix}\\ \begin{bmatrix} a & b \\ c-\frac { c }{ a } a & d-\frac { c }{ a } b \end{bmatrix}\\ \begin{bmatrix} a & b \\ 0 & d-\frac { c }{ a } b \end{bmatrix}\\ \therefore \quad \begin{vmatrix} a & b \\ 0 & d-\frac { c }{ a } b \end{vmatrix}\\ =\left( a \right) \left( d-\frac { c }{ a } b \right) \\ =ad-a\frac { c }{ a } b\\ =ad-bc $$
    * We can change an upper triangular matrix into a diagonal matrix by row operations (leaving the determinant unchanged by property five)
    * Now we can use the first part of the third property and take out each pivot
    * Eventually we are left with the identity matrix and the product of all the pivots
    * For a zero on the main diagonal we can use the property of a row of zeros and know the determinant is zero
* If the determinant is zero, the matrix is singular (only has the zero solution / not invertible)
* The determinant of the product of matrices
$$ \left| AB \right| =\left| A \right| \left| B \right| \\ \left| { A }^{ -1 } \right| =\frac { 1 }{ \left| A \right|  } \\ \left| { A }^{ 2 } \right| =\left| A \right| \left| A \right| ={ \left| A \right|  }^{ 2 }\\ \left| cA \right| ={ c }^{ n }\left| A \right|  $$
* For the determinant of a transpose of a matrix we have
$$ \left| { A }^{ T } \right| =\left| A \right|  $$

## Example problems

* Do the following by making use of the properties above

### Example problem 1


```python
A = Matrix([[101, 201, 301], [102, 202, 302], [103, 203, 303]])
A
```




$$\left[\begin{matrix}101 & 201 & 301\\102 & 202 & 302\\103 & 203 & 303\end{matrix}\right]$$



#### Solution

* By constant multiple subtraction we get
$$ \begin{bmatrix} 101 & 201 & 301 \\ 1 & 1 & 1 \\ 1 & 1 & 1 \end{bmatrix} $$
* Two identical rows, thus the determinant is zero


```python
A.det()
```




$$0$$



### Example problem 2


```python
A = Matrix([[1, a, a ** 2], [1, b, b ** 2], [1, c, c ** 2]])
A
```




$$\left[\begin{matrix}1 & a & a^{2}\\1 & b & b^{2}\\1 & c & c^{2}\end{matrix}\right]$$



#### Solution

* Subtracting constant multiple of row 1 from rows 2 and three and expanding the elements
$$ =\begin{vmatrix} 1 & a & { a }^{ 2 } \\ 0 & b-a & { b }^{ 2 }-{ a }^{ 2 } \\ 0 & c-a & { c }^{ 2 }-{ a }^{ 2 } \end{vmatrix}\\ =\begin{vmatrix} 1 & a & { a }^{ 2 } \\ 0 & b-a & \left( b-a \right) \left( b+a \right)  \\ 0 & c-a & \left( c-a \right) \left( c+a \right)  \end{vmatrix} $$
* Using property three that states that the determinant is a linear property of each row
$$ =\left( b-a \right) \left( c-a \right) =\begin{vmatrix} 1 & a & { a }^{ 2 } \\ 0 & 1 & \left( b+a \right)  \\ 0 & 1 & \left( c+a \right)  \end{vmatrix} $$
* Another elimination on row three
$$ \left( b-a \right) \left( c-a \right) =\begin{vmatrix} 1 & a & { a }^{ 2 } \\ 0 & 1 & \left( b+a \right)  \\ 0 & 1 & \left( c+a \right)  \end{vmatrix} $$
* Now we have upper triangular form and the determinant is the product of the elements in the main diagonal and also multiplying the (*b*-*a*)(*c*-*a*)
$$ =\left( b-a \right) \left( c-a \right) \left( b-c \right)  $$


```python
(A.det()).factor() # Calculating the determinant and factorizing the result
```




$$- \left(a - b\right) \left(a - c\right) \left(b - c\right)$$



* This is called a Vandermonde matrix
* http://en.wikipedia.org/wiki/Vandermonde_matrix

### Example problem 3


```python
A = Matrix([1, 2, 3]) * Matrix([[1, -4, 5]])
A
```




$$\left[\begin{matrix}1 & -4 & 5\\2 & -8 & 10\\3 & -12 & 15\end{matrix}\right]$$



#### Solution

* The rows of the resultant 3&#215;3 matrix is linearly dependent, i.e. they are 1 times the row (1,-4,5), then twice this same row for row two and lastly three times the same row for row three
* This means that the determinant will be zero


```python
A.det()
```




$$0$$



### Example problem 4


```python
A = Matrix([[0, 1, 3], [-1, 0, 4], [-3, -4, 0]])
A
```




$$\left[\begin{matrix}0 & 1 & 3\\-1 & 0 & 4\\-3 & -4 & 0\end{matrix}\right]$$



#### Solution

* Note how this matrix is *skew* symmetric
* This means that A<sup>T</sup>=-A
* With the matrices A<sup>T</sup> and -A being equal, their determinant are equal
* Remember, though that the determinant of a matrix is the same as the determinant of the transpose of the matrix
$$ \left| A \right| =\left| { A }^{ T } \right| =\left| -A \right| ={ \left( -1 \right)  }^{ 3 }\left| A \right| =-\left| A \right| \\ \left| A \right| =-\left| A \right| \\ \therefore \quad \left| A \right| =0 $$


```python
A.det()
```




$$0$$



* Not all skew symmetric matrices have a zero determinant
* It only works because *n* is odd for this size matrix being 3&#215;3 allowing for the negative


```python

```
