σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
Calculus skill›Module 4 · Optimization and sensitivities›Topic 4.2·~50 minIntermediate

Lagrange multipliers

Skill positionModule 4 of 4 · Topic 2 of 3
4.2 Lagrange multipliers
—Lab score— / 100Total XP—Streak—

Optimizing with a constraint

Without constraints, a smooth function has its maximum or minimum where the gradient is zero, ∇f=0\nabla f=0∇f=0. Real problems come with constraints: a fixed budget, portfolio weights that must sum to 1, a risk limit. You are then looking for the best point on a curve or surface g(x,y)=cg(x,y)=cg(x,y)=c, not anywhere in the plane.

∇f=λ ∇g,g(x,y)=c\nabla f=\lambda\,\nabla g,\qquad g(x,y)=c∇f=λ∇g,g(x,y)=c(1)

At the constrained optimum, the level curve of fff just touches the constraint, so the two gradients are parallel: ∇f=λ∇g\nabla f=\lambda\nabla g∇f=λ∇g. Package this as the Lagrangian L(x,y,λ)=f(x,y)−λ (g(x,y)−c)\mathcal{L}(x,y,\lambda)=f(x,y)-\lambda\,(g(x,y)-c)L(x,y,λ)=f(x,y)−λ(g(x,y)−c) and set all its partial derivatives to zero: the xxx and yyy equations give the parallel gradients and the λ\lambdaλ equation gives back the constraint.

The multiplier λ\lambdaλ has a meaning: it is the shadow price of the constraint, the rate at which the optimal value changes when the constraint is relaxed by one unit, dV∗dc=λ\frac{dV^*}{dc}=\lambdadcdV∗​=λ. In a minimum-variance portfolio with weights summing to 1, it tells you how much variance a little more budget would buy.

A budget problemMaximise f=xyf=xyf=xy subject to x+y=10x+y=10x+y=10. Here ∇f=(y,x)\nabla f=(y,x)∇f=(y,x) and ∇g=(1,1)\nabla g=(1,1)∇g=(1,1), so y=λy=\lambday=λ and x=λx=\lambdax=λ, hence x=y=5x=y=5x=y=5, λ=5\lambda=5λ=5 and the maximum is 25. If the budget grows to 11, the maximum becomes 5.5×5.5=30.255.5\times5.5=30.255.5×5.5=30.25: a gain of 5.25, close to λ×1=5\lambda\times1=5λ×1=5.
Candidates, not guaranteesSetting the Lagrangian's derivatives to zero finds candidate points. You still have to decide whether each is a maximum, a minimum or neither, and constraints written as inequalities (x≥0x\ge0x≥0) need the KKT conditions, which extend this idea.

Lab · what's graded

  • The Lagrangian15 pts
  • The optimal x20 pts
  • The maximum value15 pts
  • The multiplier15 pts
  • The geometry10 pts
  • A minimisation15 pts
  • What the multiplier means10 pts
0/ 7 answered
Tasks
1Fill the blanks15 ptsNot answered

Maximise f(x,y)=xyf(x,y)=xyf(x,y)=xy subject to x+y=10x+y=10x+y=10. Complete the Lagrangian for this problem.

L(x,y,λ)=xy−λ (x+y−)\displaystyle \mathcal{L}(x,y,\lambda)=xy-\lambda\,(x+y-\htmlData{blank=c}{\phantom{\rule[-0.35em]{2.4em}{1.35em}}})L(x,y,λ)=xy−λ(x+y−)
2Numeric answer20 ptsNot answered

Maximise f(x,y)=xyf(x,y)=xyf(x,y)=xy subject to x+y=10x+y=10x+y=10. Use ∇f=λ∇g\nabla f=\lambda\nabla g∇f=λ∇g to find the optimal xxx.

x∗=x^* =x∗=accepted: ± 0.001
3Numeric answer15 ptsNot answered

Maximise f(x,y)=xyf(x,y)=xyf(x,y)=xy subject to x+y=10x+y=10x+y=10. What is the maximum value of xyxyxy?

f∗=f^* =f∗=accepted: ± 0.001
4Numeric answer15 ptsNot answered

Maximise f(x,y)=xyf(x,y)=xyf(x,y)=xy subject to x+y=10x+y=10x+y=10. What is the value of the multiplier λ\lambdaλ at the optimum (from ∇f=λ∇g\nabla f=\lambda\nabla g∇f=λ∇g)?

λ=\lambda =λ=accepted: ± 0.001
5Choice10 ptsNot answered

At a constrained optimum, how are ∇f\nabla f∇f and ∇g\nabla g∇g related?

6Numeric answer15 ptsNot answered

Minimise x2+y2x^2+y^2x2+y2 subject to x+y=2x+y=2x+y=2. What is the minimum value? (Think of a two-asset portfolio with weights summing to 2 and squared weights as the cost.)

V∗=V^* =V∗=accepted: ± 0.001
7Explain in words10 ptsNot answered

In one or two sentences, say what the multiplier λ\lambdaλ tells you about the constraint.

Math modeKeyboard or LaTeX inputTask 1 of 7 · Ctrl ⏎ to check

Log in to run your code.

Every lecture is free to read. Create an account or log in to run code, run tests and submit this lab.

  • In-browser IDE with a bash terminal — nothing to install
  • Instant grading, XP and your place on the skill
Create an accountLog in
OR
Continue with GitHub