Determinant and Trace
Before we factor matrices, we need two numbers that summarize them: the determinant and the trace. The determinant measures how much a matrix scales volume (and whether it can be inverted); the trace sums its diagonal. Both are invariant under basis change, which is why they capture something intrinsic about a linear map — and both turn out to be built from the matrix’s eigenvalues.
A real-life example: does a mixture have a unique recipe?
You blend two base syrups to hit a target flavor with two properties (sweetness, acidity). Each syrup contributes a known amount of each. If the two syrups affect the properties in genuinely different ways, there’s a unique blend — but if one syrup is just a scaled version of the other, their “flavor vectors” are collinear and no unique recipe exists. The determinant of the recipe matrix is exactly the test: nonzero → unique blend, zero → no unique solution.
The determinant
The determinant (also written ) is defined only for square matrices. Small cases have closed forms:
and for , Sarrus’ rule:
For a triangular matrix, the determinant is just the product of the diagonal, — which is why we compute large determinants by row-reducing to triangular form. Larger matrices use recursive Laplace expansion along a row or column.
The determinant is signed volume
The most useful picture: is the signed volume of the shape spanned by the columns of . In 2-D that’s the area of the parallelogram formed by the two column vectors. Watch the area as one column rotates — it shrinks to zero exactly when the columns become collinear (a singular, non-invertible matrix), and the sign flips when their orientation flips:
That zero-area moment is the whole story of invertibility.
Determinant properties
- — determinant of a product is the product of determinants.
- — transposition doesn’t change it.
- when is invertible.
- Similar matrices have the same determinant — so it’s invariant under basis change.
- Adding a multiple of one row to another leaves unchanged; scaling a row by scales by ; swapping two rows flips the sign.
Two headline theorems tie it to earlier chapters:
The trace
The trace is the sum of the diagonal entries:
It’s linear () and — crucially — invariant under cyclic permutation: . In particular even when , and , so the trace is also basis-independent.
The bridge to eigenvalues
The characteristic polynomial is where determinant and trace meet eigenvalues (next page). Two beautiful identities fall out:
The determinant is the product of the eigenvalues; the trace is their sum. Volume scaling = product of stretches; that’s the geometry made precise.
flowchart LR A["Matrix A"] --> CP["char. polynomial
det(A − λI) = 0"] CP --> EV["eigenvalues λᵢ"] EV --> D["det(A) = Πλᵢ"] EV --> T["tr(A) = Σλᵢ"]
NumPy
import numpy as np
A = np.array([[4.0, 2.0],
[1.0, 3.0]])
print("det:", np.linalg.det(A)) # 10.0
print("trace:", np.trace(A)) # 7.0
# invertible iff det != 0
print("invertible:", not np.isclose(np.linalg.det(A), 0))
# det = product of eigenvalues, trace = sum of eigenvalues
eig = np.linalg.eigvals(A)
print("eigenvalues:", np.round(eig, 4))
print("prod eig ≈ det :", np.isclose(np.prod(eig), np.linalg.det(A)))
print("sum eig ≈ trace:", np.isclose(np.sum(eig), np.trace(A)))
# a singular matrix has det 0
S = np.array([[1.0, 2.0], [2.0, 4.0]]) # second column = 2 * first row-wise -> collinear
print("singular det:", round(np.linalg.det(S), 6))import numpy as np
A = np.array([[4.0, 2.0],
[1.0, 3.0]])
print("det:", np.linalg.det(A)) # 10.0
print("trace:", np.trace(A)) # 7.0
# invertible iff det != 0
print("invertible:", not np.isclose(np.linalg.det(A), 0))
# det = product of eigenvalues, trace = sum of eigenvalues
eig = np.linalg.eigvals(A)
print("eigenvalues:", np.round(eig, 4))
print("prod eig ≈ det :", np.isclose(np.prod(eig), np.linalg.det(A)))
print("sum eig ≈ trace:", np.isclose(np.sum(eig), np.trace(A)))
# a singular matrix has det 0
S = np.array([[1.0, 2.0], [2.0, 4.0]]) # second column = 2 * first row-wise -> collinear
print("singular det:", round(np.linalg.det(S), 6))det: 10.000000000000002
trace: 7.0
invertible: True
eigenvalues: [2. 5.]
prod eig ≈ det : True
sum eig ≈ trace: True
singular det: 0.0det: 10.000000000000002
trace: 7.0
invertible: True
eigenvalues: [2. 5.]
prod eig ≈ det : True
sum eig ≈ trace: True
singular det: 0.0Why this matters for ML
- Gaussian densities and normalizing flows need of a covariance / Jacobian to normalize probabilities — the log-det term shows up in nearly every likelihood.
- Invertibility checks: a zero (or tiny) determinant flags singular / ill-conditioned matrices that break linear solves and blow up regression coefficients.
- The trace appears in loss functions (e.g. ), regularizers, and the cyclic trace trick that simplifies gradient derivations.
🧪 Try It Yourself
Exercise 1 – Determinant and invertibility
Exercise 2 – det = product of eigenvalues
Exercise 3 – Trace is the sum of eigenvalues
Recap
- The determinant is the signed volume a matrix scales space by; ⇔ singular ⇔ not full rank ⇔ no inverse.
- , , and it’s basis-invariant.
- The trace sums the diagonal, is cyclic-invariant, and basis-independent.
- and — both are built from eigenvalues.
Next: those eigenvalues and the directions they belong to — Eigenvalues and Eigenvectors.
If this helped you, consider buying me a coffee ☕
Buy me a coffeeWas this page helpful?
Let us know how we did
