4.1 Differentiability and Continuity

Let \(S\) be a subset of \(\mathbb {R}\), let \(f: S\longrightarrow \mathbb {R}\), and let \(x_0 \in S\). The difference quotient of \(f\) at \(x_0\) is the function \[g(x) = \frac {f(x) - f(x_0)}{x - x_0}, \qquad x\in S,\ x\neq x_0 .\]

(a)
If \(x_0\) is an interior point of \(S\), we say that \(f\) is differentiable at \(x_0\) if \(\lim _{x\rightarrow x_0} g(x)\) exists (and is finite).
(b)
If \(x_0\) is the left end point of an interval \(S\), we say that \(f\) is differentiable at \(x_0\) if the right-hand limit \(\lim _{x\rightarrow x_0^+} g(x)\) exists.
(c)
If \(x_0\) is the right end point of an interval \(S\), we say that \(f\) is differentiable at \(x_0\) if the left-hand limit \(\lim _{x\rightarrow x_0^-} g(x)\) exists.

If \(f\) is differentiable at \(x_0\), the value of this limit is called the derivative of \(f\) at \(x_0\) and is denoted by \(f'(x_0)\). At an interior point, for example, \[f'(x_0) = \lim _{x\rightarrow x_0} \frac {f(x) - f(x_0)}{x - x_0} = \lim _{h\rightarrow 0} \frac {f(x_0 + h) - f(x_0)}{h} .\]

Definition 4.1.1. Let \(S\) be a subset of \(\mathbb {R}\) and \(f: S\longrightarrow \mathbb {R}\). We say that \(f\) is differentiable on \(S\) if \(f\) is differentiable at every point of \(S\).

Theorem 4.1.2. Let \(S\subseteq \mathbb {R}\), \(f: S\longrightarrow \mathbb {R}\) and \(x_0\in S\). If \(f\) is differentiable at \(x_0\), then \(f\) is continuous at \(x_0\).

