Free lesson · Linear algebra
Start with lists: addition, scaling and a dot product
Open interactive lessonPractice calculationsExplore labs
Start with the idea
- A vector is an ordered list of numbers.
- Match entries by position before combining them.
Symbols, units & horizon
- a,b: ordered two-entry vectors
- aᵢ,bᵢ: entries at position i
- i: position index, 1 or 2
- Σ: sum over the indicated positions
- ·: dot product
- entries: dimensionless in this example
When and why to use this
Use matched weighted sums for portfolio returns and linear predictions. Covariance matrices add relationships between those entries.
- Scalar: a single number.
- Use vectors and .
- Add matching entries: .
- Multiply every entry by a scalar: .
- A dot product multiplies matching entries and adds the products.
- A matrix is a rectangular list of such entries. Matrix multiplication repeats dot products.
Core rule · definition and worked arithmetic
Start with lists: addition, scaling and a dot product
- Match the first entries: 1×3=3.
- Match the second entries: 2×4=8.
- Add the products: 3+8=11. The result is one number, not a vector.
Work it by hand
Weights (.25,.75) and returns (.04,.08) give .25×.04+.75×.08=.07, a 7% weighted return over the same horizon.
Use the rule
- Name the inputs and units.
- Work the small example by hand.
- Check the result before continuing to the next lesson.
Before moving on
Explain the core rule in one sentence, reproduce the worked calculation and solve both practice variations.
Research sources, review dates and limitations
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.
def dot(a,b):
if not a or len(a)!=len(b): raise ValueError("Matching nonempty vectors required")
return sum(x*y for x,y in zip(a,b))
print(dot([1,2],[3,4]), dot([.25,.75],[.04,.08]))Continue learning
Linear Algebra — all lessons- Start with lists: addition, scaling and a dot product
- Your portfolio is a vector; your risk is a matrix
- Eigenvalues: where the risk actually lives
- Regression, conditioning, and regularisation
Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations