Why is the constraint $\|w\| = 1$ non-convex?

What makes a constraint convex is not the convexity (or otherwise) of the functions involved, but rather the convexity of the set of points that satisfy the constraint.

The set of points satisfying $\|w\|=1$ is the surface of a norm ball. For the Euclidean norm $\|w\|=\langle w, w\rangle^{1/2}$, it is the surface of an $n$-sphere. These points do not form a convex set. To see this, consider the line segment between any point in the set $w$ and its negative $-w$, also on the surface of the ball. The midpoint of this segment is the origin, which of course is not in the set. This contradicts a claim of convexity, which requires that the entire segment lie within the set. (In fact, when $n=1$, the set consists of just two points!)

The set $\|w\|\leq 1$, on the other hand, is the entire norm ball, including the interior. This is a convex set; so it is a convex constraint.

In practice, equality constraints involving nonlinear functions are almost never convex. The exceptions tend to be trivial to reduce to an equivalent set of linear equations.


Consider $x$ such that $\|x\| = 1$. Then you also have that $\|-x\| = 1$ but what about $\frac{1}{2}(x+(-x))$? This has norm $0$ and so $\frac{1}{2}(x+(-x))$ is not in the set, i.e. the unit sphere is not closed under convex combinations.