Tutorials › Real Analysis › Convex Functions

Differentiation · Tutorial 435 of 1000

Convex Functions

Learn to test convexity using chords and secant slopes, and see why convex functions have strong continuity and closure properties.

Advanced 10 min read

What You'll Learn

  • Define convex, strictly convex, and concave functions on intervals
  • Interpret convexity as a graph lying below its chords
  • Prove the three-point inequality for secant slopes
  • Verify convexity for quadratic, absolute-value, reciprocal, and maximum functions
  • Establish interior continuity of every finite convex function
  • Use sums, positive scaling, and pointwise maxima to build convex functions

Convexity as a Chord Condition

A function can bend upward without being differentiable. Convexity captures this shape using only function values: between any two points of the graph, the graph lies on or below the straight chord joining them. This viewpoint will let us study a broad class of functions before using derivatives to test convexity in the next tutorial.

Definition: Let \(I\) be an interval in \(\mathbb{R}\). A function \(f:I\to\mathbb{R}\) is convex if, for every \(x,y\in I\) and every \(\lambda\in[0,1]\), $$ f((1-\lambda)x+\lambda y)\leq (1-\lambda)f(x)+\lambda f(y). $$ It is strictly convex if this inequality is strict whenever \(x\ne y\) and \(0<\lambda<1\). The function is concave if the inequality is reversed.

Because \(I\) is an interval, \((1-\lambda)x+\lambda y\) belongs to \(I\), so the left side is always defined. The right side is the value at that same horizontal position of the line segment joining \((x,f(x))\) and \((y,f(y))\). Thus the inequality says exactly that the graph stays below each of its chords. A function is concave precisely when its negative is convex.

Three-Point Comparisons of Secant Slopes

The chord condition also constrains the slopes of secant lines. For \(u<v\) in the domain, write the secant slope as \(s_f(u,v)=(f(v)-f(u))/(v-u)\). When three points are ordered, convexity forces the slope over the left interval not to exceed the slope over the right interval.

Theorem (Three-Point Secant-Slope Inequality): Suppose \(f\) is convex on an interval \(I\), and \(x<y<z\) are points of \(I\). Then $$ \frac{f(y)-f(x)}{y-x} \leq \frac{f(z)-f(x)}{z-x} \leq \frac{f(z)-f(y)}{z-y}. $$

Proof. Set \(\lambda=(y-x)/(z-x)\). Since \(x<y<z\), we have \(0<\lambda<1\), and \(y=(1-\lambda)x+\lambda z\). Convexity gives

$$ f(y)\leq (1-\lambda)f(x)+\lambda f(z) =\frac{z-y}{z-x}f(x)+\frac{y-x}{z-x}f(z). $$

Subtract \(f(x)\) from both sides. Since \(y-x>0\), division by \(y-x\) preserves the inequality and gives

$$ \frac{f(y)-f(x)}{y-x} \leq \frac{f(z)-f(x)}{z-x}. $$

Instead, subtract the displayed convexity inequality from \(f(z)\). Since \(z-y>0\), division by \(z-y\) gives

$$ \frac{f(z)-f(x)}{z-x} \leq \frac{f(z)-f(y)}{z-y}. $$

Together these are the claimed inequalities. \(\square\)

The middle slope is the slope across the whole interval from \(x\) to \(z\); it is a weighted average of the two adjacent slopes. The theorem says that this average lies between them. This slope ordering is often useful even when a graph is difficult to sketch.

Worked Example: A Strictly Convex Quadratic

Let \(f(x)=x^2\) on \(\mathbb{R}\). For \(x,y\in\mathbb{R}\) and \(0\leq\lambda\leq1\), expand both sides of the convexity inequality. Their difference is

$$ (1-\lambda)x^2+\lambda y^2-\big((1-\lambda)x+\lambda y\big)^2 =\lambda(1-\lambda)(x-y)^2. $$

The right side is nonnegative, so \(f((1-\lambda)x+\lambda y)\leq(1-\lambda)f(x)+\lambda f(y)\). If \(x\ne y\) and \(0<\lambda<1\), then each factor on the right is positive, and the difference is strictly positive. Thus \(x^2\) is strictly convex. For example, at \(x=1\), \(y=3\), and \(\lambda=1/4\), the interpolated point is \(3/2\), and the inequality reads

