Code
import sympy as sp
import numpy as np
sp.init_printing()Signed volume, invertibility, and the geometry of matrix transformations
Guiding question.
When a matrix transforms space, how much area, volume, or higher-dimensional volume does it create, destroy, preserve, or reverse?
The determinant is often introduced as a formula. For a \(2\times 2\) matrix,
\[ \det\begin{bmatrix}a&b\\ c&d\end{bmatrix}=ad-bc. \]
But this formula is only the beginning. The main idea is geometric:
\[ \boxed{\det(A)=\text{signed volume-scaling factor of }x\mapsto Ax.} \]
If \(A\) maps the unit square to a parallelogram, then \(|\det(A)|\) is the area of that parallelogram. If \(A\) maps the unit cube to a parallelepiped, then \(|\det(A)|\) is its volume. If \(\det(A)=0\), the transformation collapses space into a lower-dimensional set.
In applied linear algebra, determinants connect many themes:
The determinant should not be memorized only as a formula. Read every formula together with this question:
What does this say about how a linear transformation changes volume?
Use Python or an AI assistant as a checking partner. Ask it to compute determinants by several methods: formula, row reduction, eigenvalues, singular values, and numerical libraries. Then ask which method is conceptual and which method is efficient.
import sympy as sp
import numpy as np
sp.init_printing()Start with two vectors in the plane,
\[ v_1=\begin{bmatrix}a\\c\end{bmatrix},\qquad v_2=\begin{bmatrix}b\\d\end{bmatrix}. \]
Place them as columns of a matrix:
\[ A=\begin{bmatrix}a&b\\c&d\end{bmatrix}. \]
The parallelogram spanned by \(v_1\) and \(v_2\) has signed area
\[ \det(A)=ad-bc. \]
The absolute value \(|\det(A)|\) is area. The sign records orientation.
For
\[ A=\begin{bmatrix}a&b\\c&d\end{bmatrix}, \]
the determinant is
\[ \det(A)=ad-bc. \]
Let
\[ A=\begin{bmatrix}2&1\\0&3\end{bmatrix}. \]
Then
\[ \det(A)=2\cdot 3-1\cdot 0=6. \]
So the transformation \(x\mapsto Ax\) changes every area by a factor of \(6\).
A = sp.Matrix([[2, 1], [0, 3]])
A.det()\(\displaystyle 6\)
Let
\[ S_k=\begin{bmatrix}1&k\\0&1\end{bmatrix}. \]
Then
\[ \det(S_k)=1. \]
A shear changes shapes, lengths, and angles, but it preserves area.
k = sp.symbols('k')
S = sp.Matrix([[1, k], [0, 1]])
sp.factor(S.det())\(\displaystyle 1\)
The reflection across the \(x\)-axis is
\[ R=\begin{bmatrix}1&0\\0&-1\end{bmatrix}. \]
It has determinant \(-1\). It preserves area but reverses orientation.
In \(\mathbb R^3\), the determinant measures signed volume.
If the columns of \(A\) are \(u,v,w\in\mathbb R^3\), then
\[ \det(A)=u\cdot(v\times w). \]
Thus \(|\det(A)|\) is the volume of the parallelepiped spanned by the three columns.
For
\[ A=\begin{bmatrix} a_{11}&a_{12}&a_{13}\\ a_{21}&a_{22}&a_{23}\\ a_{31}&a_{32}&a_{33} \end{bmatrix}, \]
\[ \det(A)= a_{11}(a_{22}a_{33}-a_{23}a_{32}) -a_{12}(a_{21}a_{33}-a_{23}a_{31}) +a_{13}(a_{21}a_{32}-a_{22}a_{31}). \]
A = sp.Matrix([[1,2,3],[2,5,7],[1,1,0]])
A.det()\(\displaystyle -2\)
The determinant is \(-2\), so the transformation reverses orientation and scales volume by \(2\).
The determinant in dimension \(n\) is the unique function of the columns that behaves like signed volume.
There is a unique function
\[ D:(\mathbb F^n)^n\to \mathbb F \]
assigning a scalar to an ordered list of \(n\) column vectors such that:
This function is the determinant.
The three properties are the algebraic fingerprints of volume:
Let \(S_n\) be the set of all permutations of \(\{1,\ldots,n\}\). For \(\sigma\in S_n\), let \(\operatorname{sgn}(\sigma)\) be \(1\) for even permutations and \(-1\) for odd permutations.
For \(A=(a_{ij})\in\mathbb F^{n\times n}\),
\[ \det(A)=\sum_{\sigma\in S_n}\operatorname{sgn}(\sigma) a_{1,\sigma(1)}a_{2,\sigma(2)}\cdots a_{n,\sigma(n)}. \]
This formula is conceptually important but computationally expensive: it has \(n!\) terms.
import math
for n in range(2, 9):
print(n, math.factorial(n))2 2
3 6
4 24
5 120
6 720
7 5040
8 40320
For \(A\in\mathbb F^{n\times n}\), let \(A_{ij}\) be the matrix obtained by deleting row \(i\) and column \(j\). The cofactor of \(a_{ij}\) is
\[ C_{ij}=(-1)^{i+j}\det(A_{ij}). \]
For any fixed row \(i\),
\[ \det(A)=\sum_{j=1}^n a_{ij}C_{ij}. \]
For any fixed column \(j\),
\[ \det(A)=\sum_{i=1}^n a_{ij}C_{ij}. \]
Cofactor expansion is excellent for proofs and small symbolic examples. It is not the preferred method for large numerical matrices.
The practical way to compute determinants is elimination.
Let \(A\) be a square matrix.
If \(U\) is upper triangular, then
\[ \det(U)=u_{11}u_{22}\cdots u_{nn}. \]
The same result holds for lower triangular matrices.
Therefore, if Gaussian elimination transforms \(A\) into an upper triangular matrix \(U\) using row replacement operations and \(s\) row swaps, then
\[ \det(A)=(-1)^s\prod_{i=1}^n u_{ii}. \]
Let
\[ A=\begin{bmatrix} 1&2&3\\ 2&5&7\\ 1&1&0 \end{bmatrix}. \]
Using row replacement operations only,
\[ A\sim \begin{bmatrix} 1&2&3\\ 0&1&1\\ 0&-1&-3 \end{bmatrix} \sim \begin{bmatrix} 1&2&3\\ 0&1&1\\ 0&0&-2 \end{bmatrix}. \]
No row swaps or row scalings were used, so
\[ \det(A)=1\cdot 1\cdot (-2)=-2. \]
A = sp.Matrix([[1,2,3],[2,5,7],[1,1,0]])
A.det(), A.rref()[0]\(\displaystyle \left( -2, \ \left[\begin{matrix}1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 1\end{matrix}\right]\right)\)
For square matrices \(A,B\in\mathbb F^{n\times n}\) and scalar \(c\in\mathbb F\):
The product rule is natural from the volume viewpoint. If \(B\) scales volume by \(\det(B)\) and \(A\) scales volume by \(\det(A)\), then \(AB\) scales volume by the product.
A = sp.Matrix([[2,1],[0,3]])
B = sp.Matrix([[1,4],[2,5]])
A.det(), B.det(), (A*B).det(), A.det()*B.det()\(\displaystyle \left( 6, \ -3, \ -18, \ -18\right)\)
The determinant detects whether a square matrix loses dimension.
For \(A\in\mathbb F^{n\times n}\), the following are equivalent:
Let
\[ A=\begin{bmatrix}1&2\\2&4\end{bmatrix}. \]
Then
\[ \det(A)=1\cdot4-2\cdot2=0. \]
The second column is twice the first column. The image of \(\mathbb R^2\) is a line, not the whole plane.
Let \(A\in\mathbb C^{n\times n}\) have eigenvalues \(\lambda_1,\ldots,\lambda_n\), counted with algebraic multiplicity. Then
\[ \det(A)=\lambda_1\lambda_2\cdots\lambda_n. \]
For a \(2\times2\) matrix
\[ A=\begin{bmatrix}a&b\\c&d\end{bmatrix}, \]
the characteristic polynomial is
\[ p_A(\lambda)=\lambda^2-\operatorname{tr}(A)\lambda+\det(A). \]
Trace and determinant are the two basic spectral invariants in dimension two.
A = sp.Matrix([[3, 1], [0, 5]])
A.det(), A.trace(), A.charpoly().as_expr()\(\displaystyle \left( 15, \ 8, \ \lambda^{2} - 8 \lambda + 15\right)\)
Eigenvalues describe invariant directions when they exist. Singular values describe orthogonal stretching directions.
Let \(A\in\mathbb R^{n\times n}\) have singular values \(\sigma_1,\ldots,\sigma_n\). Then
\[ |\det(A)|=\sigma_1\sigma_2\cdots\sigma_n. \]
The determinant gives the product of stretches, but it does not show the individual stretches.
Let
\[ A=\begin{bmatrix}1000&0\\0&0.001\end{bmatrix}. \]
Then \(\det(A)=1\), but its singular values are \(1000\) and \(0.001\), so
\[ \kappa_2(A)=\frac{1000}{0.001}=10^6. \]
The matrix preserves area but strongly stretches one direction and strongly compresses another.
A = np.array([[1000.0, 0.0], [0.0, 0.001]])
np.linalg.det(A), np.linalg.svd(A, compute_uv=False), np.linalg.cond(A)(1.0, array([1.e+03, 1.e-03]), 1000000.0)
A small determinant is not the best numerical test for near-singularity. Use singular values or condition number. A matrix can have determinant \(1\) and still be ill-conditioned.
Determinants are often computed from factorizations.
If
\[ PA=LU, \]
where \(P\) is a permutation matrix, \(L\) is unit lower triangular, and \(U\) is upper triangular, then
\[ \det(A)=\det(P)\prod_{i=1}^n u_{ii}. \]
If
\[ A=QR, \]
where \(Q\) is orthogonal and \(R\) is upper triangular, then
\[ |\det(A)|=\left|\prod_{i=1}^n r_{ii}\right|. \]
If \(A\) is symmetric positive definite and
\[ A=LL^T, \]
then
\[ \det(A)=\det(L)^2=\left(\prod_{i=1}^n L_{ii}\right)^2, \]
and
\[ \log\det(A)=2\sum_{i=1}^n\log L_{ii}. \]
This is one of the most stable ways to compute log determinants of positive definite matrices.
Sigma = np.array([[4.0, 1.2], [1.2, 2.0]])
L = np.linalg.cholesky(Sigma)
logdet_chol = 2*np.sum(np.log(np.diag(L)))
np.linalg.det(Sigma), np.linalg.slogdet(Sigma), logdet_chol\(\displaystyle \left( 6.56, \ \left( 1.0, \ 1.880990602956\right), \ 1.880990602956\right)\)
Let \(v_1,\ldots,v_k\in\mathbb R^n\), where \(k\le n\). The Gram matrix is
\[ G=(v_i\cdot v_j)_{i,j=1}^k. \]
The square of the \(k\)-dimensional volume of the parallelepiped spanned by \(v_1,\ldots,v_k\) is
\[ \det(G). \]
Therefore
\[ \operatorname{Vol}_k(v_1,\ldots,v_k)=\sqrt{\det(G)}. \]
If \(V\) is the \(n\times k\) matrix whose columns are \(v_1,\ldots,v_k\), then
\[ G=V^TV. \]
This is very important in least squares and data analysis.
V = sp.Matrix([[1,0],[0,1],[2,-1]])
G = V.T*V
G, sp.sqrt(G.det())\(\displaystyle \left( \left[\begin{matrix}5 & -2\\-2 & 2\end{matrix}\right], \ \sqrt{6}\right)\)
If \(\Sigma\) is a positive definite covariance matrix, then \(\det(\Sigma)>0\). The determinant is called the generalized variance. It measures the volume of the covariance ellipsoid.
If
\[ x\sim N(\mu,\Sigma), \]
then
\[ f(x)=\frac{1}{(2\pi)^{n/2}\det(\Sigma)^{1/2}} \exp\left(-\frac12(x-\mu)^T\Sigma^{-1}(x-\mu)\right). \]
The factor \(\det(\Sigma)^{-1/2}\) normalizes the volume.
The differential entropy of \(N(\mu,\Sigma)\) is
\[ h(x)=\frac12\log\left((2\pi e)^n\det(\Sigma)\right). \]
Thus \(\log\det(\Sigma)\) measures uncertainty volume.
Let \(A\in\mathbb R^{n\times n}\) be invertible and let \(u,v\in\mathbb R^n\). Then
\[ \det(A+uv^T)=\det(A)(1+v^TA^{-1}u). \]
More generally, if \(U,V\in\mathbb R^{n\times k}\), then
\[ \det(A+UV^T)=\det(A)\det(I_k+V^TA^{-1}U). \]
If \(A\in\mathbb R^{m\times n}\) and \(B\in\mathbb R^{n\times m}\), then
\[ \det(I_m+AB)=\det(I_n+BA). \]
Let
\[ M=\begin{bmatrix}A&B\\C&D\end{bmatrix}, \]
where \(A\) is invertible. Then
\[ \det(M)=\det(A)\det(D-CA^{-1}B). \]
If \(A\) is invertible, then
\[ d(\det A)=\det(A)\operatorname{tr}(A^{-1}dA). \]
Equivalently,
\[ \nabla_A\det(A)=\det(A)A^{-T}. \]
If \(A\) is invertible and \(\det(A)>0\), then
\[ d(\log\det A)=\operatorname{tr}(A^{-1}dA), \]
and
\[ \nabla_A\log\det(A)=A^{-T}. \]
If \(A\) is symmetric positive definite, then the gradient becomes \(A^{-1}\).
The log determinant appears in Gaussian maximum likelihood, covariance estimation, interior-point methods, graphical lasso, and optimal experimental design.
Let \(G\) be a graph with adjacency matrix \(A\) and degree matrix \(D\). The graph Laplacian is
\[ L=D-A. \]
Since \(L\mathbf 1=0\), we always have \(\det(L)=0\) for a graph with at least one vertex. However, the cofactors of \(L\) contain important combinatorial information.
If \(G\) is a connected graph and \(L\) is its Laplacian, then every cofactor of \(L\) equals the number of spanning trees of \(G\).
If \(L^{(i)}\) is obtained by deleting row \(i\) and column \(i\), then
\[ \tau(G)=\det(L^{(i)}), \]
where \(\tau(G)\) is the number of spanning trees of \(G\).
Let
\[ A=\begin{bmatrix}2&3\\1&4\end{bmatrix}. \]
Compute \(\det(A)\), interpret it geometrically, and determine whether \(A\) preserves or reverses orientation.
Compute the determinant of
\[ A=\begin{bmatrix} 1&2&3\\ 2&5&7\\ 1&1&0 \end{bmatrix} \]
using row operations, not cofactor expansion.
Suppose \(A\in\mathbb R^{4\times4}\) has eigenvalues
\[ 2,\quad -1,\quad 3,\quad 5. \]
Find \(\det(A)\) and decide whether \(A\) is invertible.
Suppose \(A\in\mathbb R^{3\times3}\) has singular values
\[ 10,\quad 1, \quad 0.01. \]
Find \(|\det(A)|\), estimate the condition number, and explain why the matrix may be numerically unstable.
Let
\[ \Sigma=\begin{bmatrix}4&0\\0&1\end{bmatrix}. \]
Compute \(\det(\Sigma)\) and interpret it as generalized variance.
\[ \det(A)=2\cdot4-3\cdot1=5. \]
The transformation scales area by \(5\) and preserves orientation because the determinant is positive.
Using row replacements only,
\[ \begin{bmatrix} 1&2&3\\ 2&5&7\\ 1&1&0 \end{bmatrix} \sim \begin{bmatrix} 1&2&3\\ 0&1&1\\ 0&-1&-3 \end{bmatrix} \sim \begin{bmatrix} 1&2&3\\ 0&1&1\\ 0&0&-2 \end{bmatrix}. \]
Thus \(\det(A)=1\cdot1\cdot(-2)=-2\).
The determinant is the product of the eigenvalues:
\[ \det(A)=2(-1)(3)(5)=-30. \]
Since \(\det(A)\ne0\), \(A\) is invertible.
\[ |\det(A)|=10\cdot1\cdot0.01=0.1. \]
The condition number is
\[ \kappa_2(A)=\frac{10}{0.01}=1000. \]
The matrix is numerically unstable because one direction is much more compressed than another.
\[ \det(\Sigma)=4. \]
The covariance ellipse has area proportional to \(\sqrt{\det(\Sigma)}=2\). The generalized variance is \(4\).
Prove that if \(A\in\mathbb R^{n\times n}\) has singular values \(\sigma_1,\ldots,\sigma_n\), then
\[ |\det(A)|=\prod_{i=1}^n\sigma_i. \]
Solution. Use the singular value decomposition \(A=U\Sigma V^T\). Then
\[ \det(A)=\det(U)\det(\Sigma)\det(V^T). \]
Since \(U\) and \(V\) are orthogonal, \(|\det(U)|=|\det(V^T)|=1\). Hence
\[ |\det(A)|=|\det(\Sigma)|=\prod_{i=1}^n\sigma_i. \]
Let \(A\in\mathbb R^{m\times n}\) with \(m\ge n\). Explain why \(\det(A^TA)\) measures the squared volume spanned by the columns of \(A\).
Solution. The matrix \(A^TA\) is the Gram matrix of the columns of \(A\). The Gram determinant equals the square of the \(n\)-dimensional volume of the parallelepiped spanned by those columns.
Let
\[ M=\begin{bmatrix}A&B\\C&D\end{bmatrix}, \]
where \(A\) is invertible. Prove that
\[ \det(M)=\det(A)\det(D-CA^{-1}B). \]
Solution. Use block elimination:
\[ \begin{bmatrix}I&0\\-CA^{-1}&I\end{bmatrix} \begin{bmatrix}A&B\\C&D\end{bmatrix} = \begin{bmatrix}A&B\\0&D-CA^{-1}B\end{bmatrix}. \]
The left multiplier has determinant \(1\), and the matrix on the right is block upper triangular. Therefore
\[ \det(M)=\det(A)\det(D-CA^{-1}B). \]
Ask an AI assistant:
Compute the determinant of \(A=\begin{bmatrix}1&2&3\\2&5&7\\1&1&0\end{bmatrix}\) by cofactor expansion, row reduction, and Python. Compare the methods.
Then verify the answer yourself.
Ask:
Explain why a matrix with determinant zero collapses volume. Give one example in \(\mathbb R^2\) and one example in \(\mathbb R^3\).
Check whether the explanation mentions linear dependence of columns.
Ask:
Give an example of a matrix with determinant one but large condition number. Explain why determinant alone is not a good numerical stability test.
Confirm by computing singular values in Python.
Ask:
Why does \(\log\det(\Sigma)\) appear in multivariate Gaussian models and covariance estimation?
Then summarize the answer in your own words using the phrase uncertainty volume.
The determinant is a unifying concept: