5.1 Differentiable functions: definitions and basic examples

Definition of differentiability

Geometrically, differentiation concerns the gradient, or slope, of a graph of a function. This notion is easiest to define when the graph is just a straight line.

Example 5.1.

Let f:f\colon\mathbb{R}\to\mathbb{R} be the function f(x):=x/2+1f(x):=x/2+1 for all xx\in\mathbb{R}. If we pick two distinct points, say aa and a+ha+h for aa\in\mathbb{R} and h{0}h\in\mathbb{R}\setminus\{0\}, then

f(a+h)f(a)=a+h2+1a21=h2f(a+h)-f(a)=\frac{a+h}{2}+1-\frac{a}{2}-1=\frac{h}{2}

is the vertical change of the function between aa and a+ha+h and h=(a+h)ah=(a+h)-a is the horizontal change: see Figure 5.3. The gradient of ff is then defined as the ratio of the vertical change and the horizontal change:

f(a+h)f(a)h=h2h=12.\frac{f(a+h)-f(a)}{h}=\frac{h}{2h}=\frac{1}{2}.

Note that we get the same value 1/21/2 no matter which values of aa and hh we choose. This is because the graph of ff is a straight line, so has constant slope everywhere.

Figure 5.3: Computing the gradient of the line f(x):=x/2+1f(x):=x/2+1.

If the graph of our function is curved, then the gradient will no longer be a constant value. In this case, when we talk about the gradient of ff at a point aa, what we really wish to describe is the gradient of the tangent line to the function at the point aa (if such a tangent line exists). But what really is a ‘tangent line’? How do we define it?

For fixed aa\in\mathbb{R} and h{0}h\in\mathbb{R}\setminus\{0\}, we can still consider the difference quotient

(5.1) (5.1) f(a+h)f(a)h.\frac{f(a+h)-f(a)}{h}.

This corresponds to the gradient of the secant line passing through the points (a,f(a))(a,f(a)) and (a+h,f(a+h))(a+h,f(a+h)) on the graph of ff: see Figure 5.4.

Figure 5.4: The gradient of the secant line through (a,f(a))(a,f(a)) and (a+h,f(a+h))(a+h,f(a+h)). The tangent line to the curve at (a,f(a))(a,f(a)) is shown as a dashed purple line.

In general, the secant line doesn’t look very much like a tangent line; indeed, this is the case in Figure 5.4, where we see the secant line is quite far from the tangent line. However, if hh is very small, then we hope that the secant line gives a reasonable approximation to a tangent line at aa. Moreover, as hh gets smaller and smaller, we can hope for a better and better approximation. This idea is illustrated in Figure 5.5. In this case, as hh gets smaller and smaller, the difference quotient (5.1) gives a better and better approximation to the slope or gradient of the function at aa. This is the intuition behind the definition of the derivative.

Definition 5.2.

Let II\subseteq\mathbb{R} be an open interval.

  1. 1

    A function f:If\colon I\to\mathbb{R} is said to be differentiable at aIa\in I if

    (5.2) (5.2) f(a):=limh0f(a+h)f(a)hf^{\prime}(a):=\lim_{h\to 0}\frac{f(a+h)-f(a)}{h}

    exists. The number f(a)f^{\prime}(a) is called the derivative of ff at aa.

  2. 2

    We say ff is differentiable if it is differentiable at all points aIa\in I. In this case, we define the derivative of ff to be the function f:If^{\prime}\colon I\to\mathbb{R} mapping aa to f(a)f^{\prime}(a) for all aIa\in I.

Figure 5.5: The definition of the derivative. We consider the secant line passing through (a,f(a))(a,f(a)) and (a+h,f(a+h))(a+h,f(a+h)) for smaller and smaller values of hh.
Remark 5.3.

In the definition of the derivative, it is sometimes convenient to change variables, replacing a+ha+h with xx. In particular, we may equivalently write (5.2) as

