Hexa Scholar

Separating hyperplanes: a line between two convex sets

A navy pebble and a gold pebble on a clay table, with a taut gold thread stretched straight between two brass pins through the gap between them.
A straight thread through the gap between two pebbles.

The question

Four pairs of convex polygons. For which pairs can one straight line keep the two shapes on opposite sides?

Draw the line yourself; the page checks every corner.

  1. 1 SeeDraw a line between two shapes.
  2. 2 TryFind closest points; make two predictions.
  3. 3 ProveBuild the line from the closest point.
  4. 4 ApplyProblems to check yourself.
Before you start · 3 quick checks on the dot product, the two sides of a line and mixing two points, about 3 min

Two ideas before you start

2 ideas

A line splits the plane in two

Figure: the line x + 2y = 6, the side where x + 2y is less than 6 shaded, and the points P = (1, 1), Q = (2, 2) and R = (4, 3). It needs JavaScript.

Point:

x + 2y at P = 1 + 2 · 1 = 3 3 < 6 P is on the shaded side.

Put a point into x + 2y and compare with 6: less, and it is on one side of the line x + 2y = 6; more, and it is on the other; equal, and it is on the line.

Exact definition

Hyperplanes and half-spaces. For a vector \(a \ne 0\) in \(\mathbb{R}^n\) and a number \(c\), the set \(H = \{x : a\cdot x = c\}\) is a hyperplane: a line when \(n = 2\), a plane when \(n = 3\). It splits \(\mathbb{R}^n\) into the two closed half-spaces \(\{x : a\cdot x \le c\}\) and \(\{x : a\cdot x \ge c\}\), which share \(H\), and the two open half-spaces where the inequalities are strict. The vector \(a\) is perpendicular to \(H\) and points into the side where \(a\cdot x \gt c\).

A line \(y = k + mx\) is the hyperplane \(a\cdot x = c\) with \(a = (-m, 1)\) and \(c = k\), so the points above it are those with \(a\cdot x \gt c\). The dot product is the one from the lesson on the dot product and the closest point on a line.

Separate: each set on its own side

Figure: a triangle A at the lower left, a triangle B at the upper right, and a dashed line between them. It needs JavaScript.

Line:

Strict: every corner of A is strictly below the line and every corner of B strictly above it. The line touches neither set.

A line separates two sets when each lies on its own closed side. If neither set touches the line, the separation is strict; if a set touches it, the separation is only weak.

Exact definition

Separation. A hyperplane \(a\cdot x = c\) with \(a \ne 0\) separates two sets \(A\) and \(B\) when \(a\cdot x \le c \le a\cdot y\) for every \(x \in A\) and every \(y \in B\), or the same with \(A\) and \(B\) swapped: each set lies in its own closed half-space. It separates them strictly when \(a\cdot x \lt c \lt a\cdot y\) for every \(x \in A\) and every \(y \in B\) (or swapped): neither set meets the hyperplane. On this page a weak separation is a separation that is not strict.

A set \(C\) is convex when it contains the point \((1 - t)u + tv\) for every \(u, v \in C\) and every \(t\) with \(0 \le t \le 1\), as in the lesson on convex sets and convex functions. Filled convex polygons, disks and half-spaces are convex sets.

Fine print: closed, bounded, and other names

A set is closed when it contains the limit of every convergent sequence of its points, and bounded when it fits inside some disk (in \(\mathbb{R}^n\), some ball). A filled polygon with its edges is closed and bounded; a half-plane \(\{(x, y) : y \le 0\}\) is closed but not bounded.

Some books reserve the name strong separation for a hyperplane with a positive gap: \(a\cdot x \le c - \varepsilon\) and \(a\cdot y \ge c + \varepsilon\) for some \(\varepsilon \gt 0\). For two nonempty, closed and bounded sets, strict and strong separation are the same thing, because \(a\cdot x\) then reaches its largest value on one set and its smallest on the other.

