Topic 11 Differentiation
11.1 Introduction
Differentiation is all about finding the gradient of functions. If you are given the equation of a straight line, such as \(y=3x+2\) you should by now be able to read off that the gradient is 3. That’s fine for straight lines, but if you are given a curve, such as \(y=x^2\) it is clear that the gradient of the curve is different at each point. That’s what differentiation allows us to do - to work out the function which gives us the gradient at each point of the curve.
The following sections start from differentiating simple functions, up to the more complicated products of functions, or functions of functions, covering some applications of differentiation on the way.
11.2 Powers
The simplest functions are powers of the x (or whatever the independent variable is), i.e. \(y=x^n\).
If \(y=x^n\)
\[\frac{dy}{dx} = nx^{n-1}\] This can be read as “the derivative of y with respect to x equals \(nx^{n-1}\)”, the more often people say “d y by d x equals …”
E.g. If \(y=x^3\)
\[\frac{dy}{dx} = 3x^{2}\]
E.g. If \(y=x^2\)
\[\frac{dy}{dx} = 2x\]
E.g. If \(y=x\)
\[\frac{dy}{dx} = 1\]
because *x** is really \(x^1\) so we get \(1\times x^0\) and anthing raised t the power 0 is 1. Another way to look at it is that \(y=x\) is the equation of a straight line with gradient 1.
E.g. If \(y=3\)
\[\frac{dy}{dx} = 0\]
because this is constant, so y does not depend on x. Another way to look at it is that this is the equation of a horizontal line, with gradient 0.
11.3 Multiplication by a constant
If \(y = au\) where a is a constant (e.g. 5), and u is a function of x, then
\[\frac{dy}{dx} = a \frac{du}{dx}\]
E.g. If \(y=2x^3\)
\[\begin{align} \frac{dy}{dx} &= 2 \times 3x^{2}\\ &= 6x^2 \end{align}\]
11.4 Sum or difference
If \(y = u + v\) where u and v are functions of x
\[\frac{dy}{dx} = \frac{du}{dx} + \frac{dv}{dx}\]
E.g. If \(y=x^3 + x^2\)
\[\frac{dy}{dx} = 3x^{2} + 2x\]
E.g. If \(y=2x^3 + 4x^2\)
\[\frac{dy}{dx} = 6x^{2} + 8x\]
11.5 Second derivative
Taking the derivative of something gives back another function, so there’s no reason we can’t differentiate again. This is called the second derivative, and is written as \(\frac{d^2y}{dx^2}\). Since this is just the derivative of a derivative, we have
\[\frac{d^2y}{dx^2} = \frac{d}{dx}\left(\frac{dy}{dx}\right)\]
E.g. If \(y=x^3\)
\[\frac{dy}{dx} = 3x^{2}\]
so
\[\begin{align} \frac{d^2y}{dx^2} &= \frac{d}{dx}\left(3x^2\right)\\ &= 6x \end{align}\]
11.6 Standard derivatives
Differentiation wouldn’t be much use if we could only do the polynomials we’ve studied so far. Here is a short list of other ones. It is definitely worth being familiar with the first six (polynomials, exponentials, logs and the basic trig functions) as they come up all the time; the rest you can normally look up on tables of standard derivatives.
\(y\) | \(\frac{dy}{dx}\) |
---|---|
\(x^n\) | \(nx^{n-1}\) |
\(e^x\) | \(e^x\) |
\(\ln(x)\) | \(\frac{1}{x}\) |
\(\sin(x)\) | \(\cos(x)\) |
\(\cos(x)\) | \(-\sin(x)\) |
\(\tan(x)\) | \(\sec^2(x)\) |
\(\sec(x)\) | \(\sec(x)\tan(x)\) |
\(\mathrm{cosec}(x)\) | \(-\mathrm{cosec}(x)\cot(x)\) |
11.7 Chain rule
Often you get functions such as \(y=\sin x^2\) which aren’t covered by anything we’ve looked at so far. However, we can rewrite this as \(u=x^2\) and \(y=\sin u\), both of which we know how to differentiate with respect to their argument:
\[\frac{du}{dx} = 2x\mbox{,}\qquad \frac{dy}{du} = \cos u\] We can then apply the chain rule:
if \(y=\mathrm{f}(u)\) and u is a function of x then
\[\frac{dy}{dx} = \frac{dy}{du}\frac{du}{dx}\]
So, in our example: \[\begin{align} \frac{dy}{dx} &= \frac{dy}{du}\frac{du}{dx}\\ &= (\cos u)(2x)\\ &= (\cos x^2)(2x)\\ &= 2x\cos x^2 \end{align}\]
The chain rule is used when y is a function of a function, and is probably the most used rule. The simplest example is when the inner function is a constant times x, e.g. \(y=\sin 5x\).
- Identify the outer function \(\sin u\) and the inner function \(5x\).
- Set u equal to the inner function, \(u=5x\)
- Write the outer function in terms of u, \(y=\sin u\)
- Differentiate each function with respect to its argument: \[\frac{du}{dx} = 5\mbox{,}\qquad \frac{dy}{du} = \cos u\]
- Use the chain rule \[\begin{align} \frac{dy}{dx} &= \frac{dy}{du}\frac{du}{dx}\\ &= (\cos u)(5)\\ &= (\cos 5x)(5)\\ &= 5\cos 5x \end{align}\]
A step up from this is if the inner function is a linear function of x, i.e. \(ax+b\) where a and b are constants. E.g. \(y=\tan(2x+3)\):
- Identify the outer function \(\tan u\) and the inner function \(2x+3\).
- Set u equal to the inner function, \(u=2x+3\)
- Write the outer function in terms of u, \(y=\tan u\)
- Differentiate each function with respect to its argument: \[\frac{du}{dx} = 2\mbox{,}\qquad \frac{dy}{du} = \sec^2 u\]
- Use the chain rule \[\begin{align} \frac{dy}{dx} &= \frac{dy}{du}\frac{du}{dx}\\ &= (\sec^2 u)(2)\\ &= (\sec^2(2x+3))(2)\\ &= 2\sec^2(2x+3) \end{align}\]
E.g. \(y=(2x+3)^5\):
- Identify the outer function \(u^5\) and the inner function \(2x+3\).
- Set u equal to the inner function, \(u=2x+3\)
- Write the outer function in terms of u, \(y=u^5\)
- Differentiate each function with respect to its argument: \[\frac{du}{dx} = 2\mbox{,}\qquad \frac{dy}{du} = 5u^4\]
- Use the chain rule \[\begin{align} \frac{dy}{dx} &= \frac{dy}{du}\frac{du}{dx}\\ &= (5u^4)(2)\\ &= (5(2x+3)^4)(2)\\ &= 10(2x+3)^4 \end{align}\]
In practice, if u is just a linear function of x, i.e. \(u=ax+b\), experience shows that the result will always be a times the derivative of the outer function with respect to its argument, so most people don’t explicitly write out the steps of the chain rule. E.g.
y | \(\frac{dy}{dx}\) |
---|---|
\(\sin \mathbf{6}x\) | \(\mathbf{6}\cos 6x\) |
\(\sin (\mathbf{4}x+3)\) | \(\mathbf{4}\cos (4x+3)\) |
\(e^{\mathbf{7}x+2}\) | \(\mathbf{7}e^{7x+2}\) |
\((\mathbf{7}x+2)^6\) | \(\mathbf{7}\times 6(7x+2)^5\) |
Linear functions of x are very common, but of course the inner function can be more complicated. Here are some examples:
E.g. \(y=(2x^2+3x+7)^5\):
- Identify the outer function \(u^5\) and the inner function \(2x^2+3x+7\).
- Set u equal to the inner function, \(u=2x^2+3x+7\)
- Write the outer function in terms of u, \(y=u^5\)
- Differentiate each function with respect to its argument: \[\frac{du}{dx} = 2x+3\mbox{,}\qquad \frac{dy}{du} = 5u^4\]
- Use the chain rule \[\begin{align} \frac{dy}{dx} &= \frac{dy}{du}\frac{du}{dx}\\ &= (5u^4)(2x+3)\\ &= (5(2x^2+3x+3)^4)(2x+3)\\ &= 5(2x+3)(2x^2+3x+3)^4 \end{align}\]
E.g. \(y=\cos(2x^2+3x+7)\):
- Identify the outer function \(\cos u\) and the inner function \(2x^2+3x+7\).
- Set u equal to the inner function, \(u=2x^2+3x+7\)
- Write the outer function in terms of u, \(y=\cos u\)
- Differentiate each function with respect to its argument: \[\frac{du}{dx} = 2x+3\mbox{,}\qquad \frac{dy}{du} = -\sin u\]
- Use the chain rule \[\begin{align} \frac{dy}{dx} &= \frac{dy}{du}\frac{du}{dx}\\ &= (-\sin u)(2x+3)\\ &= (-\sin(2x^2+3x+3)(2x+3)\\ &= -(2x+3)\sin(2x^2+3x+3) \end{align}\]
E.g. \(y=\cos^2 x\):
- Identify the outer function \(u^2\) and the inner function \(\cos x\).
- Set u equal to the inner function, \(u=\cos x\)
- Write the outer function in terms of u, \(y=u^2\)
- Differentiate each function with respect to its argument: \[\frac{du}{dx} = -\sin x\mbox{,}\qquad \frac{dy}{du} = 2u\]
- Use the chain rule \[\begin{align} \frac{dy}{dx} &= \frac{dy}{du}\frac{du}{dx}\\ &= (2u)(-\sin x)\\ &= (2\cos x)(-\sin x)\\ &= -2\cos x \sin x \end{align}\]
11.8 Product rule
If y can be written as the product of two function, u and v, say, i.e. \(y = uv\) then you can calculate the derivative of the product by the product rule
\[\frac{dy}{dx} = u\frac{dv}{dx} + v\frac{du}{dx}\]
E.g. If \(y = x^2 \cos x\)
- Set \(u=x^2\) and \(v=\cos x\) (it doesn’t matter which is which)
- Take the derivatives of each function \[\frac{du}{dx} = 2x\mbox{,}\qquad \frac{dv}{dx} = - \sin x\]
- Apply the product rule \[\begin{align} \frac{dy}{dx} &= u\frac{dv}{dx} + v\frac{du}{dx}\\ &= (x^2)(-\sin x) + (\cos x)(2x)\\ &= -x^2\sin x + 2x\cos x \end{align}\]
11.9 More on the chain and product rules
If you have mastered the chain and product rules, you have mastered differentiation. Whenever you are faced with a derivative, the questions to ask are:
- Is this a derivative I already know, or can see on a table of derivatives?
- Just do it.
- Is it the product of two functions?
- Use the product rule.
- Is it a function of a function?
- Use the chain rule.
As part of the product and chain rule you are doing differentiation on part of the original expression, and for each one of these differentiations you need to ask yourself the same questions — you may have to apply the product or chain rule again.
E.g. \(y = e^{x^2+1}\sin x^3\)
- Is this a derivative I know? No.
- Is it the product of two functions? Yes.
- \(u=e^{x^2+1}\)
- Is this something I know? No.
- Is it the product of two functions? No.
- Is it the function of a function? Yes.
- Using the chain rule gives \(\frac{du}{dx} = 2xe^{x^2+1}\)
- \(v=\sin x^3\)
- Is this something I know? No.
- Is it the product of two functions? No.
- Is it the function of a function? Yes.
- Using the chain rule gives \(\frac{dv}{dx} = 3x^2\cos x^3\)
- Using the product rule gives \[\begin{align} \frac{dy}{dx} &= u\frac{dv}{dx} + v\frac{du}{dx}\\ &= (e^{x^2+1})(3x^2\cos x^3) + (\sin x^3)(2xe^{x^2+1})\\ &= 3x^2e^{x^2+1}\cos x^3 + 2xe^{x^2+1}\sin x^3\\ &= xe^{x^2+1}(3x\cos x^3 +2\sin x^3) \end{align}\]
11.10 Implicit differentiation
From the moment you were introduced to equations, the fundamental rule that has been drilled in is “what you do to one side, you do to the other side.” This is is still true when you do differentiation.
For instance, if I want \(\frac{dy}{dx}\) and I know \(y+x=x^2\) I could rearrange the equation as \(y = x^2 - x\) and differentiate, or I could differentiate first and rearrange:
\[\begin{align} y+x &=x^2\\ \frac{dy}{dx} +1 &= 2x\\ \frac{dy}{dx} &= 2x -1 \end{align}\]
Another example is if we have \(y^2 + x = x^2\). Rearranging this to give y as a function of x would involve a square root, and possible sign ambiguities. Instead we could differentiate it first, then rearrange. The trick is to treat any term in y using the chain rule, with the “inner function” being y, and leaving its derivative as \(\frac{dy}{dx}\), e.g.
\[\frac{d}{dx}(y^2) = 2y \frac{dy}{dx}\] \[\frac{d}{dx}(\sin y) = \cos y \frac{dy}{dx}\]
\[\frac{d}{dx}(e^y) = e^y \frac{dy}{dx}\]
\[\frac{d}{dx}(e^{y^2}) = 2ye^{y^2} \frac{dy}{dx}\]
Going back to our example of \(y^2 + x = x^2\), gives
\[\begin{align} y^2+x &=x^2\\ 2y\frac{dy}{dx} +1 &= 2x\\ 2y\frac{dy}{dx} &= 2x -1\\ \frac{dy}{dx} &= \frac{2x -1}{2y} \end{align}\]
which has left \(\frac{dy}{dx}\) as an implicit function of y, hence the name of this technique implicit differentiation.
11.11 Stationary points
Since the derivative gives us the gradient of the function, we can use it to find out where the function has a maximum or a minimum, where the gradient is 0.
At a maximum the curve had a positive gradient before, and has a negative gradient afterwards, so it must have been zero at the top.
At a minimum the curve had a negative gradient before, and has a positive gradient afterwards, so it must have been zero at the bottom.
Maxima and minima are places where the function turns from increasing to decreasing, or decreasing to increasing, so are also called turning points. Some functions also have points where they flatten out briefly but then continue increasing or decreasing as before, these are horizontal points of inflection. Maxima, minima and horizontal points of inflection are all points at which the curve is temporarily flat, and are, collectively, called stationary points.
To find the stationary points on a curve, take the first derivative to find the gradient function, set it to zero, and solve. The solutions are the points where the gradient of the original curve were zero, i.e. the stationary points.
E.g. If \(y = 2x^3 - 9x^2 +12 +3\)
- Find the first derivative \[\frac{dy}{dx} = 6x^{2} - 18x +12\]
- Set it equal to zero and solve \[\begin{align} 6x^{2} - 18x +12 &= 0\\ x^{2} - 3x + 2 &= 0\\ (x-1)(x-2) &= 0\\ x &= 1\quad\mbox{or}\quad 2 \end{align}\]
So far we’ve found the stationary points, but remember that there are three sorts of stationary points: maxima, minima, and points of inflection.
- At maxima, the curve changes from increasing to decreasing, so the gradient of the curve is decreasing
- At minima, the curve changes from decreasing to increasing, so the gradient of the curve is increasing
If a function is decreasing, its gradient must be negative, so that means that at a maximum the gradient of the gradient, i.e. the second derivative, must be negative, and similarly at a minimum the gradient of the gradient is increasing, so the second derivative is positive. Hence:
- There is a maximum when \(\frac{dy}{dx} = 0\) and \(\frac{d^2y}{dx^2} < 0\).
- There is a minimum when \(\frac{dy}{dx} = 0\) and \(\frac{d^2y}{dx^2} > 0\).
- If \(\frac{dy}{dx} = 0\) and \(\frac{d^2y}{dx^2} = 0\) more investigation is needed.
Taking the example from earlier \(y = 2x^3 - 9x^2 +12 +3\), we have:
- Find the first derivative \[\frac{dy}{dx} = 6x^{2} - 18x +12\]
- Set it equal to zero and solve \[\begin{align} 6x^{2} - 18x +12 &= 0\\ x^{2} - 3x + 2 &= 0\\ (x-1)(x-2) &= 0\\ x &= 1\quad\mbox{or}\quad 2 \end{align}\]
- Find the second derivative \[\begin{align} \frac{d^2y}{dx^2} &= \frac{d}{dx}(6x^{2} - 18x +12)\\ &= 12x - 18 \end{align}\]
- Evaluate the second derivative at each stationary point
- At \(x=1\) \(\frac{d^2y}{dx^2} = -6\), i.e. it is negative, so we have a maximum.
- At \(x=2\) \(\frac{d^2y}{dx^2} = 6\), i.e. it is positive, so we have a minimum.
11.12 Further Resources
- Khan Academy - Differential Calculus
- Mathtutor - Differentiation
- HELM
- MathsEG
- Algebraic functions
- Chain Rule
- Elementary functions
- Product Rule