Skip to main content
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 material has been adapted from material by Fergus Cooper and others from the "Essential Mathematics" module at the Doctoral Training Centre, University of Oxford.

Creative Commons License
This course material was developed as part of UNIVERSE-HPC, which is funded through the SPF ExCALIBUR programme under grant number EP/W035731/1

This course material was developed as part of UNIVERSE-HPC, which is funded through the SPF ExCALIBUR programme under grant number EP/W035731/1

Creative Commons License

Differentiation 3


YouTube lecture recording from October 2020

A recording of this lecture from October 2020; the material has changed a little since.
Youtube lecture thumbnail

Why exponentials and partial derivatives?

In this lecture we use the chain rule to differentiate the exponential and logarithmic functions from the lecture on indices and logs. We need these whenever a quantity grows or decays (e.g. e−kte^{-kt}).
We then look at functions of more than one variable (e.g. the temperature at each point on a plate). We often want to know how such a function changes when just one of its variables changes. This is called partial differentiation, and we will need it when we study systems of differential equations.

Examples of applying chain rule to the exponential function

  1. y=e−axy=e^{-ax}
    Let u=−axu=-ax, so du/dx=−adu/dx=-a. Thus y=euy=e^u and
    dydu=eu⇒dydx=dydu×dudx=eu×(−a)=−ae−ax.\frac{dy}{du}=e^u \quad\Rightarrow\quad \frac{dy}{dx}=\frac{dy}{du}\times\frac{du}{dx}=e^u\times(-a)=-ae^{-ax}.
  2. y=ex2y = e^{x^2}
    Then, letting u=x2u = x^2:
    ddxex2=dydx=dydu×dudx=eu⋅2x=ex2⋅2x.\frac{d}{dx}e^{x^2}=\frac{dy}{dx}=\frac{dy}{du}\times\frac{du}{dx}=e^u\cdot 2x = e^{x^2}\cdot 2x.
So an important generalisation is:
ddxef(x)=ef(x)f′(x)\frac{d}{dx}e^{f(x)}=e^{f(x)}f'(x)
for any function f(x)f(x).

Example with the natural logarithm

  1. y=ln⁡((a−x)2)=2ln⁡∣a−x∣=2ln⁡∣u∣y=\ln\left((a-x)^2\right)=2\ln|a-x|=2\ln|u|.
    Let u=(a−x)u=(a-x):
    ⇒dudx=−1anddydu=2uThusdydx=2u×(−1)=−2a−x\Rightarrow \frac{du}{dx}=-1 \quad\text{and}\quad \frac{dy}{du}=\frac{2}{u} \quad\text{Thus}\quad \frac{dy}{dx}=\frac{2}{u}\times (-1)=\frac{-2}{a-x}
This also generalises:
ddxln⁡(f(x))=f′(x)f(x)\frac{d}{dx}\ln(f(x)) = \frac{f'(x)}{f(x)}

The derivative of axa^x

For a>0a>0, by the properties of logarithms and indices we have
ax=(eln⁡a)x=e(x⋅ln⁡a).a^x = \left(e^{\ln a}\right)^x=e^{\left(x\cdot\ln a\right)}.
Thus, as we saw above we have:
ddxax=ddxe(x⋅ln⁡a)=e(x⋅ln⁡a)ddx(x⋅ln⁡a)=ax⋅ln⁡a\frac{d}{dx}a^x = \frac{d}{dx}e^{\left(x\cdot\ln a\right)} = e^{\left(x\cdot\ln a\right)}\frac{d}{dx}\left(x\cdot\ln a\right) =a^x\cdot\ln a
So, at x=0x=0, where ax=1a^x=1, the gradient of axa^x is just ln⁡a\ln a. The following plot shows this for a=2a=2, where the gradient is ln⁡2≈0.69\ln 2\approx 0.69. For exe^x (in grey) the gradient at x=0x=0 is ln⁡e=1\ln e=1, and ee is the only base for which this is the case.
The graph of 2 to the power x and its tangent at x = 0, with the graph of e to the power x
Similarly, in general:
ddxaf(x)=af(x)⋅ln⁡a⋅f′(x)\frac{d}{dx}a^{f(x)} = a^{f(x)}\cdot \ln a\cdot f'(x)

SymPy example

Let's try and use SymPy to check this:
import sympy as sp x, a = sp.symbols('x a') # declare the variables x and a f = sp.Function('f') # declare a function dependent on another variable sp.diff(a**f(x),x) # write the expression we wish to evaluate
af(x)log⁡(a)ddxf(x)a^{f{\left(x \right)}} \log{\left(a \right)} \frac{d}{d x} f{\left(x \right)}
(SymPy writes log⁡\log for the natural logarithm, ln⁡\ln.)

The derivative of log⁡ax\log_a x

For a>0a>0, a≠1a\neq 1, recall the conversion formula log⁡ax=ln⁡x/ln⁡a\log_a x = \ln x/\ln a and note that ln⁡a\ln a is a constant. Thus:
ddxlog⁡ax=ddx(1ln⁡a⋅ln⁡x)=(1ln⁡a)⋅ddxln⁡x=(1ln⁡a)⋅1x=1x⋅ln⁡a\begin{aligned} \frac{d}{dx}\log_a x &= \frac{d}{dx}\left(\frac{1}{\ln a}\cdot\ln x\right) \\ &= \left(\frac{1}{\ln a}\right)\cdot\frac{d}{dx}\ln x \\ &= \left(\frac{1}{\ln a}\right)\cdot\frac{1}{x} \\ &= \frac{1}{x\cdot\ln a} \end{aligned}
In general:
ddxlog⁡af(x)=f′(x)f(x)(ln⁡a)\frac{d}{dx}\log_a f(x) = \frac{f'(x)}{f(x)(\ln a)}

SymPy example

Again, let's use SymPy to check this:
x, a = sp.symbols('x a') # declare the variables x and a f = sp.Function('f') # declare a function dependent on another variable sp.diff(sp.log(f(x),a),x) # write the expression we wish to evaluate
ddxf(x)f(x)log⁡(a)\frac{\frac{d}{d x} f{\left(x \right)}}{f{\left(x \right)} \log{\left(a \right)}}

Further examples

  1. Product rule: let y=x2 exy = x^2\,e^x. Then:
    dydx=ddxx2ex=ddxx2⋅ex+x2⋅ddxex=(2x+x2)ex\frac{dy}{dx}=\frac{d}{dx}x^2e^x=\frac{d}{dx}x^2\cdot e^x+x^2\cdot\frac{d}{dx}e^x = (2x + x^2)e^x
  2. Quotient rule: let y=ex/xy = e^x/x. Then:
    dydx=ddxex⋅x−ex⋅ddxxx2=ex⋅x−ex⋅1x2=x−1x2ex\frac{dy}{dx}=\frac{\frac{d}{dx}e^x\cdot x - e^x\cdot \frac{d}{dx}x}{x^2}=\frac{e^x\cdot x - e^x\cdot 1}{x^2}=\frac{x - 1}{x^2}e^x
  3. Chain rule: y=ex2y = e^{x^2}. Then, letting f(x)=x2f(x) = x^2:
    ddxex2=ef(x)f′(x)=ex2⋅2x\frac{d}{dx}e^{x^2} = e^{f(x)}f'(x) = e^{x^2}\cdot 2x
  4. y=ln⁡(x2+1)y=\ln (x^2 + 1). Then, letting f(x)=x2+1f(x) = x^2+1:
    ddxln⁡(x2+1)=f′(x)f(x)=2xx2+1\frac{d}{dx}\ln(x^2+1) = \frac{f'(x)}{f(x)} = \frac{2x}{x^2+1}
  5. ddx2x3=2x3⋅ln⁡2⋅3x2\frac{d}{dx}2^{x^3}=2^{x^3}\cdot\ln 2\cdot 3x^2
  6. ddx10x2+1=10x2+1⋅ln⁡10⋅2x\frac{d}{dx}10^{x^2+1}=10^{x^2+1}\cdot\ln 10\cdot 2x
  7. ddxlog⁡10(7x+5)=7(7x+5)⋅ln⁡10\frac{d}{dx}\log_{10}(7x+5)=\frac{7}{(7x+5)\cdot \ln10}
  8. ddxlog⁡2(3x+x4)=3x⋅ln⁡3+4x3ln⁡2⋅(3x+x4)\frac{d}{dx}\log_2(3^x+x^4)=\frac{3^x\cdot\ln3 + 4x^3}{\ln 2\cdot(3^x+x^4)}

Functions of several variables: partial differentiation

Definition: Given a function z=f(x,y)z=f(x,y) of two variables xx and yy, the partial derivative of zz with respect to xx is the function obtained by differentiating f(x,y)f(x,y) with respect to xx, holding yy constant.
We denote this using ∂\partial (a "curly" d, sometimes pronounced "del") as shown below:
∂z∂x=∂∂xf(x,y)=fx(x,y)\frac{\partial z}{\partial x}=\frac{\partial}{\partial x}f(x,y) = f_x(x,y)

Example 1

f(x,y)=z=x2−2y2f(x,y)=z=x^2-2y^2 fx=∂z∂x=2xandfy=∂z∂y=−4yf_x=\frac{\partial z}{\partial x}=2x\qquad\text{and}\qquad f_y=\frac{\partial z}{\partial y}=-4y
To see what holding yy constant means, imagine slicing through the surface z=x2−2y2z=x^2-2y^2 with the plane y=1y=1 (on the left, below). The slice is the curve z=x2−2z=x^2-2 (on the right), which is an ordinary function of xx. Its gradient at any point is fx=2xf_x=2x, so at x=1x=1 it is 2. Moving the plane to a different value of yy moves the curve up or down, but does not change its gradient, because fxf_x does not depend on yy.
The surface z = x squared minus 2 y squared cut by the plane y = 1, and the curve where they meet, with its tangent at x = 1

Example 2

Let z=3x2y+5xy2z=3x^2y+5xy^2. Then the partial derivative of zz with respect to xx, holding yy fixed, is:
∂z∂x=∂∂x (3x2y+5xy2)=3y⋅2x+5y2⋅1=6xy+5y2\begin{aligned} \frac{\partial z}{\partial x}&=\frac{\partial}{\partial x}\,\left(3x^2y+5xy^2\right) \\ &=3y\cdot 2x + 5y^2\cdot 1 \\ &=6xy+5y^2 \end{aligned}
while the partial of zz with respect to yy holding xx fixed is:
∂z∂y=∂∂y (3x2y+5xy2)=3x2⋅1+5x⋅2y=3x2+10xy\begin{aligned} \frac{\partial z}{\partial y}&=\frac{\partial}{\partial y}\,\left(3x^2y+5xy^2\right) \\ &=3x^2\cdot 1 + 5x\cdot 2y = 3x^2+10xy \end{aligned}

SymPy example

Above, we had:
∂∂x (3x2y+5xy2)=6xy+5y2\frac{\partial}{\partial x}\,\left(3x^2y+5xy^2\right) = 6xy+5y^2
Let's redo this in SymPy:
x, y = sp.symbols('x y') sp.diff(3*x**2*y + 5*x*y**2,x)
6xy+5y26 x y + 5 y^{2}

Higher-order partial derivatives

Given z=f(x,y)z = f(x,y) there are now four distinct possibilities for the second-order partial derivatives.
  1. With respect to xx twice:
    ∂∂x(∂z∂x)=∂2z∂x2=zxx\frac{\partial}{\partial x}\left(\frac{\partial z}{\partial x}\right) =\frac{\partial^2z}{\partial x^2} =z_{xx}
  2. With respect to yy twice:
    ∂∂y(∂z∂y)=∂2z∂y2=zyy\frac{\partial}{\partial y}\left(\frac{\partial z}{\partial y}\right) =\frac{\partial^2z}{\partial y^2} =z_{yy}
  3. First with respect to xx, then with respect to yy:
    ∂∂y(∂z∂x)=∂2z∂y∂x=zxy\frac{\partial}{\partial y}\left(\frac{\partial z}{\partial x}\right) =\frac{\partial^2z}{\partial y\partial x} =z_{xy}
  4. First with respect to yy, then with respect to xx:
    ∂∂x(∂z∂y)=∂2z∂x∂y=zyx\frac{\partial}{\partial x}\left(\frac{\partial z}{\partial y}\right) =\frac{\partial^2z}{\partial x\partial y} =z_{yx}

Example: Laplace's equation for equilibrium temperature distribution on a copper plate

Let T(x,y)T(x,y) give the temperature at the point (x,y)(x,y).
According to a result of the French mathematician Pierre-Simon Laplace (1749 - 1827), at every point (x,y)(x,y) the second-order partials of TT must satisfy the equation:
Txx+Tyy=0T_{xx} + T_{yy} = 0
We can verify that the function T(x,y)=y2−x2T(x,y)=y^2-x^2 satisfies Laplace's equation:
First with respect to xx:
Tx(x,y)=0−2x=−2xsoTxx(x,y)=−2T_x(x,y)=0-2x=-2x\qquad\text{so}\qquad T_{xx}(x,y)=-2
Then with respect to yy:
Ty(x,y)=2y−0=2ysoTyy(x,y)=2T_y(x,y)=2y-0=2y\qquad\text{so}\qquad T_{yy}(x,y)=2
Finally:
Txx(x,y)+Tyy(x,y)=−2+2=0T_{xx}(x,y)+T_{yy}(x,y) = -2 + 2 = 0
which proves the result.
The following plot shows this temperature on a square plate, with −1≤x≤1-1\le x\le 1 and −1≤y≤1-1\le y\le 1. It is the temperature that the plate settles to when its top and bottom edges are held warm and its left and right edges are held cold. (Only differences in temperature matter here, so a negative value of TT just means colder than some reference temperature.) Note that the hottest and coldest points are on the edges of the plate. A solution of Laplace's equation can never have a hot or cold spot inside the plate.
The temperature T = y squared minus x squared on a square plate, warm along the top and bottom edges and cold along the left and right edges
The function z=x2y−xy2z=x^2y - xy^2 does not satisfy Laplace's equation (and so cannot be a model for thermal equilibrium).
First note that
zx=2xy−y2zxx=2y\begin{aligned} z_x &= 2xy - y^2 \\ z_{xx} &= 2y \end{aligned}
and that
zy=x2−2xyzyy=−2x\begin{aligned} z_y &= x^2 - 2xy \\ z_{yy} &= -2x \end{aligned}
Therefore:
zxx+zyy=2y−2xz_{xx}+z_{yy}=2y-2x
which is not zero everywhere (it is only zero on the line y=xy=x).
We can also verify this in SymPy like so:
T1 = y**2 - x**2 sp.diff(T1, x, x) + sp.diff(T1, y, y)
00
and for the second function:
T2 = x**2*y - x*y**2 sp.diff(T2, x, x) + sp.diff(T2, y, y)
−2x+2y- 2 x + 2 y

A note on the mixed partials fxyf_{xy} and fyxf_{yx}

For almost any function you will meet, fxy=fyxf_{xy}=f_{yx}, so it does not matter in which order we take the partial derivatives (there are exceptions, but you are unlikely to meet them).

Example

Let z=x2y3+3x2−2y4z = x^2y^3+3x^2-2y^4. Then zx=2xy3+6xz_x=2xy^3+6x and zy=3x2y2−8y3z_y = 3x^2y^2-8y^3.
Taking the partial of zxz_x with respect to yy we get
zxy=∂∂y(2xy3+6x)=6xy2z_{xy}=\frac{\partial}{\partial y}\left(2xy^3+6x\right)=6xy^2
Taking the partial of zyz_y with respect to xx we get the same thing:
zyx=∂∂x(3x2y2−8y3)=6xy2z_{yx}=\frac{\partial}{\partial x}\left(3x^2y^2-8y^3\right)=6xy^2
So the operators ∂/∂x\partial/\partial x and ∂/∂y\partial/\partial y are commutative:
i.e.∂∂x(∂z∂y)=∂∂y(∂z∂x)\text{i.e.} \qquad \frac{\partial}{\partial x}\left(\frac{\partial z}{\partial y}\right) = \frac{\partial}{\partial y}\left(\frac{\partial z}{\partial x}\right)

Introductory problems

Tip

For more practice, an AI tool can write new problems like the ones below. Ask it for problems of the same type and difficulty, or for problems set in your own field. For example, you could ask it to "write five chemistry problems on partial derivatives, at the level of these ones". Work them on paper first, then ask the tool to check your answers and to explain any step you are unsure of.

Introductory problems 1

Differentiate the following functions with respect to xx, using the stated rules where indicated:
  1. Product rule: x ex\sqrt{x}\,e^x
  2. Product rule: 3x2ln⁡(x)3x^2 \ln(x)
  3. Chain rule: e−4x3e^{-4x^3}
  4. Chain rule: ln⁡x3/2/6\ln \sqrt{x^{3/2}/6}
  5. Chain rule: 10x210^{x^2}
  6. Any rules: ln⁡x/(5x−7)\ln x/(5x-7)
  7. Any rules: ex/(2x3−1)e^x/(2x^3-1)
  8. Any rules: log⁡2(xcos⁡(x))\log_2\left(x\cos(x)\right)

Introductory problems 2

If y=e−axy=e^{-ax}, show that
2d2ydx2+adydx−a2y=0.2\frac{d^2y}{dx^2}+a\frac{dy}{dx}-a^2y=0.

Introductory problems 3

If y=e−xsin⁡(x)y=e^{-x}\sin(x), show that
d2ydx2+2dydx+2y=0.\frac{d^2y}{dx^2} + 2\frac{dy}{dx} + 2y = 0.

Introductory problems 4

Find the partial derivatives fxf_x and fyf_y of the following functions:
  1. f(x,y)=x3+4xy2−y4f(x,y) = x^3 + 4xy^2 - y^4
  2. f(x,y)=e2xsin⁡(y)f(x,y) = e^{2x}\sin(y)
  3. f(x,y)=ln⁡(x2+y2)f(x,y) = \ln\left(x^2 + y^2\right)

Main problems

Main problems 1

The power, WW, that a certain machine develops is given by the formula
W=EI−RI2W=EI-RI^2
where II is the current and EE and RR are positive constants.
Find the maximum value of WW as II varies.

Main problems 2

Environmental health officers monitoring an outbreak of food poisoning after a wedding banquet were able to model the time course of the recovery of the guests using the equation:
r=100t1+tr = \frac{100t}{1+t}
where tt represents the number of days since infection and rr is the percentage of guests who no longer display symptoms. Determine an expression for the rate of recovery.

Main problems 3

An experiment called 'the reptilian drag race' looks at how agamid lizards accelerate from a standing start.
The distance xx travelled in time tt on a horizontal surface has been modelled as
x=vmax(t+e−ktk−1k),x = v_{\text{max}} \left(t + \frac{e^{-kt}}{k} - \frac{1}{k}\right),
where vmaxv_{\text{max}} is the maximum velocity, and kk is a rate constant.
  1. Find expressions for the velocity vv and acceleration aa as functions of time.
  2. For vmax=3 v_{\text{max}} = 3\,m \,s−1^{-1} and k=10 k=10\,s−1^{-1}, sketch xx, vv and a/10a/10 on the same axes for 0≤t≤1 0\leq t\leq 1\,s.

Main problems 4

The distance xx that a particular organism travels over time from its starting location is modelled by the equation
x(t)=t2ek(1−t),x(t) = t^2 e^{k(1-t)},
where kk is a positive constant and 0≤t≤1 0\leq t\leq 1\,s.
  1. Sketch xx over time for k=1/2k=1/2 and k=3k=3.
  2. Calculate an expression for the organism's velocity as a function of time.
  3. What is the largest value of kk such that the organism never starts moving back towards where it started?

Main problems 5

The function
S=Smax(1−e−t/τ)S = S_{\text{max}}(1- e^{-t/\tau})
is used to describe sediment thickness accumulating in an extensional basin through time. What is the sedimentation rate?

Main problems 6

Which of these functions could describe the equilibrium temperature T(x,y)T(x,y) of a copper plate? That is, which satisfy Laplace's equation, Txx+Tyy=0T_{xx} + T_{yy} = 0?
  1. T=x3−3xy2T = x^3 - 3xy^2
  2. T=exsin⁡(y)T = e^x\sin(y)
  3. T=x2+y2T = x^2 + y^2
  4. T=ln⁡(x2+y2)T = \ln\left(x^2 + y^2\right), for (x,y)≠(0,0)(x,y) \neq (0,0)

Extension problems

Extension problems 1

Let
z=23x3−34x2y+25y3.z = \frac{2}{3}x^3 - \frac{3}{4}x^2y + \frac{2}{5}y^3.
  1. Find zxz_x and zyz_y
  2. Find zxxz_{xx} and zyyz_{yy}
  3. Show that zxy=zyxz_{xy} = z_{yx}

Extension problems 2

Show that fxy=fyxf_{xy}=f_{yx} for the following functions:
  1. f(x,y)=x2−xy+y3f(x,y) = x^2 - xy + y^3
  2. f(x,y)=ey ln⁡(2x−y)f(x,y) = e^y\,\ln(2x-y)
  3. f(x,y)=2 x y e2xyf(x,y) = 2\,x\,y\,e^{2xy}
  4. f(x,y)=x sin⁡(y)f(x,y) = x\,\sin(y)

Extension problems 3

The body mass index, BB, is used as a parameter to classify people as underweight, normal, overweight and obese. It is defined as their weight in kg, ww, divided by the square of their height in metres, hh.
  1. Sketch a graph of BB against ww for a person who is 1.7m tall.
  2. Find the rate of change of BB with weight of this person.
  3. Sketch a graph of BB against hh for a child whose weight is constant at 35 kg.
  4. Find the rate of change of BB with height hh of this child.
  5. Show that
    ∂2B∂h∂w=∂2B∂w∂h.\frac{\partial^2 B}{\partial h \partial w}=\frac{\partial^2 B}{\partial w \partial h}.

Extension problems 4

A light wave or a sound wave propagated through time and space can be represented in a simplified form by:
y=Asin⁡(2π(xλ+ft))y=A\sin\left(2\pi\left(\frac{x}{\lambda}+f t\right)\right)
where AA is the amplitude, λ\lambda is the wavelength and ff is the frequency of the wave. xx and tt are position and time respectively.
An understanding of this function is essential for many problems such as sound, light microscopy, phase microscopy and X-ray diffraction.
  1. Draw a graph of yy as a function of xx assuming t=0t=0.
  2. Draw a graph of yy as a function of tt assuming x=0x=0.
  3. At what values of xx and tt does the function repeat itself?
  4. Find the rate at which yy changes at an arbitrary fixed position.
  5. Show that yxt=ytxy_{xt} = y_{tx}.