$$ \left(\frac{3}{2}\right)^2=\frac94 < \frac34(1)^2+\frac14(3)^2=3. $$

Examples Without Derivatives

The definition can be applied directly, so differentiability is not required. The absolute-value function and the reciprocal function on the positive half-line provide two useful examples.

Worked Example: The Absolute-Value Function

Define \(f(x)=|x|\) on \(\mathbb{R}\). The triangle inequality gives

$$ |(1-\lambda)x+\lambda y| \leq |(1-\lambda)x|+|\lambda y| =(1-\lambda)|x|+\lambda|y|, $$

because \(1-\lambda\) and \(\lambda\) are nonnegative. This is the convexity inequality, so \(|x|\) is convex. It is not strictly convex: for example, if \(x=1\), \(y=2\), and \(\lambda=1/2\), both sides equal \(3/2\). This example also shows why convexity does not require a smooth graph; \(|x|\) has a corner at zero.

Worked Example: The Reciprocal on the Positive Half-Line

Let \(f(x)=1/x\) for \(x>0\). Take \(x,y>0\) and \(0\leq\lambda\leq1\). The difference between the proposed chord value and the function value at the interpolated point is

$$ \frac{1-\lambda}{x}+\frac{\lambda}{y} -\frac{1}{(1-\lambda)x+\lambda y} = \frac{\lambda(1-\lambda)(x-y)^2} {xy\big((1-\lambda)x+\lambda y\big)}. $$

The identity follows by putting the three terms over the common denominator \(xy((1-\lambda)x+\lambda y)\) and expanding the numerator. That denominator is positive, and the numerator is nonnegative. Therefore \(1/x\) is convex on \((0,\infty)\); it is strictly convex when \(x\ne y\) and \(0<\lambda<1\). For instance, with \(x=1\), \(y=3\), and \(\lambda=1/2\), the midpoint value is \(1/2\), while the average endpoint value is \(2/3\), so \(1/2\leq2/3\).

Building New Convex Functions

Several basic operations preserve convexity. These rules let us recognize new examples from old ones and explain why a pointwise maximum of affine functions is convex.

Theorem (Basic Closure Properties): Let \(I\) be an interval, and let \(f,g:I\to\mathbb{R}\) be convex. Then \(f+g\) is convex. If \(c\geq0\), then \(cf\) is convex. If \(f_1,\ldots,f_n\) are convex on \(I\), their pointwise maximum \(F(x)=\max_{1\leq j\leq n}f_j(x)\) is convex on \(I\).

Proof. Take \(x,y\in I\) and \(\lambda\in[0,1]\). Applying convexity separately to \(f\) and \(g\) gives

$$ (f+g)((1-\lambda)x+\lambda y) \leq (1-\lambda)f(x)+\lambda f(y) +(1-\lambda)g(x)+\lambda g(y), $$

which equals \((1-\lambda)(f+g)(x)+\lambda(f+g)(y)\). Thus \(f+g\) is convex. Multiplying the convexity inequality for \(f\) by \(c\geq0\) proves the claim for \(cf\), including \(c=0\).

For the maximum, each \(j\) satisfies

$$ f_j((1-\lambda)x+\lambda y) \leq (1-\lambda)f_j(x)+\lambda f_j(y) \leq (1-\lambda)F(x)+\lambda F(y). $$

Taking the maximum over the finitely many indices \(j\) on the left proves \(F((1-\lambda)x+\lambda y)\leq(1-\lambda)F(x)+\lambda F(y)\). Hence \(F\) is convex. \(\square\)

Worked Example: The Positive-Part Function

Define \(h(x)=\max\{0,x\}\) on \(\mathbb{R}\). The constant function \(0\) and the identity function \(x\mapsto x\) are affine, and affine functions satisfy the convexity inequality with equality. The closure theorem therefore shows that their pointwise maximum \(h\) is convex. Directly, \(h(-2)=0\) and \(h(2)=2\); at their midpoint, \(h(0)=0\leq1=(h(-2)+h(2))/2\). The function has a corner at zero, yet the chord condition still applies.

