Convexity and concavity

Level UniversityDifficulty ★★★★★Concept⌖ Open in the map

What is it?

ff is convex if the chord between any two points of its graph lies above the graph — equivalently, for smooth ff, if f′′≥0f'' \ge 0. For convex functions every local minimum is global, which is why convex problems are the ones optimization can reliably solve.

Why does it exist?

General optimization is hopeless: a function can hide its minimum anywhere. Convexity is the structural property that makes local information (the slope here) globally trustworthy: if the slope says "downhill is that way", the global minimum really is that way.

Intuition

A convex function is a bowl: no bumps, no secondary valleys. The tangent line at any point lies entirely below the graph, so f(y)≥f(x)+f′(x)(y−x)f(y) \ge f(x) + f'(x)(y - x) — the linear prediction is always an underestimate, and a point with zero slope beats every other point.

Formal definition

ff is convex on an interval if for all x,yx, y and t∈[0,1]t \in [0,1]:

f(tx+(1−t)y)≤tf(x)+(1−t)f(y).f\big(tx + (1-t)y\big) \le t f(x) + (1 - t) f(y).

For differentiable ff: convex   ⟺  f(y)≥f(x)+f′(x)(y−x)\iff f(y) \ge f(x) + f'(x)(y - x); for twice differentiable ff: convex   ⟺  f′′≥0\iff f'' \ge 0. ff is concave if −f-f is convex. An inflection point is where concavity changes.

Idea of the proof

Local ⇒ global: if x∗x^\ast were a local but not global minimum, the chord to a lower point yy would lie below f(x∗)f(x^\ast) arbitrarily close to x∗x^\ast, contradicting local minimality.

Formulas

f(tx+(1−t)y)≤tf(x)+(1−t)f(y)f\big(tx + (1-t)y\big) \le t f(x) + (1 - t) f(y)
f(𝔼[X])≤𝔼[f(X)]f\big(\E[X]\big) \le \E\big[f(X)\big]
Jensen's inequality (convex ff)
∇2f(x)⪰0  ∀x  ⟺  f convex\nabla^2 f(x) \succeq 0 \ \ \forall x \iff f \text{ convex}
several variables: positive semidefinite Hessian

Why does it matter?

Linear and logistic regression, support vector machines, LASSO and most of operations research are convex: they come with guarantees and reliable solvers. Deep networks are not, which is why their training is an empirical art — and why it is remarkable that gradient descent works so well on them anyway.

Where it shows up in computing

  • Operations research and logistics★★★★★fundamentalOptimization and systems

    Convex optimization (linear, quadratic, conic programs) is the workhorse of planning and logistics.

Where it shows up in AI

  • Loss function★★★★★fundamentalAI and machine learning

    Squared error and cross-entropy are convex in the predictions; for linear models, in the parameters too.

  • Support vector machines★★★★★fundamentalAI and machine learning

    Training an SVM is a convex quadratic program: a unique global optimum.

  • Loss landscape★★★★★frequentAI and machine learning

    Deep-network losses are non-convex: many minima and saddles, yet good minima are easy to find in practice.

Where is it used?

Computing topics reachable from here, through the chain of ideas that leads to them:

What depends on it

Exercises

1Proof

Show that f(x)=ln⁡(1+ex)f(x) = \ln(1 + e^x) (softplus) is convex.

Solution

f′(x)=σ(x)f'(x) = \sigma(x) and f′(x)=σ(x)(1−σ(x))>0f'(x) = \sigma(x)(1 - \sigma(x)) > 0.

2AI

Is the loss of a 1-hidden-layer network convex in its weights? Hint: swap two hidden neurons.

Solution

No. Swapping two hidden neurons (and their outgoing weights) gives a different weight vector with the same loss. If θ1≠θ2\theta_1 \ne \theta_2 are both minima, convexity would make their midpoint at least as good — but the midpoint averages the two neurons into identical ones, generally worse. Symmetric minima rule out convexity.

↑ ↓ to navigate · ↵ · Esc