Convexity describes a geometric and analytic property of sets and functions. For a convex set, the straight line joining any two points remains entirely inside the set. For a convex function, weighted averages of function values are at least as large as the function evaluated at the corresponding weighted-average input. section 3.7 section 3.7.1 section 3.7.2
Figure 3.15 Convex and nonconvex sets. The points in the left-hand shaded region form a convex set.The line joining any pair of points in that shaded region lies entirely in the shaded region: for example, AB.The points in the right-hand shaded region form a nonconvex set. For instance, the line joining points C and D passes through a nonshaded region even though both end points belong to a shaded region.
Compare convex and nonconvex regions by testing whether every line segment between two points stays inside the region. section 3.7.1
Geometrically, a convex curve lies below every secant line joining two points on it. Equivalently, the weighted-average point on the secant lies above the curve at the same horizontal coordinate. A related tangent characterization says that the entire convex curve lies above each tangent line, touching it at the point of tangency. section 3.7.2 section 3.7.2
For a twice-differentiable one-dimensional function, convexity can be checked through its second derivative:
- If the second derivative is always positive, the curve bends so that it lies above its tangent locally. section 3.7.3
- The first-order Taylor approximation is the tangent line; adding the second-order term produces a quadratic approximation that is at least as large when the second derivative is positive. section 3.7.3
- The criterion connects local curvature with the tangent-line and weighted-average definitions of convexity. section 3.7.2 section 3.7.3
Common convex functions
The function g(x) = x² is convex because its second derivative is 2. More generally, even powers such as x⁴ and x⁶ are convex, as is eˣ. Since log x is concave, −log x is convex. Multiplying a convex function by a positive scalar preserves convexity, and sums of convex functions remain convex. section 3.7.4

