Convex cones
Drop the "add up to one" rule and keep "never negative" — the shape behind colour mixing and most of optimization.
- Define a convex cone and tell it apart from a convex hull
- Recognise the non-negative orthant, the second-order cone and the PSD cone
- Spot when code generates a hull instead of a cone
A convex cone is what you get from non-negative combinations with no requirement that the weights sum to one:
\[\theta_1 \mathbf{x}_1 + \theta_2 \mathbf{x}_2 + \cdots, \qquad \theta_i \ge 0\]Scaling any point in the cone by a non-negative number keeps it in the cone, so a cone always contains the origin and stretches out to infinity along rays.
Colour mixing
Mixing light is the natural example. With red, green and blue as base colours, any non-negative amounts of each give a colour — dim or bright, any hue. That set is a convex cone: the whole positive corner (octant) of RGB space.
The script builds the cloud like this:
weights = np.random.rand(num_points, len(base_colors))
weights = weights / np.sum(weights, axis=1)[:, np.newaxis] # rows now sum to 1
points = np.dot(weights, base_colors)
Look closely at the second line. Normalising every row to sum to one turns these into convex combinations, so every point lands on the flat triangle \(r + g + b = 1\) — the convex hull of the three base colours, not the cone. Remove that normalisation, or multiply each point by a random intensity, and the cloud fills the cone.
The difference is not pedantic. A hull is bounded; a cone is not. Optimization problems are written over cones precisely because scaling is free.
The cones that matter
Three cones carry most of convex optimization, each with its own problem family:
| Cone | Points | Problems it gives |
|---|---|---|
| non-negative orthant | vectors with every entry \(\ge 0\) | linear and quadratic programs |
| second-order cone | \((\mathbf{x}, t)\) with \(|\mathbf{x}|_2 \le t\) | SOCPs — next-but-one lesson |
| positive semidefinite cone | symmetric matrices with eigenvalues \(\ge 0\) | SDPs |
Each lesson that follows is really about one of these cones.
Non-convex regions
The same script ends with the opposite case: a square with circular holes. Two allowed points can have every straight path between them blocked, so the region is not convex — and a solver that relies on convexity can no longer guarantee anything.
Try it yourself. Edit create_color_cone so it produces a genuine cone: keep np.random.rand but drop the normalisation, or scale each normalised row by np.random.uniform(0, 1.5). Re-plot and confirm the points leave the triangle. Then show that the set of 2×2 symmetric matrices with non-negative eigenvalues is a cone: if \(X\) has non-negative eigenvalues, why must \(3X\)?