The closure theorem concerns sums with nonnegative coefficients and maxima, not arbitrary combinations. For example, products of convex functions need not be convex: on \(\mathbb{R}\), both \(f(x)=x\) and \(g(x)=-x\) are affine and hence convex, but their product \(-x^2\) is not convex. Checking the operation matters as much as checking the component functions.

Convex Functions Are Continuous in the Interior

Continuity was not part of the definition, but convexity forces it at every interior point of the domain. The three-point slope inequality gives a proof using only bounds from fixed points on either side.

Theorem (Interior Continuity of a Convex Function): If \(f:I\to\mathbb{R}\) is convex on an interval \(I\), then \(f\) is continuous at every interior point of \(I\).

Proof. Fix an interior point \(c\in I\). Choose \(u,v\in I\) with \(u<c<v\), and define the finite numbers \(m_L=(f(c)-f(u))/(c-u)\) and \(m_R=(f(v)-f(c))/(v-c)\). For \(c<x<v\), the three-point inequality applied to \(u<c<x\) gives \(m_L\leq(f(x)-f(c))/(x-c)\). Convexity applied to the endpoints \(c,v\) gives \(f(x)\leq f(c)+(x-c)m_R\). Consequently,

$$ f(c)+(x-c)m_L\leq f(x)\leq f(c)+(x-c)m_R \qquad(c<x<v). $$

For \(u<x<c\), the three-point inequality applied to \(x<c<v\) gives \((f(c)-f(x))/(c-x)\leq m_R\), or \(f(x)\geq f(c)+(x-c)m_R\). Convexity on the segment from \(u\) to \(c\) gives \(f(x)\leq f(c)+(x-c)m_L\). Thus

$$ f(c)+(x-c)m_R\leq f(x)\leq f(c)+(x-c)m_L \qquad(u<x<c). $$

On either side, the two bounding linear expressions tend to \(f(c)\) as \(x\to c\). More explicitly, let \(M=\max\{|m_L|,|m_R|\}\). The displayed bounds imply \(|f(x)-f(c)|\leq M|x-c|\) whenever \(u<x<v\). If \(M=0\), this difference is zero throughout that neighborhood. If \(M>0\), then for every \(\varepsilon>0\), choosing \(|x-c|<\varepsilon/M\) gives \(|f(x)-f(c)|<\varepsilon\). Therefore \(f\) is continuous at \(c\), as required. \(\square\)

The conclusion is specifically about interior points. At an endpoint of an interval, there may be no domain points on one side to control the function by chords in both directions. Convexity alone should not be confused with a claim of continuity at every included endpoint.

How to Use the Chord Definition

The definition is global: it compares every pair of points in the domain and every interpolation parameter. The secant-slope inequality and closure rules offer efficient ways to work with it, while the continuity theorem supplies a consequence that was not assumed. Keep the following distinctions in mind:

  • Convexity is not strict convexity. Equality may hold for distinct endpoints, as it does for \(|x|\) on the positive half-line.
  • Concavity reverses the inequality. Equivalently, \(f\) is concave exactly when \(-f\) is convex.
  • Convexity does not mean differentiability. The absolute-value and positive-part examples are convex despite their corners.
  • Midpoint checks alone need care. Testing only \(\lambda=1/2\) is not the definition; additional hypotheses are needed to infer the full chord inequality from midpoint inequalities.

In the next tutorial, derivatives will provide a practical criterion for convexity when differentiability is available. The chord and slope formulations developed here remain useful even when derivatives do not exist.

Check Your Understanding

Use the definitions and results in this tutorial to answer the following questions.

  1. State the chord inequality that defines a convex function on an interval.
  2. For \(x<y<z\), which adjacent secant slope is smaller for a convex function?
  3. Why does the absolute-value function satisfy the convexity inequality?
  4. Which condition on a scalar \(c\) ensures that multiplying a convex function by \(c\) preserves convexity?
  5. Why does the continuity theorem apply at interior points but not automatically at included endpoints?