Skip to content

Matrix multiplication

Matrix multiplication forms row-column sums and composes linear maps. Follow strategy quantities through asset holdings into factor sensitivities, and distinguish regrouping, reordering and entrywise products.

Matrix multiplication combines two matrices by taking a row from the first and a column from the second, multiplying their corresponding entries, and summing. Its central use is to combine successive linear transformations: one matrix turns strategy quantities into asset positions; another turns those positions into factor sensitivities. Their product maps strategies straight to sensitivities.

The shared dimension is the handoff

For AA with mm rows and nn columns, and BB with nn rows and pp columns,

A⏟m×nB⏟n×p=C⏟m×p,cij=∑k=1naikbkj.\underbrace{A}_{m\times n}\underbrace{B}_{n\times p} =\underbrace{C}_{m\times p}, \qquad c_{ij}=\sum_{k=1}^{n}a_{ik}b_{kj}.
The inner dimensions must agree: each row of AA and each column of BB must contain the same number of entries. The result keeps the outer dimensions. Entry cijc_{ij} is the dot product of row ii of AA with column jj of BB.
There is a second reading: column jj of ABAB is AA applied to column jj of BB. Each column of BB describes one input recipe; the corresponding column of ABAB gives that recipe's final output. These are two views of the same calculation. MIT's lecture notes develop these row and column views alongside other ways of forming a product.

A shape check is necessary; names and units must agree too. If AA's columns refer to assets in a particular order, BB's rows must use that same order. Matching three columns with three rows cannot detect a swapped asset label.

A two-stage risk calculation

Consider a hypothetical desk with two strategies and three assets. One unit of strategy 1 holds one lot each of assets 1 and 3. One unit of strategy 2 holds one lot each of assets 2 and 3. The bundle matrix is

B=[100111].B=\begin{bmatrix}1&0\\0&1\\1&1\end{bmatrix}.
Rows identify assets; columns identify strategies. Entry bijb_{ij} measures asset-ii lots per unit of strategy jj. For strategy quantities x=(2,3)T\mathbf{x}=(2,3)^{\mathsf T}, the holdings vector is
Bx=[235].B\mathbf{x} =\begin{bmatrix}2\\3\\5\end{bmatrix}.
Now specify two risk factors. Each factor move is measured in basis points, and each asset has the following fixed local P&L sensitivities:
A=[120011].A=\begin{bmatrix}1&2&0\\0&1&1\end{bmatrix}.

Rows identify factors; columns identify the same three assets. Each entry measures USD per basis point per asset lot. For example, one lot of asset 2 contributes USD 2 per bp to factor 1 and USD 1 per bp to factor 2. The two portfolio sensitivities are

A(Bx)=[1(2)+2(3)+0(5)0(2)+1(3)+1(5)]=[88]USD per bp.A(B\mathbf{x}) =\begin{bmatrix}1(2)+2(3)+0(5)\\0(2)+1(3)+1(5)\end{bmatrix} =\begin{bmatrix}8\\8\end{bmatrix} \quad\text{USD per bp}.

These are separate sensitivities to the specified factors, rather than two cash payments. Under this local model, a one-bp move in factor 1 with factor 2 unchanged gives approximately USD 8 of P&L. Changing both factors requires their respective moves. Larger moves can require nonlinear repricing; multiplying sensitivities does not establish exact payoff replication or remove unmeasured risks.

Two strategy quantities, 2 and 3, map through B into asset lots 2, 3 and 5, then through A into two sensitivities of USD 8 per bp. The shortcut AB has columns 1,1 and 2,2, measured in USD per bp per strategy unit.
Two strategy quantities, 2 and 3, map through B into asset lots 2, 3 and 5, then through A into two sensitivities of USD 8 per bp. The shortcut AB has columns 1,1 and 2,2, measured in USD per bp per strategy unit.
Original synthetic example. The intermediate three-asset book and the combined two-strategy map produce the same two factor sensitivities. All asset and factor orders are fixed.

Build the shortcut once

Calculate all four entries by row-column sums:

