MathFin
Map / Choice · Portfolio choice / MathFin.Choice.Portfolio.MarkowitzLagrangian

N-asset Markowitz from constrained-variance Lagrangian (first principles)

MathFin.Choice.Portfolio.MarkowitzLagrangianMSC 91G10MSC 90C25JEL G11 source

The 2-asset Sharpe-ratio file (Choice/Portfolio/SharpeFOCDerivation.lean) derives the cross-product FOC r₂(Σw)₁ = r₁(Σw)₂ from d(Sh²)/dw = 0. This file extends the first-principles derivation to N assets, but for the constrained variance minimization formulation — which is the textbook Markowitz statement and gives the canonical Lagrangian FOC Σw = lam_1 · 1 + lam_2 · μ.

The problem

Minimize (1/2) · w^T Σ w (portfolio variance) subject to

  • 1^T w = 1 (budget constraint),
  • μ^T w = m (expected-return target).

The Lagrangian

L(w, lam_1, lam_2) := (1/2) · w^T Σ w − lam_1 · (1^T w − 1) − lam_2 · (μ^T w − m).

The FOC (textbook derivation)

∂L/∂w_i = (Σw)_i − lam_1 − lam_2 · μ_i = 0, i.e., Σw = lam_1 · 1 + lam_2 · μ.

This says the marginal variance vector lies in the 2-d span of the constraint normals — the canonical "two-fund separation" structural fact.

Variational characterisation

A portfolio w is a constrained variance critical point if for every admissible perturbation δw (orthogonal to budget and expected-return normals, i.e., 1^T δw = 0 and μ^T δw = 0),

(Σw)^T δw = 0.

For symmetric Σ this is the vanishing of d/dt [(1/2) (w + t δw)^T Σ (w + t δw)] |_{t=0}: quadratic_form_perturb_linear_coeff identifies (Σw)^T δw as the linear coefficient of that polynomial in t (no derivative statement is proved).

Main definitions

  • IsConstrainedVarianceCriticalPoint: w is a critical point of (1/2) wᵀ Σ w under the budget constraint 1ᵀ w = 1 and the return constraint μᵀ w = m, in the variational form: (Σw)ᵀ δw = 0 for every perturbation δw orthogonal to 1 and μ.

Main results

  • isCriticalPoint_of_lagrangian_FOC (forward direction): if Σw = lam_1 · 1 + lam_2 · μ componentwise, then w is a constrained-variance critical point. Proof: direct algebra — substitute the FOC, use the perturbation's orthogonality to the constraint normals.
  • variance_objective_eq_self_dot / quadratic_form_perturb_linear_coeff: the variance objective as a self-dot, and the explicit linear coefficient (Σw) · δw of a perturbation of (1/2) wᵀΣw for symmetric Σ — the directional-derivative content underlying the FOC.
  • portfolioVarN_le_of_lagrangian_FOC: for positive semidefinite Σ, a portfolio meeting both constraints and the Lagrangian FOC has the least variance among all portfolios meeting the same constraints — the KKT sufficiency theorem kkt_sufficient_of_eq (Choice/Portfolio/ConvexQPKKT.lean) for the QP min ½ wᵀΣw.
  • posSemidef_covariance, variance_le_of_lagrangian_FOC: the same for the covariance matrix of square-integrable random returns, whose positive semidefiniteness is derived (covariance_kernel_psd), stated for the variance of the portfolio return itself.
  • isTangentPortfolioN_and_portfolioVarN_le: a portfolio with Σw = λ(μ − r_f) is a tangent portfolio and has the least variance at its budget and expected return.
  • portfolioVarN_minVarWeightTwo_le: the closed-form two-asset weight minimises portfolioVarN.
  • Two assets: portfolioVarN_covTwo and portfolioVarTwo_eq_variance identify the closed form portfolioVarTwo (Choice/Portfolio/Markowitz.lean) with the quadratic form portfolioVarN and with Var[w R₁ + (1 − w) R₂]; marginalVariance_minVarWeightTwo shows that at the minimum-variance weight each asset's marginal variance equals V_min (for D ≠ 0), so (isConstrainedVarianceCriticalPoint_minVarWeightTwo) that weight satisfies the budget-only Lagrangian FOC with multiplier V_min.

