# Convex Functions

## Definition of Convexity of a Function

Consider a function y = f (x), which is assumed to be continuous on the interval [a, b]. The function y = f (x) is called convex downward (or concave upward) if for any two points x1 and x2 in [a, b], the following inequality holds:

$f\left( {\frac{{{x_1} + {x_2}}}{2}} \right) \le \frac{{f\left( {{x_1}} \right) + f\left( {{x_2}} \right)}}{2}.$

If this inequality is strict for any x1, x2 [a, b], such that x1x2, then the function f (x) is called strictly convex downward on the interval [a, b].

Similarly, we define a concave function. A function f (x) is called convex upward (or concave downward) if for any two points x1 and x2 in the interval [a, b], the following inequality is valid:

$f\left( {\frac{{{x_1} + {x_2}}}{2}} \right) \ge \frac{{f\left( {{x_1}} \right) + f\left( {{x_2}} \right)}}{2}.$

If this inequality is strict for any x1, x2 [a, b], such that x1x2, then the function f (x) is called strictly convex upward on the interval [a, b].

## Geometric Interpretation of Convexity

The introduced concept of convexity has a simple geometric interpretation.

If a function is convex downward (Figure $$1$$), the midpoint $$B$$ of each chord $${A_1}{A_2}$$ lies above the corresponding point $${A_0}$$ of the graph of the function or coincides with this point.

Similarly, if a function is convex upward (Figure $$2$$), the midpoint $$B$$ of each chord $${A_1}{A_2}$$ is located below the corresponding point $${A_0}$$ of the graph of the function or coincides with this point.

Convex functions have another obvious property, which is related to the location of the tangent to the graph of the function. The function $$f\left( x \right)$$ is convex downward on the interval $$\left[ {a,b} \right]$$ if and only if its graph does not lie below the tangent drawn to it at any point $${x_0}$$ of the segment $$\left[ {a,b} \right]$$ (Figure $$3$$).

Accordingly, the function $$f\left( x \right)$$ is convex upward (or concave downward) on the interval $$\left[ {a,b} \right]$$ if and only if its graph does not lie above the tangent drawn to it at any point $${x_0}$$ of the segment $$\left[ {a,b} \right]$$ (Figure $$4$$). These properties represent a theorem and can be proved using the definition of convexity.

## Sufficient Conditions for Convexity/Concavity (Convexity/Concavity Test)

Suppose that the first derivative $$f'\left( x \right)$$ of a function $$f\left( x \right)$$ exists in a closed interval $$\left[ {a,b} \right],$$ and the second derivative $$f^{\prime\prime}\left( x \right)$$ exists in an open interval $$\left( {a,b} \right).$$ Then the following sufficient conditions for convexity/concavity are valid:

• If $$f^{\prime\prime}\left( x \right) \ge 0$$ for all $$x \in \left( {a,b} \right),$$ then the function $$f\left( x \right)$$ is convex downward (or concave upward) on the interval $$\left[ {a,b} \right];$$
• If $$f^{\prime\prime}\left( x \right) \le 0$$ for all $$x \in \left( {a,b} \right),$$ then the function $$f\left( x \right)$$ is convex upward (or concave downward) on the interval $$\left[ {a,b} \right].$$

In the cases where the second derivative is strictly greater (or less) than zero, we say, respectively, about the strict convexity downward (or strict convexity upward).

We prove the theorem for the case of convexity downward. Let the function $$f\left( x \right)$$ have a non-negative second derivative on the interval $$\left( {a,b} \right):$$ $$f^{\prime\prime}\left( x \right) \ge 0.$$ Let $${x_0}$$ be the midpoint of the interval $$\left[ {{x_1},{x_2}} \right].$$ Suppose that the length of this interval is equal to $$2h.$$ Then the coordinates $${x_1}$$ and $${x_2}$$ can be written as

${x_1} = {x_0} - h,\;\;{x_2} = {x_0} + h.$

Expand the function $$f\left( x \right)$$ at $${x_0}$$ in the Taylor series with the remainder in the Lagrange form. We obtain the following expressions:

$f\left( {{x_1}} \right) = f\left( {{x_0} - h} \right) = f\left( {{x_0}} \right) - f'\left( {{x_0}} \right)h + \frac{{f^{\prime\prime}\left( {{\xi _1}} \right){h^2}}}{{2!}},$
$f\left( {{x_2}} \right) = f\left( {{x_0} + h} \right) = f\left( {{x_0}} \right) + f'\left( {{x_0}} \right)h + \frac{{f^{\prime\prime}\left( {{\xi _2}} \right){h^2}}}{{2!}},$

where $${x_0} - h \lt {\xi _1} \lt {x_0},$$ $${x_0} \lt {\xi _2} \lt {x_0} + h.$$