AB=[1(1)+2(0)+0(1)1(0)+2(1)+0(1)0(1)+1(0)+1(1)0(0)+1(1)+1(1)]=[1212].AB= \begin{bmatrix} 1(1)+2(0)+0(1)&1(0)+2(1)+0(1)\\ 0(1)+1(0)+1(1)&0(0)+1(1)+1(1) \end{bmatrix} =\begin{bmatrix}1&2\\1&2\end{bmatrix}.

The first column is strategy 1's two sensitivities; the second is strategy 2's. Their units are USD per bp per strategy unit. Thus

(AB)x=[1(2)+2(3)1(2)+2(3)]=[88]=A(Bx).(AB)\mathbf{x} =\begin{bmatrix}1(2)+2(3)\\1(2)+2(3)\end{bmatrix} =\begin{bmatrix}8\\8\end{bmatrix} =A(B\mathbf{x}).

A desk evaluating many strategy allocations can reuse ABAB while the bundle definitions and sensitivities stay fixed. If either changes, the combined map must change as well. For a single calculation, keeping the two matrix-vector steps may avoid forming a larger product unnecessarily.

Regrouping preserves order; reordering changes the map

Matrix multiplication is associative: for compatible matrices, (AB)C=A(BC)(AB)C=A(BC). Parentheses select which intermediate result to calculate first; the matrices retain their order. With column vectors, ABxAB\mathbf{x} applies BB first and then AA.
It is generally not commutative. ABAB and BABA may have different shapes, one may be undefined, and even same-size square matrices need not give equal products. Here both numerical products exist, but
AB=[1212]is 2×2,BA=[120011131]is 3×3.AB=\begin{bmatrix}1&2\\1&2\end{bmatrix} \quad\text{is }2\times2, \qquad BA=\begin{bmatrix}1&2&0\\0&1&1\\1&3&1\end{bmatrix} \quad\text{is }3\times3.
Algebraic compatibility does not create an economic reverse workflow. In the desk example, AA outputs factor sensitivities, whereas BB expects strategy quantities. The two-dimensional arrays fit numerically, but their labels and units do not describe the same interface. Treating BABA as a meaningful financial operation would require a separately defined interpretation. It is also not an inverse of ABAB.

The same discipline matters for a covariance matrix: the asset order in every adjacent vector or matrix must match. Correct dimensions alone do not establish a correct risk calculation.

Multiplying corresponding entries is a different operation

The Hadamard product, written A∘DA\circ D, multiplies entries in the same positions: (A∘D)ij=aijdij(A\circ D)_{ij}=a_{ij}d_{ij}. It requires equal shapes and preserves that shape. It does not perform the row-column sums that compose two maps.

For the combined map C=ABC=AB above and the 2×22\times2 identity matrix I2I_2,

CI2=C=[1212],C∘I2=[1002].CI_2=C=\begin{bmatrix}1&2\\1&2\end{bmatrix}, \qquad C\circ I_2=\begin{bmatrix}1&0\\0&2\end{bmatrix}.

Ordinary multiplication by the identity preserves the map. Entrywise multiplication by the identity masks its off-diagonal entries. Both operations are useful, but answer different questions.

For a fuller treatment, Matrix Algebra: Operations, Rules, and the Transpose develops product laws and transpose identities (membership for the full lesson; public preview). Vectors and Matrices introduces matrix-vector products through portfolio factor exposures with the same access arrangement.

Sources

  • Gilbert Strang, Introduction to Linear Algebra, 5th edition, Wellesley–Cambridge Press, 2016, §2.4, “Rules for Matrix Operations,” pp. 70–73. Dimensions, row-column products, associativity and order.
  • MIT OpenCourseWare, Gilbert Strang, “Multiplication and Inverse Matrices,” 18.06SC, Fall 2011, especially the accompanying lecture summary, p. 1. Equivalent row, column and outer-product readings.
Last updated
  • linear algebra
  • matrix products
  • linear maps
  • factor sensitivities
  • dimensions
← Back to the glossaryBack to top ↑