σμ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
  • 日本語
  • 中文
Optimization skill›Module 1 · Objectives and gradients›Topic 1.1·~40 minBeginner

Objective functions gradients and minima

Skill positionModule 1 of 5 · Topic 1 of 1
1.1 Objective functions gradients and minima
—Lab score— / 100Total XP—Streak—

What an optimizer looks for

An optimisation problem has a number to make small, the objective f(w)f(\mathbf w)f(w), and variables w\mathbf ww that you are free to change. The objective can be a least-squares loss, the variance wTΣw\mathbf w^{T}\Sigma\mathbf wwTΣw of a portfolio, or the gap between model prices and market prices in a calibration. Making something large is the same problem with the sign flipped, because maximising fff is minimising −f-f−f.

∇f(w)=(∂f∂w1,…,∂f∂wn),Hij=∂2f∂wi ∂wj\nabla f(\mathbf w)=\Big(\frac{\partial f}{\partial w_1},\dots,\frac{\partial f}{\partial w_n}\Big),\qquad H_{ij}=\frac{\partial^{2} f}{\partial w_i\,\partial w_j}∇f(w)=(∂w1​∂f​,…,∂wn​∂f​),Hij​=∂wi​∂wj​∂2f​(1)

The gradient points in the direction in which fff rises fastest, so −∇f-\nabla f−∇f is the direction of steepest descent. At a minimum the gradient is zero, which is the first-order condition. A zero gradient alone is not enough, because maxima and saddle points have it too. The Hessian HHH tells them apart: if HHH is positive definite (all eigenvalues positive) the point is a local minimum, if it is negative definite a maximum, and if it has eigenvalues of both signs the point is a saddle.

A two-variable exampleTake f(x,y)=(x−1)2+2(y+2)2f(x,y)=(x-1)^2+2(y+2)^2f(x,y)=(x−1)2+2(y+2)2. Then ∇f=(2(x−1), 4(y+2))\nabla f=(2(x-1),\,4(y+2))∇f=(2(x−1),4(y+2)). At the point (3,0)(3,0)(3,0) the gradient is (4,8)(4,8)(4,8), so moving against it lowers fff. The gradient is zero only at (1,−2)(1,-2)(1,−2). There H=diag(2,4)H=\mathrm{diag}(2,4)H=diag(2,4) has positive eigenvalues, so (1,−2)(1,-2)(1,−2) is the minimum and f=0f=0f=0 at it.
  • Stationary point: ∇f=0\nabla f=0∇f=0. Necessary for a minimum, not sufficient.
  • Classification: positive definite HHH means a local minimum, indefinite HHH a saddle.
  • In one variable: f′(x)=0f'(x)=0f′(x)=0 with f′′(x)>0f''(x)>0f′′(x)>0 is a minimum.
Check your gradient numericallyMost optimisation bugs are wrong gradients. Compare your formula with the central difference (f(x+h)−f(x−h))/(2h)\big(f(x+h)-f(x-h)\big)/(2h)(f(x+h)−f(x−h))/(2h) for a small hhh such as 10−510^{-5}10−5: the two should agree to several digits. Do this once for every new objective before trusting a solver that uses it.

Lab · what's graded

  • A partial derivative15 pts
  • The length of the gradient15 pts
  • The minimum of a cubic15 pts
  • Classifying a stationary point15 pts
  • Match the vocabulary15 pts
  • Finding a minimum by hand10 pts
  • Why move against the gradient15 pts
0/ 7 answered
Tasks
1Numeric answer15 ptsNot answered

For f(x,y)=(x−1)2+2(y+2)2f(x,y)=(x-1)^2+2(y+2)^2f(x,y)=(x−1)2+2(y+2)2, what is ∂f/∂y\partial f/\partial y∂f/∂y at the point (3,0)(3,0)(3,0)?

dfdy=dfdy =dfdy=accepted: ± 0.01
2Numeric answer15 ptsNot answered

For the same fff at (3,0)(3,0)(3,0) the gradient is (4,8)(4,8)(4,8). What is its Euclidean length ∥∇f∥\lVert\nabla f\rVert∥∇f∥? Give it to two decimals.

length=length =length=accepted: ± 0.02
3Numeric answer15 ptsNot answered

The function f(x)=x3−3xf(x)=x^3-3xf(x)=x3−3x has a local minimum where f′(x)=0f'(x)=0f′(x)=0 and f′′(x)>0f''(x)>0f′′(x)>0. What is the value of fff at that local minimum?

fmin=fmin =fmin=accepted: ± 0.01
4Choice15 ptsNot answered

The function f(x,y)=x2−y2f(x,y)=x^2-y^2f(x,y)=x2−y2 has ∇f=0\nabla f=0∇f=0 at the origin and H=diag(2,−2)H=\mathrm{diag}(2,-2)H=diag(2,−2). What is the origin?

5Match15 ptsNot answered

Match each term with its meaning.

Pick the partner of each item on the left.

Gradient
Hessian
Stationary point
Objective
6Order the steps10 ptsNot answered

Put the steps in order.

Drag to reorder, or focus an item, press Space to lift it, the arrow keys to move it and Space to drop it.

  1. 1Check that the Hessian is positive definite
  2. 2Write the objective fff
  3. 3Solve ∇f=0\nabla f=0∇f=0 for the stationary points
  4. 4Compute the gradient ∇f\nabla f∇f and the Hessian HHH
7Explain in words15 ptsNot answered

In one or two sentences, explain why an optimizer that wants to lower fff steps in the direction −∇f-\nabla f−∇f.

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