SECTION 05 / 7

Detour E — Convex functions (detailed)

2 min read
On this page 4 headings
Figure 18. Convex versus concave functions.
Figure 18. Convex versus concave functions.
Open image ↗
Illustration: Detour E — Convex functions (detailed)

A function f defined on a convex domain is convex when its graph never rises above the straight chord joining two points of its graph. Formally, for any a,b in the domain and 0≤λ≤10\leq\lambda\leq1:

Figure 17. Convex function and chord.
Figure 17. Convex function and chord.
Open image ↗
Illustration: Detour E — Convex functions (detailed)
f(λa+(1−λ)b)≤λf(a)+(1−λ)f(b)\begin{aligned}&f\bigl(\lambda a+(1-\lambda)b\bigr)\\&\leq\lambda f(a)\\&+(1-\lambda)f(b)\end{aligned}

The left side is the function evaluated at the weighted-average input. The right side is the weighted average of the two function values. The direction ≤\leq is essential. A differentiable function with f′′(x)≥0f''(x)\geq0 throughout an interval is convex there, when the second derivative exists.

Figure 19. The convexity inequality.
Figure 19. The convexity inequality.
Open image ↗
Illustration: Detour E — Convex functions (detailed)

Verify convexity for f(x)=x2f(x)=x^2

  1. Choose a=−2a = -2, b=2b = 2 and λ=12\lambda = \frac{1}{2}. The weighted-average input is 0.

  2. Left side:

    f(0)=0f(0) = 0

    Right side:

    0.5f(−2)+0.5f(2)=40.5 f(-2) + 0.5 f(2) = 4

    Thus 0≤40 \leq 4.

  3. This checks one example, not the entire definition. For a full proof, note

    λa2+(1−λ)b2−(λa+(1−λ)b)2=λ(1−λ)(a−b)2≥0\begin{aligned}&\lambda a^2+(1-\lambda)b^2\\&\quad-(\lambda a+(1-\lambda)b)^2\\&=\lambda(1-\lambda)(a-b)^2\\&\geq0\end{aligned}

A counterexample to convexity is

f(x)=−x2f(x)=-x^2

At a=−1a=-1, b=1b=1 and λ=12\lambda =\frac{1}{2}, the convexity inequality would require 0≤−10\leq -1, which is false. The earlier coordinate-incorrect Image 18 is intentionally omitted.

Checking the inequality numerically

Let

f(x)=x2f(x)=x^2

a=1a = 1, b=3b = 3 and λ=14\lambda = \frac{1}{4}. The weighted input is (14)⋅1+(34)⋅3=2.5(\frac{1}{4})\cdot 1 + (\frac{3}{4})\cdot 3 = 2.5. The left side is

f(2.5)=6.25f(2.5) = 6.25

The right side is

(14)f(1)+(34)f(3)=0.25+6.75=7\begin{aligned}&(\frac{1}{4})f(1)\\&+ (\frac{3}{4})f(3)\\&= 0.25\\&+ 6.75\\&= 7\end{aligned}

Thus 6.25≤76.25 \leq 7, as required.

Why one example is not a proof

A single successful substitution only checks the inequality at the chosen a, b and λ\lambda . Convexity requires the inequality for every allowed a, b and λ\lambda . The algebraic identity above proves this universally for

f(x)=x2f(x)=x^2

A nonconvex example

For

f(x)=−x2f(x)=-x^2

take a=−1a=-1, b=1b=1, λ=12\lambda =\frac{1}{2}. The left side is

f(0)=0f(0)=0

but the right side is

f(−1)+f(1)2=−1\frac{f(-1)+f(1)}{2}=-1

Since 0≤−10 \leq -1 is false, f is not convex on R\mathbb{R}. This is a valid counterexample: to disprove a universal claim, one failure is enough.

YOUR STUDY PROGRESS

Finished this section? Save your progress.

Back to top ↑