The Multiplicative Identity
For scalars: . The number 1 is the identity. For matrices: . The identity matrix — diagonal of 1s, zeros elsewhere — plays the same role.
This isn't trivia. The identity matrix is the anchor every "undo" definition leans on.
The Inverse — Matrix Division, Sort Of
For scalars: (with ). For matrices: . The inverse "undoes" the original transformation. Rotated 30° clockwise? rotates 30° counter-clockwise. Doubled in size? halves it.
Not Every Matrix Has an Inverse
Two requirements:
- Square. Rectangular matrices change dimensionality, and you can't fully undo "throwing away a dimension."
- Non-zero determinant. If the determinant is 0, the matrix collapses space — multiple inputs map to the same output, so there's no way to undo it. Singular = un-invertible.
For singular or rectangular matrices, the pseudoinverse () gives a best-effort generalization. Used everywhere in regression and least-squares.
Practically: Don't Compute the Inverse
To solve , the textbook says . The textbook is teaching you the concept, not the algorithm. In practice you call np.linalg.solve(A, B), which uses LU decomposition — faster and more numerically stable than inverting and multiplying.
solve is the implementation. Use the inverse when you're reasoning. Use solve when you're computing.
import numpy as np
A = np.array([[2., 0.], [0., 2.]]) Ainv = np.linalg.inv(A)
print('Ainv =') print(Ainv)
v = np.array([10., 8.]) print('Ainv @ v =', Ainv @ v) print('v / 2 =', v / 2)
S = np.array([[1., 2.], [1., 2.]]) try: np.linalg.inv(S) except Exception as e: print(type(e).name, '->', e)
에러는 역행렬이 존재하지 않으므로 발생, LinAlgError -> Singular matrix