$f\left( {{x_1}} \right) + f\left( {{x_2}} \right) = 2f\left( {{x_0}} \right) + \frac{{{h^2}}}{2}\left[ {f^{\prime\prime}\left( {{\xi _1}} \right) + f^{\prime\prime}\left( {{\xi _2}} \right)} \right].$

Since $${\xi _1},{\xi _2} \in \left( {a,b} \right),$$ then the second derivatives in the right-hand side are non-negative. Consequently,

$f\left( {{x_1}} \right) + f\left( {{x_2}} \right) \ge 2f\left( {{x_0}} \right)$

or

$f\left( {\frac{{{x_1} + {x_2}}}{2}} \right) \le \frac{{f\left( {{x_1}} \right) + f\left( {{x_2}} \right)}}{2},$

that is according to the definition, the function $$f\left( x \right)$$ is convex downward.

Note that the necessary condition for convexity (for example, the implication when from the convexity downwards it follows that $$f^{\prime\prime}\left( x \right) \ge 0$$) holds only for the non-strict inequality. In the case of strict convexity, the necessary condition is generally not valid. For example, the function $$f\left( x \right) = {x^4}$$ is strictly convex downward. However, its second derivative is zero at $$x = 0$$, that is the strict inequality $$f^{\prime\prime}\left( x \right) \gt 0$$ does not hold in this case.

## Properties of Convex Functions

We list some properties of convex functions assuming that all functions are defined and continuous on the interval $$\left[ {a,b} \right].$$

1. If the functions $$f$$ and $$g$$ are convex downward (upward), then any linear combination $$af + bg$$ where $$a$$, $$b$$ are positive real numbers is also convex downward (upward).
2. If the function $$u = g\left( x \right)$$ is convex downward, and the function $$y = f\left( u \right)$$ is convex downward and non-decreasing, then the composite function $$y = f\left( {g\left( x \right)} \right)$$ is also convex downward.
3. If the function $$u = g\left( x \right)$$ is convex upward, and the function $$y = f\left( u \right)$$ is convex downward and non-increasing, then the composite function $$y = f\left( {g\left( x \right)} \right)$$ is convex downward.
4. Any local maximum of a convex upward function defined on the interval $$\left[ {a,b} \right]$$ is also its global maximum on this interval.
5. Any local minimum of a convex downward function defined on the interval $$\left[ {a,b} \right]$$ is also its global minimum on this interval.

## Solved Problems

Click or tap a problem to see the solution.

### Example 1

Sketch schematically the graphs of the functions for all possible combinations of $$y$$, $$y'$$, $$y^{\prime\prime}$$ where each of these values is positive or negative.

### Example 2

Find the values of $$x,$$ at which the cubic function $f\left( x \right) = {x^3} + a{x^2} + bx + c$ is convex downward.

### Example 3

Find the intervals of convexity and concavity of the function $f\left( x \right) = - {x^3} + 6{x^2} - 2x + 1.$

### Example 4

Find the intervals of convexity and concavity of the function $f\left( x \right) = 2{x^3} - 18{x^2}.$

### Example 5

Find the intervals on which the function $f\left( x \right) = {x^3} + ax + b$ (where $$a, b$$ are any real numbers) is convex upward.

### Example 6

Find the intervals of convexity and concavity of the function $f\left( x \right) = \sqrt {2 + {x^2}} .$

### Example 1.

Sketch schematically the graphs of the functions for all possible combinations of $$y$$, $$y'$$, $$y^{\prime\prime}$$ where each of these values is positive or negative.

Solution.

Consider an arbitrary combination of these values, such as the following:

$y \gt 0,\;\;y' \lt 0,\;\;y^{\prime\prime} \gt 0.$

