Lectures

Math Camp

Lecture 4: Differential Calculus

1 Functions of one variable

1.1 Definition

Let II\subseteq\mathbb{R} be an open interval and let f:If:I\to\mathbb{R}. If the input moves from x0x_0 to x0+hx_0+h, then the input changes by hh and the value of the function changes by f(x0+h)f(x0).f(x_0+h)-f(x_0). For h0h\neq0, the ratio

f(x0+h)f(x0)h\frac{f(x_0+h)-f(x_0)}{h}(1)

is the average rate of change between the two points. Geometrically, it is the slope of the line that goes through (x0,f(x0))(x_0,f(x_0)) and (x0+h,f(x0+h))(x_0+h,f(x_0+h)). The derivative is the limiting slope as h0h\to0. Thus x0x_0 is the fixed point at which the derivative is evaluated, while x0+hx_0+h is the moving input.

Definition 1.1 (Derivative). The function ff is differentiable at x0x_0 if there is aa\in\mathbb{R} such that limh0f(x0+h)f(x0)h=a.\lim_{h\to0}\frac{f(x_0+h)-f(x_0)}{h}=a. The number aa is the derivative of ff at x0x_0, written f(x0)f'(x_0). If ff is differentiable at every point of II, then ff' denotes the derivative function xf(x)x\mapsto f'(x).

Figure 1.1. Left: for h\neq0 the difference quotient (1) is the rise f(x_0+h)-f(x_0) over the run h, that is, the slope of the secant line through (x_0,f(x_0)) and (x_0+h,f(x_0+h)). Right: as h\to0 the second point slides along the graph toward the first and the secants rotate toward a single limiting line. Its slope is the derivative f'(x_0), and the line itself is the tangent to the graph at (x_0,f(x_0)).

We begin with three direct computations of the derivative using the definition.

Example 1.2 (Constant, affine, and quadratic functions).

Fix x0x_0\in\mathbb{R}, and let a,b,ca,b,c\in\mathbb{R}.

  1. If f(x)=cf(x)=c, then [f(x0+h)f(x0)]/h=0[f(x_0+h)-f(x_0)]/h=0 for every h0h\neq0, so f(x0)=0f'(x_0)=0.

  2. If f(x)=ax+bf(x)=ax+b, then f(x0+h)f(x0)h=a(x0+h)+b(ax0+b)h=a,\frac{f(x_0+h)-f(x_0)}{h} =\frac{a(x_0+h)+b-(ax_0+b)}{h}=a, so f(x0)=af'(x_0)=a. The slope of an affine function is the same at every point.

  3. If f(x)=x2f(x)=x^2, then f(x0+h)f(x0)h=(x0+h)2x02h=2x0+h2x0.\frac{f(x_0+h)-f(x_0)}{h} =\frac{(x_0+h)^2-x_0^2}{h} =2x_0+h\longrightarrow2x_0. Thus f(x)=2xf'(x)=2x. In particular, f(3)=6f'(3)=6.

1.2 Derivative as a linear approximation

Definition 1.1 has an equivalent form that will extend cleanly to several variables. Because II is open, f(x0+h)f(x_0+h) is defined for every sufficiently small change hh, so the limit below makes sense.

Theorem 1.3 (Derivative as a linear approximation).

Let II\subseteq\mathbb{R} be an open interval, let f:If:I\to\mathbb{R}, and let x0Ix_0\in I. Then ff is differentiable at x0x_0 if and only if there is aa\in\mathbb{R} such that

limh0|f(x0+h)f(x0)ah||h|=0.\lim_{h\to0}\frac{\lvert f(x_0+h)-f(x_0)-ah \rvert}{\lvert h \rvert}=0.(2)

In that case aa is unique, and a=f(x0)a=f'(x_0).

Proof. The proof relies on two facts. First, for any real-valued function uu of hh, |u(h)|0\lvert u(h) \rvert\to0 if and only if u(h)0u(h)\to0 as h0h\to0 (see Lecture 2). Second, |b/c|=|b|/|c|\lvert b/c \rvert = \lvert b \rvert/\lvert c \rvert for all bb \in \mathbb{R} and c\{0}c \in \mathbb{R}\setminus\{0\}. We have: f is differentiable at x0a such that limh0f(x0+h)f(x0)h=a.a such that limh0(f(x0+h)f(x0)ahh)=0.a such that limh0|f(x0+h)f(x0)ahh|=0.a such that limh0|f(x0+h)f(x0)ah||h|=0,\begin{aligned} f \text{ is differentiable at } x_0 \iff \exists a \in \mathbb{R}\text{ such that } \lim_{h \to 0} \frac{f(x_0 + h) - f(x_0)}{h} = a. \\ \iff \exists a \in \mathbb{R}\text{ such that } \lim_{h \to 0} \left( \frac{f(x_0 + h) - f(x_0) - ah}{h} \right) = 0. \\ \iff \exists a \in \mathbb{R}\text{ such that } \lim_{h \to 0} \left\lvert \frac{f(x_0 + h) - f(x_0) - ah}{h} \right\rvert = 0. \\ \iff \exists a \in \mathbb{R}\text{ such that } \lim_{h \to 0} \frac{\lvert f(x_0 + h) - f(x_0) - ah \rvert}{\lvert h \rvert} = 0, \end{aligned} where the first equivalence is by the definition of differentiability, the second equivalence is by subtracting aa from both sides, the third equivalence is the first fact, and the fourth equivalence is the second fact. Furthermore, the aa in Definition 1.1 is unique and equals f(x0)f'(x_0), so the aa in (2) is also unique and equals f(x0)f'(x_0). ◻

