Vectors, Matrices, Matrix Multiplication, Inverse Matrices TODO
Concept
A vector is an element expressed in coordinates, and a matrix is a linear transformation written in coordinates with respect to a basis. Matrix multiplication is composition of transformations, so it's associative but generally not commutative; for an (m×n) matrix times an (n×p) matrix, the inner dimensions must match, and the naive computation cost is O(mnp). An inverse exists only for a square matrix that is invertible, which is equivalent to having a nonzero determinant — equivalently, to the columns being linearly independent. When solving a linear system Ax=b in actual numerical computation, it's faster and more stable to solve it directly via a method like LU decomposition rather than explicitly computing the inverse. For matrices with a large condition number, small input errors get amplified significantly in the solution.
If you can't read linear algebra notation, you effectively can't read optimization, statistics, or cryptography material at all — and overusing matrix inversion means blindly trusting numerically unstable results.
Code & Formula
# 벡터·행렬·행렬곱·역행렬 — numpy로 기본 연산과, AB != BA(비교환성), A@A^-1=I 를 확인한다.
import numpy as np
A = np.array([[1.0, 2.0], [3.0, 4.0]])
B = np.array([[0.0, 1.0], [1.0, 0.0]])
v = np.array([1.0, 2.0])
print("A =\n", A)
print("A @ v (선형변환으로서의 행렬-벡터곱) =", A @ v)
AB = A @ B
BA = B @ A
print("\nA@B =\n", AB)
print("B@A =\n", BA)
commute = np.allclose(AB, BA)
print(f"A@B == B@A ? {commute} → 이 예처럼 행렬곱은 일반적으로 교환법칙이 성립하지 않는다")
det_A = np.linalg.det(A)
print(f"\ndet(A) = {det_A:.4f} (0이 아니므로 A는 가역)")
A_inv = np.linalg.inv(A)
identity_check = A @ A_inv
print("A @ A_inv =\n", np.round(identity_check, 10), "→ 단위행렬 I 확인")
# Ax = b 를 풀 때는 명시적 역행렬보다 solve()가 수치적으로 더 안정적이고 빠르다
b = np.array([5.0, 10.0])
x_via_solve = np.linalg.solve(A, b)
x_via_inv = A_inv @ b
print(f"\nAx=b 해: solve()={x_via_solve}, inv()@b={x_via_inv} (둘 다 일치, solve가 권장 방식)")
Exercise
Compute the product and inverse of a 2x2 and a 3x3 matrix by hand and check them against NumPy's output, then experiment with how much the error in the computed inverse grows for matrices with a large condition number.
Practical Connection
This is used directly in state-transition probability matrices, parameter estimation via regression, and market-maker parameter calibration; linear algebra over finite fields is also fundamental to cryptography and erasure-code implementations.
Where it lands in Jayverse
- Verex: implement market-maker parameter calibration via a stable solve (e.g., LU decomposition) instead of explicit matrix inversion, and log the condition number so a poorly conditioned calibration is flagged rather than silently producing unstable prices.
- Number: any regression or state-transition model published on Number's research site should report its condition number alongside coefficients, since that determines how much input error gets amplified.
- DeFi: implement the liquid-staking algorithm's state-transition/rebase accounting with the same LU-based solve, and unit-test the from-scratch inverse against NumPy to catch drift.
Key expressions
| Expression | 뜻 · 쓰이는 자리 |
|---|---|
| linearly independent | 선형독립인 · 행렬이 가역이 될 조건을 설명할 때. "equivalently, to the columns being linearly independent" |
| numerically stable | 수치적으로 안정적인 · 오차가 계산 과정에서 크게 증폭되지 않는 성질. "it's faster and more stable to solve it directly" |
| blindly trust | 무작정·맹목적으로 신뢰하다 · 결과를 검증 없이 그대로 받아들일 때. "means blindly trusting numerically unstable results" |
| inner dimensions must match | (행렬의) 안쪽 차원이 맞아야 한다 · 행렬곱 조건을 설명할 때. "the inner dimensions must match" |
| amplified significantly | 크게 증폭되다 · 작은 입력 오차가 결과에서 크게 불어날 때. "small input errors get amplified significantly in the solution" |
| effectively can't | 사실상 ~할 수 없다 · 기초가 없으면 다른 분야를 이해할 수 없다는 강조. "you effectively can't read optimization, statistics, or cryptography" |
| fundamental to | ~의 근간이 되는 · 어떤 이론이 다른 분야의 토대가 될 때. "is also fundamental to cryptography and erasure-code implementations" |
| LU | LU 분해(LU decomposition, 하삼각·상삼각 행렬로 분해) · 역행렬을 직접 구하지 않고 선형계를 더 빠르고 안정적으로 푸는 방법. "solve it directly via a method like LU decomposition" |
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/.