f(a):=limxaf(x)f(a)xa.f^{\prime}(a):=\lim_{x\to a}\frac{f(x)-f(a)}{x-a}.

By generalising the computation from Example 5.1, we can show that the definition of a derivative agrees with our usual notion of gradient or slope when the graph of the function is a straight line.

Exercise 5.4.

Let mm, cc\in\mathbb{R} and consider the linear function f:f\colon\mathbb{R}\to\mathbb{R} given by f(x):=mx+cf(x):=mx+c for all xx\in\mathbb{R}. Arguing from the definition, show that ff is differentiable and f(a)=mf^{\prime}(a)=m for all aa\in\mathbb{R}.

The motivation for the definition of a derivative relied on our intuition about tangent lines. However, so far we still have not given a precise definition of a ‘tangent line’. Now that we have a formal definition of a derivative, we can address this.

Definition 5.5.

Let II\subseteq\mathbb{R} be an open interval and f:If\colon I\to\mathbb{R} be differentiable at aIa\in I. We define the tangent line to the graph of ff at aa to be the line through (a,f(a))(a,f(a)) with slope f(a)f^{\prime}(a).

The next example illustrates the derivative in a case where the graph of the function is curved.

Example 5.6.

Consider the function p2:p_{2}\colon\mathbb{R}\to\mathbb{R} given by p2(x):=x2p_{2}(x):=x^{2} for all xx\in\mathbb{R}. Then p2p_{2} is differentiable and p2(a)=2ap_{2}^{\prime}(a)=2a for all aa\in\mathbb{R}.

You are no doubt aware of this fact from earlier courses, but our goal here is to justify the value of the derivative by arguing from the definition. Reasoning in this way gives a rigorous foundation for why the various derivative formulæ  you’ve encountered hold, exploiting the tools that we have built up so far in the course.

Proof.

Fix aa\in\mathbb{R} and h{0}h\in\mathbb{R}\setminus\{0\}. By expanding out the square, we see that

p2(a+h)p2(a)h=(a+h)2a2h=a2+2ah+h2a2h=2ah+h2h=2a+h.\frac{p_{2}(a+h)-p_{2}(a)}{h}=\frac{(a+h)^{2}-a^{2}}{h}=\frac{a^{2}+2ah+h^{2}-% a^{2}}{h}=\frac{2ah+h^{2}}{h}=2a+h.

Taking the limit as h0h\to 0, we therefore see that

limh0p2(a+h)p2(a)h=2a\lim_{h\to 0}\frac{p_{2}(a+h)-p_{2}(a)}{h}=2a

and so p2p_{2} is differentiable at aa and p2(a)=2ap_{2}^{\prime}(a)=2a, as required. ∎

It is equally important to identify functions which fail to be differentiable. The following functions are classic examples of functions which are continuous but are not differentiable.

Example 5.7.

The continuous function f:f\colon\mathbb{R}\to\mathbb{R} given by f(x):=|x|f(x):=|x| (shown as f1f_{1} in Figure 5.1) is not differentiable at 0.

Proof.

The one-sided limits of the difference quotient are given by

limh0+f(0+h)f(0)h=limh0+hh=1,limh0f(0+h)f(0)h=limh0hh=1.\lim_{h\to 0_{+}}\frac{f(0+h)-f(0)}{h}=\lim_{h\to 0_{+}}\frac{h}{h}=1,\qquad% \lim_{h\to 0_{-}}\frac{f(0+h)-f(0)}{h}=\lim_{h\to 0_{-}}-\frac{h}{h}=-1.

Since the one-sided limits do not agree, we know from Exercise 4.72 that limh0f(0+h)f(0)h\lim_{h\to 0}\frac{f(0+h)-f(0)}{h} does not exist. Hence, ff is not differentiable at 0. ∎

Example 5.8.

