Hexa Scholar

Convex sets and convex functions

A taut cream thread stretches between two brass pegs on a dark drafting board.
A taut thread stretched between two pegs traces a straight segment.

The question

What can a straight segment tell you about a region or a curve?

Place a point between two endpoints, then decide what the segment reveals.

  1. 1 SeeClassify regions and graphs.
  2. 2 TryMove a point along a chord.
  3. 3 ProveConnect a function to a set.
  4. 4 ApplyTest constraints and model costs.
Before you start · 3 quick checks on vector arithmetic, evaluating a function, and reading an inequality

Two ideas before you start

2 ideas

A weight picks a point on a segment

Two marked endpoints and a point between them. The point moves when you choose a weight.

Place the mark

Use the same pair of weights for every coordinate. The resulting point slides from the first endpoint to the second.

Exact definition

Let \(u,v\) be points of \(\mathbb R^n\), the space of real vectors with \(n\) coordinates. For a real weight \(0\le t\le 1\), the point \(z=(1-t)u+tv\) is a convex combination of \(u\) and \(v\). The weights are nonnegative and sum to one. The closed segment is the set of all such \(z\), including the endpoints. A set \(C\) is convex if it contains this entire segment for every pair \(u,v\in C\).

The dot product and projection lesson uses a real parameter to move along a whole line. Restricting the parameter in \(u+t(v-u)\) to the unit interval gives the segment here.

Compare two heights at one input

A straight graph with two marked endpoints. The graph and its chord share the same height at the selected input.

Compare at

The graph uses the mixed input. The chord mixes the two endpoint heights. For this affine function, the heights agree at every weight.

Exact definition

Let \(C\subseteq\mathbb R^n\) be convex and let \(f:C\to\mathbb R\). For every \(u,v\in C\) and \(t\in[0,1]\), compare the graph height at \(z=(1-t)u+tv\) with the chord height. The function \(f\) is convex when

\[ f(z)\le (1-t)f(u)+tf(v). \]

It is strictly convex if the inequality is strict whenever \(u\ne v\) and \(0\lt t\lt 1\). An affine function on the real line has the form \(f(x)=ax+b\) for constants \(a,b\). Its chord heights agree with the graph heights, so it is convex but not strictly convex.

Refresher: coordinates, graph height, and boundary points

Multiply a vector by a scalar by multiplying every coordinate. Add vectors by adding the corresponding coordinates. A function assigns an output to each input in its domain. On the graph of a one-variable function, the point at input \(x\) has vertical coordinate \(f(x)\).

The inequality \(y\le b\) includes the boundary \(y=b\). A point must satisfy every listed inequality to belong to a region cut out by those inequalities. In the game, a solid boundary is included.

The chord test concerns the full domain. For a disconnected domain such as two separated intervals, a mixture of inputs can land in the gap. Under the convention here, check that the domain is convex before asking whether its function is convex.

1 See

Classify each region or graph

2 Try

Move along a chord

The chord explorer opens after you check your prediction.

3 Prove

Turn the chord test into a set test

Theorem: the epigraph

Let \(n\) be a positive integer, \(C\subseteq\mathbb R^n\) a nonempty convex set, and \(f:C\to\mathbb R\) a real-valued function. Its epigraph is the set above the graph, including the graph itself:

\[ E=\{(x,r): x\in C,\ r\ge f(x)\}. \]

Then \(f\) is convex exactly when \(E\) is convex.

Build both directions. Fix any \(u,v\in C\), possibly equal, and any weight \(0\le t\le1\). Let \(z=(1-t)u+tv\). In the first direction, take real heights \(a\ge f(u)\), \(b\ge f(v)\), and put \(r=(1-t)a+tb\). In the reverse direction, use the two points on the graph.

A shortcut for smooth functions of one variable

Let \(I\) be an open interval and let \(f\) be twice differentiable on \(I\). Then \(f\) is convex on \(I\) exactly when \(f''(x)\ge 0\) for every \(x\in I\). If \(f''(x)\gt 0\) for every \(x\in I\), then \(f\) is strictly convex on \(I\).

The strict version runs one way only: \(f(x)=x^4\) is strictly convex on the real line, yet \(f''(0)=0\). The test also needs both of its hypotheses. The function \(f(x)=|x|\) is convex but has no second derivative at \(0\), so the test says nothing about it; the chord inequality settles it instead. The function \(f(x)=1/x^2\) has \(f''(x)=6/x^4\gt 0\) at every \(x\ne 0\), but its domain, the real line without \(0\), is not an interval, so under the convention here it is not a convex function.

The test agrees with the examples on this page. For \(f(x)=x^2\), \(f''(x)=2\gt 0\). For \(f(x)=3-x^2\), \(f''(x)=-2\lt 0\), so it is convex on no open interval. For \(f(x)=x^3\), \(f''(x)=6x\lt 0\) for \(x\lt 0\), which matches the chord below the graph in Apply.

4 Apply

Use the tests on new examples

Enter one number for each problem. Start with the endpoints and the weight, then decide whether the problem compares coordinates, graph heights, or both. Each problem has hints and a worked solution.

Key point For a set, check membership of the mixed point. For a function, check the domain and compare the two heights. A single failed comparison certifies a violation.
Level Advanced undergraduate Prerequisites Vector addition and scalar multiplication, refreshed above Time About half an hour

Related lessons: critical points studies the local behavior of a smooth surface near a stationary point. Jensen’s inequality extends the chord comparison to expectations.

Further reading