---
title: "Differentiation and Convexity"
book: "High School Mathematics"
subject: math
language: en
chapter: 22
exercises: 9
source: https://one-course.com/books/math/2/en/chapter/22-differentiation-and-convexity
---

# Chapter 22 — Differentiation and Convexity

The [derivative](#def-g12-deriv-derivative) measures the instantaneous rate of change of a [function](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function); it is the [slope](https://one-course.com/books/math/2/en/chapter/4-reference-functions#def-g10-reffunc-affine) of the [tangent](#def-g12-deriv-tangent) line to its [graph](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-graph). This chapter reviews and extends the differentiation rules, links the sign of $f'$ to the variations of $f$, and introduces [convexity](#def-g12-deriv-convex), which is governed by the second [derivative](#def-g12-deriv-derivative).

## 22.1 The derivative

**Definition 22.1 (Derivative at a point).**

Let $f$ be defined on an [interval](https://one-course.com/books/math/2/en/chapter/1-numbers-and-sets-of-numbers#def-g10-numbers-interval) $I$ and $a \in I$. The [function](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function) $f$ is *differentiable at $a$* if the difference quotient

$$
\frac{f(a+h) - f(a)}{h}
$$

has a finite limit as $h \to 0$. This limit is called the *derivative of $f$ at $a$* and written $f'(a)$. If $f$ is differentiable at every point of $I$, the [function](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function) $f' \colon x \mapsto f'(x)$ is the *derivative* of $f$.

**Definition 22.2 (Tangent line).**

If $f$ is [differentiable](#def-g12-deriv-derivative) at $a$, the *tangent* to the curve of $f$ at the point $(a, f(a))$ is the line of [equation](https://one-course.com/books/math/2/en/chapter/2-algebra-equations-and-inequalities#def-g10-algebra-equation)

$$
y = f(a) + f'(a)(x - a).
$$

![As h decreases, the secant line through A = (a, f(a)) and (a+h, f(a+h)) (orange) rotates towards the tangent at A (red): its slope f(a+h)-f(a)/h tends to f'(a).](https://one-course.com/images/onecourse/chapters/math-2/g12-deriv/fig-c4beb608d696.svg)

*As $h$ decreases, the [secant](https://one-course.com/books/math/2/en/chapter/12-differentiation-a-first-course#def-g11-deriv-rate) line through $A = (a, f(a))$ and $(a+h, f(a+h))$ (orange) rotates towards the [tangent](#def-g12-deriv-tangent) at $A$ (red): its [slope](https://one-course.com/books/math/2/en/chapter/4-reference-functions#def-g10-reffunc-affine) $\frac{f(a+h)-f(a)}{h}$ tends to $f'(a)$.*

**Proposition 22.3.**

A [function](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function) [differentiable](#def-g12-deriv-derivative) at $a$ is [continuous](https://one-course.com/books/math/2/en/chapter/21-limits-and-continuity#def-g12-limcont-continuity) at $a$. The converse is false.

**Proof.** For $h \neq 0$ small, $f(a+h) - f(a) = h \cdot \frac{f(a+h)-f(a)}{h}$. As $h \to 0$, the right side tends to $0 \times f'(a) = 0$, so $f(a+h) \to f(a)$. For the converse, $x \mapsto \abs{x}$ is [continuous](https://one-course.com/books/math/2/en/chapter/21-limits-and-continuity#def-g12-limcont-continuity) at $0$, but its difference quotient at $0$ equals $\frac{\abs h}{h} = \pm 1$ depending on the sign of $h$, and has no limit. ∎

### 22.1.1 Differentiation rules

**Proposition 22.4 (Operations).**

Let $u, v$ be [differentiable](#def-g12-deriv-derivative) on $I$ and $\lambda \in \R$. Then $u + v$, $\lambda u$, $uv$ are [differentiable](#def-g12-deriv-derivative) on $I$, as is $\frac{u}{v}$ where $v \neq 0$, and

$$
(u+v)' = u' + v', \quad (\lambda u)' = \lambda u', \quad
(uv)' = u'v + uv', \quad
\left(\frac{u}{v}\right)' = \frac{u'v - uv'}{v^2}.
$$

**Proof of the product rule.** Write the difference quotient of $uv$ at $a$ as

$$
\frac{u(a+h)v(a+h) - u(a)v(a)}{h}
= \frac{u(a+h) - u(a)}{h}\,v(a+h) + u(a)\,\frac{v(a+h) - v(a)}{h}.
$$

As $h \to 0$, $v(a+h) \to v(a)$ by [continuity](https://one-course.com/books/math/2/en/chapter/21-limits-and-continuity#def-g12-limcont-continuity) ([Proposition 22.3](#prop-g12-deriv-diffcont)), so the right side tends to $u'(a)v(a) + u(a)v'(a)$. The other rules are proved similarly. ∎

**Theorem 22.5 (Chain rule).**

Let $u$ be [differentiable](#def-g12-deriv-derivative) on $I$ with values in $J$, and $g$ [differentiable](#def-g12-deriv-derivative) on $J$. Then $g \circ u$ is [differentiable](#def-g12-deriv-derivative) on $I$ and

$$
(g \circ u)' = (g' \circ u) \cdot u' .
$$

In particular, for $u$ [differentiable](#def-g12-deriv-derivative):

$$
(u^n)' = n\,u'\,u^{n-1} \ (n \in \Z), \qquad
\left(\sqrt{u}\right)' = \frac{u'}{2\sqrt{u}} \ (u > 0), \qquad
\left(\eu^{u}\right)' = u'\,\eu^{u}.
$$

**Proof sketch.** When $u(a+h) \neq u(a)$ for $h$ small, write

$$
\frac{g(u(a+h)) - g(u(a))}{h}
= \frac{g(u(a+h)) - g(u(a))}{u(a+h) - u(a)} \cdot \frac{u(a+h) - u(a)}{h}.
$$

As $h \to 0$, $u(a+h) \to u(a)$, so the first factor tends to $g'(u(a))$ and the second to $u'(a)$. (A complete proof must handle the case where $u(a+h) = u(a)$ for $h$ arbitrarily small; this technical point is treated at university.) ∎

**Example 22.6.**

The usual [derivatives](#def-g12-deriv-derivative), valid on the natural [domains](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function):

$$
(x^n)' = nx^{n-1}, \quad
\left(\frac{1}{x}\right)' = -\frac{1}{x^2}, \quad
(\sqrt{x})' = \frac{1}{2\sqrt{x}}, \quad
(\cos x)' = -\sin x, \quad
(\sin x)' = \cos x .
$$

The first is proved by induction from the product rule, and the last two in [Chapter 24](https://one-course.com/books/math/2/en/chapter/24-trigonometric-functions#ch-g12-trigo).

## 22.2 Variations and extrema

**Theorem 22.7 (Sign of the derivative and variations).**

Let $f$ be [differentiable](#def-g12-deriv-derivative) on an [interval](https://one-course.com/books/math/2/en/chapter/1-numbers-and-sets-of-numbers#def-g10-numbers-interval) $I$.

1. $f$ is [increasing](https://one-course.com/books/math/2/en/chapter/20-sequences#def-g12-seq-monotonic) on $I$ if and only if $f' \geq 0$ on $I$ .
2. $f$ is [decreasing](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-variations) on $I$ if and only if $f' \leq 0$ on $I$ .
3. If $f' > 0$ on $I$ except at finitely many points where it vanishes, then $f$ is strictly [increasing](https://one-course.com/books/math/2/en/chapter/20-sequences#def-g12-seq-monotonic) on $I$ .

**Partial proof.** If $f$ is [increasing](https://one-course.com/books/math/2/en/chapter/20-sequences#def-g12-seq-monotonic), every difference quotient $\frac{f(a+h)-f(a)}{h}$ is $\geq 0$, and passing to the limit gives $f'(a) \geq 0$. The converse implications rest on the [mean](https://one-course.com/books/math/2/en/chapter/17-descriptive-statistics#def-g11-stat-mean) value theorem, proved at university; they are *admitted at this level*. ∎

**Definition 22.8 (Local extremum).**

$f$ has a *local maximum* at $a$ if $f(x) \leq f(a)$ for all $x$ near $a$; local minima are defined symmetrically.

**Proposition 22.9 (First-order condition).**

If $f$ is [differentiable](#def-g12-deriv-derivative) on an *open* [interval](https://one-course.com/books/math/2/en/chapter/1-numbers-and-sets-of-numbers#def-g10-numbers-interval) $I$ and has a local [extremum](#def-g12-deriv-extremum) at $a \in I$, then $f'(a) = 0$. The converse is false ($f(x) = x^3$ at $a = 0$).

**Proof.** Say $a$ is a [local maximum](#def-g12-deriv-extremum). For $h > 0$ small, $\frac{f(a+h)-f(a)}{h} \leq 0$, so letting $h \to 0^+$ gives $f'(a) \leq 0$; for $h < 0$ the quotient is $\geq 0$, giving $f'(a) \geq 0$. Hence $f'(a) = 0$. ∎

![At a local extremum inside an open interval, the tangent (orange) is horizontal: f'(a) = 0. Here f(x) = x3 - 3x, with a local maximum at -1 and a local minimum at 1.](https://one-course.com/images/onecourse/chapters/math-2/g12-deriv/fig-407cf2af40d9.svg)

*At a local [extremum](#def-g12-deriv-extremum) inside an open [interval](https://one-course.com/books/math/2/en/chapter/1-numbers-and-sets-of-numbers#def-g10-numbers-interval), the [tangent](#def-g12-deriv-tangent) (orange) is horizontal: $f'(a) = 0$. Here $f(x) = x^3 - 3x$, with a [local maximum](#def-g12-deriv-extremum) at $-1$ and a local [minimum](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-extrema) at $1$.*

**Method 22.10 (Variation table).**

To study a [function](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function) $f$: determine its [domain](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function) and limits at the boundary; compute $f'$ and factor it; determine the sign of $f'$ on each subinterval; record everything in a [variation table](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-table), marking extrema; deduce the number of solutions of $f(x) = k$ using the bijection theorem ([Theorem 21.15](https://one-course.com/books/math/2/en/chapter/21-limits-and-continuity#thm-g12-limcont-bijection)).

## 22.3 Convexity

**Definition 22.11 (Convex function).**

A [function](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function) $f$ defined on an [interval](https://one-course.com/books/math/2/en/chapter/1-numbers-and-sets-of-numbers#def-g10-numbers-interval) $I$ is *convex* on $I$ if every chord of its [graph](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-graph) lies above the [graph](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-graph): for all $a, b \in I$ and $t \in \intcc{0}{1}$,

$$
f\bigl((1-t)a + t b\bigr) \leq (1-t) f(a) + t f(b).
$$

It is *concave* if the reverse inequality holds ($-f$ convex).

![A convex function: every chord (red) lies above the graph, and the graph lies above each of its tangents (orange). The dashed segment shows the gap between f ((1-t)a+tb ) and (1-t)f(a)+tf(b).](https://one-course.com/images/onecourse/chapters/math-2/g12-deriv/fig-06e488af635d.svg)

*A [convex](#def-g12-deriv-convex) [function](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function): every chord (red) lies above the [graph](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-graph), and the [graph](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-graph) lies above each of its [tangents](#def-g12-deriv-tangent) (orange). The dashed segment shows the gap between $f\bigl((1-t)a+tb\bigr)$ and $(1-t)f(a)+tf(b)$.*

**Theorem 22.12 (Convexity and derivatives).**

Let $f$ be [differentiable](#def-g12-deriv-derivative) on an [interval](https://one-course.com/books/math/2/en/chapter/1-numbers-and-sets-of-numbers#def-g10-numbers-interval) $I$. The following are equivalent:

1. $f$ is [convex](#def-g12-deriv-convex) on $I$ ;
2. $f'$ is [increasing](https://one-course.com/books/math/2/en/chapter/20-sequences#def-g12-seq-monotonic) on $I$ ;
3. the [graph](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-graph) of $f$ lies above each of its [tangents](#def-g12-deriv-tangent) .

If $f$ is twice [differentiable](#def-g12-deriv-derivative), these are also equivalent to $f'' \geq 0$ on $I$.

**Proof of (2) $\Rightarrow$ (3).** Fix $a \in I$ and set $g(x) = f(x) - f(a) - f'(a)(x-a)$, the gap between the curve and the [tangent](#def-g12-deriv-tangent) at $a$. Then $g$ is [differentiable](#def-g12-deriv-derivative) and $g'(x) = f'(x) - f'(a)$. If $f'$ is [increasing](https://one-course.com/books/math/2/en/chapter/20-sequences#def-g12-seq-monotonic), $g' \leq 0$ on $I \cap \intoc{-\infty}{a}$ and $g' \geq 0$ on $I \cap \intco{a}{+\infty}$: $g$ decreases before $a$ and increases after, so $g$ attains its [minimum](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-extrema) $g(a) = 0$, hence $g \geq 0$. The remaining implications are admitted at this level; the equivalence with $f'' \geq 0$ follows from [Theorem 22.7](#thm-g12-deriv-variations) applied to $f'$. ∎

**Definition 22.13 (Inflection point).**

A point where the curve of $f$ crosses its [tangent](#def-g12-deriv-tangent) is an *inflection point*. For $f$ twice [differentiable](#def-g12-deriv-derivative), inflection points are the points where $f''$ changes sign.

**Example 22.14.**

$f(x) = x^3$ has $f''(x) = 6x$: $f$ is [concave](#def-g12-deriv-convex) on $\intoc{-\infty}{0}$, [convex](#def-g12-deriv-convex) on $\intco{0}{+\infty}$, with an [inflection point](#def-g12-deriv-inflection) at the origin, where the curve crosses its [tangent](#def-g12-deriv-tangent) (the $x$-axis).

![The inflection point of x x3 at the origin: the curve crosses its tangent (orange), concave on the left, convex on the right.](https://one-course.com/images/onecourse/chapters/math-2/g12-deriv/fig-240fadeaea91.svg)

*The [inflection point](#def-g12-deriv-inflection) of $x \mapsto x^3$ at the origin: the curve crosses its [tangent](#def-g12-deriv-tangent) (orange), [concave](#def-g12-deriv-convex) on the left, [convex](#def-g12-deriv-convex) on the right.*

**Example 22.15 (Convexity inequalities).**

The exponential is [convex](#def-g12-deriv-convex) on $\R$ (its second [derivative](#def-g12-deriv-derivative) is itself, positive). Its [tangent](#def-g12-deriv-tangent) at $0$ is $y = 1 + x$, so

$$
\eu^x \geq 1 + x \quad \text{for all } x \in \R .
$$

Such *[tangent](#def-g12-deriv-tangent) line inequalities* are a standard product of [convexity](#def-g12-deriv-convex).

**Method 22.16 (Using convexity).**

- To prove an inequality $f(x) \geq ax + b$ : identify the line as a [tangent](#def-g12-deriv-tangent) of a [convex](#def-g12-deriv-convex) $f$ and invoke [Theorem 22.12](#thm-g12-deriv-convexity) (3).
- To locate [inflection points](#def-g12-deriv-inflection) : solve $f''(x) = 0$ *and* check that $f''$ changes sign there.
- In a [variation table](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-table) , [convexity](#def-g12-deriv-convex) refines the sketch of the curve (which way it bends).

## 22.4 Exercises

**Exercise 22.1 ★.**

Differentiate the following [functions](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function) on their [domains](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function):

$$
f(x) = x^3 - 5x + 2, \quad
g(x) = \frac{x}{x^2+1}, \quad
h(x) = (2x+1)^5, \quad
k(x) = \sqrt{x^2 + 1}.
$$

**Solution of Exercise 22.1.**

$f'(x) = 3x^2 - 5$.

Quotient rule: $g'(x) = \dfrac{(x^2+1) - x\cdot 2x}{(x^2+1)^2} = \dfrac{1 - x^2}{(x^2+1)^2}$.

Chain rule with $u = 2x+1$: $h'(x) = 5 \cdot 2 \cdot (2x+1)^4 = 10(2x+1)^4$.

Chain rule with $u = x^2 + 1$: $k'(x) = \dfrac{2x}{2\sqrt{x^2+1}} = \dfrac{x}{\sqrt{x^2+1}}$.

**Exercise 22.2 ★.**

Give the [equation](https://one-course.com/books/math/2/en/chapter/2-algebra-equations-and-inequalities#def-g10-algebra-equation) of the [tangent](#def-g12-deriv-tangent) to the curve of $f(x) = x^2 - 3x + 1$ at the point of [abscissa](https://one-course.com/books/math/2/en/chapter/5-coordinate-geometry#def-g10-coordgeom-system) $a = 2$, and determine the positions of the curve relative to this [tangent](#def-g12-deriv-tangent).

**Solution of Exercise 22.2.**

$f'(x) = 2x - 3$, so $f(2) = -1$ and $f'(2) = 1$: the [tangent](#def-g12-deriv-tangent) is $y = -1 + (x - 2) = x - 3$. The gap is

$$
f(x) - (x - 3) = x^2 - 4x + 4 = (x-2)^2 \geq 0 ,
$$

so the curve lies above the [tangent](#def-g12-deriv-tangent) everywhere, touching it only at $x = 2$ (as expected: $f$ is [convex](#def-g12-deriv-convex)).

**Exercise 22.3 ★.**

Using the definition of the [derivative](#def-g12-deriv-derivative), compute

$$
\lim_{x \to 0} \frac{(1+x)^{100} - 1}{x}
\qquad\text{and}\qquad
\lim_{h \to 0} \frac{\sqrt{4+h} - 2}{h}.
$$

**Solution of Exercise 22.3.**

Both are difference quotients. With $f(x) = (1+x)^{100}$ at $0$: $f'(x) = 100(1+x)^{99}$, so the limit is $f'(0) = 100$. With $g(x) = \sqrt{x}$ at $4$: $g'(x) = \frac{1}{2\sqrt{x}}$, so the limit is $g'(4) = \frac14$.

**Exercise 22.4 ★★.**

Study the [function](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function) $f(x) = \dfrac{x^2 + 3}{x - 1}$ on its [domain](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function): limits, [derivative](#def-g12-deriv-derivative), [variation table](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-table), local extrema.

**Solution of Exercise 22.4.**

[Domain](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function) $\R \setminus \{1\}$. Limits: at $\pm\infty$, $f(x) \sim x \to
\pm\infty$; at $1^\pm$, numerator $\to 4 > 0$ and denominator $\to 0^\pm$, so $f \to \pm\infty$; the line $x = 1$ is a [vertical asymptote](https://one-course.com/books/math/2/en/chapter/21-limits-and-continuity#def-g12-limcont-asymptote).

$$
f'(x) = \frac{2x(x-1) - (x^2+3)}{(x-1)^2} = \frac{x^2 - 2x - 3}{(x-1)^2}
= \frac{(x-3)(x+1)}{(x-1)^2}.
$$

Hence $f' > 0$ on $\intoo{-\infty}{-1}$ and $\intoo{3}{+\infty}$, $f' < 0$ on $\intoo{-1}{1}$ and $\intoo{1}{3}$. The [function](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function) increases to a [local maximum](#def-g12-deriv-extremum) $f(-1) = -2$, decreases to $-\infty$, jumps to $+\infty$ after the [asymptote](https://one-course.com/books/math/2/en/chapter/21-limits-and-continuity#def-g12-limcont-asymptote), decreases to a local [minimum](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-extrema) $f(3) = 6$, then increases.

**Exercise 22.5 ★★.**

A box without a lid is made from a square sheet of cardboard of side $30\,$cm by cutting equal squares of side $x$ from the corners and folding up the sides. Determine $x$ maximizing the volume of the box.

**Solution of Exercise 22.5.**

For $x \in \intoo{0}{15}$, the box has a square base of side $30 - 2x$ and height $x$, so

$$
V(x) = x(30 - 2x)^2 .
$$

$V'(x) = (30-2x)^2 + x \cdot 2(30-2x)(-2) = (30-2x)(30 - 2x - 4x)
= (30-2x)(30-6x)$. On $\intoo{0}{15}$, $30 - 2x > 0$, so $V'$ has the sign of $30 - 6x$: positive before $x = 5$, negative after. The volume is maximal for $x = 5$ cm, giving $V(5) = 5 \times 20^2 = 2000\ \text{cm}^3$.

**Exercise 22.6 ★★.**

Let $f(x) = x^4 - 4x^3 + 10$.

1. Compute $f''$ and determine the [convexity](#def-g12-deriv-convex) [intervals](https://one-course.com/books/math/2/en/chapter/1-numbers-and-sets-of-numbers#def-g10-numbers-interval) and [inflection points](#def-g12-deriv-inflection) of $f$ .
2. Show that the [tangent](#def-g12-deriv-tangent) at the [inflection point](#def-g12-deriv-inflection) of [abscissa](https://one-course.com/books/math/2/en/chapter/5-coordinate-geometry#def-g10-coordgeom-system) $2$ crosses the curve there.

**Solution of Exercise 22.6.**

*1.* $f'(x) = 4x^3 - 12x^2$ and $f''(x) = 12x^2 - 24x = 12x(x-2)$. Thus $f'' > 0$ on $\intoo{-\infty}{0}$ and on $\intoo{2}{+\infty}$ ([convex](#def-g12-deriv-convex)), $f'' < 0$ on $\intoo{0}{2}$ ([concave](#def-g12-deriv-convex)). $f''$ changes sign at $0$ and at $2$: both are [inflection points](#def-g12-deriv-inflection).

*2.* At $a = 2$: $f(2) = 16 - 32 + 10 = -6$, $f'(2) = 32 - 48 = -16$, [tangent](#def-g12-deriv-tangent) $y = -6 - 16(x-2) = -16x + 26$. The gap is

$$
g(x) = f(x) + 16x - 26 = x^4 - 4x^3 + 16x - 16 .
$$

Since $g(2) = g'(2) = g''(2) = 0$, $(x-2)^3$ divides $g$; division gives $g(x) = (x-2)^3(x+2)$. Near $x = 2$, $x + 2 > 0$, so $g$ has the sign of $(x-2)^3$: negative before $2$, positive after. The curve crosses the [tangent](#def-g12-deriv-tangent): $2$ is indeed an [inflection point](#def-g12-deriv-inflection).

**Exercise 22.7 ★★.**

Using a [tangent](#def-g12-deriv-tangent) line inequality, show that for all $x > 0$,

$$
\sqrt{x} \leq \frac{x + 1}{2},
$$

and identify when equality holds. (Hint: the square root is [concave](#def-g12-deriv-convex).)

**Solution of Exercise 22.7.**

The [function](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function) $f(x) = \sqrt{x}$ satisfies $f''(x) = -\frac{1}{4}x^{-3/2} < 0$ on $\intoo{0}{+\infty}$: it is [concave](#def-g12-deriv-convex), so its [graph](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-graph) lies *below* each [tangent](#def-g12-deriv-tangent). The [tangent](#def-g12-deriv-tangent) at $a = 1$ is

$$
y = f(1) + f'(1)(x - 1) = 1 + \tfrac12 (x-1) = \frac{x+1}{2},
$$

whence $\sqrt{x} \leq \frac{x+1}{2}$ for all $x > 0$. Equality means the curve touches the [tangent](#def-g12-deriv-tangent), which happens only at the point of tangency $x = 1$. (Equivalently: $\left(\sqrt x - 1\right)^2 \geq 0$.)

**Exercise 22.8 ★★★.**

Let $f$ be [convex](#def-g12-deriv-convex) and [differentiable](#def-g12-deriv-derivative) on $\R$, and suppose that $f'$ vanishes at some point $a$. Show that $f(a)$ is the *global* [minimum](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-extrema) of $f$ on $\R$.

**Solution of Exercise 22.8.**

By [Theorem 22.12](#thm-g12-deriv-convexity), the [graph](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-graph) of a [differentiable](#def-g12-deriv-derivative) [convex](#def-g12-deriv-convex) [function](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function) lies above each of its [tangents](#def-g12-deriv-tangent). The [tangent](#def-g12-deriv-tangent) at $a$ is horizontal ($f'(a) = 0$), of [equation](https://one-course.com/books/math/2/en/chapter/2-algebra-equations-and-inequalities#def-g10-algebra-equation) $y = f(a)$. Hence $f(x) \geq f(a)$ for all $x \in \R$: $f(a)$ is the global [minimum](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-extrema).

**Exercise 22.9 ★★★.**

Show that among all rectangles of fixed perimeter $p$, the square has the largest area. Then show that among all rectangles of fixed area $A$, the square has the smallest perimeter, and explain how the two statements are related.

**Solution of Exercise 22.9.**

*Fixed perimeter.* A rectangle with sides $x$ and $\frac{p}{2} - x$ ($0 < x < \frac p2$) has area $S(x) = x\left(\frac p2 - x\right)$. Then $S'(x) = \frac p2 - 2x$ vanishes at $x = \frac p4$, positive before and negative after: the [maximum](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-extrema) is at $x = \frac{p}{4}$, where both sides equal $\frac p4$ — a square.

*Fixed area.* Sides $x$ and $\frac Ax$ give perimeter $P(x) = 2\left(x + \frac Ax\right)$, with $P'(x) = 2\left(1 - \frac{A}{x^2}\right)$, negative for $x < \sqrt A$ and positive after: [minimum](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-extrema) at $x = \sqrt{A}$, a square again.

*Relation.* The two statements are dual. Suppose a non-square rectangle minimized the perimeter at fixed area $A$; the square of the same perimeter would have area $> A$ by the first statement, and shrinking it homothetically to area $A$ would strictly decrease its perimeter — contradicting minimality. Each statement thus implies the other.

## 22.5 Problem: The lifeguard’s calculation

**Problem 22.1.**

Weekend problem — the fastest rescue path obeys Snell’s law of light, convexity certifies every optimum, and the ideal soda can is exactly as tall as it is wide

A lifeguard sees a swimmer in trouble — diagonally down the beach, out in the water. Running is faster than swimming: the straight line is *not* the fastest route. The route that minimizes time bends at the shoreline, and its bending law is precisely the law by which light refracts entering water: nature, too, differentiates. This problem trains the chain rule ([Theorem 22.5](#thm-g12-deriv-chain)), performs the rescue, harvests the inequalities of [convexity](#def-g12-deriv-convex) ([Theorem 22.12](#thm-g12-deriv-convexity)), and designs a tin can.

**Part I — Chain-rule fluency.**

1. Differentiate: $\left(3x^2 + 1\right)^5$ ; $\sqrt{x^2 + 9}$ ; $\dfrac{1}{x^2 + 1}$ .
2. Give the [tangent](#def-g12-deriv-tangent) to $y = \sqrt{x^2 + 9}$ at $x = 4$ .
3. Build the [variation table](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-table) of $f(x) = \dfrac{x}{x^2 + 1}$ on $\R$ (extrema included).
4. For $g(x) = x^3 - 3x^2 + 4$ : [variation table](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-table) *and* [convexity](#def-g12-deriv-convex) table ( $g''$ ), with the [inflection point](#def-g12-deriv-inflection) ( [Definition 22.13](#def-g12-deriv-inflection) ).
5. Compute the [tangent](#def-g12-deriv-tangent) to $g$ at its [inflection point](#def-g12-deriv-inflection) , and show that $g(x) - (\text{tangent}) = (x - 1)^3$ : what does the sign change say about how the [tangent](#def-g12-deriv-tangent) meets the curve at an inflection?

**Part II — The rescue.** Shoreline along the $x$-axis; the lifeguard stands on sand at $A(0, 30)$, the swimmer waits at $B(40, -20)$ (meters). The guard runs at $5$ m/s on sand, swims at $2$ m/s, and enters the water at a point $(x, 0)$ of her choice.

6. Model: express the total rescue time $T(x)$ , and say why only $x \in \intcc{0}{40}$ deserves consideration.
7. Differentiate $T$ (chain rule at work — twice).
8. Let $\theta_1$ be the angle of the running leg with the *perpendicular* to the shore, $\theta_2$ that of the swimming leg. Show that $\sin\theta_1 = \frac{x}{\sqrt{x^2 + 900}}$ and that the condition $T'(x) = 0$ reads $$\frac{\sin\theta_1}{5} = \frac{\sin\theta_2}{2}$$ — *Snell’s law*, with the two speeds in place of the speeds of light in air and water.
9. The straight segment $[AB]$ crosses the shore at $x = 24$ . Compute $T(24)$ , $T(40)$ (run along the beach, then swim straight out) and $T(0)$ : is the geometric straight line the fastest? Is either extreme strategy?
10. Locate the optimal entry point by [dichotomy](https://one-course.com/books/math/2/en/chapter/21-limits-and-continuity#thm-g12-limcont-ivt) on $T'$ (it is $\approx 33.7$ m): give $x^*$ to the meter and the record time $T(x^*)$ to the tenth of a second. How much does the optimal bend save over the straight line?
11. Why is the critical point a *global* [minimum](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-extrema) ? (Each term of $T$ is [convex](#def-g12-deriv-convex) — admit that a sum of [convex](#def-g12-deriv-convex) [functions](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function) is [convex](#def-g12-deriv-convex) — and apply [Exercise 22.8](#exo-g12-deriv-8) .)
12. Fermat’s principle states that light always travels the path of least *time* . Deduce why a light ray bends exactly at the surface when entering water (where light is slower), and name the everyday observation this explains about a pencil in a glass of water.

**Part III — [Convexity](#def-g12-deriv-convex)’s harvest.**

13. Show that $x \mapsto x^2$ is [convex](#def-g12-deriv-convex) , and prove the [midpoint](https://one-course.com/books/math/2/en/chapter/5-coordinate-geometry#prop-g10-coordgeom-midpoint) inequality $\left(\frac{a + b}{2}\right)^2 \leq  \frac{a^2 + b^2}{2}$ twice: once from [convexity](#def-g12-deriv-convex) , once by [expanding](https://one-course.com/books/math/2/en/chapter/2-algebra-equations-and-inequalities#def-g10-algebra-expand) $(a - b)^2 \geq 0$ .
14. Deduce that the *quadratic [mean](https://one-course.com/books/math/2/en/chapter/17-descriptive-statistics#def-g11-stat-mean)* $\sqrt{\frac{a^2 + b^2}{2}}$ dominates the arithmetic [mean](https://one-course.com/books/math/2/en/chapter/17-descriptive-statistics#def-g11-stat-mean) , and assemble the complete chain of the series — harmonic $\leq$ geometric $\leq$ arithmetic $\leq$ quadratic — verifying all four on $a = 2$ , $b = 8$ .
15. Tangent-below-the-curve: $x \mapsto \frac1x$ is [convex](#def-g12-deriv-convex) on $\intoo{0}{+\infty}$ ; write its [tangent](#def-g12-deriv-tangent) at $1$ and deduce the inequality $\frac1x \geq 2 - x$ for all $x > 0$ . Where is it an equality?
16. Inflection in the wild: during an epidemic, the cumulative case count follows an S-shaped curve. What happens at its [inflection point](#def-g12-deriv-inflection) , and why is that date the one epidemiologists watch for? Relate to the sign of the second [derivative](#def-g12-deriv-derivative) on each side.

**Part IV — The ideal can.** A cylindrical can must hold $V = 330$ cm$^3$ with the least metal: surface $S = 2\pi r^2 + 2\pi r h$, constraint $\pi r^2 h = V$.

17. Express $S(r) = 2\pi r^2 + \dfrac{2V}{r}$ , differentiate, and compute the optimal radius and height for $V = 330$ (millimeter precision).
18. Prove the elegant general law: at the optimum, $h = 2r$ — the ideal can is exactly as tall as it is wide.
19. Check $S''(r) > 0$ and conclude (via [Exercise 22.8](#exo-g12-deriv-8) again) that the optimum is global. Real soda cans are visibly taller than wide: name a non-mathematical reason.
20. Finale — the optimization pipeline: model, ask the [derivative](#def-g12-deriv-derivative) , solve for critical points, certify with [convexity](#def-g12-deriv-convex) or a table, interpret. Run the list over the lifeguard, the can, and grade 11’s strongest beam ( [Problem 12.1](https://one-course.com/books/math/2/en/chapter/12-differentiation-a-first-course#pb-g11-deriv-1) ) — and state what Fermat’s principle says about who else runs this pipeline.

**Solution of Problem 22.1.**

**1.** $30x\left(3x^2 + 1\right)^4$; $\dfrac{x}{\sqrt{x^2 + 9}}$; $-\dfrac{2x}{\left(x^2 + 1\right)^2}$.

**2.** $y(4) = 5$, [slope](https://one-course.com/books/math/2/en/chapter/4-reference-functions#def-g10-reffunc-affine) $\frac45$: [tangent](#def-g12-deriv-tangent) $y = 5 + \frac45(x - 4)$, i.e. $y = \frac45 x + \frac95$.

**3.** $f'(x) = \frac{(x^2 + 1) - x \cdot 2x}{(x^2+1)^2}
= \frac{1 - x^2}{(x^2 + 1)^2}$: negative, positive, negative across $-1$ and $1$: [minimum](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-extrema) $f(-1) = -\frac12$, [maximum](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-extrema) $f(1) = \frac12$, with [horizontal asymptote](https://one-course.com/books/math/2/en/chapter/21-limits-and-continuity#def-g12-limcont-asymptote) $0$ on both sides.

**4.** $g'(x) = 3x^2 - 6x = 3x(x - 2)$: [increasing](https://one-course.com/books/math/2/en/chapter/20-sequences#def-g12-seq-monotonic), [decreasing](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-variations), [increasing](https://one-course.com/books/math/2/en/chapter/20-sequences#def-g12-seq-monotonic) across $0$ and $2$; local max $g(0) = 4$, local min $g(2) = 0$. $g''(x) = 6x - 6$: [concave](#def-g12-deriv-convex) before $1$, [convex](#def-g12-deriv-convex) after: inflection at $(1, 2)$.

**5.** [Tangent](#def-g12-deriv-tangent) at $1$: [slope](https://one-course.com/books/math/2/en/chapter/4-reference-functions#def-g10-reffunc-affine) $g'(1) = -3$: $y = 2 - 3(x - 1) = -3x + 5$. Difference: $x^3 - 3x^2 + 4 - (-3x + 5) = x^3 - 3x^2 + 3x - 1 =
(x - 1)^3$, which changes sign at $1$: the [tangent](#def-g12-deriv-tangent) *crosses* the curve — the signature behavior at an [inflection point](#def-g12-deriv-inflection), where the curve switches sides.

**6.** $T(x) = \dfrac{\sqrt{x^2 + 900}}{5} +
\dfrac{\sqrt{(40 - x)^2 + 400}}{2}$. Entering before $0$ or beyond $40$ lengthens *both* legs: pointless.

**7.** $T'(x) = \dfrac{x}{5\sqrt{x^2 + 900}} -
\dfrac{40 - x}{2\sqrt{(40 - x)^2 + 400}}$.

**8.** In the running triangle, the side along the shore is $x$ and the hypotenuse $\sqrt{x^2 + 900}$: the [sine](https://one-course.com/books/math/2/en/chapter/14-trigonometry-the-unit-circle#def-g11-trigo-cossin) of the angle with the perpendicular is precisely their quotient (opposite over hypotenuse); likewise $\sin\theta_2 = \frac{40 - x}{\sqrt{(40-x)^2 + 400}}$. Then $T'(x) = 0$ reads $\frac{\sin\theta_1}{5} = \frac{\sin\theta_2}{2}$ — Snell’s law with speeds $5$ and $2$.

**9.** $T(24) \approx 20.5$ s; $T(40) = 10 + 10 = 20$ s; $T(0) = 6 + \sqrt{2000}/2 \approx 28.4$ s. The straight line loses even to “run all the way, then swim straight” — and both lose to the refracted path.

**10.** [Dichotomy](https://one-course.com/books/math/2/en/chapter/21-limits-and-continuity#thm-g12-limcont-ivt) on $T'$ (negative at $24$, positive at $40$) [converges](https://one-course.com/books/math/2/en/chapter/20-sequences#def-g12-seq-limit) to $x^* \approx 34$ m, with $T(x^*) \approx 19.5$ s: about one second faster than the straight line — the difference between a rescue and a tragedy.

**11.** Each leg-time is a [convex](#def-g12-deriv-convex) [function](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function) of $x$ (a $\sqrt{\text{quadratic}}$ branch), so $T$ is [convex](#def-g12-deriv-convex), and a critical point of a [convex](#def-g12-deriv-convex) [differentiable](#def-g12-deriv-derivative) [function](https://one-course.com/books/math/2/en/chapter/11-functions-and-variations#def-g11-func-function) is its global [minimum](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-extrema) ([Exercise 22.8](#exo-g12-deriv-8)): $x^*$ is not merely stationary, it is unbeatable.

**12.** Light in water is slower; by Fermat’s principle the fastest air-to-water path bends at the surface exactly by Snell’s law — so rays from a submerged pencil reach the eye bent, and the brain, extrapolating straight lines, sees the pencil broken at the waterline.

**13.** $(x^2)'' = 2 > 0$: [convex](#def-g12-deriv-convex). [Convexity](#def-g12-deriv-convex) at the [midpoint](https://one-course.com/books/math/2/en/chapter/5-coordinate-geometry#prop-g10-coordgeom-midpoint): $f\left(\frac{a+b}{2}\right) \leq
\frac{f(a) + f(b)}{2}$, which is the claim. By hand: $\frac{a^2 + b^2}{2} - \left(\frac{a+b}{2}\right)^2 =
\frac{(a - b)^2}{4} \geq 0$.

**14.** Taking square roots ([increasing](https://one-course.com/books/math/2/en/chapter/20-sequences#def-g12-seq-monotonic)) in question 13: $\frac{a + b}{2} \leq \sqrt{\frac{a^2 + b^2}{2}}$. Full chain on $2, 8$: harmonic $\frac{2 \cdot 16}{10} = 3.2$; geometric $\sqrt{16} = 4$; arithmetic $5$; quadratic $\sqrt{34} \approx 5.83$: each [mean](https://one-course.com/books/math/2/en/chapter/17-descriptive-statistics#def-g11-stat-mean) bows to the next.

**15.** [Tangent](#def-g12-deriv-tangent) to $\frac1x$ at $1$: value $1$, [slope](https://one-course.com/books/math/2/en/chapter/4-reference-functions#def-g10-reffunc-affine) $-1$: $y = 2 - x$. [Convex](#def-g12-deriv-convex) curves sit above their [tangents](#def-g12-deriv-tangent) ([Theorem 22.12](#thm-g12-deriv-convexity)): $\frac1x \geq 2 - x$ for all $x > 0$, with equality exactly at the contact point $x = 1$.

**16.** At the inflection, the *daily* case count (the [derivative](#def-g12-deriv-derivative)) peaks: growth stops accelerating and begins to decelerate — the first mathematical signal that the wave is turning, long before the counts themselves fall. Before it, $f'' > 0$ (each day worse than the last); after it, $f'' < 0$ (still growing, but more slowly).

**17.** $S'(r) = 4\pi r - \frac{2V}{r^2} = 0$ gives $r^3 = \frac{V}{2\pi} = \frac{330}{2\pi}$: $r \approx 3.74$ cm, and $h = \frac{330}{\pi r^2} \approx 7.49$ cm.

**18.** $h = \frac{V}{\pi r^2} = \frac{2\pi r^3}{\pi r^2}
= 2r$ at the optimum: height equals diameter, whatever the volume.

**19.** $S''(r) = 4\pi + \frac{4V}{r^3} > 0$: [convex](#def-g12-deriv-convex), so the critical radius is the global [minimum](https://one-course.com/books/math/2/en/chapter/3-functions#def-g10-functions-extrema). Real cans stand taller for grip, stacking, shelf presence and the thicker top/bottom metal — optimization always minimizes exactly what you wrote, not what you meant.

**20.** Lifeguard: model $T(x)$, differentiate, Snell, [convexity](#def-g12-deriv-convex), one second saved. Can: model $S(r)$, differentiate, $h = 2r$, [convexity](#def-g12-deriv-convex), metal saved. Beam ([Problem 12.1](https://one-course.com/books/math/2/en/chapter/12-differentiation-a-first-course#pb-g11-deriv-1)): model $S(w)$, differentiate, $d = w\sqrt2$, table, stiffness gained. And by Fermat’s principle, light itself runs the pipeline at every surface it meets — nature was the first optimizer.
