Mean-Variance Portfolio Optimization & The Efficient Frontier
A Masterclass Edition lesson on the Nobel Prize-winning framework for constructing optimal portfolios.
In our last lesson, we forged our primary tool: the equation for portfolio variance, σp2=wTΣw. We now have a precise, mathematical definition of risk. This is a monumental step, but it is not the end of our journey. It is the beginning.
The question that has driven finance for a century is: How should one invest?
It’s a question of choice. Given thousands of stocks and bonds, there are an infinite number of portfolios we could construct. Are some choices fundamentally "better" than others? In 1952, a young economist named Harry Markowitz provided the first rigorous mathematical answer to this question, and it was so profound it won him the Nobel Prize.
His framework, known as Mean-Variance Optimization, is the bedrock of Modern Portfolio Theory. Today, we will walk through his logic, build his model from the ground up, and discover for ourselves the beautiful and powerful concept of the Efficient Frontier.
Part 1: The Two Dimensions of Investment - Risk and Return
Every investment can be characterized by two fundamental numbers:
The Expected Return (The "Mean"): What reward do we expect to get?
The Risk (The "Variance"): How uncertain is that reward?
As we learned, for a portfolio with a weight vector w and an asset expected return vector μ, the portfolio's expected return is:
μp=wTμ
And for a portfolio with a covariance matrix Σ, the portfolio's risk (variance) is:
σp2=wTΣw
The set of all possible portfolios forms the **investment opportunity set**. A key insight from plotting this set is that the portfolio with the minimum risk is a mix of assets. This is the mathematical proof of **diversification**.
The top part of this opportunity set curve is the **Efficient Frontier**. It represents all portfolios that are "Pareto-optimal"—you cannot increase your return without also increasing your risk. These are the only "smart" choices.
Part 2: The Formal Problem Statement
The goal is to find the weights `w` that trace out the efficient frontier. The most common way to frame this is as a **constrained optimization** problem:
For a specific, desired level of expected return, `μ*`, find the set of weights `w` that achieves this return with the absolute minimum possible variance.
Minimize:21wTΣw
Subject to the constraints:
wTμ=μ∗ (The portfolio's return must be our target return)
wT1=1 (The weights must sum to 100%. 1 is a vector of ones.)
Part 3: The Method of Lagrange Multipliers
We use the Method of Lagrange Multipliers to solve this constrained problem by converting it into a larger, unconstrained problem using the Lagrangian function L.
L(w,λ1,λ2)=21wTΣw−λ1(wTμ−μ∗)−λ2(wT1−1)
To find the minimum, we take the derivative of L with respect to `w`, `λ₁`, and `λ₂` and set them to zero.
Part 4: From Calculus to Linear Algebra - The Solution
Taking the derivatives gives us a system of linear equations:
∂w∂L=Σw−λ1μ−λ21=0
∂λ1∂L=wTμ−μ∗=0⟹μTw=μ∗
∂λ2∂L=wT1−1=0⟹1Tw=1
This system can be written in the grand Ax=b form using block matrices, where our unknown vector is xsol=[wT,λ1,λ2]T:
ΣμT1T−μ00−100wλ1λ2=0μ∗1
By solving this system for a range of different target returns `μ*`, we can trace out the entire Efficient Frontier.
Summary: The Triumph of Optimization
We identified the **Efficient Frontier** as the set of optimal portfolios.
We framed the search as a **constrained optimization problem**: Minimize risk for a given return.
We used the **Method of Lagrange Multipliers** to turn this into a solvable problem.
The solution is a **system of linear equations (`Ax=b`)** that gives the exact portfolio weights `w` for any point on the frontier.
**Up Next:** We will shift our focus from building portfolios to analyzing individual assets. We will explore the **Capital Asset Pricing Model (CAPM)**.