Convexity and local minima
Quick answer
A convex function lies at or below the straight line between any two points on its graph (over a convex domain). Every local minimum of a convex function on a convex feasible set is global. Strict convexity gives at most one minimizer, if one exists. Nonconvex objectives can have multiple local minima, maxima and saddle points.
Check the chord inequality
For x², the midpoint of -2 and 4 is 1. Its function value is 1, while the mean of the endpoint values is (4+16)/2 = 10. Convexity requires this inequality for every pair and every mixing coefficient t in [0,1], not just midpoints. For twice differentiable scalar functions on an interval, a nonnegative second derivative throughout the interval establishes convexity. In multiple dimensions the analogous Hessian condition is positive semidefiniteness. One negative second derivative at an interior point rules out convexity there.
for a,b in [(-2,4), (1,3), (2,2)]: middle = ((a+b)/2)**2 chord = (a*a+b*b)/2 print(middle, chord, middle <= chord)Expected output (local Python 3.13.5):
1.0 10.0 True4.0 5.0 True4.0 4.0 TrueThese checks illustrate the inequality; the algebraic difference (a-b)²/4 proves the midpoint case for all real a,b.
Stationary points need interpretation
Consider f(w)=(w²-1)². Its derivative is 4w(w²-1); its second derivative is 12w²-4. The stationary points are -1, 0 and 1. The second derivative is positive at ±1 (local minima) and negative at 0 (local maximum). Both minima are global because the objective is a square and equals zero there. For a nonconvex problem with unequal local minima, a local method may settle at a worse solution. A saddle point has directions of increase and decrease, for example f(x,y)=x²-y² at (0,0). A zero Hessian or derivative is not by itself decisive.
for w in [-1,0,1]: print(w, (w*w-1)**2, 4*w*(w*w-1), 12*w*w-4)Expected output (local Python 3.13.5):
-1 0 0 80 1 0 -41 0 0 8The gradient is zero at all three points, but their curvature differs.
Common mistakes
Do not infer global optimality from a small gradient in a nonconvex objective. A positive Hessian at one point does not prove global convexity. A flat direction can produce multiple minimizers even for a convex function. A finite set of chord checks can disprove convexity but cannot generally establish it.
Practice and next steps
For f(w)=-w², evaluate the chord inequality at -1 and 1. Explain what happens if descent starts exactly at the stationary point w=0 for (w²-1)². Next, examine numerical errors that can obscure optimization behavior.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Convexity and local minima — knowledge check
Apply optimization reasoning to synthetic examples.
What does convexity imply about a local minimum on a convex feasible set?
At w=0 for (w²-1)², what is the stationary point?
What is the chord gap for x² between -1 and 1 at t=.5?
Can three successful chord tests prove arbitrary global convexity?
Why is a tiny gradient insufficient for nonconvex global optimality?