What is not in this file

Necessity — "every constrained minimiser (or critical point) satisfies the Lagrangian FOC for some multipliers" — is not proved. It requires showing Σw ∈ span{1, μ}, which by the orthogonal-complement characterization is equivalent to Σw ⊥ {δw : 1·δw = 0 ∧ μ·δw = 0}; in finite dimensions this needs Submodule.orthogonalComplement machinery. The file proves the converse direction: every weight satisfying the Lagrangian equations is a critical point and, for positive semidefinite Σ, a global minimiser.

Why this is "first principles"

Choice/Portfolio/Markowitz.lean states the two-asset minimum-variance weight in closed form and Choice/Portfolio/MarkowitzNAsset.lean the n-asset variance identities. This file derives the optimality of Lagrangian-FOC weights from the constrained variance-minimization problem, for N assets with budget and target-return constraints (the standard textbook setup).

References

Tags

Markowitz, mean-variance optimization, Lagrangian, first-order condition, two-fund separation, minimum variance, constrained optimization, MSC 91G10, MSC 90C25, JEL G11

Import neighbourhood

Above: what it imports. Below: what imports it.

Corpus entries

mf-markowitz-lagrangian-sufficient · portfolio_and_performance.json · full statement
Markowitz Lagrangian First-Order Condition Is Sufficient for Minimum Variance

For a positive semidefinite covariance matrix Σ, a portfolio w with budget ∑ wᵢ = 1, target return ∑ wᵢ μᵢ = m and Lagrangian first-order condition (Σw)ᵢ = λ₁ + λ₂ μᵢ for every asset has variance wᵀΣw no larger than that of any portfolio meeting the same two constraints. Sufficiency only: that every minimum-variance portfolio satisfies the first-order condition is not proved.

mf-markowitz-variance-random-returns · portfolio_and_performance.json · full statement
Markowitz Minimum Variance for Random Returns

For square-integrable random returns R₁, …, Rₙ, a portfolio w with ∑ wᵢ = 1, ∑ wᵢ μᵢ = m and Lagrangian first-order condition ∑ⱼ cov(Rᵢ, Rⱼ) wⱼ = λ₁ + λ₂ μᵢ for every asset satisfies Var[∑ wᵢ Rᵢ] ≤ Var[∑ vᵢ Rᵢ] for every portfolio v meeting the same constraints. Positive semidefiniteness of the covariance matrix is derived, not assumed. Sufficiency only: necessity of the first-order condition is not proved.

mf-markowitz-two-asset-variance-of-returns · portfolio_and_performance.json · full statement
Two-Asset Portfolio Variance Is the Variance of the Portfolio Return

For square-integrable returns R₁, R₂ with Var[R₁] = σ₁², Var[R₂] = σ₂² and cov(R₁, R₂) = ρσ₁σ₂, the two-asset formula w²σ₁² + (1 − w)²σ₂² + 2w(1 − w)ρσ₁σ₂ equals Var[w R₁ + (1 − w) R₂] for every weight w: the closed form is derived from the covariance kernel of the returns.

mf-markowitz-gmv-equal-marginal-variance · portfolio_and_performance.json · full statement
Two-Asset Minimum-Variance Portfolio Equalises Marginal Variances

At the two-asset minimum-variance weight w* = (σ₂² − ρσ₁σ₂)/D, with D = σ₁² − 2ρσ₁σ₂ + σ₂² ≠ 0, each asset's marginal variance (Σw*)ᵢ, its covariance with the portfolio, equals the minimum variance V_min = σ₁²σ₂²(1 − ρ²)/D. So w* satisfies the budget-only Lagrangian first-order condition with multiplier V_min.

Declarations 16

defMathFin.IsConstrainedVarianceCriticalPointsource
{ι : Type u_1} → Finset ι → (ι → ι → ℝ) → (ι → ℝ) → (ι → ℝ) → Prop

Constrained-variance critical-point property (variational form): w is a critical point of (1/2) w^T Σ w subject to 1^T w = 1 and μ^T w = m if, for every admissible perturbation δw (orthogonal to both constraint normals), the directional derivative (Σw) · δw vanishes.