Setting x=x0+hx=x_0+h gives an equivalent moving-point form of (2):

limxx0|f(x)f(x0)a(xx0)||xx0|=0.\lim_{x\to x_0} \frac{\lvert f(x)-f(x_0)-a(x-x_0) \rvert}{\lvert x-x_0 \rvert}=0.(3)

In both forms x0x_0 is fixed. In (2), h0h\to0; in (3), the input x=x0+hx=x_0+h tends to x0x_0.

The reason why Equation 2 is called derivative as a linear approximation is as follows. Let r(h)=f(x0+h)f(x0)ahr(h) = f(x_0+h)-f(x_0)-ah in the numerator of (2). Then, f(x0+h)=f(x0)+ah+r(h)f(x_0+h)=f(x_0)+ah+r(h), where f(x0)+ahf(x_0)+ah is the linear approximation of ff evaluated at x0+hx_0+h, while r(h)r(h) is the remainder term. The condition in (2), now written as |r(h)|/|h|0|r(h)|/|h| \to 0 as h0h \to 0 says that the remainder term is negligible compared to hh as h0h \to 0.

Example 1.4 (Reading the derivative from an expansion).

Let f:f:\mathbb{R}\to\mathbb{R} be given by f(x)=x2f(x)=x^2, and let x0=3x_0=3. The function evaluated at x0+hx_0+h is f(3+h)=(3+h)2=9f(3)+6hlinear term+h2r(h).f(3+h) = (3+h)^2 = \underbrace{9}_{f(3)}+\underbrace{6h}_{\text{linear term}} +\underbrace{h^2}_{r(h)}.

The remainder satisfies limh0|r(h)||h|=limh0|h2||h|=limh0|h|=0.\lim_{h \to 0} \frac{|r(h)|}{|h|} = \lim_{h \to 0} \frac{|h^2|}{|h|} = \lim_{h \to 0} |h| = 0. Therefore the linear coefficient is the derivative: f(3)=6f'(3)=6.

We now have two ways of calculating derivatives for functions from \mathbb{R} to \mathbb{R}: the difference-quotient Definition 1.1 and the linear-expansion method of Theorem 1.3. The latter method is generalizable to functions of several variables, so we will use it in the next section.

1.3 Properties of differentiability

Theorem 1.5 (Differentiability implies continuity).

Let II\subseteq\mathbb{R} be an open interval, let f:If:I\to\mathbb{R}, and let x0Ix_0\in I. If ff is differentiable at x0x_0, then ff is continuous at x0x_0.

Proof (optional). For h0h\neq0 small enough that x0+hIx_0+h\in I, limh0[f(x0+h)f(x0)]=limh0(f(x0+h)f(x0)hh)=(limh0f(x0+h)f(x0)h)(limh0h)=f(x0)0=0,\begin{aligned} \lim_{h\to0}\left[f(x_0+h)-f(x_0)\right] &=\lim_{h\to0}\left(\frac{f(x_0+h)-f(x_0)}{h}\cdot h\right)\\ &=\left(\lim_{h\to0}\frac{f(x_0+h)-f(x_0)}{h}\right) \left(\lim_{h\to0}h\right)\\ &=f'(x_0)\cdot0=0, \end{aligned} where the last line uses Definition 1.1. Hence limh0f(x0+h)=f(x0)+limh0[f(x0+h)f(x0)]=f(x0),\lim_{h\to0}f(x_0+h) =f(x_0)+\lim_{h\to0}\left[f(x_0+h)-f(x_0)\right] =f(x_0), which is continuity of ff at x0x_0. ◻

The converse fails: a continuous function need not be differentiable.

Example 1.6 (Continuity without differentiability).

Let f:f:\mathbb{R}\to\mathbb{R} be given by f(x)=|x|f(x)=\lvert x \rvert. At the origin, |f(x)f(0)|=|x|0\lvert f(x)-f(0) \rvert=\lvert x \rvert\to0, so ff is continuous. But for h0h\neq0, the difference quotient [f(h)f(0)]/h=|h|/h[f(h)-f(0)]/h=\lvert h \rvert/h equals 11 when h>0h>0 and 1-1 when h<0h<0. It has no limit as h0h\to0, so ff is not differentiable at 00.

Theorem 1.7 (Rules of differentiation). Let ff and gg be differentiable at x0x_0, and let α,β\alpha,\beta\in\mathbb{R}. Then

  1. (αf+βg)(x0)=αf(x0)+βg(x0)(\alpha f+\beta g)'(x_0)=\alpha f'(x_0)+\beta g'(x_0);

  2. (fg)(x0)=f(x0)g(x0)+f(x0)g(x0)(fg)'(x_0)=f'(x_0)g(x_0)+f(x_0)g'(x_0);

  3. if g(x0)0g(x_0)\neq0, then (f/g)(x0)=f(x0)g(x0)f(x0)g(x0)g(x0)2.(f/g)'(x_0) =\frac{f'(x_0)g(x_0)-f(x_0)g'(x_0)}{g(x_0)^2}.

Its proof uses Definition 1.1 and is left as an exercise.

Theorem 1.8 (Chain rule). Let I,JI,J\subseteq\mathbb{R} be open intervals, let g:Ig:I\to\mathbb{R} satisfy g(I)Jg(I)\subseteq J, and let f:Jf:J\to\mathbb{R}. If gg is differentiable at x0Ix_0\in I and ff is differentiable at g(x0)g(x_0), then fgf\circ g is differentiable at x0x_0 and (fg)(x0)=f(g(x0))g(x0).(f\circ g)'(x_0)=f'(g(x_0))\,g'(x_0).

