2. Differentiation#

In this chapter we introduce the concept of a derivative and some standard results. After completing this chapter you should be able to:

  • demonstrate how the derivative of \(x^n\) is found from first principles, and explain the steps involved

  • Use correct notation for first and second derivatives, and write valid mathematical expressions involving derivatives

  • apply the sum, product, reciprocal and chain rules for differentiation involving polynomials and exponentials

  • use Wolfram Alpha to differentiate functions and check your answers

2.1. Differentiation principle#

Based on our argument that interpolation is improved when the datapoints are closer together, we can obtain a better numeric estimate of the slope by using more datapoints in the interval.

Analytically, we can obtain the result with arbitray precision by taking the limit as \(\Delta x\to 0\). We call the result “the derivative”, and we denote it by

(2.1)#\[\frac{\mathrm{d}y}{\mathrm{d}x} = \lim_{\Delta x\to 0}\frac{\Delta y}{\Delta x} =\lim_{\Delta x \to 0}\frac{y(x+\Delta x)-y(x)}{\Delta x}.\]

The process of finding the derivative is called “differentiation”, due to the fact that involves a ratio of differences. In the expression above we call \(y\) the dependent variable and \(x\) the independent variable.

Examples of how the analytic definition can be applied to find the derivatives of polynomials and exponentials from first principles are given below. The analytic definition can also be used to find the derivatives of non-algebraic functions, such as \(\sin(x)\), but it is very difficult to apply, and where we need these results we will just look them up.

Wolfam Alpha

You can also use Wolfram Alpha to find the derivatives of function. Try typing “derivative of x^n” into the natural language search box and inspect the results.

2.1.1. Polynomials#

By way of example, let’s consider the function \(y(x)=x^2\). Using the definition we have

\[\begin{align*} \frac{\Delta f}{\Delta x}=\frac{f(x+\Delta x)-f(x)}{\Delta x} &= \frac{(x+\Delta x)^2-x^2}{\Delta x}\\ &=\frac{x^2+2\Delta x+(\Delta x)^2-x^2}{\Delta x}=2x+\Delta x. \end{align*}\]

In the limit,

\[\begin{equation*} \frac{\mathrm{d}y}{\mathrm{d}x} = \lim_{\Delta x\rightarrow 0}\frac{\Delta f}{\Delta x}=2x. \end{equation*}\]

Exercise 2.1

Calculate the derivative of \(y=x^n\) from first principles, where \(n\) is a natural number. (1,2,3,…)

2.1.2. Exponentials#

For the function \(y=e^x\) we have

\[\begin{equation*} \frac{\Delta y}{\Delta x} = \frac{e^{x+\Delta x}-e^x}{\Delta x} = e^x \left(\frac{e^{\Delta x}-1}{\Delta x}\right). \end{equation*}\]

Recall from our earlier work on exponentials that the natural exponent \(e\) satisfies

\[\begin{equation*} \lim_{\Delta x\rightarrow 0}\frac{e^{\Delta x}-1}{\Delta x}=1 \qquad \implies \quad \frac{\mathrm{d}y}{\mathrm{d}x}=e^x. \end{equation*}\]

2.2. Notation#

There are two main types of notation that are used for differentiation. The use of either one may be a matter of personal preference, though there are contexts where one is more suited than the other.

The operator notation is more favourable for beginners and is arguably more versatile, as it is easier to identify the independent variable from this notation. Lagrange’s notation may be used when the independent variable is ambiguous.

2.2.1. Operator notation#

We can think of differentiation as an operation that we carry out on a function. With this in mind, we also use the following notation in which \(\mathrm{d}/\mathrm{d}x\) represents the differential operator

(2.2)#\[\frac{\mathrm{d}}{\mathrm{d}x}\biggr(y\biggr).\]

This notation can be straightforwardly extended to use for repeated differentiation. For example, the “second derivative” is given by

(2.3)#\[\frac{\mathrm{d}}{\mathrm{d}x}\biggr(\frac{\mathrm{d}y}{\mathrm{d}x}\biggr) = \frac{\mathrm{d}^2}{\mathrm{d}x^2}\biggr(y\biggr).\]

Exercise 2.2

Find the second derivative of \(y=x^4\).

Warning: incorrect notation

Since \(\frac{\mathrm{d}}{\mathrm{d}x}\) is an operator it must be applied to a variable. It is meaningless to write this quantity by itself and so the following expression and others like it do not make mathematical sense

(2.4)#\[\begin{equation} y=x^2: \qquad \frac{\mathrm{d}}{\mathrm{d}x} = 2x \end{equation}\]

2.2.2. Lagrange’s notation#

This notation uses a prime mark to denote the derivative in the following manner:

\[\begin{equation*} y^{\prime}(x)=\frac{\mathrm{d}y}{\mathrm{d}x}, \qquad y^{\prime\prime}(x) = \frac{\mathrm{d}^2 y}{\mathrm{d}x^2}, \qquad y^{\prime\prime\prime}(x) = \frac{\mathrm{d}^3 y}{\mathrm{d}x^3}, \qquad \text{etc.} \end{equation*}\]

The dash notation becomes a bit cumbersome for higher derivatives so we write

\[\begin{equation*} y^{(n)}(x)=\frac{\mathrm{d}^n y}{\mathrm{d}x^n}. \end{equation*}\]

2.3. Differentiation rules#

The following rules can all be proved from the limit definition. We will not prove them, though we will apply them to find some derviatives of compound functions. You can check your answers for any of the functions using Wolfram Alpha. For example, “derivative of e^(x^3)”

2.3.1. Sum rule:#

Taking \(y=u(x)+v(x)\),

(2.5)#\[\begin{equation} \frac{\mathrm{d}}{\mathrm{d}x}\biggr(u+v\biggr)=\frac{\mathrm{d}u}{\mathrm{d}x}+\frac{\mathrm{d}v}{\mathrm{d}x}. \end{equation}\]

Exercise 2.3

Use the sum rule to calculate the derivative of \(y=x^3+e^x\)

2.3.2. Product rule:#

Taking \(y=u(x)v(x)\),

(2.6)#\[\begin{equation} \frac{\mathrm{d}}{\mathrm{d}x}\biggr(uv\biggr)=u\frac{\mathrm{d}v}{\mathrm{d}x}+v\frac{\mathrm{d}u}{\mathrm{d}x}. \end{equation}\]

Exercise 2.4

Use the product rule to calculate the derivative of \(x^3e^x\)

2.3.3. Chain rule:#

Taking \(y=y(u)\) where \(u=u(x)\),

(2.7)#\[\begin{equation} \frac{\mathrm{d}y}{\mathrm{d}x} = \frac{\mathrm{d}y}{\mathrm{d}u}\frac{\mathrm{d}u}{\mathrm{d}x}. \end{equation}\]

Exercise 2.5

Use the chain rule to find the derivative of \(y=e^{x^3}\)

2.3.4. Reciprocal rule:#

As a special case of the chain rule we may derive the following result:

(2.8)#\[\begin{equation} \frac{\mathrm{d}y}{\mathrm{d}y} = \frac{\mathrm{d}y}{\mathrm{d}x}\frac{\mathrm{d}x}{\mathrm{d}y} \qquad \implies \quad \frac{\mathrm{d}y}{\mathrm{d}x} = 1\biggr/\frac{\mathrm{d}x}{\mathrm{d}y}. \end{equation}\]

Exercise 2.6

Use the reciprocal rule to find the derivative of \(y=\ln(x)\).

Hint: start by rearranging the given equation so that you can use the known result for the derivative of the exponential function.