Eigenvalues/Eigenvectors TODO
Concept
For a square matrix A, a nonzero vector v satisfying Av = λv is called an eigenvector, and the scalar λ is its eigenvalue — meaning the linear transformation doesn't change direction along v, only scales its magnitude by a factor of λ. Eigenvalues are found as the roots of the characteristic equation det(A - λI) = 0; if the eigenvectors form a basis for the space, A can be diagonalized as A = PDP^(-1), which simplifies computing powers of A to simply raising the diagonal entries to that power. A real symmetric matrix always has real eigenvalues and a basis of mutually orthogonal eigenvectors (the spectral theorem), and matrices commonly encountered in practice, like covariance matrices, fall into this category. The magnitude of the eigenvalues governs growth and decay under repeated application of the transformation, so whether the spectral radius is less than 1 determines whether an iterative process converges.
The stationary distribution of a Markov chain, dimensionality reduction via PCA, the convergence condition of iterative numerical solvers, and structural analysis of graphs all reduce to eigenvalue problems.
Code & Formula
# 고유값/고유벡터 — Av = λv 를 수치로 검증하고, 대각화 A=PDP^-1 로 A^n 계산을 단순화한다.
import numpy as np
A = np.array([[4.0, 1.0], [2.0, 3.0]])
eigvals, eigvecs = np.linalg.eig(A)
print("A =\n", A)
print(f"\n고유값: {eigvals}")
print("고유벡터(열 벡터):\n", eigvecs)
# 검증: 각 고유쌍에 대해 Av == λv
for i in range(len(eigvals)):
lam, v = eigvals[i], eigvecs[:, i]
lhs, rhs = A @ v, lam * v
print(f"\nλ_{i}={lam:.4f}: Av={lhs}, λv={rhs}, 일치? {np.allclose(lhs, rhs)}")
# 대각화: A = P D P^-1 → A^n = P D^n P^-1 (대각원소만 거듭제곱하면 됨)
P = eigvecs
D = np.diag(eigvals)
P_inv = np.linalg.inv(P)
n = 5
A_power_direct = np.linalg.matrix_power(A, n)
A_power_via_diag = (P @ np.diag(eigvals ** n) @ P_inv).real
print(f"\nA^{n} 직접 계산:\n{A_power_direct}")
print(f"A^{n} 대각화로 계산 (P D^{n} P^-1):\n{np.round(A_power_via_diag, 6)}")
print(f"일치? {np.allclose(A_power_direct, A_power_via_diag)}")
Exercise
Take a small transition matrix, repeatedly apply it, and observe the distribution converging — then check whether that limit matches the normalized eigenvector corresponding to eigenvalue 1.
Practical Connection
Eigendecomposing a covariance matrix built from multiple markets' prices or asset returns reveals that a small number of common factors explain most of the variation, which is used directly when aggregating the risk of correlated positions.
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/.