Convex Sets
A set is convex if for any two points , the entire line segment connecting them stays inside .
The line segment from to consists of all points for . Convexity says: if both endpoints are in , every intermediate point is too.
Examples: all of (obviously convex), any halfspace , balls, cubes, and any intersection of convex sets. Non-examples: a donut (you can draw a chord that exits the hole), an L-shape, a star.
Intersections of convex sets are convex — a key fact that lets us build complex feasible regions for optimization from simple halfspace constraints.
Formal View
Interactive Visualization
Convex Set Visualizer
Why This Matters
Convex domains appear everywhere in optimization: linear programs live on polytopes, semidefinite programs live on the cone of PSD matrices, and ball constraints regularize machine learning models.
- Linear programming feasible regions are polytopes (intersections of halfspaces)
- Semidefinite programming feasible regions are PSD matrix cones — convex
- regularization: feasible region is a ball (convex)
- Support vector machine margins: convex feasible region
Quiz
Which of these sets is NOT convex?
The intersection of two convex sets is always convex.
A polytope in is the intersection of:
The set of symmetric PSD matrices is a convex set.
Common Mistakes
- Confusing "connected" with "convex" — a set can be connected (one piece) without being convex (e.g., a donut).
- Assuming the union of convex sets is convex — unions are generally not convex, only intersections are.