Activating project at `~/Documents/github.com/ucla-biostat-216/2023fall/slides/09-det`
Status `~/Documents/github.com/ucla-biostat-216/2023fall/slides/09-det/Project.toml`
[91a5bcdd] Plots v1.39.0
[0c5d862f] Symbolics v5.10.0
[37e2e46d] LinearAlgebra
usingLinearAlgebra, Plots, Symbolics
We review some basic facts about matrix determinant.
1 Definition of determinant
The determinant of a square matrix \(\mathbf{A} \in \mathbb{R}^{n \times n}\) is \[
\det (\mathbf{A}) = \sum (-1)^{\phi(j_1,\ldots,j_n)} \prod_{i=1}^n a_{ij_i},
\] where the summation is over all permutation \((j_1, \ldots, j_n)\) of the set of integers \((1,\ldots,n)\) and \(\phi(j_1,\ldots,j_n)\) is the number of transpositions to change \((1,\ldots,n)\) to \((j_1,\ldots,j_n)\). \((-1)^{\phi(j_1,\ldots,j_n)}\) is also called the sign of permutation.
Interpretation of the (absolute value of) determinant as the volume of the parallelotope defined by the columns of the matrix. For example, if \(\mathbf{X} \in \mathbb{R}^2\) has two columns \(\mathbf{x}_1\) and \(\mathbf{x}_2\), then \[\begin{eqnarray*}
\text{area} &=& bh = \|\mathbf{x}_1\|\|\mathbf{x}_2\| \sin(\theta) \\
&=& \|\mathbf{x}_1\| \|\mathbf{x}_2\| \sqrt{1 - \left( \frac{\langle \mathbf{x}_1, \mathbf{x}_2 \rangle}{\|\mathbf{x}_1\| \|\mathbf{x}_2\|} \right)^2} \\
&=& \sqrt{\|\mathbf{x}_1\|^2 \|\mathbf{x}\|^2 - (\langle \mathbf{x}_1, \mathbf{x}_2\rangle)^2} \\
&=& \sqrt{(x_{11}^2 + x_{12}^2)(x_{21}^2+x_{22}^2) - (x_{11}x_{21} + x_{12}x_{22})^2} \\
&=& |x_{11} x_{22} - x_{12} x_{21}| \\
&=& |\det(\mathbf{X})|.
\end{eqnarray*}\]
Another interpretation of the determinant is the volume changing factor when operating on a set in \(\mathbb{R}^n\). \(\text{vol}(f(S)) = |\det(\mathbf{A})| \text{vol}(S)\) where \(f: \mathbb{R}^n \mapsto \mathbb{R}^n\) is the linear mapping defined by \(\mathbf{A}\).
Recall that for differentiable function \(f: \mathbb{R}^n \mapsto \mathbb{R}^n\), the Jacobian matrix\(\operatorname{D} f(\mathbf{x}) \in \mathbb{R}^{n \times n}\) is \[
\operatorname{D} f(\mathbf{x}) = \begin{pmatrix}
\frac{\partial f_1}{\partial x_1} (\mathbf{x}) & \frac{\partial f_1}{\partial x_2} (\mathbf{x}) & \cdots & \frac{\partial f_1}{\partial x_n} (\mathbf{x}) \\
\frac{\partial f_2}{\partial x_1} (\mathbf{x}) & \frac{\partial f_2}{\partial x_2} (\mathbf{x}) & \cdots & \frac{\partial f_2}{\partial x_n} (\mathbf{x}) \\
\vdots & \vdots & & \vdots \\
\frac{\partial f_n}{\partial x_1} (\mathbf{x}) & \frac{\partial f_n}{\partial x_2} (\mathbf{x}) & \cdots & \frac{\partial f_n}{\partial x_n} (\mathbf{x})
\end{pmatrix} = \begin{pmatrix}
\nabla f_1(\mathbf{x})' \\
\nabla f_2(\mathbf{x})' \\
\vdots \\
\nabla f_n(\mathbf{x})'
\end{pmatrix}.
\] Its determinant, the Jacobian determinant, appears in the higher-dimensional version of integration by substitution or change of variable\[
\int_{f(U)} \phi(\mathbf{v}) \, \operatorname{d} \mathbf{v} = \int_U \phi(f(\mathbf{u})) | \det \operatorname{D} f(\mathbf{u})| \, \operatorname{d} \mathbf{u}
\] for function \(\phi: \mathbb{R}^n \mapsto \mathbb{R}\). This result will be used in transformation of random variables in 202A.
For an example of \(n=1\), an indefinite integral can be transformed to a definite integral over box [-1,1] via change of variable \(v = u / (1-u^2)\): \[
\int_{-\infty}^\infty f(v) \, dv = \int_{-1}^1 f\left(\frac{u}{1-u^2}\right) \frac{1+u^2}{(1-u^2)^2} \, du.
\]
3 Some properties of determinant (important)
The determinant of a lower or upper triangular matrix\(\mathbf{A}\) is the product of the diagonal elements \(\prod_{i=1}^n a_{ii}\). (Why?)
Any square matrix \(\mathbf{A}\) is singular if and only if \(\det(\mathbf{A}) = 0\).
Product rule is extremely useful. For example, computer calculates the determinant of a square matrix \(\mathbf{A}\) by first computing the LU decomposition \(\mathbf{A} = \mathbf{L} \mathbf{U}\) and then \(\det(\mathbf{A}) = \det(\mathbf{L}) \det(\mathbf{U})\).
Determinant of an orthogonal matrix is 1 (rotation) or -1 (reflection).
This classifies orthogonal matrices into two classes: rotations and reflections.
# a rotatorθ =π/4A = [cos(θ) -sin(θ); sin(θ) cos(θ)]