1 See

Draw a line between two shapes

How the page decides

Your line runs from \(x = 0\) to \(x = 10\); each handle sets its height at one end, in steps of 0.1 from 0 to 7. The page checks the corners. Each side of a line is convex, and every point of a convex polygon is a weighted average of its corners, with nonnegative weights that add up to 1. So a polygon lies on one closed side of the line exactly when all its corners do, and strictly on one side exactly when all its corners do. Every corner has coordinates in halves, so the comparisons are exact.

A check that fails leaves the round open. A line that separates, or the button, ends the round. There are four rounds; after the last one a table compares your answers with the best possible ones. Start over clears everything.

2 Try

One point and one convex set

A prediction first. The explorer below it opens once it is answered.

The explorer and its goals open after you answer the prediction.

Two sets that do not meet

3 Prove

Why a closest point gives a separating line

Theorem

Assumptions. \(n \ge 1\), \(C\) is a nonempty, closed, convex subset of \(\mathbb{R}^n\), and \(b\) is a point of \(\mathbb{R}^n\) that is not in \(C\).

Conclusion. There are a vector \(a \ne 0\) and a number \(c\) with \(a\cdot x \lt c \lt a\cdot b\) for every \(x \in C\): the hyperplane \(a\cdot x = c\) separates \(b\) from \(C\) strictly.

Facts the proof uses.

  • a closest point exists: there is \(p \in C\) with \(|b - p| \le |b - x|\) for every \(x \in C\) (see below);
  • convexity: \((1 - t)p + tx \in C\) for \(p, x \in C\) and \(0 \le t \le 1\);
  • dot product algebra: \(|u|^2 = u\cdot u\), positive for \(u \ne 0\), and \[\begin{aligned} &|u - v|^2 \\ &= |u|^2 - 2u\cdot v + |v|^2. \end{aligned}\]

Setup. Fix a closest point \(p\) and put \(a = b - p\). Since \(p\) is in \(C\) and \(b\) is not, \(a \ne 0\).

Why a closest point exists

Pick any \(x_0 \in C\) and let \(K\) be the set of points of \(C\) at distance at most \(|b - x_0|\) from \(b\). \(K\) is closed (both conditions survive limits), bounded and nonempty, and the distance \(x \mapsto |b - x|\) is continuous, so it reaches a smallest value on \(K\) at some \(p\). Every point of \(C\) outside \(K\) is farther from \(b\) than \(x_0\), so \(p\) is a closest point of all of \(C\). Convexity also makes \(p\) unique (the last item under "What else follows", after the proof), but the proof does not need that.

Each option is one step about \(C\), \(b\), \(p\) and \(a\) of the theorem. Pick the one that is true for every set and point the theorem covers. A step that says "for every \(x \in C\)" must hold for every point of \(C\), the point \(p\) itself included.

4 Apply

Problems

Each problem has hints and a full solution. Exact answers can be typed as a decimal or a fraction.

Key point To separate a point \(b\) from a closed convex set, find its closest point \(p\); the hyperplane through the midpoint of \(p\) and \(b\), perpendicular to \(b - p\), separates them strictly. For two convex polygons and a fixed direction \(a\), compare the largest value of \(a\cdot x\) on one polygon with the smallest on the other: every \(c\) strictly between them gives a strictly separating line, and checking the corners is enough.
Level Advanced undergraduate Prerequisites Convex sets and convex functions; the dot product (refreshed in Before you start) Time ~40 min

Related lessons: the dot product and the closest point on a line finds the closest point when \(C\) is a line through 0, where \(b - p\) is perpendicular to the whole line. Critical points finds optima where the gradient is zero; on a convex feasible set an optimum of a differentiable objective can also sit on the boundary. There, when the gradient is not zero, the line through the optimum perpendicular to the gradient has the whole set on one side, a supporting line like the one in stage 3. Lagrange multipliers treats optima on a constraint curve.

Further reading