σμ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 3 · Convexity and curvature›Topic 3.1·~50 minIntermediate

Convexity and why it matters

Skill positionModule 3 of 5 · Topic 1 of 2
3.1 Convexity and why it matters
—Lab score— / 100Total XP—Streak—

One valley, one answer

A function is convex if the straight segment between any two points of its graph lies on or above the graph: f(θx+(1−θ)y)≤θf(x)+(1−θ)f(y)f(\theta\mathbf x+(1-\theta)\mathbf y)\le\theta f(\mathbf x)+(1-\theta)f(\mathbf y)f(θx+(1−θ)y)≤θf(x)+(1−θ)f(y) for every θ∈[0,1]\theta\in[0,1]θ∈[0,1]. For a twice-differentiable function there is a practical test: fff is convex exactly when its Hessian is positive semidefinite everywhere, meaning all eigenvalues are ≥0\ge0≥0. Sums of convex functions, positive multiples of them and the maximum of convex functions are convex again, which is how large convex objectives are built from small pieces.

H(w)⪰0  ∀ w ⟹ ∇f(w∗)=0 ⇒ f(w∗)=min⁡wf(w)H(\mathbf w)\succeq0\ \ \forall\,\mathbf w\ \Longrightarrow\ \nabla f(\mathbf w^{*})=0\ \Rightarrow\ f(\mathbf w^{*})=\min_{\mathbf w}f(\mathbf w)H(w)⪰0  ∀w ⟹ ∇f(w∗)=0 ⇒ f(w∗)=wmin​f(w)(1)

Convexity is what makes optimisation reliable. Every local minimum is a global minimum, a zero gradient is enough to stop, and the answer does not depend on where the solver starts. If the function is strictly convex the minimiser is also unique, and if it is strongly convex, with curvature at least μ>0\mu>0μ>0 in every direction, gradient descent converges at the geometric rate you saw before. Without convexity none of this is guaranteed: the solver may stop in a valley that is not the deepest one.

A check and a counterexampleFor f(x)=x2f(x)=x^2f(x)=x2 take the points 000 and 444 with θ=12\theta=\tfrac12θ=21​. The midpoint value is f(2)=4f(2)=4f(2)=4, while the average of the end values is (0+16)/2=8(0+16)/2=8(0+16)/2=8; the gap of 444 is positive, as convexity demands. Now take f(x,y)=x2+4xy+y2f(x,y)=x^2+4xy+y^2f(x,y)=x2+4xy+y2. Its Hessian (2442)\begin{pmatrix}2&4\\4&2\end{pmatrix}(24​42​) has eigenvalues 666 and −2-2−2. One is negative, so fff is not convex: the origin is a saddle point.

In finance the convex objectives include the portfolio variance wTΣw\mathbf w^{T}\Sigma\mathbf wwTΣw (because a covariance matrix is positive semidefinite), least-squares losses, the ℓ1\ell_1ℓ1​ norm ∥w∥1\lVert\mathbf w\rVert_1∥w∥1​ and the expected shortfall (CVaR) as a function of the weights. Value-at-risk, a cap on the number of non-zero weights and the Sharpe ratio taken as it stands are not convex. A sample covariance matrix estimated from fewer observations than assets is positive semidefinite but singular, so the variance is convex without being strictly convex, and many weight vectors tie for the minimum.

  • Hessian test: all eigenvalues ≥0\ge0≥0 everywhere means convex; one negative eigenvalue means not convex.
  • Payoff: every local minimum is global, so the start point does not matter.
  • Building blocks: sums, positive multiples and maxima of convex functions stay convex.
Relax what is not convexWhen a requirement is not convex, such as at most kkk non-zero weights, a common move is to replace it with a convex cousin, here the ℓ1\ell_1ℓ1​ penalty. The relaxed problem is solved reliably and usually gives a good answer, but it is a different problem, so check the result against the original requirement before you use it.

Lab · what's graded

  • A convexity gap15 pts
  • The eigenvalue that breaks convexity15 pts
  • Which Hessian is convex15 pts
  • Convex objectives in finance15 pts
  • A zero gradient10 pts
  • Convexity vocabulary15 pts
  • Why solvers like convex problems15 pts
0/ 7 answered
Tasks
1Numeric answer15 ptsNot answered

For f(x)=x2f(x)=x^2f(x)=x2 and the points 000 and 444 with θ=12\theta=\tfrac12θ=21​, compute 12f(0)+12f(4)−f(2)\tfrac12 f(0)+\tfrac12 f(4)-f(2)21​f(0)+21​f(4)−f(2).

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

The function f(x,y)=x2+4xy+y2f(x,y)=x^2+4xy+y^2f(x,y)=x2+4xy+y2 has Hessian (2442)\begin{pmatrix}2&4\\4&2\end{pmatrix}(24​42​). What is its smallest eigenvalue?

mineig=mineig =mineig=accepted: ± 0.01
3Choice15 ptsNot answered

A function has the same constant Hessian everywhere. For which Hessian is the function convex?

4Choice15 ptsNot answered

Which of these are convex functions of the weight vector w\mathbf ww? Select all that apply.

5Choice10 ptsNot answered

For a convex, differentiable fff, what does ∇f(w∗)=0\nabla f(\mathbf w^{*})=0∇f(w∗)=0 tell you?

6Match15 ptsNot answered

Match each term with what it guarantees.

Pick the partner of each item on the left.

Convex
Strictly convex
Strongly convex
Non-convex
7Explain in words15 ptsNot answered

In one or two sentences, say what convexity gives a portfolio optimizer.

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