The continuous function f:f\colon\mathbb{R}\to\mathbb{R} given by f(x):=|x|f(x):=\sqrt{|x|} (shown as f3f_{3} in Figure 5.1) is not differentiable at 0.

Proof.

For h{0}h\in\mathbb{R}\setminus\{0\}, the difference quotient is given by

f(0+h)f(0)h=h1/2h=h1/2.\frac{f(0+h)-f(0)}{h}=\frac{h^{1/2}}{h}=h^{-1/2}.

For any δ>0\delta>0, the right-hand expression is unbounded on the interval (0,δ)(0,\delta), and so limh0f(0+h)f(0)h\lim_{h\to 0}\frac{f(0+h)-f(0)}{h} does not exist by Exercise 4.48 ii). Hence, ff is not differentiable at 0. ∎

Exercise 5.9.

Show that the function f:f\colon\mathbb{R}\to\mathbb{R} given by f(x):={x2if x0xif x>0f(x):=\begin{cases}x^{2}&\text{if }x\leq 0\\ x&\text{if }x>0\end{cases} (shown as f2f_{2} in Figure 5.1) is not differentiable at 0.

Remark 5.10.

There are different ways to denote derivatives, some of which you will likely have come across. For instance, it is common to use the notation

f=f(1)=dfdx=Dxff^{\prime}=f^{(1)}=\frac{\mathrm{d}f}{\mathrm{d}x}=D_{x}f

interchangeably. We shall primarily use ff^{\prime} in this course.

Further examples of differentiable functions

We shall consider some more sophisticated examples of differentiable functions and their derivatives. Many or all of these formulæ  will be familiar to you, but as before the onus is on developing a rigorous understanding of why the formulæ  hold by arguing from the definition. We want to get ‘under the hood’ and really understand how and why derivatives work! Our first example generalises Example 5.6.

Example 5.11 (Monomials).

For all kk\in\mathbb{N}, the function pk:p_{k}\colon\mathbb{R}\to\mathbb{R} given by pk(x):=xkp_{k}(x):=x^{k} for all xx\in\mathbb{R} is differentiable. Moreover, pk(a)=kak1p_{k}^{\prime}(a)=ka^{k-1} for all aa\in\mathbb{R}.

Note that the k=2k=2 case corresponds to Example 5.6; however, here we shall use a slightly different argument to that of Example 5.6, since it will later help us to study the exponential function.

Proof.

Fix aa\in\mathbb{R} and hh\in\mathbb{R} with 0<|h|10<|h|\leq 1. We apply the binomial theorem to write

pk(a+h)pk(a)=j=0k(kj)akjhjak=kak1h+j=2k(kj)akjhj,p_{k}(a+h)-p_{k}(a)=\sum_{j=0}^{k}\binom{k}{j}a^{k-j}h^{j}-a^{k}=ka^{k-1}h+% \sum_{j=2}^{k}\binom{k}{j}a^{k-j}h^{j},

since in the sum, the j=0j=0 term is aka^{k} and the j=1j=1 term is kak1hka^{k-1}h. This rearranges to give

(5.3) (5.3) pk(a+h)pk(a)hkak1=hj=2k(kj)akjhj2.\frac{p_{k}(a+h)-p_{k}(a)}{h}-ka^{k-1}=h\sum_{j=2}^{k}\binom{k}{j}a^{k-j}h^{j-% 2}.

Here for k=1k=1 the right-hand sum in (5.3) is interpreted as equal to 0. By the triangle inequality, the hypothesis |h|1|h|\leq 1 and a second application of the binomial theorem,

(5.4) (5.4) |j=2k(kj)akjhj2|j=2k(kj)|a|kj|h|j2j=0k(kj)|a|kj=(1+|a|)k.\Big{|}\sum_{j=2}^{k}\binom{k}{j}a^{k-j}h^{j-2}\Big{|}\leq\sum_{j=2}^{k}\binom% {k}{j}|a|^{k-j}|h|^{j-2}\leq\sum_{j=0}^{k}\binom{k}{j}|a|^{k-j}=(1+|a|)^{k}.

Combining (5.3) and (5.4) we see that

(5.5) (5.5) |pk(a+h)pk(a)hkak1||h|(1+|a|)k.\Big{|}\frac{p_{k}(a+h)-p_{k}(a)}{h}-ka^{k-1}\Big{|}\leq|h|(1+|a|)^{k}.

Thus, we conclude from the squeeze theorem that

limh0pk(a+h)pk(a)h=kak1\lim_{h\to 0}\frac{p_{k}(a+h)-p_{k}(a)}{h}=ka^{k-1}

and so pkp_{k} is differentiable at aa and p(a)=kak1p^{\prime}(a)=ka^{k-1}, as required. ∎

We can use the ideas introduced in Example 5.11 to study the following very important example.

Lemma 5.12.

The function exp:\exp\colon\mathbb{R}\to\mathbb{R} introduced in Definition 4.5 is differentiable with

exp(a)=exp(a)for all a.\exp^{\prime}(a)=\exp(a)\qquad\text{for all $a\in\mathbb{R}$.}

Lemma 5.12 tells us that the function exp\exp is its own derivative. As a consequence, exp\exp plays a very special role in the theory of differentiation. We shall see many important consequences of this result in Section 5.7 below.

Proof (of Lemma 5.12).

As in Example 5.11, for each k0k\in\mathbb{N}_{0} let pk:p_{k}\colon\mathbb{R}\to\mathbb{R} be given by pk(x):=xkp_{k}(x):=x^{k} for all xx\in\mathbb{R}. Then, given n0n\in\mathbb{N}_{0}, let

sn:be given bysn(x):=k=0nxkk!=k=0npk(x)k!for x,s_{n}\colon\mathbb{R}\to\mathbb{R}\qquad\text{be given by}\qquad s_{n}(x):=% \sum_{k=0}^{n}\frac{x^{k}}{k!}=\sum_{k=0}^{n}\frac{p_{k}(x)}{k!}\qquad\text{% for $x\in\mathbb{R}$,}

so that sn(x)s_{n}(x) corresponds to the nnth partial sum of the series exp(x)\exp(x) for all xx\in\mathbb{R}. Fix aa\in\mathbb{R} and hh\in\mathbb{R} with 0<|h|10<|h|\leq 1 and consider the difference quotient

(5.6) (5.6) sn(a+h)sn(a)h=k=1n1k!pk(a+h)pk(a)h;\frac{s_{n}(a+h)-s_{n}(a)}{h}=\sum_{k=1}^{n}\frac{1}{k!}\cdot\frac{p_{k}(a+h)-% p_{k}(a)}{h};

notice that the sum on the right starts from k=1k=1 since p0(a+h)p0(a)=0p_{0}(a+h)-p_{0}(a)=0. On the other hand, by reindexing the sum we can write

(5.7) (5.7) sn1(a)=k=0n1akk!=k=1nak1(k1)!=k=1nkak1k!.s_{n-1}(a)=\sum_{k=0}^{n-1}\frac{a^{k}}{k!}=\sum_{k=1}^{n}\frac{a^{k-1}}{(k-1)% !}=\sum_{k=1}^{n}\frac{ka^{k-1}}{k!}.

Combining (5.6) and (5.7), we see that

sn(a+h)sn(a)hsn1(a)=k=1n1k![pk(a+h)pk(a)hkak1]\frac{s_{n}(a+h)-s_{n}(a)}{h}-s_{n-1}(a)=\sum_{k=1}^{n}\frac{1}{k!}\cdot\Big{[% }\frac{p_{k}(a+h)-p_{k}(a)}{h}-ka^{k-1}\Big{]}

Notice that the right-hand side involves the difference quotients for the monomials pkp_{k} we studied in Example 5.11. So, we can apply some of the inequalities we proved in that example.

Using the triangle inequality and the bound (5.5) from Example 5.11, we obtain

|sn(a+h)sn(a)hsn1(a)||h|k=1n(1+|a|)kk!|h|k=0(1+|a|)kk!=|h|exp(1+|a|).\Big{|}\frac{s_{n}(a+h)-s_{n}(a)}{h}-s_{n-1}(a)\Big{|}\leq|h|\sum_{k=1}^{n}% \frac{(1+|a|)^{k}}{k!}\leq|h|\sum_{k=0}^{\infty}\frac{(1+|a|)^{k}}{k!}=|h|\exp% (1+|a|).

Since the above inequality holds for all nn\in\mathbb{N}, we can take the limit as nn\to\infty to deduce (by Exercise 2.46) that

|exp(a+h)exp(a)hexp(a)||h|exp(1+|a|).\Big{|}\frac{\exp(a+h)-\exp(a)}{h}-\exp(a)\Big{|}\leq|h|\exp(1+|a|).

As h0h\to 0, the right-hand side converges to 0. Thus, by the squeeze theorem,

limh0exp(a+h)exp(a)h=exp(a)\lim_{h\to 0}\frac{\exp(a+h)-\exp(a)}{h}=\exp(a)

and so exp\exp is differentiable at aa and exp(a)=exp(a)\exp^{\prime}(a)=\exp(a), as required. ∎

Example 5.13 (Trigonometric functions).

The functions sin:\sin\colon\mathbb{R}\to\mathbb{R} and cos:\cos\colon\mathbb{R}\to\mathbb{R} are differentiable with sin(a)=cosa\sin^{\prime}(a)=\cos a and cos(a)=sina\cos^{\prime}(a)=-\sin a for all aa\in\mathbb{R}.

Proof.

For sinc\mathrm{sinc}^{*} the function defined in Example 4.44, observe that

limh0sinhsin0h=limh0sinhh=limh0sinc(h)=1.\lim_{h\to 0}\frac{\sin h-\sin 0}{h}=\lim_{h\to 0}\frac{\sin h}{h}=\lim_{h\to 0% }\mathrm{sinc}^{*}(h)=1.

This tells us that sin\sin is differentiable at 0 and sin(0)=1\sin^{\prime}(0)=1. A similar argument shows that cos\cos is differentiable at 0 and cos(0)=0\cos^{\prime}(0)=0: see Exercise 5.14 (i).

So far we have only shown sin\sin and cos\cos are differentiable at 0. However, this special case can be combined with the angle summation formulæ  to prove the full result: see Exercise 5.14 (ii). ∎

Exercise 5.14.

Fill in the details of Example 5.13 by carrying out the following steps.

  1. (i)

    Use Exercise 4.46 to show that cos\cos is differentiable at 0 and cos(0)=0\cos^{\prime}(0)=0.

  2. (ii)

    Fix aa\in\mathbb{R} and use the angle summation formulæ  to show that sin\sin and cos\cos are both differentiable at aa\in\mathbb{R} with sin(a)=cosa\sin^{\prime}(a)=\cos a and cos(a)=sina\cos^{\prime}(a)=-\sin a.

Higher-order derivatives

If a function f:If\colon I\to\mathbb{R} is differentiable, this means that the derivative f:If^{\prime}\colon I\to\mathbb{R} exists – but the function ff^{\prime} may or may not be differentiable. This motivates the following definition, to distinguish the different types of behaviour that are possible.

Definition 5.15.

Let II\subseteq\mathbb{R} be an open interval and f:If\colon I\to\mathbb{R} be differentiable.

  1. 1

    If ff^{\prime} is differentiable then we say ff is twice differentiable and define f(2):=(f)f^{(2)}:=(f^{\prime})^{\prime}.

  2. 2

    More generally, for nn\in\mathbb{N} we say f:If\colon I\to\mathbb{R} is nn-times differentiable if the (recursively-defined) higher-order derivatives f(k+1):=(f(k))f^{(k+1)}:=(f^{(k)})^{\prime} exist for all 0kn10\leq k\leq n-1.

  3. 3

    Finally, we say that ff is infinitely differentiable if it is nn-times differentiable for all nn\in\mathbb{N}.

Exercise 5.16.

Show that exp:\exp\colon\mathbb{R}\to\mathbb{R} is infinitely differentiable.

Exercise 5.17.

Consider the function p2:p_{2}\colon\mathbb{R}\to\mathbb{R} given by p2(x):=x2p_{2}(x):=x^{2} for all xx\in\mathbb{R}. Is p2p_{2} twice differentiable? Three times differentiable? Infinitely differentiable?

Example 5.18.

The function

(5.8) (5.8) f:,f(x):={0if x<0,x2if x0f\colon\mathbb{R}\to\mathbb{R},\qquad f(x):=\begin{cases}0&\text{if $x<0$,}\\ x^{2}&\text{if $x\geq 0$}\end{cases}

is differentiable but not twice differentiable. To see this, note our earlier examples show that ff is differentiable on (,0)(-\infty,0) with derivative f(a)=0f^{\prime}(a)=0 for all a<0a<0 and ff is is differentiable on (0,)(0,\infty) with derivative f(a)=2af^{\prime}(a)=2a for all x>0x>0. For a=0a=0, we have

limh0+f(0+h)f(0)h=limh0+h2h=0,limh0f(0+h)f(0)h=limh00=0.\lim_{h\to 0_{+}}\frac{f(0+h)-f(0)}{h}=\lim_{h\to 0_{+}}\frac{h^{2}}{h}=0,% \qquad\lim_{h\to 0_{-}}\frac{f(0+h)-f(0)}{h}=\lim_{h\to 0_{-}}0=0.

Since the left and right limits agree, we conclude from Exercise 4.72 that ff is differentiable at 0 with f(0)=0f^{\prime}(0)=0. However, the above argument shows that

f(x):={0if x<0,2xif x0f^{\prime}(x):=\begin{cases}0&\text{if $x<0$,}\\ 2x&\text{if $x\geq 0$}\end{cases}

and it is easy to see this is not differentiable using an argument similar to that from Example 5.7. We illustrate this example in Figure 5.6.

Figure 5.6: The function ff from (5.8) and its derivative ff^{\prime}.
Remark 5.19.

Again, there are different ways to denote higher-order derivatives. These include

f(n)=dnfdxn=Dxnf.f^{(n)}=\frac{d^{n}f}{dx^{n}}=D^{n}_{x}f.

Furthermore, second derivatives can be written as f(2)f^{(2)} or f′′f^{\prime\prime} (and similarly for higher-order derivatives, although by the time we get to fourth order the notation f′′′′f^{\prime\prime\prime\prime} gets out of hand).

One-sided derivatives

As with continuity, it is convenient to define one-sided derivatives to deal with functions whose domains are closed (or half-open) intervals. For instance, given aa, bb\in\mathbb{R} with a<ba<b, we say f:[a,b]f\colon[a,b]\to\mathbb{R} is differentiable on [a,b][a,b] if ff is differentiable at all points x(a,b)x\in(a,b) and the limits

fR(a):=limh0+f(a+h)f(a)handfL(b):=limh0f(b+h)f(b)h.f^{\prime}_{R}(a):=\lim_{h\to 0_{+}}\frac{f(a+h)-f(a)}{h}\qquad\text{and}% \qquad f^{\prime}_{L}(b):=\lim_{h\to 0_{-}}\frac{f(b+h)-f(b)}{h}.

exist. In this case, fR(a)f^{\prime}_{R}(a) is called the right derivative at aa and fL(b)f^{\prime}_{L}(b) is called left derivative at bb.