Proof (optional). Write y0=g(x0)y_0=g(x_0). Because JJ is open, y0+tJy_0+t\in J for every sufficiently small tt, and for those tt define φ(t)={f(y0+t)f(y0)t,t0,f(y0),t=0.\varphi(t)= \begin{cases} \dfrac{f(y_0+t)-f(y_0)}{t}, & t\neq0,\\[2ex] f'(y_0), & t=0. \end{cases} By Definition 1.1, φ(t)f(y0)=φ(0)\varphi(t)\to f'(y_0)=\varphi(0) as t0t\to0, so φ\varphi is continuous at 00. Multiplying by tt,

f(y0+t)f(y0)=tφ(t),f(y_0+t)-f(y_0)=t\,\varphi(t),(4)

which holds for every tt in the domain of φ\varphi, including t=0t=0.

Next, let h0h\neq0 tend to zero with x0+hIx_0+h\in I, and set t=g(x0+h)g(x0)t=g(x_0+h)-g(x_0). Since gg is continuous at x0x_0 by Theorem 1.5, t0t\to0, so for every sufficiently small hh, (4) reads f(g(x0+h))f(g(x0))=[g(x0+h)g(x0)]φ(g(x0+h)g(x0)),f(g(x_0+h))-f(g(x_0)) =\left[g(x_0+h)-g(x_0)\right]\, \varphi\left(g(x_0+h)-g(x_0)\right), Dividing by hh, f(g(x0+h))f(g(x0))h=g(x0+h)g(x0)hφ(g(x0+h)g(x0)).\frac{f(g(x_0+h))-f(g(x_0))}{h} =\frac{g(x_0+h)-g(x_0)}{h}\cdot \varphi\left(g(x_0+h)-g(x_0)\right). As h0h\to0, the first factor tends to g(x0)g'(x_0) by Definition 1.1. For the second, t0t\to0 as noted above, and φ\varphi is continuous at 00, so φ(g(x0+h)g(x0))φ(0)=f(y0)\varphi(g(x_0+h)-g(x_0))\to\varphi(0)=f'(y_0). Hence limh0f(g(x0+h))f(g(x0))h=(limh0g(x0+h)g(x0)h)(limh0φ(g(x0+h)g(x0)))=g(x0)f(y0).\begin{aligned} \lim_{h\to0}\frac{f(g(x_0+h))-f(g(x_0))}{h} &=\left(\lim_{h\to0}\frac{g(x_0+h)-g(x_0)}{h}\right) \left(\lim_{h\to0} \varphi\left(g(x_0+h)-g(x_0)\right)\right)\\ &=g'(x_0)\,f'(y_0). \end{aligned} ◻

1.4 Useful theorems for functions of one variable

Theorem 1.9 (Interior extremum). Let a<ba<b, let f:[a,b]f:[a,b]\to\mathbb{R}, and let x*(a,b)x^*\in(a,b). Suppose ff is differentiable at x*x^* and that for some ε>0\varepsilon>0, f(x*)f(x)for every x[a,b] with |xx*|<ε.f(x^*)\geq f(x) \qquad\text{for every }x\in[a,b]\text{ with }\lvert x-x^* \rvert<\varepsilon. Then f(x*)=0f'(x^*)=0. The same conclusion holds if instead f(x*)f(x)f(x^*)\leq f(x) for every such xx.

Proof (optional). Because x*(a,b)x^*\in(a,b), we have x*+h[a,b]x^*+h\in[a,b] for every sufficiently small |h|\lvert h \rvert. For such hh with 0<|h|<ε0<\lvert h \rvert<\varepsilon the hypothesis gives f(x*+h)f(x*)0f(x^*+h)-f(x^*)\leq0, and dividing by hh preserves the inequality when h>0h>0 and reverses it when h<0h<0: f(x*+h)f(x*)h0if h>0,f(x*+h)f(x*)h0if h<0.\frac{f(x^*+h)-f(x^*)}{h}\leq0 \quad\text{if }h>0, \qquad \frac{f(x^*+h)-f(x^*)}{h}\geq0 \quad\text{if }h<0. Since ff is differentiable at x*x^*, the two-sided limit of the difference quotient exists, so both one-sided limits exist and equal f(x*)f'(x^*). Letting h0h\downarrow0 gives f(x*)0f'(x^*)\leq0, and letting h0h\uparrow0 gives f(x*)0f'(x^*)\geq0, so f(x*)=0f'(x^*)=0. For the reversed inequality, apply this to f-f. ◻

Theorem 1.10 (Rolle’s theorem). Let a<ba<b and let f:[a,b]f:[a,b]\to\mathbb{R} be continuous on [a,b][a,b] and differentiable on (a,b)(a,b). If f(a)=f(b)f(a)=f(b), then there is c(a,b)c\in(a,b) such that f(c)=0f'(c)=0.

Proof (optional). If ff is constant, then f(c)=0f'(c)=0 for every c(a,b)c\in(a,b).

Otherwise f(t)f(a)f(t)\neq f(a) for some t[a,b]t\in[a,b]. Suppose f(t)>f(a)f(t)>f(a). Since [a,b][a,b] is compact and ff is continuous, Theorem 3.5 from Lecture 2 gives a maximizer c[a,b]c\in[a,b] of ff on [a,b][a,b]. We thus have f(c)f(t)>f(a)=f(b),f(c)\geq f(t)>f(a)=f(b), in particular, c(a,b)c \in (a,b). Then ff is differentiable at cc, and f(c)f(x)f(c)\geq f(x) holds for every x[a,b]x \in [a,b], including those xx with |xc|<ε\lvert x-c \rvert<\varepsilon for some ε>0\varepsilon>0. By Theorem 1.9, we conclude that f(c)=0f'(c)=0.

If instead f(t)<f(a)f(t)<f(a), run the same argument with cc being a minimizer. ◻

Theorem 1.11 (Mean value theorem). Let a<ba<b and let f:[a,b]f:[a,b]\to\mathbb{R} be continuous on [a,b][a,b] and differentiable on (a,b)(a,b). Then there is c(a,b)c\in(a,b) such that f(b)f(a)=(ba)f(c).f(b)-f(a)=(b-a)f'(c).

Proof (optional). Let g(t)=f(t)f(a)f(b)f(a)ba(ta),t[a,b].g(t)=f(t)-f(a)-\frac{f(b)-f(a)}{b-a}(t-a), \qquad t\in[a,b]. Then gg is continuous on [a,b][a,b], differentiable on (a,b)(a,b), and g(a)=g(b)=0g(a)=g(b)=0. By Theorem 1.10 there is c(a,b)c\in(a,b) with 0=g(c)=f(c)f(b)f(a)ba,0=g'(c)=f'(c)-\frac{f(b)-f(a)}{b-a}, yielding the result. ◻

2 Real-valued functions of several variables

In this section, we consider functions from n\mathbb{R}^{n} to \mathbb{R}. Input vectors are column vectors. We use xx for a generic or moving input and x0x_0 for a fixed point at which a derivative is evaluated. Thus h=xx0h=x-x_0 is the change from x0x_0 to xx.

2.1 Partial derivatives

Recall from Lecture 3 that eie_i is the iith standard basis vector of n\mathbb{R}^{n}, with 11 in coordinate ii and 00 in every other coordinate. For a real number tt, the vector teite_i has tt in coordinate ii and 00 elsewhere, and x0+teix_0+te_i adds tt to coordinate ii of x0x_0 while leaving every other coordinate of x0x_0 unchanged.

Definition 2.1 (Partial derivative). Let UnU\subseteq\mathbb{R}^{n} be open, let f:Uf:U\to\mathbb{R}, and let x0Ux_0\in U. The iith partial derivative of ff at x0x_0, where i{1,,n}i\in\{1,\ldots,n\}, is fxi(x0)=limt0f(x0+tei)f(x0)t,\frac{\partial f}{\partial x_i}(x_0) =\lim_{t\to0}\frac{f(x_0+te_i)-f(x_0)}{t}, provided the limit exists.

This is an ordinary one-variable derivative: hold all variables except xix_i fixed and differentiate with respect to xix_i.

Example 2.2 (A function of two variables). Let f:2f:\mathbb{R}^2\to\mathbb{R} be given by f(x1,x2)=x12x2.f(x_1,x_2)=x_1^2x_2. Holding x2x_2 fixed and differentiating in x1x_1, and then reversing their roles, gives fx1(x1,x2)=2x1x2,fx2(x1,x2)=x12.\frac{\partial f}{\partial x_1}(x_1,x_2)=2x_1x_2, \qquad \frac{\partial f}{\partial x_2}(x_1,x_2)=x_1^2.

2.2 Differentiability and C1C^1 functions

Partial derivatives describe a function only along the coordinate lines through a point. Differentiability requires one linear approximation to work for small changes in all directions at once. A linear map from n\mathbb{R}^{n} to \mathbb{R} has the form hahh\mapsto a\cdot h for some ana\in\mathbb{R}^{n}, so aa and hh, which were scalars in the one-variable case, are now both vectors.

Definition 2.3 (Differentiability). Let UnU\subseteq\mathbb{R}^{n} be open, let f:Uf:U\to\mathbb{R}, and let x0Ux_0\in U. The function ff is differentiable at x0x_0 if there is ana\in\mathbb{R}^{n} such that limh0|f(x0+h)f(x0)ah|h=0,\lim_{h\to0} \frac{\lvert f(x_0+h)-f(x_0)-a\cdot h \rvert}{\lVert h \rVert}=0, where the limit is over hnh\in\mathbb{R}^{n} with h0h\neq0. It is differentiable on UU if it is differentiable at every point of UU.

When n=1n=1, the vector hh and the coefficient aa are scalars, ah=aha\cdot h=ah, and h=|h|\lVert h \rVert=\lvert h \rvert. Thus Definition 2.3 is exactly the linear-approximation form of the one-variable derivative in Theorem 1.3. Only the form of the linear term has changed.

Equivalently,

f(x0+h)=f(x0)+ah+r(h),|r(h)|h0as h0.f(x_0+h)=f(x_0)+a\cdot h+r(h), \qquad \frac{\lvert r(h) \rvert}{\lVert h \rVert}\longrightarrow0 \quad\text{as }h\to0.(5)

The same rule hahh\mapsto a\cdot h must work for every way in which hh can approach zero.

Alternatively, set x=x0+hx=x_0+h. Then ff is differentiable at x0x_0 if and only if there is ana\in\mathbb{R}^{n} such that

limxx0|f(x)f(x0)a(xx0)|xx0=0.\lim_{x\to x_0} \frac{\lvert f(x)-f(x_0)-a\cdot (x-x_0) \rvert}{\lVert x-x_0 \rVert}=0.(6)

The base point x0x_0 is fixed in this limit; xx is the moving input.

Definition 2.4 (Gradient). If all partial derivatives of ff exist at x0x_0, the gradient of ff at x0x_0 is the column vector f(x0)=(f/x1(x0)f/xn(x0))n.\nabla f(x_0) =\begin{pmatrix} \partial f/\partial x_1(x_0)\\ \vdots\\ \partial f/\partial x_n(x_0) \end{pmatrix}\in\mathbb{R}^{n}.

When ff is differentiable, the vector in its linear approximation is exactly the gradient.

Theorem 2.5 (Consequences of differentiability).

Let UnU\subseteq\mathbb{R}^{n} be open and let f:Uf:U\to\mathbb{R} be differentiable at x0Ux_0\in U, with vector aa as in Definition 2.3. Then every partial derivative of ff exists at x0x_0 and a=f(x0).a=\nabla f(x_0). In particular, the vector aa is unique. Moreover, ff is continuous at x0x_0.

Proof (optional). Fix ii and set h=teih=te_i. Then h=|t|\lVert h \rVert=\lvert t \rvert and ah=taia\cdot h=ta_i, so Definition 2.3 gives |f(x0+tei)f(x0)tai||t|0.\frac{\lvert f(x_0+te_i)-f(x_0)-ta_i \rvert}{\lvert t \rvert}\longrightarrow0. Equivalently, |f(x0+tei)f(x0)tai|0,\left\lvert \frac{f(x_0+te_i)-f(x_0)}{t}-a_i\right\rvert\longrightarrow0, so the difference quotient tends to aia_i. Thus the iith partial derivative exists and equals aia_i. Repeating the argument for every ii gives a=f(x0)a=\nabla f(x_0), and because the partial derivatives are defined independently of aa, this also proves uniqueness.

For continuity, the Cauchy–Schwarz inequality gives |ah|ah0,\lvert a\cdot h \rvert\leq\lVert a \rVert\lVert h \rVert\longrightarrow0, and |r(h)|=|r(h)|hh0.\lvert r(h) \rvert =\frac{\lvert r(h) \rvert}{\lVert h \rVert}\lVert h \rVert\longrightarrow0. Thus (5) gives f(x0+h)f(x0)f(x_0+h)\to f(x_0). ◻

Example 2.6 (A linear approximation in two variables).

Let f:2f:\mathbb{R}^2\to\mathbb{R} be given by f(x1,x2)=x12x2f(x_1,x_2)=x_1^2x_2, and let x0=(1,2)x_0=(1,2)^{\top}. Expanding around x0x_0 gives f(x0+h)=(1+h1)2(2+h2)=2+4h1+h2+(2h12+2h1h2+h12h2).\begin{aligned} f(x_0+h) &=(1+h_1)^2(2+h_2)\\ &=2+4h_1+h_2 +\left(2h_1^2+2h_1h_2+h_1^2h_2\right). \end{aligned} The constant is f(x0)f(x_0) and the linear term is (4,1)h(4,1)^{\top}\cdot h. If h1\lVert h \rVert\leq1, the absolute value of the remainder is at most 2|h1|2+2|h1h2|+|h1|2|h2|5h2.2\lvert h_1 \rvert^2+2\lvert h_1h_2 \rvert+\lvert h_1 \rvert^2\lvert h_2 \rvert \leq5\lVert h \rVert^2. After division by h\lVert h \rVert, this bound tends to zero. Thus ff is differentiable at x0=(1,2)x_0=(1,2)^{\top} and f(x0)=(41).\nabla f(x_0)=\begin{pmatrix}4\\1\end{pmatrix}.

The converse of the first claim in Theorem 2.5 is false: partial derivatives can exist without a valid linear approximation. A convenient condition rules out this problem.

Definition 2.7 (C1C^1 function). Let UnU\subseteq\mathbb{R}^{n} be open. A function f:Uf:U\to\mathbb{R} is C1C^1 on UU, or continuously differentiable on UU, if every partial derivative f/xi\partial f/\partial x_i exists on UU and is continuous as a function from UU to \mathbb{R}.

Theorem 2.8 (C1C^1 implies differentiable). If f:Uf:U\to\mathbb{R} is C1C^1 on the open set UnU\subseteq\mathbb{R}^{n}, then ff is differentiable on UU and the gradient f:Un\nabla f:U\to\mathbb{R}^{n} is continuous.

We use this theorem without proof. It provides the usual way to verify differentiability: compute the partial derivatives and check that they are continuous. In particular, polynomials are C1C^1 on n\mathbb{R}^{n}, and rational functions are C1C^1 wherever their denominators are nonzero.

The implications established in this section are C1differentiablecontinuous,differentiableall partial derivatives exist.\begin{gathered} C^1\quad\Longrightarrow\quad \text{differentiable}\quad\Longrightarrow\quad\text{continuous},\\ \text{differentiable}\quad\Longrightarrow\quad \text{all partial derivatives exist}. \end{gathered} None of the converses holds in general.

The linear approximation can also be written using differential notation.

Remark 2.9 (Differential notation). If ff is differentiable at x0x_0, its differential at x0x_0 is the linear map dfx0(h):=f(x0)h=i=1nfxi(x0)hi.\mathrm{d}f_{x_0}(h) :=\nabla f(x_0)\cdot h =\sum_{i=1}^n \frac{\partial f}{\partial x_i}(x_0)h_i. Thus dfx0(h)=f(x0)h\mathrm{d}f_{x_0}(h)=\nabla f(x_0)\cdot h is exactly the linear term in f(x0+h)=f(x0)+f(x0)h+r(h).f(x_0+h)=f(x_0)+\nabla f(x_0)\cdot h+r(h). Economics texts often write the same expression as df=i=1nfxi(x0)dxi.\mathrm{d}f =\sum_{i=1}^n \frac{\partial f}{\partial x_i}(x_0)\,\mathrm{d}x_i. Here dxi\mathrm{d}x_i labels a coordinate change; it is not the product of a number dd and xix_i. We use the actual changes hih_i when applying the differential.

2.3 Directional derivatives

A partial derivative permits only one coordinate to change. A directional derivative allows the coordinates to change together in fixed proportions: for v=(v1,,vn)v=(v_1,\ldots,v_n)^{\top}, varying tt traces the line x0+tvx_0+tv through x0x_0.

Definition 2.10 (Directional derivative). Let UnU\subseteq\mathbb{R}^{n} be open, let f:Uf:U\to\mathbb{R}, and let x0Ux_0\in U. The directional derivative of ff at x0x_0 in the direction vnv\in\mathbb{R}^{n} is vf(x0)=limt0f(x0+tv)f(x0)t,\partial_v f(x_0)=\lim_{t\to0}\frac{f(x_0+tv)-f(x_0)}{t}, provided the limit exists.

Taking v=eiv=e_i gives the iith partial derivative. We do not require v=1\lVert v \rVert=1, so vv specifies both the relative changes in the coordinates and their scale. When ff is differentiable, its gradient gives every directional derivative.

Theorem 2.11 (Directional derivatives from the gradient).

Let UnU\subseteq\mathbb{R}^{n} be open and let f:Uf:U\to\mathbb{R} be differentiable at x0Ux_0\in U. Then, for every vnv\in\mathbb{R}^{n}, the directional derivative exists and vf(x0)=f(x0)v=i=1nfxi(x0)vi.\partial_v f(x_0)=\nabla f(x_0)\cdot v =\sum_{i=1}^n\frac{\partial f}{\partial x_i}(x_0)v_i.

Proof (optional). If v=0v=0, the difference quotient is zero for every t0t\neq0, so the result holds. If v0v\neq0, substitute h=tvh=tv into (5) and use a=f(x0)a=\nabla f(x_0): f(x0+tv)f(x0)t=f(x0)v+r(tv)t.\frac{f(x_0+tv)-f(x_0)}{t} =\nabla f(x_0)\cdot v+\frac{r(tv)}{t}. Moreover, |r(tv)t|=v|r(tv)|tv0.\left\lvert \frac{r(tv)}{t}\right\rvert =\lVert v \rVert\frac{\lvert r(tv) \rvert}{\lVert tv \rVert} \longrightarrow0. Taking the limit proves the first equality; the second writes out the inner product coordinate by coordinate. ◻

2.4 Steepest increase

To compare directions independently of scale, we restrict vv to unit vectors and ask which one gives the largest directional derivative.

Theorem 2.12 (Steepest increase). Let UnU\subseteq\mathbb{R}^{n} be open, let f:Uf:U\to\mathbb{R} be differentiable at x0Ux_0\in U, and suppose f(x0)0\nabla f(x_0)\neq0. Define the unit vector v*=f(x0)f(x0).v^*=\frac{\nabla f(x_0)}{\lVert \nabla f(x_0) \rVert}. Among all unit vectors vnv\in\mathbb{R}^{n}, the directional derivative vf(x0)\partial_v f(x_0) has its unique maximum at v=v*v=v^* and its unique minimum at v=v*v=-v^*. The corresponding values are v*f(x0)=f(x0),v*f(x0)=f(x0).\partial_{v^*}f(x_0)=\lVert \nabla f(x_0) \rVert, \qquad \partial_{-v^*}f(x_0)=-\lVert \nabla f(x_0) \rVert.

Proof (optional). Write g=f(x0)g=\nabla f(x_0). For every unit vector vv, Theorem 2.11 and the Cauchy–Schwarz inequality give vf(x0)=gv|gv|gv=g.\partial_v f(x_0)=g\cdot v \leq\lvert g\cdot v \rvert \leq\lVert g \rVert\lVert v \rVert =\lVert g \rVert. The unit vector v*=g/gv^*=g/\lVert g \rVert satisfies gv*=gg\cdot v^*=\lVert g \rVert, so it attains the bound. If a unit vector vv also attains it, then gv=gg\cdot v=\lVert g \rVert and ggv2=2g(ggv)=0.\lVert g-\lVert g \rVert v \rVert^2 =2\lVert g \rVert\left(\lVert g \rVert-g\cdot v\right)=0. Hence v=g/g=v*v=g/\lVert g \rVert=v^*. Applying the maximum result to f-f gives the minimum and its unique minimizer. ◻

Thus the gradient points in the direction of steepest increase, and its norm is the largest rate of increase per unit change. By Theorem 2.11, vf(x0)=0\partial_v f(x_0)=0 exactly when f(x0)v=0\nabla f(x_0)\cdot v=0. In this case, vv and f(x0)\nabla f(x_0) are orthogonal. If f(x0)=0\nabla f(x_0)=0, every directional derivative is zero, so first-order information does not select a direction of increase or decrease.

This result underlies gradient descent, an algorithm used to train many machine-learning and AI models. If ff is the loss function and xkx_k is the current parameter vector, gradient descent chooses a step size αk>0\alpha_k>0 and updates xk+1=xkαkf(xk).x_{k+1}=x_k-\alpha_k\nabla f(x_k). The negative gradient gives the direction of steepest local decrease, while αk\alpha_k determines the size of the step.

3 Vector-valued functions

3.1 Jacobians

A map F:UnmF:U\subseteq\mathbb{R}^{n}\to\mathbb{R}^m has mm outputs. Its linear approximation is therefore a linear map from n\mathbb{R}^{n} to m\mathbb{R}^m, represented by an m×nm\times n matrix.

Definition 3.1 (Jacobian). Let UnU\subseteq\mathbb{R}^{n} be open, let F:UmF:U\to\mathbb{R}^m, and let x0Ux_0\in U. The map FF is differentiable at x0x_0 if there is an m×nm\times n matrix AA such that limh0F(x0+h)F(x0)Ahh=0,\lim_{h\to0} \frac{\lVert F(x_0+h)-F(x_0)-Ah \rVert}{\lVert h \rVert}=0, where the limit is over hnh\in\mathbb{R}^{n} with h0h\neq0. The matrix AA is the derivative, or Jacobian, of FF at x0x_0, written DF(x0)\mathrm{D}F(x_0). If F=(F1,,Fm)F=(F_1,\ldots,F_m)^{\top}, the scalar-valued maps Fi:UF_i:U\to\mathbb{R} are the component functions of FF. The map FF is C1C^1 on UU if every component FiF_i is C1C^1 on UU.

Equivalently,

F(x0+h)=F(x0)+DF(x0)h+r(h),r(h)h0as h0.F(x_0+h)=F(x_0)+\mathrm{D}F(x_0)h+r(h), \qquad \frac{\lVert r(h) \rVert}{\lVert h \rVert}\longrightarrow0 \quad\text{as }h\to0.(7)

The linear term has dimensions DF(x0)h:(m×n)(n×1)=m×1,\mathrm{D}F(x_0)h: \qquad (m\times n)(n\times1)=m\times1, so each row corresponds to an output and each column to an input.

With the moving input x=x0+hx=x_0+h, the same definition is

limxx0F(x)F(x0)DF(x0)(xx0)xx0=0.\lim_{x\to x_0} \frac{\lVert F(x)-F(x_0)-\mathrm{D}F(x_0)(x-x_0) \rVert}{\lVert x-x_0 \rVert}=0.(8)

Theorem 3.2 (Entries of the Jacobian). The map F:UmF:U\to\mathbb{R}^m is differentiable at x0x_0 if and only if every component FiF_i is differentiable at x0x_0. In that case the Jacobian is unique and DF(x0)=(F1x1(x0)F1xn(x0)Fmx1(x0)Fmxn(x0)).\mathrm{D}F(x_0) =\begin{pmatrix} \dfrac{\partial F_1}{\partial x_1}(x_0) & \cdots & \dfrac{\partial F_1}{\partial x_n}(x_0)\\[2ex] \vdots & \ddots & \vdots\\[1ex] \dfrac{\partial F_m}{\partial x_1}(x_0) & \cdots & \dfrac{\partial F_m}{\partial x_n}(x_0) \end{pmatrix}. Thus the iith row of DF(x0)\mathrm{D}F(x_0) is Fi(x0)\nabla F_i(x_0)^{\top}.

Proof (optional). Suppose first that FF is differentiable with derivative AA, and let r(h)=F(x0+h)F(x0)Ahr(h)=F(x_0+h)-F(x_0)-Ah. Since the absolute value of each coordinate of r(h)r(h) is at most r(h)\lVert r(h) \rVert, |Fi(x0+h)Fi(x0)j=1nAijhj|h0.\frac{\lvert F_i(x_0+h)-F_i(x_0)-\sum_{j=1}^n A_{ij}h_j \rvert} {\lVert h \rVert} \longrightarrow0. Thus FiF_i is differentiable, and Theorem 2.5 gives (Ai1,,Ain)=Fi(x0).(A_{i1},\ldots,A_{in})^{\top}=\nabla F_i(x_0).

Conversely, suppose each FiF_i is differentiable, and define A=(Aij)A=(A_{ij}) by Aij=Fixj(x0).A_{ij}=\frac{\partial F_i}{\partial x_j}(x_0). If ri(h)r_i(h) is the approximation error for component ii, then |ri(h)|/h0\lvert r_i(h) \rvert/\lVert h \rVert\to0. Because there are only finitely many components, F(x0+h)F(x0)Ahh=(i=1m(ri(h)h)2)1/20.\frac{\lVert F(x_0+h)-F(x_0)-Ah \rVert}{\lVert h \rVert} =\left(\sum_{i=1}^m \left(\frac{r_i(h)}{\lVert h \rVert}\right)^2\right)^{1/2} \longrightarrow0. Thus FF is differentiable with derivative AA. The first part identifies every entry of any possible derivative, so the Jacobian is unique. ◻

It follows from Theorem 2.8 and Theorem 3.2 that every C1C^1 map is differentiable.

Example 3.3 (A 2×32\times3 Jacobian).

Let F:32F:\mathbb{R}^3\to\mathbb{R}^2 be given by F(x,y,z)=(x2yy+3z).F(x,y,z)=\begin{pmatrix}x^2y\\y+3z\end{pmatrix}. Then DF(x,y,z)=(2xyx20013),DF(x0)=(410013)at x0=(1,2,0).\mathrm{D}F(x,y,z) =\begin{pmatrix} 2xy & x^2 & 0\\ 0 & 1 & 3 \end{pmatrix}, \qquad \mathrm{D}F(x_0) =\begin{pmatrix} 4 & 1 & 0\\ 0 & 1 & 3 \end{pmatrix} \quad\text{at }x_0=(1,2,0)^{\top}. The two rows correspond to the two outputs, and the three columns correspond to the inputs x,y,zx,y,z.

For a scalar-valued function f:Uf:U\to\mathbb{R}, the Jacobian is a 1×n1\times n row, whereas the gradient is an n×1n\times1 column:

Df(x0)=f(x0).\mathrm{D}f(x_0)=\nabla f(x_0)^{\top}.(9)

Consequently, Df(x0)h=f(x0)h\mathrm{D}f(x_0)h=\nabla f(x_0)\cdot h. The gradient is convenient for geometric statements, while the Jacobian is convenient for composition. When n=1n=1, both contain the ordinary derivative f(x0)f'(x_0).

3.2 The multivariable chain rule

The one-variable chain rule says that derivatives multiply. The same rule holds for functions between Euclidean spaces, with matrix multiplication in place of scalar multiplication.

Theorem 3.4 (Chain rule). Let UnU\subseteq\mathbb{R}^{n} and VmV\subseteq\mathbb{R}^m be open. Let G:UmG:U\to\mathbb{R}^m satisfy G(U)VG(U)\subseteq V, and let F:VpF:V\to\mathbb{R}^p. If GG is differentiable at x0Ux_0\in U and FF is differentiable at G(x0)G(x_0), then FGF\circ G is differentiable at x0x_0 and D(FG)(x0)=DF(G(x0))DG(x0).\mathrm{D}(F\circ G)(x_0) =\mathrm{D}F(G(x_0))\,\mathrm{D}G(x_0).

We use this theorem without proof. Using the row description from Theorem 3.2, the product is D(FG)(x0)=(F1(G(x0))Fp(G(x0)))p×m(G1(x0)Gm(x0))m×n.\mathrm{D}(F\circ G)(x_0) = \underbrace{ \begin{pmatrix} \nabla F_1(G(x_0))^{\top}\\ \vdots\\ \nabla F_p(G(x_0))^{\top} \end{pmatrix}}_{p\times m} \underbrace{ \begin{pmatrix} \nabla G_1(x_0)^{\top}\\ \vdots\\ \nabla G_m(x_0)^{\top} \end{pmatrix}}_{m\times n}. The product is p×np\times n, the required size for the derivative of FG:UpF\circ G:U\to\mathbb{R}^p. The outer rows are evaluated at G(x0)G(x_0), while the inner rows are evaluated at x0x_0. When n=m=p=1n=m=p=1, the formula reduces to the one-variable chain rule.

A useful special case follows a curve through the domain of a real-valued function.

Corollary 3.5 (Derivative along a curve). Let VmV\subseteq\mathbb{R}^m be open, let γ:IV\gamma:I\to V be differentiable at t0It_0\in I, where II\subseteq\mathbb{R} is an open interval, and let f:Vf:V\to\mathbb{R} be differentiable at γ(t0)\gamma(t_0). Then (fγ)(t0)=f(γ(t0))γ(t0)=i=1mfxi(γ(t0))γi(t0).(f\circ\gamma)'(t_0) =\nabla f(\gamma(t_0))\cdot \gamma'(t_0) =\sum_{i=1}^m \frac{\partial f}{\partial x_i}(\gamma(t_0))\gamma_i'(t_0).

Indeed, (9) and the chain rule give Df(γ(t0))Dγ(t0)=f(γ(t0))γ(t0)\mathrm{D}f(\gamma(t_0))\mathrm{D}\gamma(t_0) =\nabla f(\gamma(t_0))^{\top}\gamma'(t_0).

3.3 A worked chain rule

Example 3.6 (A vector-valued composition). Define G:3,G(t)=(1+t23+2t),F:32,F(u,v,w)=(uwv+w2).G:\mathbb{R}\to\mathbb{R}^3, \qquad G(t)=\begin{pmatrix}1+t\\2\\3+2t\end{pmatrix}, \qquad F:\mathbb{R}^3\to\mathbb{R}^2, \qquad F(u,v,w)=\begin{pmatrix}uw\\v+w^2\end{pmatrix}. To find the derivative of FGF\circ G at t=0t=0, compute DG(t)=G(t)=(102),DF(u,v,w)=(w0u012w).\mathrm{D}G(t)=G'(t)=\begin{pmatrix}1\\0\\2\end{pmatrix}, \qquad \mathrm{D}F(u,v,w) =\begin{pmatrix} w & 0 & u\\ 0 & 1 & 2w \end{pmatrix}. Because G(0)=(1,2,3)G(0)=(1,2,3)^{\top}, the chain rule gives D(FG)(0)=DF(G(0))DG(0)=(301016)(102)=(512).\begin{aligned} \mathrm{D}(F\circ G)(0) &=\mathrm{D}F(G(0))\,\mathrm{D}G(0)\\ &=\begin{pmatrix} 3 & 0 & 1\\ 0 & 1 & 6 \end{pmatrix} \begin{pmatrix}1\\0\\2\end{pmatrix} =\begin{pmatrix}5\\12\end{pmatrix}. \end{aligned} The dimensions are (2×3)(3×1)=2×1(2\times3)(3\times1)=2\times1, as required for a map from \mathbb{R} to 2\mathbb{R}^2.

For a direct check, (FG)(t)=((1+t)(3+2t)2+(3+2t)2)=(3+5t+2t211+12t+4t2).(F\circ G)(t) =\begin{pmatrix} (1+t)(3+2t)\\ 2+(3+2t)^2 \end{pmatrix} =\begin{pmatrix} 3+5t+2t^2\\ 11+12t+4t^2 \end{pmatrix}. Differentiating the components at 00 again gives (5,12)(5,12)^{\top}.