Quant Memo
Core

Matrix Inverses and Linear Systems

The matrix operation that 'undoes' a linear transformation — and the standard tool for solving systems of equations like hedge ratios or portfolio weights in one shot.

Prerequisites: Determinants, Linear Independence and Rank

A market maker needs to find hedge ratios for three correlated instruments so the combined position has zero net exposure to three separate risk factors. That's three equations in three unknowns — solvable by hand for small cases, but tedious and error-prone by substitution once the system grows. The matrix inverse turns this into one clean operation: write the system as a matrix equation, apply the inverse, and read off every unknown at once.

An analogy: undoing a mixing recipe

Imagine a machine that takes two input amounts and mixes them into two output amounts according to a fixed recipe — say, output 1 is always "2 times input A plus 1 times input B," and output 2 is "1 times input A plus 3 times input B." If you're handed the outputs and asked to figure out what inputs produced them, you need the "un-mixing" recipe — the exact reverse operation. The matrix inverse is that reverse recipe: applied to the machine's matrix, it undoes whatever the original matrix did, turning outputs back into the unique inputs that produced them (as long as the original recipe didn't destroy information by collapsing two different inputs onto the same output).

The mathematics, one symbol at a time

For a square matrix AA, its inverse A1A^{-1} is the unique matrix satisfying

AA1=A1A=I,A A^{-1} = A^{-1} A = I,

where II is the identity matrix (the "do nothing" transformation). In words: applying AA then A1A^{-1}, in either order, gets you back exactly where you started. The inverse exists if and only if det(A)0\det(A) \neq 0 (see Determinants), equivalently if AA's columns are linearly independent. Given a linear system Ax=bAx = b — a matrix AA of known coefficients, a vector bb of known targets, and an unknown vector xx to solve for — the solution is

x=A1b,x = A^{-1} b,

read as: multiplying both sides of Ax=bAx=b by A1A^{-1} cancels the AA on the left, leaving xx isolated and solved for directly, all unknowns at once. In practice, computers rarely form A1A^{-1} explicitly — they solve the system via decomposition methods like LU (see LU Decomposition) which are faster and more numerically stable — but the formula x=A1bx = A^{-1}b captures the idea cleanly.

Worked example 1: a 2×2 hedge ratio system by hand

Solve (2113)(x1x2)=(813)\begin{pmatrix} 2 & 1 \\ 1 & 3 \end{pmatrix} \begin{pmatrix} x_1 \\ x_2 \end{pmatrix} = \begin{pmatrix} 8 \\ 13 \end{pmatrix}. First, the inverse of a 2×22\times2 matrix (abcd)\begin{pmatrix} a & b \\ c & d \end{pmatrix} is 1adbc(dbca)\frac{1}{ad-bc}\begin{pmatrix} d & -b \\ -c & a \end{pmatrix}. Here det=(2)(3)(1)(1)=5\det = (2)(3)-(1)(1)=5, so A1=15(3112)A^{-1} = \frac{1}{5}\begin{pmatrix} 3 & -1 \\ -1 & 2 \end{pmatrix}. Then x=A1b=15(3(8)1(13)1(8)+2(13))=15(1118)=(2.23.6)x = A^{-1}b = \frac{1}{5}\begin{pmatrix} 3(8) - 1(13) \\ -1(8) + 2(13) \end{pmatrix} = \frac{1}{5}\begin{pmatrix} 11 \\ 18 \end{pmatrix} = \begin{pmatrix} 2.2 \\ 3.6 \end{pmatrix}. Check: 2(2.2)+1(3.6)=4.4+3.6=82(2.2)+1(3.6) = 4.4+3.6=8 ✓, and 1(2.2)+3(3.6)=2.2+10.8=131(2.2)+3(3.6)=2.2+10.8=13 ✓.

Worked example 2: solving for hedge notionals

A trader wants a position long $0 exposure to two risk factors using two hedge instruments with sensitivities: instrument 1 has factor sensitivities (1.2,0.5)(1.2, 0.5) per $1, instrument 2 has (0.3,1.8)(0.3, 1.8) per $1, and the existing book has raw exposures (6.0,4.5)(6.0, 4.5) that need to be exactly offset. Solve (1.20.30.51.8)(n1n2)=(6.04.5)\begin{pmatrix} 1.2 & 0.3 \\ 0.5 & 1.8 \end{pmatrix}\begin{pmatrix} n_1 \\ n_2\end{pmatrix} = \begin{pmatrix} 6.0 \\ 4.5 \end{pmatrix}: determinant =1.2(1.8)0.3(0.5)=2.160.15=2.01= 1.2(1.8)-0.3(0.5) = 2.16-0.15=2.01; n1=(1.8(6.0)0.3(4.5))/2.01=(10.81.35)/2.014.70n_1 = (1.8(6.0)-0.3(4.5))/2.01 = (10.8-1.35)/2.01 \approx 4.70, n2=(1.2(4.5)0.5(6.0))/2.01=(5.43.0)/2.011.19n_2 = (1.2(4.5)-0.5(6.0))/2.01 = (5.4-3.0)/2.01 \approx 1.19. Buying about $4.70 of instrument 1 and $1.19 of instrument 2 exactly neutralizes both factor exposures at once.

Matrix explorer
dashed = before · solid = after
det 1.25trace 2.50λ 1.81, 0.69area scales by 1.25×

Drag the transform above, note the transformed shape, then imagine reading it backward: the inverse matrix is exactly the transform that maps the distorted shape back to the original unit square — it exists as long as the shape hasn't been flattened onto a line.

x (unknowns) A b (known targets) A inverse
A maps unknowns x to known targets b; the inverse retraces the same path backward, recovering x uniquely from b whenever A is invertible.

What this means in practice

Solving Ax=bAx=b via a matrix inverse (or, better, a stable decomposition) is the standard way to compute hedge ratios, factor-neutral portfolio weights, and the coefficients in ordinary least squares regression, where x=(XTX)1XTyx = (X^TX)^{-1}X^Ty. When AA isn't square or isn't invertible — more equations than unknowns, or redundant instruments — the closely related pseudoinverse (see The Moore-Penrose Pseudoinverse) provides the best-fit generalization.

The inverse A1A^{-1} of a square matrix undoes what AA does, satisfying AA1=IAA^{-1}=I; it exists exactly when det(A)0\det(A)\neq0, and it turns a linear system Ax=bAx=b into a direct solution x=A1bx = A^{-1}b, solving for every unknown simultaneously instead of by substitution.

Never compute A1A^{-1} explicitly and then multiply by bb in real code — it's numerically wasteful and less stable than solving the system directly via a decomposition (LU, QR). Forming the full inverse matrix is a fine way to think about the operation, but production code should call a linear-solve routine, not construct A1A^{-1} as an intermediate object, especially for large or nearly singular systems where the difference in numerical accuracy can be substantial.

Related concepts

Practice in interviews

Further reading

  • Strang, Introduction to Linear Algebra, ch. 2
  • Golub & Van Loan, Matrix Computations, ch. 1
ShareTwitterLinkedIn