Proof. For \(x\neq x_0\) we can write \(f(x) - f(x_0) = \frac {f(x) - f(x_0)}{x - x_0}\cdot (x - x_0)\). By the product rule for limits, \[\lim _{x\rightarrow x_0}\bigl (f(x) - f(x_0)\bigr ) = \lim _{x\rightarrow x_0} \frac {f(x) - f(x_0)}{x - x_0}\cdot \lim _{x\rightarrow x_0}(x - x_0) = f'(x_0)\cdot 0 = 0 .\] Hence \(\lim _{x\rightarrow x_0} f(x) = f(x_0)\), and \(f\) is continuous at \(x_0\). (At an end point, use the one-sided limit.)

The converse is false: a continuous function need not be differentiable, as the next example shows. □

Example 4.1.3. The function \(f(x) = |x|\) is continuous at \(0\) but not differentiable there.

Solution. Since \(\bigl ||x| - 0\bigr | = |x|\), \(f(x)\longrightarrow f(0)\) as \(x\longrightarrow 0\), so \(f\) is continuous at \(0\). For the derivative, \(\frac {f(x) - f(0)}{x - 0} = \frac {x}{x}= 1\) when \(x> 0\), and \(\frac {-x}{x} = -1\) when \(x < 0\). Hence \[\lim _{x\rightarrow 0^+} \frac {f(x) - f(0)}{x - 0} = 1 \qquad \text {but}\qquad \lim _{x\rightarrow 0^-}\frac {f(x) - f(0)}{x - 0} = -1 .\] Since \(0\) is an interior point of \(\mathbb {R}\) and the one-sided limits differ, the difference quotient has no limit at \(0\), and \(f\) is not differentiable at the origin.

Theorem 4.1.4. Let \(f, g: S\longrightarrow \mathbb {R}\), and let \(c\) be an interior point of \(S\). If \(f\) and \(g\) are differentiable at \(c\), then

(a)
\(f+ g\) is differentiable at \(c\) and \((f + g)'(c) = f'(c) + g'(c)\);
(b)
for every real number \(a\), \(af\) is differentiable at \(c\) and \((af)'(c) = a f'(c)\);
(c)
\(fg\) is differentiable at \(c\) and \((fg)'(c) = g(c) f'(c) + f(c) g'(c)\);
(d)
if \(g(c)\neq 0\), then \(\frac {1}{g}\) is differentiable at \(c\) and \(\left (\frac {1}{g}\right )'(c) = -\frac {g'(c)}{g(c)^2}\);
(e)
if \(g(c)\neq 0\), then \(\frac {f}{g}\) is differentiable at \(c\) and \(\left (\frac {f}{g}\right )'(c) = \frac {g(c) f'(c) - f(c) g'(c)}{g(c)^2}\).

Proof. By the previous theorem \(f\) and \(g\) are continuous at \(c\), so \(f(x)\longrightarrow f(c)\) and \(g(x)\longrightarrow g(c)\) as \(x\longrightarrow c\). All limits below are as \(x\longrightarrow c\).

(a) \(\displaystyle \frac {(f+g)(x) - (f+g)(c)}{x - c} = \frac {f(x) - f(c)}{x - c} + \frac {g(x) - g(c)}{x - c}\longrightarrow f'(c) + g'(c)\).

(b) \(\displaystyle \frac {af(x) - af(c)}{x - c} = a\,\frac {f(x) - f(c)}{x - c}\longrightarrow af'(c)\).

(c) Adding and subtracting \(g(x)f(c)\), \[\frac {f(x) g(x) - f(c) g(c)}{x - c} = g(x)\,\frac {f(x) - f(c)}{x - c} + f(c)\,\frac {g(x) - g(c)}{x - c}\longrightarrow g(c) f'(c) + f(c) g'(c) .\]

(d) Since \(g(c)\neq 0\) and \(g\) is continuous at \(c\), \(g(x)\neq 0\) near \(c\) (Theorem 2.3.3). For such \(x\), \[\frac {\frac {1}{g(x)} - \frac {1}{g(c)}}{x - c} = -\frac {1}{g(x) g(c)}\cdot \frac {g(x) - g(c)}{x - c}\longrightarrow -\frac {g'(c)}{g(c)^2} .\]

(e) Write \(\frac {f}{g} = f\cdot \frac {1}{g}\) and use (c) and (d): \[\left (\frac {f}{g}\right )'(c) = \frac {f'(c)}{g(c)} - \frac {f(c) g'(c)}{g(c)^2} = \frac {g(c) f'(c) - f(c) g'(c)}{g(c)^2} .\] There are analogous results for one-sided derivatives at end points. □

Remark. Let \(c\) be an interior point of \(S\). Then \(f\) is differentiable at \(c\) if and only if there is a function \(L: S\longrightarrow \mathbb {R}\), continuous at \(c\), such that \[f(x) - f(c) = L(x)\,(x - c)\qquad \text {for all } x\in S,\] and in that case \(f'(c) = L(c)\). Indeed, if \(f'(c)\) exists, put \(L(x) = \frac {f(x) - f(c)}{x - c}\) for \(x\neq c\) and \(L(c) = f'(c)\); then \(L\) is continuous at \(c\) by the definition of the derivative. Conversely, if such an \(L\) exists, then for \(x\neq c\) the difference quotient equals \(L(x)\), which tends to \(L(c)\). This form of the definition (due to Carathéodory) is convenient for the chain rule.

Theorem 4.1.5 (Chain Rule). Let \(f: S\longrightarrow \mathbb {R}\), where \(S\) is a neighbourhood of \(c\in \mathbb {R}\), and let \(g: T\longrightarrow \mathbb {R}\), where \(T\) is a neighbourhood of \(f(c)\), with \(f(S)\subseteq T\), so that the composition \(g\circ f: S\longrightarrow \mathbb {R}\) is defined. If \(f\) is differentiable at \(c\) and \(g\) is differentiable at \(f(c)\), then \(g\circ f\) is differentiable at \(c\) and \[(g\circ f)'(c) = g'(f(c))\, f'(c) .\]

Proof. Write \(h = g\circ f\). By the remark, there exists a function \(L: S\longrightarrow \mathbb {R}\), continuous at \(c\), such that \begin {equation} \label {eq:chainL} f(x) - f(c) = L(x)\, (x - c) \quad \text {for all } x\in S, \end {equation} and \(L(c) = f'(c)\). Similarly, there is a function \(K: T\longrightarrow \mathbb {R}\), continuous at \(f(c)\), with \(K(f(c)) = g'(f(c))\) and \begin {equation} \label {eq:chainK} g(y) - g(f(c)) = K(y)\, (y - f(c)) \quad \text {for all } y \in T. \end {equation} If \(x\in S\) then \(f(x)\in T\); putting \(y = f(x)\) in (4.2) and using (4.1) gives \[h(x) - h(c) = K(f(x))\, \bigl (f(x) - f(c)\bigr ) = K(f(x))\, L(x)\, (x - c) .\] The function \((K\circ f) L\) is continuous at \(c\), because \(f\) is continuous at \(c\) and \(K\) is continuous at \(f(c)\). By the remark, \(h\) is differentiable at \(c\) and \[h'(c) = K(f(c))\, L(c) = g'(f(c))\, f'(c) .\] □

Example 4.1.6. Let \[f(x) = \begin {cases} x \sin \frac {1}{x}, & x\neq 0,\\ 0, & x = 0, \end {cases} \qquad g(x) = \begin {cases} x^2 \sin \frac {1}{x}, & x\neq 0,\\ 0, & x = 0. \end {cases} \] Determine whether \(f\) and \(g\) are (a) continuous, (b) differentiable, and find their derivatives where they exist.

Solution.

(a)
Both functions are continuous at every \(x\neq 0\), as products and composites of continuous functions. At the origin, \(|f(x) - f(0)| = \left |x \sin \frac {1}{x}\right | \leq |x|\longrightarrow 0\), so \(f\) is continuous at \(0\). Since \(g(x) = x f(x)\), \(g\) is continuous everywhere too.
(b)
For \(x\neq 0\), the chain rule gives \(\frac {d}{dx}\sin \frac {1}{x} = -\frac {1}{x^2} \cos \frac {1}{x}\), and the product rule gives \[f'(x) = \sin \frac {1}{x} - \frac {1}{x} \cos \frac {1}{x}, \qquad g'(x) = 2x \sin \frac {1}{x} - \cos \frac {1}{x} \qquad (x\neq 0).\] At the origin, \[\frac {f(x) - f(0)}{x - 0} = \sin \frac {1}{x},\] which has no limit as \(x\longrightarrow 0\) (see the examples on limits in Chapter 2). So \(f\) is not differentiable at \(0\). On the other hand \[\frac {g(x) - g(0)}{x - 0} = x \sin \frac {1}{x}\longrightarrow 0,\] so \(g\) is differentiable at the origin with \(g'(0) = 0\). Note that \(g'(x)\) has no limit as \(x\longrightarrow 0\), because of the term \(\cos \frac {1}{x}\): \(g\) is differentiable everywhere, but \(g'\) is not continuous at \(0\).

Definition 4.1.7. Let \(f\) be defined on \([a,b]\). Suppose that \(f\) is differentiable at every point of \((a,b)\), and that the one-sided limits \[f'(a) = \lim _{x\rightarrow a^+} \frac {f(x) - f(a)}{x - a}\qquad \text {and}\qquad f'(b) = \lim _{x\rightarrow b^-} \frac {f(x) - f(b)}{x - b}\] both exist and are finite. Then \(f\) is said to be differentiable on the closed interval \([a,b]\).

Example 4.1.8. Find the derivatives of \(f(x) = x^n\) (\(n\in \mathbb {N}\)) and \(g(x) = \sqrt {x}\) (\(x>0\)) from the definition.

Solution. For \(x^n\), use \(x^n - c^n = (x-c)(x^{n-1} + x^{n-2}c + \dots + c^{n-1})\): \[\frac {x^n - c^n}{x - c} = x^{n-1} + x^{n-2}c + \dots + c^{n-1}\longrightarrow nc^{n-1}\quad (x\rightarrow c),\] since each of the \(n\) terms tends to \(c^{n-1}\). So \(f'(c) = nc^{n-1}\).

For \(\sqrt {x}\) at \(c>0\), multiply by the conjugate: \[\frac {\sqrt {x} - \sqrt {c}}{x - c} = \frac {1}{\sqrt {x}+\sqrt {c}}\longrightarrow \frac {1}{2\sqrt {c}} .\] At \(c = 0\) the one-sided difference quotient \(\frac {\sqrt {x}}{x} = \frac {1}{\sqrt {x}}\longrightarrow \infty \), so \(\sqrt {x}\) is not differentiable at \(0\): its graph has a vertical tangent there.

Example 4.1.9. Show that \(f(x) = x|x|\) is differentiable on \(\mathbb {R}\) with \(f'(x) = 2|x|\), but that \(f'\) is not differentiable at \(0\).

Solution. For \(x>0\), \(f(x) = x^2\) and \(f'(x) = 2x\); for \(x<0\), \(f(x) = -x^2\) and \(f'(x) = -2x\). At \(0\), \[\frac {f(x) - f(0)}{x - 0} = |x|\longrightarrow 0,\] so \(f'(0) = 0\). In all cases \(f'(x) = 2|x|\). By the example on \(|x|\), \(f'\) is continuous but not differentiable at \(0\). So \(f\) is differentiable once, but not twice, at the origin.

Example 4.1.10. Use the chain rule and the quotient rule to differentiate \(h(x) = \sin \left (\frac {x}{1+x^2}\right )\), and find the points where \(h'(x) = 0\).

Solution. Let \(u(x) = \frac {x}{1+x^2}\). By the quotient rule, \[u'(x) = \frac {(1+x^2)\cdot 1 - x\cdot 2x}{(1+x^2)^2} = \frac {1-x^2}{(1+x^2)^2},\] and by the chain rule \(h'(x) = \cos (u(x))\,u'(x)\). Since \(|u(x)|\leq \frac {1}{2}<\frac {\pi }{2}\) (because \(1+x^2\geq 2|x|\)), the factor \(\cos u(x)\) is never \(0\). So \(h'(x) = 0\) exactly when \(1 - x^2 = 0\), that is, at \(x = \pm 1\).

Questions on this section

Stuck on something here? Ask below and it stays attached to this topic.