Lesson 0011

Convexity: Why Local Is Global

Every dual you read in Lessons 0004–0010 came with a hidden assumption: that the solver's answer was the answer. Convexity is the property that makes that true — and it is the first thing to check in any portfolio paper.

The One-Step Skill

Given any term in a portfolio formulation — an objective piece or a constraint — classify it as convex or non-convex. That single classification tells you two things your mission cares about:

Is the answer trustworthy?

If every term is convex, any local optimum is the global optimum. The solver cannot get trapped, and the duals you learned to read are meaningful sensitivities.

Which solver class?

All convex → QP/SOCP-style solvers with a global guarantee. One non-convex term → the paper must reach for mixed-integer solvers or heuristics, and its “optimum” is only as good as its search.

The Picture First

Think of the objective as terrain and the solver as a ball rolling downhill.

A convex objective is a single bowl. Drop the ball anywhere — left rim, right rim, dead center — and it rolls to the same bottom. There is nothing to get stuck in, because there is only one valley. That is the entire meaning of “local = global.”

A non-convex objective is a mountain range. The ball rolls into whichever valley is nearest, and it has no way of knowing a deeper valley exists across the ridge. Gradient-based solvers are ball-rollers: on non-convex terrain, where you start determines what you find.

Memory hook: convex = one bowl, one bottom. Non-convex = mountain range, and the ball keeps the first valley it finds.

The Chord Test

The formal definition is a picture in disguise. A function f is convex when the straight chord drawn between any two points on its graph never dips below the graph:

f is convex if, for all x, y and 0 <= t <= 1:

  f(t*x + (1-t)*y)  <=  t*f(x) + (1-t)*f(y)

  left side:  the curve, evaluated between x and y
  right side: the chord, evaluated between x and y

Read it slowly once: t*x + (1-t)*y is a point on the segment between x and y; t*f(x) + (1-t)*f(y) is the matching point on the chord. “Curve below chord, always” is the whole definition.

When f is twice differentiable there is a faster test: curvature never turns downward.

1D test:      f''(x) >= 0   for all x

Portfolio:    f(w) = w' Σ w
Hessian:      2Σ
Σ is PSD (a variance can never be negative), so
portfolio risk is convex for any covariance matrix.

This is why the quadratic risk term from Lesson 0002 is such a gift: the core of every mean-variance problem is convex before you add a single constraint.

Lab: Chord Test and Ball Roll

Two experiments in one chart. First, drag the chord endpoints and watch the verdict: on the bowl and the kink the chord never dips below the curve; on the double dip, place one endpoint in each valley and watch the chord fail. Second, pick a start point and roll the ball: on the double dip, start left of the ridge and you land in the shallow valley — a local optimum the solver would happily report.

Chord verdict-
Chord midpoint-
Curve midpoint-
Ball landed at-
Global min at-
Roll verdict-

Compare the two midpoint metrics: convexity is exactly the claim “curve midpoint <= chord midpoint” for every possible chord. Note the kink terrain: not differentiable at the bottom, yet every chord passes. Convex does not require smooth.

Why Local Must Be Global

The proof is three sentences, and it is the chord picture again. Suppose the solver found a local minimum x*, but some faraway point z is strictly better.

1. Draw the chord from x* to z.
2. Convexity: the curve lies on or below that chord,
   and the chord slopes downward from x* (f(z) < f(x*)).
3. So points immediately next to x*, toward z, are already
   below f(x*) — contradicting that x* was a local minimum.

No better faraway point can exist without betraying itself right next to x*. That is the theorem your duals toolkit has been resting on: with convexity, the KKT conditions from Lesson 0004 are not just necessary — they certify the global optimum.

Convexity Calculus: Building Legal Objectives

You rarely test convexity from the raw definition. Real formulations are assembled from convex pieces using rules that preserve convexity:

sum:        convex + convex               -> convex
scaling:    (nonnegative number) * convex -> convex
max:        max(convex, convex)           -> convex
affine map: convex(A*w + b)               -> convex

Apply the rules to a realistic single-period objective:

minimize   w'Σw  -  γ μ'w  +  κ ||w - w_prev||_1

w'Σw              convex  (Hessian 2Σ, PSD)
-γ μ'w             convex  (linear is both convex and concave)
κ ||w - w_prev||_1  convex  (kinked, but every chord passes)
sum of all three   convex  (sum rule)

The turnover penalty is the payoff: ||w - w_prev||_1 is a multidimensional version of the kink you just rolled a ball over. Non-smooth, but convex — which is exactly why solvers accept it, and why the next lessons can price trading limits with duals.

The Portfolio Dividing Line

The same real-world idea can land on either side of the line depending on how it is modeled. This is what you scan for when reading a paper:

Convex: proportional trading cost

Pay 5 bps per dollar traded: c'|Δw|. Kinked at zero trade, but every chord passes. Stays in QP/SOCP land.

Non-convex: fixed ticket fee

Pay $10 if you touch a name at all. Cost jumps from 0 to 10 at the first penny traded — a cliff, not a bowl. Needs integer variables.

Convex: leverage cap

||w||_1 <= 1.5. The set of allowed portfolios is a diamond — any blend of two legal portfolios is still legal. Convex feasible set.

Non-convex: cardinality

“Hold at most 20 names.” Two legal 20-name portfolios can blend into an illegal 40-name one — the chord leaves the set. Needs MIQP or heuristics.

Convex: box caps

0 <= w_i <= 0.07 — the caps from Lessons 0007–0010. Intervals are convex sets, and intersections of convex sets stay convex.

Non-convex: minimum position

“Either w_i = 0 or w_i >= 2%.” The allowed set has a hole: blend a zero holding with a 2% holding and you land in the forbidden gap.

Reading rule: one non-convex term poisons the whole problem. The paper must then say how it copes — mixed-integer solver, relaxation, or heuristic — and its duals stop being trustworthy shadow prices.

Retrieval Practice

Your solver minimizes w'Σw + κ||w - w_prev||_1 with box caps and reports an optimum. How many better portfolios might it have missed?

Which trading-cost model pushes the problem out of convex land?

A non-convex objective has a shallow dip and a deep dip. Gradient descent started near the shallow one lands where?

Portfolio Reading

This lesson upgrades how you read papers, per your mission. The scan: find the objective and the constraints, then walk term by term asking “convex?” If yes for all — the paper is a convex program, its solution is global, its duals are real sensitivities, and CVXPY-style tools can reproduce it. If any term fails — look for the words mixed-integer, relaxation, or heuristic, expect no global guarantee, and treat any reported duals with suspicion. Boyd et al.'s multiperiod trading paper spends its early pages doing exactly this classification — you can now read those pages as a checklist rather than as ritual.

Primary Source

Read sections 2.1–2.3 and 3.1 of Boyd and Vandenberghe's Convex Optimization — convex sets, then convex functions; the pictures there are the canonical versions of this lab. For the code-side view, CVXPY's disciplined convex programming rules are the convexity calculus above turned into a compiler. Keep the convexity cheat sheet open while reading, and revisit the risk quadratic-form reference for why Σ is PSD.

Questions?

Ask your agent anything unclear — good prompts: “show me a 2D non-convex feasible set as a picture,” “why exactly is the L1 norm convex?”, or “walk me through the local-implies-global proof one more time with numbers.”