Determinant and Rank TODO
Concept
The determinant is a scalar associated with a square matrix that expresses by what factor the linear transformation it represents scales volume, and whether it flips orientation. A determinant of zero means the transformation flattens the space into a lower dimension, which is equivalent to the inverse not existing. Rank is the dimension of the space spanned by the matrix's columns — the maximum number of linearly independent columns — and row rank always equals column rank. By the rank-nullity theorem, for a matrix with n columns, rank plus the dimension of the null space equals n, and this relationship determines whether a system of linear equations has a unique solution or infinitely many. In numerical computation, it's more stable to look at the condition number derived from the singular values than to check whether the determinant is zero, because the determinant is scale-sensitive and unsuitable as an indicator for detecting near-singular matrices.
Whether a linear system has a unique solution, whether the data effectively has redundant explanatory variables, and whether the numerical computation will become unstable — all of these are determined by rank and condition number.
Code & Formula
# 행렬식과 랭크 — det=0 <=> 열이 선형종속 <=> 역행렬 없음 <=> 랭크 부족, 을 수치로 확인한다.
import numpy as np
A_full_rank = np.array([[1.0, 2.0, 0.0],
[0.0, 1.0, 3.0],
[4.0, 0.0, 1.0]])
# 세 번째 열을 앞 두 열의 선형결합으로 만들어 일부러 랭크를 하나 부족하게 만든 행렬
A_deficient = A_full_rank.copy()
A_deficient[:, 2] = 2 * A_full_rank[:, 0] - A_full_rank[:, 1]
for name, A in [("full-rank 행렬", A_full_rank), ("랭크 부족 행렬 (열3 = 2*열1 - 열2)", A_deficient)]:
det = np.linalg.det(A)
rank = np.linalg.matrix_rank(A)
invertible = not np.isclose(det, 0)
print(f"[{name}]")
print(f" det(A) = {det:.6f}")
print(f" rank(A) = {rank} (정방행렬 크기 = {A.shape[0]})")
print(f" 역행렬 존재? {invertible}\n")
# 랭크-널리티 정리: rank(A) + dim(null(A)) = n (열 개수)
n = A_deficient.shape[1]
rank_deficient = np.linalg.matrix_rank(A_deficient)
# SVD로 영공간 차원을 구한다 (특이값이 ~0인 개수)
_, S, _ = np.linalg.svd(A_deficient)
nullity = np.sum(np.isclose(S, 0))
print(f"랭크-널리티 검증: rank({rank_deficient}) + nullity({nullity}) = {rank_deficient + nullity} = n({n})")
Exercise
Construct a rank-deficient 3x3 matrix, confirm its determinant is zero, then add a very small value to one entry and compare how the determinant and the condition number each change.
Practical Connection
When working with data whose columns are nearly linearly dependent — like a price correlation matrix or risk metrics across multiple markets — the solution becomes unstable, so checking rank and condition number before regression or covariance estimation needs to be a habit.
Where it lands in Jayverse
- Number: check the condition number, not just whether the determinant is zero, before regression on market data. Before running covariance estimation or regression on Number's price-correlation or risk matrices, screen for near-singular inputs with the condition number, since the determinant is scale-sensitive and misses the near-zero case.
- DeFi: add a rank check before trusting any derived hedge ratio in jayverse-defi's risk model. If collateral or asset correlations feed a hedge calculation, a rank check catches redundant columns before they produce an unstable result.
Key expressions
| Expression | 뜻 · 쓰이는 자리 |
|---|---|
| flatten | 짓눌러 차원을 낮추다 · 변환이 공간을 더 낮은 차원으로 찌그러뜨릴 때. "flattens the space into a lower dimension" |
| span | (벡터들이) ~을 생성하다·펼쳐내다 · 열벡터들이 이루는 부분공간을 가리키는 선형대수 용어. "the space spanned by the matrix's columns" |
| redundant | 중복된·불필요하게 겹치는 · 설명변수들이 서로 비슷한 정보를 담고 있을 때. "the data effectively has redundant explanatory variables" |
| near-singular | 거의 특이(비가역)에 가까운 · 역행렬이 거의 존재하지 않는 불안정한 행렬 상태. "detecting near-singular matrices" |
| scale-sensitive | 척도(단위)에 민감한 · 값의 크기를 바꾸면 결과도 따라 바뀌어 지표로 부적합할 때. "the determinant is scale-sensitive" |
| a habit | 습관·늘 하는 절차 · 특정 점검을 매번 당연히 해야 할 일로 만들라는 조언. "needs to be a habit" |
| rank-deficient | 계수(rank)가 부족한 · 열들이 선형독립이 아니어서 최대 계수보다 낮은 행렬. "Construct a rank-deficient 3x3 matrix" |
If you study this on a given day, add a note link and a ✅ to this line in the source curriculum (docs/knowledge/math-50-curriculum.md) and this spot will lead straight to the note body. You can also write directly on this page — but regenerating overwrites it, so it's safer to keep anything you want to save as markdown under docs/algorithms/.