In mathematics, an object is **convex** if for any pair of points within the object, any point on the straight line segment that joins them is also within the object. For example, a solid cube is convex, but anything that is hollow or has a dent in it is not convex. The concepts of convexity and concavity are important in optics; see convex lens and concave lens. ## Convex set
Let *C* be a set in a real or complex vector space. *C* is said to be **convex** if, for all *x* and *y* in *C* and all *t* in the interval [0,1], the point - (1 −
*t*) *x* + *t y* is in *C*. In other words, every point on the line segment connecting *x* and *y* is in *C*. The convex subsets of **R** (the set of real numbers) are simply the intervals of **R**. Some examples of convex subsets of Euclidean 2-space are regular polygons and bodies of constant width. Some examples of convex subsets of Euclidean 3-space are the Archimedean solids and the Platonic solids. The Kepler-Poinsot solids are examples of non-convex sets.
### Properties of convex sets The intersection of any collection of convex sets is itself convex, so the convex subsets of a (real or complex) vector space form a complete lattice. This also means that any subset *A* of the vector space is contained within a smallest convex set (called the convex hull of *A*), namely the intersection of all convex sets containing *A*. Closed convex sets can be characterised as the intersections of *closed half-spaces* (sets of point in space that lie on and to one side of a hyperplane). From what has just been said, it is clear that such intersections are convex, and they will also be closed sets. To prove the converse, i.e., every convex set may be represented as such intersection, one needs the *supporting hyperplane theorem* in the form that for a given closed convex set *C* and point *P* outside it, there is a closed half-space *H* that contains *C* and not *P*. The supporting hyperplane theorem is a special case of the Hahn-Banach theorem of functional analysis.
## Convex function A real-valued function *f* defined on an interval (or on any convex subset *C* of some vector space) is called **convex** if for any two points *x* and *y* in its domain *C* and any *t* in [0,1], we have I.e., a function is convex if and only if its epigraph (the set of points lying on or above the graph) is a convex set. A function is also said to be **strictly convex** if *f*(*t**x* + (1 - *t*)*y*) < *t**f*(*x*) + (1 - *t*)*f*(*y*). for any *t* in (0,1).
### Properties of convex functions A convex function *f* defined on some convex open interval *C* is continuous on the whole *C* and differentiable at all but at most countably many points. If *C* is closed, then *f* may fail to be continuous at the border. A continuous function on *C* is convex if and only if for any *x* and *y* in *C*. A differentiable function of one variable is convex on an interval if and only if its derivative is monotonically non-decreasing on that interval. A continuously differentiable function of one variable is convex on an interval if and only if the function lies above all of its tangents: *f*(*y*) ≥ *f*(*x*) + *f'*(*x*) (*y* - *x*) for all *x* and *y* in the interval. A twice differentiable function of one variable is convex on an interval if and only if its second derivative is non-negative there; this gives a practical test for convexity. If its second derivative is positive then it is strictly convex, but the opposite is not true, as shown by *f*(*x*) = *x*^{4}. More generally, a continuous, twice differentiable function of multiple variables is convex on a convex set if and only if its Hessian matrix is positive semidefinite on the interior of the convex set. If two functions *f* and *g* are convex, then so is any weighted combination *a* *f* + *b* *g* with non-negative coefficients *a* and *b*. Any local minimum of a convex function is also a global minimum. A *strictly* convex function will have at most one global minimum. For a convex function *f*, the level sets {*x*|*f*(*x*)<*a*} and {*x*|*f*(*x*)≤*a*} with *a*∈**R** are convex sets. A convex function respects Jensen's inequality.
### Examples of convex functions - The second derivative of
*x*^{2} is 2; it follows that *x*^{2} is a convex function of *x*. - The absolute value function |
*x*| is convex, even though it does not have a derivative at *x* = 0. - The function
*f*(*x*) = *x* is convex but not strictly convex. - The function
*x*^{3} has second derivative 6*x*; thus it is convex for *x* ≥ 0 and concave for *x* ≤ 0. |