skip to content

Convexity & Optimality

Convex sets and functions, the guarantee that a convex problem has a single global minimum, and the conditions certifying a point is optimal. A staple of 'why does this even converge' questions.

on this pageshow

explore

questions

10

What is the formal definition of a convex set?

level: juniorimportance: must knowfreq 66%

answer

  1. think about straight lines
  2. pick any two points of the set
  3. the whole segment must stay inside
  4. t*x + (1-t)*y for t in [0,1]

basics

~20 s

A set is convex if the straight segment joining any two of its points lies entirely inside it: for every x and y in the set C and every t in [0, 1], the point t*x + (1-t)*y is also in C.

solid answer

~40 s

A set `C` is convex when, for all `x, y` in `C` and all `t` in `[0, 1]`, the convex combination `t*x + (1-t)*y` belongs to `C`. Geometrically: pick any two points of the set, draw the segment between them, and the segment never leaves the set. Half-planes such as `{(x, y) : x + y <= 3}`, balls, boxes and the L1 ball `{x : sum |x_i| <= 1}` are convex; a crescent, an annulus like `1 <= x^2 + y^2 <= 4`, and the union of two disjoint disks are not, because you can pick two points whose connecting segment leaves the region. Convexity survives intersection, translation, scaling and affine maps, which is why feasible regions built from linear constraints are automatically convex.

go deeper

for a junior

Be ready to state the segment condition precisely and to classify simple shapes on sight: disk yes, half-plane yes, annulus no, union of two disks no.

for a middle

Explain why the condition is stated with a parameter t in [0,1], and show that intersections preserve convexity while unions do not, with the one-line segment argument.

for a senior

Demonstrate that you build convexity rather than check it: recognise a feasible region as an intersection of half-spaces or norm balls, and know which operations you may apply without re-proving anything.

for a principal

Own the modelling call — whether to express a constraint set so that it is convex at all, since the choice between a convex relaxation and an exact non-convex description determines what solver guarantees you can promise.

## The definition A set `C` in `R^n` is **convex** if for every pair of points `x, y` in `C` and every scalar `t` in `[0, 1]`, ``` t*x + (1 - t)*y is in C ``` The expression `t*x + (1 - t)*y` is called a **convex combination** of `x` and `y`. As `t` sweeps from `0` to `1`, the point traces the straight segment from `y` to `x`. So the definition says exactly: *the segment between any two points of the set stays inside the set*. Nothing about smoothness, symmetry or roundness is required. The definition extends to more than two points: `C` is convex if and only if every convex combination `t_1*x_1 + ... + t_k*x_k` (with `t_i >= 0` and `sum t_i = 1`) of points of `C` is again in `C`. The two-point version already implies the general one by induction. ## Examples that are convex - A **half-space**: `{x : a . x <= b}` for a fixed vector `a` and scalar `b`. If two points each satisfy the inequality, so does every point between them, because `a . x` is linear in `x`. - Any **ball** in any norm, including the Euclidean ball `{x : ||x||_2 <= 1}` and the **L1 ball** `{x : sum |x_i| <= 1}` (the diamond). Norm balls are convex because norms satisfy the triangle inequality and positive homogeneity. - A **box** `{x : l_i <= x_i <= u_i}`, which is an intersection of half-spaces. - The whole space, a single point, and the empty set (vacuously). ## Examples that are not convex - An **annulus** such as `1 <= x^2 + y^2 <= 4`. Take the points `(-1.5, 0)` and `(1.5, 0)`: both are in the ring, but their midpoint `(0, 0)` is in the hole, so the segment escapes. - A **crescent** or any shape with a dent: the segment across the dent leaves the region. - The **union of two disjoint disks**: a segment from one disk to the other passes through empty space. - A **curve** such as the circle `x^2 + y^2 = 1` on its own (as opposed to the filled disk): the chord between two points of the circle is inside the disk, not on the circle. ## Operations that preserve convexity This is the practical part, because most convex sets you meet are built rather than checked from scratch: - **Intersection** of any number of convex sets is convex. If a segment lies in each set, it lies in all of them at once. This is why a feasible region defined by many linear inequalities is convex. - **Translation** `C + v`, **scaling** `a*C`, and more generally **affine images** `{A*x + b : x in C}` are convex. - **Minkowski sum** `{x + y : x in C, y in D}` of two convex sets is convex. - **Union** is the notable failure: the union of two convex sets is generally not convex. ## The bridge to convex functions Convex sets and convex functions are two views of the same idea. A function `f` is convex exactly when its **epigraph** — the set of points lying on or above its graph, `{(x, t) : t >= f(x)}` — is a convex set in one higher dimension. In the other direction, every **sublevel set** `{x : f(x) <= c}` of a convex function is a convex set. The converse of that last statement is false: `f(x) = sqrt(|x|)` has sublevel sets `[-c^2, c^2]`, which are intervals and therefore convex, yet the function itself is not convex. Functions whose sublevel sets are all convex are called quasiconvex, a strictly weaker property. ## Why interviewers ask Convexity of the feasible region is half of what makes an optimisation problem tractable — the other half is convexity of the objective. Being able to say *why* a region qualifies (it is an intersection of half-spaces, it is a norm ball) rather than pointing at a picture is the difference between recognition and understanding.

  • Is the intersection of two convex sets always convex, and what about their union?
    The intersection always is: if a segment lies inside each set, it lies inside both, hence inside the intersection. The union generally is not — two disjoint disks are each convex, but a segment from one to the other passes through empty space. This asymmetry is why feasible regions built from many constraints (an intersection) stay convex.
  • How does the epigraph connect convex sets to convex functions?
    The epigraph of `f` is the set of points on or above its graph: `{(x, t) : t >= f(x)}`. A function is convex if and only if its epigraph is a convex set in one higher dimension. That equivalence lets you transfer every fact about convex sets to convex functions and back, and it is the standard way the two definitions are unified.
  • Are the sublevel sets of a convex function convex, and does the converse hold?
    Yes for the forward direction: `{x : f(x) <= c}` is convex whenever `f` is convex, since the chord bound keeps intermediate points below `c`. The converse fails. `f(x) = sqrt(|x|)` has sublevel sets `[-c^2, c^2]`, which are convex intervals, yet the function is not convex. Such functions are called quasiconvex.

