Free lesson · Math & notation
Vectors, matrices and transpose notation
Open interactive lessonPractice calculationsExplore labs
Start with the idea
Write a two-asset example explicitly. Once the dimensions and signs work there, vector notation lets the same operations scale to a larger book.
Symbols, units & horizon
- w: ordered vector of signed capital weights
- r: matching decimal return vector
- T: transpose, not elapsed time here
- Σ: covariance matrix in squared return units
- Σᵢⱼ: covariance of assets i and j
- Σ with limits: summation rather than the matrix name
- i, j: asset indices
When and why to use this
Use a dot product for return and a quadratic form for variance. This is the bridge between arithmetic and portfolio models.
A vector is an ordered list. A portfolio’s weights form one vector and the assets’ returns form another. A matrix is a rectangular table; a covariance matrix records a relationship for each pair of assets. Superscript T or ⊤ means transpose: swap rows and columns.
Multiply two-vector and two-matrix expressions
- For w=(w₁,w₂), r=(r₁,r₂), .
- First calculate Σw, then take the dot product with w. Expanding a symmetric two-by-two matrix gives .
w=(.5,.5), r=(.02,−.01) gives return .005. With diagonal covariance (.01,.04) and zero covariance, variance=.0125.
Capital Σ in this context is a matrix, while Σ with limits can be a summation symbol. The entry Σᵢⱼ is row i, column j. Matrix multiplication is ordered: multiply matching coordinates and add. The superscript −1 on a matrix means its inverse, if one exists, not taking each entry’s reciprocal.
Python implementation
Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.
# Dependency: numpy. Asset ordering must match in all arrays.
import numpy as np
def portfolio_moments(weights, returns, covariance):
w, r, cov = map(np.asarray, (weights, returns, covariance))
return float(w @ r), float(w @ cov @ w)
print(portfolio_moments([.5, .5], [.02, -.01], [[.01, 0], [0, .04]]))Continue learning
Math & Notation Essentials — all lessons- Start with numbers, variables and an equals sign
- Percentages, basis points and units
- Rearrange an equation without changing its meaning
- Powers, square roots, exponentials and logarithms
- Read sums, indices, averages and squared deviations
- Probability, expectation and conditioning
- Vectors, matrices and transpose notation
- Derivatives, integrals and approximations
Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations