This material has been adapted from material by Fergus Cooper and others from the "Essential Mathematics" module at the Doctoral Training Centre, University of Oxford.
This course material was developed as part of UNIVERSE-HPC, which is funded through the SPF ExCALIBUR programme under grant number EP/W035731/1
Differentiation 2
Learning outcomes
Be able to recognise the derivatives of standard functions
Understand the associative, commutative and distributive properties of derivatives
Be able to use the chain rule to differentiate a function of a function
Be able to use the product rule for differentiating a product of functions
Be able to use the quotient rule for differentiating the ratio of functions
Be able to use SymPy to calculate derivatives in Python
YouTube lecture recording from October 2020
The following YouTube video was recorded for the 2020 iteration of the course.
The material is still very similar:
Product, Chain and Quotient Rules
Linear approximation and the derivative
By definition, the derivative of a function f(x) is
f′(x)=limh→0hf(x+h)−f(x)
This means that for small h, this expression approximates the derivative. By rearranging this, we have
f(x+h)≈f(x)+hf′(x)
In other words, f(x+h) can be approximated by starting at f(x) and moving a distance h along the tangent f′(x).
Example
Estimate 5218
To do this, we first need an f(x) that is easy to calculate, and close to 5218. For this we can take that 702=4900.
To calculate the approximation, we need f′(x), where f(x)=x.
f′(x)=2x1 > f′(x)=2x1
Since 5218 = 4900 + 318, we can set x=4900 and h=318.
Using the approximation, we have:
f(5218)≈f(4900)+318×f′(4900) > f(5218)≈70+318×1401≈72.27 > 5218=72.2357252 - not a bad appriximation!
Standard derivatives
It's useful to know the derivatives of all the standard functions, and some basic rules.
To understand the derivative of sin and cos, consider their graphs, and when they are changing positively (increasing), negatively (decreasing) or not at all (no rate of change).
Other Differentiation Rules
Differentiation of sums, and scalar multiples
(f(x)±g(x))′=f′(x)±g′(x)(af(x))′=af′(x)
Differentiation of products
While differentiating sums, and scalar multiples is straightforward, differentiating products is more complex
So both rules produce the same result. While for simple examples the product rule requires more work, as functions get more complex it saves a lot of time.
Differentiating a function of a function - The Chain Rule
One of the most useful rules is differentiating a function that has another function inside it y=f(g(x)). For this we use the chain rule:
y=f(g(x)) > y′(x)=f′(g(x))g′(x)=dgdfdxdg
Example 1: y=(5x2+2)4
We can write this as y=g4, where g=5x2+2. Given this, we have that
dgdy=4g3=4(5x2+2)3 > dxdg=10x
This means that
dxdy=dgdydxdg=4(5x2+2)310x=40x(5x2+2)3
This extends infinitely to nested functions, meaning
dxd(a(b(c))=dbdadxd(b(c))=dbdadcdbdxdc
Differentiating the ratio of two functions - The Quotient Rule
If y(x)=g(x)f(x), then by using the product rule, and setting h(x)=(g(x))−1, we can show that
For any function y=f(x), with a well defined inverse f−1(x) (not to be confused with (f(x))−1)), we have by definition that
x=f−1(f(x))=f−1(y).
This means that we can apply the chain rule
dxd(x)=dxd(f−1(y))=dyd(f−1(y))dxdy
But since dxd(x)=1
dyd(f−1(y))=dxdy1
Example: y=ln(x)
If y=ln(x), this means that f−1(y)=ey=x
By definition (f−1(y))′=ey, as ey doesn't change under differentiation. This means that
dxd(ln(x))=dyd(f−1(y))1=ey1
But since y=ln(x):
dxd(ln(x))=eln(x)1=x1
Example - Differentiating using sympy
In Python, there is a special package for calculating derivatives symbolically, called sympy.
This can quickly and easily calculate derivatives (as well as do all sorts of other analytic calculations).
import sympy as sp
x = sp.symbols('x')# This creates a variable x, which is symbolically represented as the string x.# Calculate the derivative of x^2sp.diff(x**2, x)
2x
sp.diff(sp.cos(x), x)
−sin(x)
f =(x+1)**3* sp.cos(x**2-5)sp.diff(f,x)
−2x(x+1)3sin(x2−5)+3(x+1)2cos(x2−5)
f =(x+1)**3*(x-2)**2*(x**2+4*x +1)**4sp.diff(f, x)
You can look at the documentation for Sympy to see many other possibilities (e.g. we will use Sympy to do symbolic integration later on in this course)
Differentiate these series term by term to verify the standard expressions for dxd(sinx) and dxd(cosx).
Extension problems
Extension problems 1
The focal length of the lens of the eye, f(t), can be controlled so that an object at distance u(t) in front of the eye can be brought to perfect focus on the retina at a constant v=1.8cm behind the lens.
A fly is moving towards the eye at a speed of 0.7ms−1.
Assuming that the optics of the eye lens obeys the thin lens formula
f(t)1=u(t)1+v1,
find the rate of change of focal length required to keep the fly in perfect focus at a distance of 3m.
Note: consider carefully what you are differentiating with respect to, and the physical interpretation of the mathematics.
Extension problems 2
A contaminated lake is treated with a bactericide.
The rate of change of harmful bacteria t days after treatment is given by
dtdN=−1+t22000t
where N(t) is the number of bacteria in 1ml of water.
State with a reason whether the count of bacteria increases or decreases during the period 0≤t≤10.
Find the minimum value of dtdN during this period.
Extension problems 3
Consider a population of lions L(t) and zebra Z(t) interacting over time t.
One type of model for this situation is
dtdZ=aZ−bZLanddtdL=−cL+dZL,
where a, b, c and d are positive constants.
What values of dtdZ and dtdL correspond to stable populations?
How would the statement 'zebra go extinct' be represented mathematically?
For parameters a=0.05, b=0.001, c=0.05, and d=0.00001, find all population pairs (Z,L) that yield stable populations. Is extinction inevitable?