Think of the set as a room. It is convex if, standing anywhere inside, you can see every other point of the room without a wall blocking the line of sight.

saying these in an interview costs you the question

  • Confuses a convex set with a convex function
  • Claims the union of convex sets is always convex
  • Says an annulus is convex because it is round
  • Requires the boundary to be smooth or curved outward
  • Checks only endpoints instead of the whole segment

context

open as a page

Why is a zero gradient necessary but not sufficient for a local minimum?

level: juniorimportance: must knowfreq 82%

basics

~20 s

At a smooth interior local minimum the gradient must vanish, so a zero gradient is necessary. But maxima, saddle points and flat inflection points also have a zero gradient, so vanishing slope on its own certifies nothing.

open as a page

Using the chord test, why is f(x) = x^2 convex but f(x) = x^3 not?

level: middleimportance: must knowfreq 70%

basics

~20 s

A function is convex when every chord lies on or above its graph: f(t*x + (1-t)y) <= tf(x) + (1-t)*f(y). Squaring passes everywhere. Cubing fails between x = -2 and 0, where f(-1) = -1 sits above the chord value -4.

open as a page

Why is the origin a saddle point of f(x, y) = x^2 - y^2 rather than a minimum?

level: middleimportance: must knowfreq 68%

basics

~20 s

The gradient of x^2 - y^2 vanishes at the origin, but the surface curves up along the x-axis and down along the y-axis. A point that is a minimum one way and a maximum another is a saddle.

open as a page

What is the second-order test for convexity of a twice-differentiable function?

level: middleimportance: should knowfreq 55%

basics

~20 s

On an open convex domain, a twice-differentiable function is convex exactly when its Hessian is positive semidefinite at every point of that domain. In one variable this reduces to f''(x) >= 0 everywhere. A positive definite Hessian everywhere implies strict convexity.

open as a page

How does the sign of f''(c) classify a stationary point c of a one-variable function?

level: middleimportance: should knowfreq 60%

basics

~10 s

At a stationary point c: positive f''(c) means a strict local minimum, negative means a strict local maximum, and f''(c) = 0 is inconclusive, since minima, maxima and inflections all produce it.

open as a page

What does Jensen's inequality say about a convex function of a weighted average?

level: seniorimportance: should knowfreq 36%

basics

~20 s

For a convex f and weights t_i >= 0 summing to 1, f(sum t_i x_i) <= sum t_i f(x_i): the function of the weighted average never exceeds the weighted average of the function values. For a concave f the inequality reverses.

open as a page

For the double well f(x) = x^4 - 4x^2, why does the starting point decide which minimum you reach?

level: seniorimportance: should knowfreq 50%

basics

~20 s

f(x) = x^4 - 4x^2 has minima at x = -sqrt(2) and x = +sqrt(2) with a local maximum at x = 0 between them. A downhill search never climbs that barrier, so the starting sign fixes the answer.

open as a page

Why is the pointwise maximum of two linear functions convex despite its kink?

level: seniorimportance: nice to knowfreq 28%

basics

~20 s

Convexity is defined by the chord inequality, which never mentions derivatives. Each linear piece satisfies that inequality, and taking the maximum of two bounds preserves it, so the max is convex. The corner where the two lines cross affects smoothness only.

open as a page

How do you distinguish a long flat plateau from a true stationary point of an objective?

level: seniorimportance: nice to knowfreq 33%

basics

~20 s

At a true stationary point the gradient is exactly zero. On a plateau it is merely small and still consistently signed, so the objective keeps creeping down and a long enough step leaves the flat region.

open as a page