theoremMathFin.isCriticalPoint_of_lagrangian_FOCsource
∀ {ι : Type u_1} (s : Finset ι) (Sg : ι → ι → ℝ) (μ w : ι → ℝ) (lam_1 lam_2 : ℝ), (∀ i ∈ s, marginalVariance s Sg w i = lam_1 + lam_2 * μ i) → IsConstrainedVarianceCriticalPoint s Sg μ w

Forward direction of the Lagrangian FOC characterisation: if there exist scalars lam_1, lam_2 such that (Σw)_i = lam_1 + lam_2 · μ_i for every asset i ∈ s, then w is a constrained-variance critical point.

The "Lagrangian FOC" Σw = lam_1 · 1 + lam_2 · μ is the textbook characterisation of efficient portfolios. Only this direction (FOC ⟹ critical point) is proved here, together with FOC ⟹ global minimum for positive semidefinite Σ (portfolioVarN_le_of_lagrangian_FOC); that every variance-minimising portfolio satisfies the FOC is not proved.

Proof: substitute the FOC into the directional-derivative sum and use the perturbation's orthogonality to the constraint normals (∑ δw = 0 kills the lam_1 term, ∑ μ δw = 0 kills the lam_2 μ term).

theoremMathFin.variance_objective_eq_self_dotsource
∀ {ι : Type u_1} (s : Finset ι) (Sg : ι → ι → ℝ) (w : ι → ℝ), 1 / 2 * portfolioVarN s w Sg = 1 / 2 * ∑ i ∈ s, w i * marginalVariance s Sg w i

Self-dot identity for the variance objective: (1/2) w^T Σ w (the variance objective, up to constant 1/2) equals (1/2) · ∑_i w_i · (Σw)_i. This is the same self-dot identity used in Choice/Portfolio/SharpeFOCDerivation.lean, restated for N assets.

theoremMathFin.quadratic_form_perturb_linear_coeffsource
∀ {ι : Type u_1} (s : Finset ι) (Sg : ι → ι → ℝ) (w δw : ι → ℝ), (∀ i ∈ s, ∀ j ∈ s, Sg i j = Sg j i) → 1 / 2 * (∑ i ∈ s, ∑ j ∈ s, Sg i j * δw i * w j + ∑ i ∈ s, ∑ j ∈ s, Sg i j * w i * δw j) = ∑ i ∈ s, marginalVariance s Sg w i * δw i

Directional derivative of the variance objective at w in direction δw, for symmetric Sg:

d/dt [(1/2) (w + t δw)^T Σ (w + t δw)] |_{t=0} = (Σw)^T δw.

This is the calculus content underlying the FOC. Proof: expand the quadratic in t, the linear coefficient is (1/2) · [(δw)^T Σ w + w^T Σ δw], which for symmetric Σ equals (Σw)^T δw.

(No HasDerivAt statement is proved: the identity below is the linear coefficient of the polynomial t ↦ ½ (w + t δw)ᵀ Σ (w + t δw), stated algebraically.)

theoremMathFin.isTangent_of_lagrangian_no_budgetsource
∀ {ι : Type u_1} (s : Finset ι) (μ w : ι → ℝ) (Sg : ι → ι → ℝ) (lam_2 : ℝ), (∀ i ∈ s, marginalVariance s Sg w i = lam_2 * μ i) → IsTangentPortfolioN s μ Sg w

Sufficient condition for tangency from the Lagrangian FOC: specialising to the case lam_1 = 0 (no budget constraint, only expected- return constraint), the FOC becomes Σw = lam_2 · μ, recovering the cross-product tangent characterisation IsTangentPortfolioN from Choice/Portfolio/TangentPortfolio.lean.

theoremMathFin.marginalVariance_univsource
∀ {ι : Type u_1} [Fintype ι] (Sg : Matrix ι ι ℝ) (w : ι → ℝ), marginalVariance Finset.univ Sg w = Sg.mulVec w

On a finite asset set the marginal-variance vector is the matrix–vector product.

theoremMathFin.portfolioVarN_univsource
∀ {ι : Type u_1} [Fintype ι] (Sg : Matrix ι ι ℝ) (w : ι → ℝ), portfolioVarN Finset.univ w Sg = w ⬝ᵥ Sg.mulVec w

