What is a convex function?
An important concept in calculus, optimization, applied mathematics, probability, and statistics
What exactly is a convex function? In this post1, I will define it and share a few examples.
A convex function is a type of mathematical function with a specific property related to its shape. Take any 2 points on the graph of the function, and connect the line segment between them. If this line is above or on the graph, then the function is convex. This graph often has the shape of a bowl or the letter "U", but there are exceptions, and I will mention one below.
Here is the rigorous definition of convexity: Consider
a real-valued function f(x),
any two points, b and c, within a convex set2 in the domain of f(x),
a constant λ such that 0 ≤ λ ≤ 1.
The function f(x) is convex if
Below are some common examples of convex functions.



The absolute-value function is convex because it forms a “V” shape, and the line segment between any two points on the graph lies above or on the graph. Strictly speaking, this function does not have a bowl or "U" shape, but it is still convex.
There are several important mathematical properties of convex functions:
One way to test for convexity is the second-derivative test. If f(x) is twice differentiable, then it is convex if and only if its second derivative f''(x) ≥ 0 for all values of x in the interval of interest.
One application of convex functions is Jensen’s inequality, an important concept in probability and statistics. It states that, for a convex function f(x) and any random variable X,
where E[X] is the expected value.
In a later post, I will elaborate on Jensen’s inequality and why it is useful in probability and statistics.
In future posts about statistics and probability, I will refer back to convex functions, so stay tuned!
A set of points is convex if it contains every line segment between two points in the set.