Linear algebra is the language of models with many variables: many goods, many assets, many regressors. Its basic operation, the dot product, is already familiar in disguise: total spending is prices times quantities, summed over goods.
We will compute dot products, measure lengths and angles, and finish with orthogonality.
Step 1: Computing dot products
A vector in ℝⁿ is a list of n numbers, such as the quantities of n goods. Vectors add and scale component by component, and the dot product combines two vectors into a single number:
With prices p = (2, 5, 1) and quantities q = (3, 1, 4), total spending is p·q = 6 + 5 + 4 = 15. A portfolio's return is the dot product w·r of its weights and the asset returns. The dot product of a vector with itself, x·x, is the sum of its squared components: the squared length of x.
Step 2: Length and angle
The length of a vector is the square root of its dot product with itself, and the dot product of two vectors measures the angle θ between them:
So (3, 4) has length 5, and (3, 4)·(4, 3) = 24 = 5 × 5 × cos θ gives cos θ = 0.96, a small angle: the vectors point almost the same way. The sign of x·y says whether the angle is acute (positive), a right angle (zero) or obtuse (negative). Since cos θ lies between −1 and 1, |x·y| ≤ |x|·|y|, the Cauchy–Schwarz inequality. Statistics uses exactly this to measure how closely two variables move together: list each variable's deviations from its mean as a vector, and the cosine of the angle between the two vectors is that measure, so it always lies between −1 and 1.
Step 3: Orthogonality
Two vectors are orthogonal (perpendicular) when their dot product is zero:
(1, 2) and (2, −1) are orthogonal, since 2 − 2 = 0, while (1, 2) and (2, 1) are not. To make (3, k) orthogonal to (2, 6), solve 6 + 6k = 0, so k = −1. Orthogonality appears throughout economics: in regression, the residuals are orthogonal to every regressor, and a price vector is orthogonal to every bundle of trades that costs nothing.