On a finite asset set the portfolio variance is the quadratic form w ⬝ᵥ (Σ *ᵥ w).

theoremMathFin.portfolioVarN_le_of_lagrangian_FOCsource
∀ {ι : Type u_1} [Fintype ι] {Sg : Matrix ι ι ℝ}, Sg.PosSemidef → ∀ {μ w : ι → ℝ} {m lam₁ lam₂ : ℝ}, ∑ i, w i = 1 → portfolioReturn Finset.univ w μ = m → (∀ (i : ι), marginalVariance Finset.univ Sg w i = lam₁ + lam₂ * μ i) → ∀ {v : ι → ℝ}, ∑ i, v i = 1 → portfolioReturn Finset.univ v μ = m → portfolioVarN Finset.univ w Sg ≤ portfolioVarN Finset.univ v Sg

The Lagrangian FOC is sufficient for minimum variance. Let Σ be positive semidefinite and let w meet the budget ∑ wᵢ = 1 and the return target ∑ wᵢ μᵢ = m. If (Σw)ᵢ = λ₁ + λ₂ μᵢ for every asset, then w has the least variance among all portfolios meeting the same two constraints.

This is kkt_sufficient_of_eq for the QP min ½ wᵀΣw with the equality constraints 1 ⬝ᵥ w = 1, μ ⬝ᵥ w = m and multipliers (λ₁, λ₂). Only sufficiency is proved: that every minimiser satisfies the FOC is not.

theoremMathFin.posSemidef_covariancesource
∀ {ι : Type u_1} [Finite ι] {Ω : Type u_2} {mΩ : MeasurableSpace Ω} {P : Measure Ω} [IsFiniteMeasure P] (R : ι → Ω → ℝ), (∀ (i : ι), MemLp (R i) 2 P) → (Matrix.of fun i j => covariance (R i) (R j) P).PosSemidef