The graph of such a function is located in the upper half-plane, and the function is strictly decreasing (since $$y' \lt 0$$). Given that $$y^{\prime\prime} \gt 0,$$ the function is convex downward. Its schematic view is shown in Figure $$5$$ in the first column and second row.

It is clear that the total number of possible combinations of the three variables with different signs is $$8.$$ The corresponding sketches of the graphs of the functions are shown in Figure $$5.$$

### Example 2.

Find the values of $$x,$$ at which the cubic function $f\left( x \right) = {x^3} + a{x^2} + bx + c$ is convex downward.

Solution.

We compute the second derivative of the given function:

$f'\left( x \right) = {\left( {{x^3} + a{x^2} + bx + c} \right)^\prime } = 3{x^2} + 2ax + b;$
$f^{\prime\prime}\left( x \right) = \left( {3{x^2} + 2ax + b} \right)^\prime = 6x + 2a.$

The function is convex upward if $$f^{\prime\prime}\left( x \right) \le 0.$$ Find the corresponding values of $$x:$$

$f^{\prime\prime}\left( x \right) \le 0,\;\; \Rightarrow 6x + 2a \le 0,\;\; \Rightarrow 6x \le - 2a,\;\; \Rightarrow x \le - \frac{a}{3}.$

As you can see, only the point $$x = \sqrt 2$$ falls in the interval $$\left[ {0.5,2} \right].$$ Calculate the values of the function at the extremum point $$x = \sqrt 2$$ and at the boundary points of the interval:

$f\left( {\sqrt 2 } \right) = \sqrt 2 + \frac{2}{{\sqrt 2 }} = 2\sqrt 2 \approx 2.83;\;\;f\left( {0.5} \right) = 0.5 + \frac{2}{{0.5}} = 4.5;\;\;f\left( 2 \right) = 2 + \frac{2}{2} = 3.$

So the maximum value of the function in this interval is equal to $$4.5$$ at the point $$x = 0.5,$$ and the minimum value is $$2.83$$ at $$x = \sqrt 2.$$

### Example 3.

Find the intervals of convexity and concavity of the function $f\left( x \right) = - {x^3} + 6{x^2} - 2x + 1.$

Solution.

Compute the derivatives:

$f^\prime\left( x \right) = \left( { - {x^3} + 6{x^2} - 2x + 1} \right)^\prime = - 3{x^2} + 12x - 2;$
$f^{\prime\prime}\left( x \right) = \left( { - 3{x^2} + 12x - 2} \right)^\prime = - 6x + 12.$

The second derivative is equal to zero at the following point:

$f^{\prime\prime}\left( x \right) = 0,\;\; \Rightarrow - 6x + 12 = 0,\;\; \Rightarrow x = 2.$

The second derivative is positive to the left of this point and negative to the right. Hence, the function is convex downward on $$\left( { -\infty, 2} \right)$$ and convex upward on $$\left( {2, +\infty} \right).$$

### Example 4.

Find the intervals of convexity and concavity of the function $f\left( x \right) = 2{x^3} - 18{x^2}.$

Solution.

Differentiating this function, we have

$f^\prime\left( x \right) = \left( {2{x^3} - 18{x^2}} \right)^\prime = 6{x^2} - 36x;$
$f^{\prime\prime}\left( x \right) = \left( {6{x^2} - 26x} \right)^\prime = 12x - 36.$

We set $$f^{\prime\prime}\left( x \right)$$ equal to zero and solve the equation:

$f^{\prime\prime}\left( x \right) = 0,\;\; \Rightarrow 12x - 36 = 0,\;\; \Rightarrow x = 3.$

The second derivative is negative if $$x \lt 3$$ and positive if $$x \gt 3.$$ Hence, the function is convex downward on the interval $$\left( {3, +\infty} \right)$$ and convex upward on $$\left( {-\infty, 3} \right).$$

### Example 5.

Find the intervals on which the function $f\left( x \right) = {x^3} + ax + b$ (where $$a, b$$ are any real numbers) is convex upward.

Solution.

Take the derivatives:

$f^\prime\left( x \right) = \left( {{x^3} + ax + b} \right)^\prime = 3{x^2} + a;$
$f^{\prime\prime}\left( x \right) = \left( {3{x^2} + a} \right)^\prime = 6x.$

We see that $$f^{\prime\prime}\left( x \right) \lt 0$$ at $$x \lt 0.$$ Hence, the function is convex upward on $$\left( { -\infty, 0} \right).$$

### Example 6.

Find the intervals of convexity and concavity of the function $f\left( x \right) = \sqrt {2 + {x^2}} .$

Solution.

This function is defined and differentiable for all $$x \in \mathbb{R}.$$ Calculate the second derivative:

$f'\left( x \right) = \left( {\sqrt {2 + {x^2}} } \right)^\prime = \frac{1}{{2\sqrt {2 + {x^2}} }} \cdot {\left( {2 + {x^2}} \right)^\prime } = \frac{{\cancel{2}x}}{{\cancel{2}\sqrt {2 + {x^2}} }} = \frac{x}{{\sqrt {2 + {x^2}} }};$
$f^{\prime\prime}\left( x \right) = \left( {\frac{x}{{\sqrt {2 + {x^2}} }}} \right)^\prime = \frac{{x'\sqrt {2 + {x^2}} - x{{\left( {\sqrt {2 + {x^2}} } \right)}^\prime }}}{{{{\left( {\sqrt {2 + {x^2}} } \right)}^2}}} = \frac{{\sqrt {2 + {x^2}} - x \cdot \frac{x}{{\sqrt {2 + {x^2}} }}}}{{2 + {x^2}}} = \frac{{{{\left( {\sqrt {2 + {x^2}} } \right)}^2} - {x^2}}}{{\left( {2 + {x^2}} \right)\sqrt {2 + {x^2}} }} = \frac{{2 + \cancel{x^2} - \cancel{x^2}}}{{\sqrt {{{\left( {2 + {x^2}} \right)}^3}} }} = \frac{2}{{\sqrt {{{\left( {2 + {x^2}} \right)}^3}} }}.$

It can be seen that the second derivative is always positive. Therefore, the function is convex downward for all values of $$x.$$

See more problems on Page 2.