Covariance matrices are positive semidefinite (in Mathlib's Matrix.PosSemidef sense): the covariance matrix of square-integrable returns is symmetric (covariance_comm) and its quadratic form is the variance of ∑ vᵢ Rᵢ (covariance_kernel_psd).

theoremMathFin.variance_le_of_lagrangian_FOCsource
∀ {ι : Type u_1} [Fintype ι] {Ω : Type u_2} {mΩ : MeasurableSpace Ω} {P : Measure Ω} [IsFiniteMeasure P] (R : ι → Ω → ℝ), (∀ (i : ι), MemLp (R i) 2 P) → ∀ {μ w : ι → ℝ} {m lam₁ lam₂ : ℝ}, ∑ i, w i = 1 → portfolioReturn Finset.univ w μ = m → (∀ (i : ι), marginalVariance Finset.univ (fun i j => covariance (R i) (R j) P) w i = lam₁ + lam₂ * μ i) → ∀ {v : ι → ℝ}, ∑ i, v i = 1 → portfolioReturn Finset.univ v μ = m → variance (∑ i, w i • R i) P ≤ variance (∑ i, v i • R i) P

Markowitz for random returns. For square-integrable returns R, a portfolio w meeting the budget and the return target whose covariances with the assets satisfy the Lagrangian FOC ∑ⱼ cov(Rᵢ, Rⱼ) wⱼ = λ₁ + λ₂ μᵢ minimises the variance of the portfolio return ∑ wᵢ Rᵢ among all portfolios meeting the same constraints. The positive semidefiniteness that portfolioVarN_le_of_lagrangian_FOC needs is derived (posSemidef_covariance), not assumed. Sufficiency only.

theoremMathFin.isTangentPortfolioN_and_portfolioVarN_lesource
∀ {ι : Type u_1} [Fintype ι] {Sg : Matrix ι ι ℝ}, Sg.PosSemidef → ∀ {μ w : ι → ℝ} {rf lam : ℝ}, ∑ i, w i = 1 → (∀ (i : ι), marginalVariance Finset.univ Sg w i = lam * (μ i - rf)) → IsTangentPortfolioN Finset.univ (fun i => μ i - rf) Sg w ∧ ∀ (v : ι → ℝ), ∑ i, v i = 1 → portfolioReturn Finset.univ v μ = portfolioReturn Finset.univ w μ → portfolioVarN Finset.univ w Sg ≤ portfolioVarN Finset.univ v Sg

The tangent portfolio is mean–variance efficient. If Σw = λ(μ − r_f) and ∑ wᵢ = 1, then w is a tangent portfolio, and it has the least variance among the portfolios with the same budget and expected return: the tangency condition is the Lagrangian condition with multipliers (−λ r_f, λ). Positive semidefiniteness of Σ is a hypothesis.

theoremMathFin.portfolioVarN_covTwosource
∀ (σ₁ σ₂ ρ w : ℝ), portfolioVarN Finset.univ ![w, 1 - w] (covTwo σ₁ σ₂ ρ) = portfolioVarTwo σ₁ σ₂ ρ w

The two-asset portfolioVarN with the covariance matrix covTwo and weights (w, 1 − w) is the closed form portfolioVarTwo of Choice/Portfolio/Markowitz.lean.

theoremMathFin.portfolioVarTwo_eq_variancesource
∀ {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {P : Measure Ω} [IsFiniteMeasure P] {R₁ R₂ : Ω → ℝ}, MemLp R₁ 2 P → MemLp R₂ 2 P → ∀ {σ₁ σ₂ ρ : ℝ}, variance R₁ P = σ₁ ^ 2 → variance R₂ P = σ₂ ^ 2 → covariance R₁ R₂ P = ρ * σ₁ * σ₂ → ∀ (w : ℝ), portfolioVarTwo σ₁ σ₂ ρ w = variance (w • R₁ + (1 - w) • R₂) P

The two-asset variance formula is the variance of the portfolio return. For square-integrable returns with Var[R₁] = σ₁², Var[R₂] = σ₂² and cov[R₁, R₂] = ρσ₁σ₂, portfolioVarTwo σ₁ σ₂ ρ w = Var[w R₁ + (1 − w) R₂]: the closed form of Choice/Portfolio/Markowitz.lean is derived from the covariance kernel (portfolioVarN_covariance_eq_variance), not posited.

theoremMathFin.marginalVariance_minVarWeightTwosource
∀ {σ₁ σ₂ ρ : ℝ}, minVarDenom σ₁ σ₂ ρ ≠ 0 → ∀ (i : Fin 2), marginalVariance Finset.univ (covTwo σ₁ σ₂ ρ) ![minVarWeightTwo σ₁ σ₂ ρ, 1 - minVarWeightTwo σ₁ σ₂ ρ] i = minPortfolioVarTwo σ₁ σ₂ ρ

The minimum-variance mix equalises marginal variances. At the two-asset minimum-variance weight w* = minVarWeightTwo, each asset's marginal variance (Σw*)ᵢ — its covariance with the portfolio — equals the minimum variance V_min.

theoremMathFin.isConstrainedVarianceCriticalPoint_minVarWeightTwosource
∀ {σ₁ σ₂ ρ : ℝ}, minVarDenom σ₁ σ₂ ρ ≠ 0 → IsConstrainedVarianceCriticalPoint Finset.univ (covTwo σ₁ σ₂ ρ) 0 ![minVarWeightTwo σ₁ σ₂ ρ, 1 - minVarWeightTwo σ₁ σ₂ ρ]

The two-asset minimum-variance weight satisfies the Lagrangian FOC with budget multiplier V_min (and no return constraint, μ = 0), so it is a critical point of the variance under the budget constraint (isCriticalPoint_of_lagrangian_FOC).

theoremMathFin.portfolioVarN_minVarWeightTwo_lesource
∀ {σ₁ σ₂ ρ : ℝ}, 0 < minVarDenom σ₁ σ₂ ρ → ∀ (w : ℝ), portfolioVarN Finset.univ ![minVarWeightTwo σ₁ σ₂ ρ, 1 - minVarWeightTwo σ₁ σ₂ ρ] (covTwo σ₁ σ₂ ρ) ≤ portfolioVarN Finset.univ ![w, 1 - w] (covTwo σ₁ σ₂ ρ)

The closed-form two-asset weight minimises the portfolio variance. When D = σ₁² − 2ρσ₁σ₂ + σ₂² > 0, the weights (w*, 1 − w*) have the least portfolioVarN under covTwo among all two-asset budgets (w, 1 − w).