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
Differential equations 2
Learning outcomes
Be able to translate a literal description between quantities into a differential equation
Be able to use partial fractions to solve a separable differential equation
Be able to check a solution numerically with SciPy
Understand how to use the method of substitution to solve higher-order differential equations
YouTube lecture recording from October 2020
A recording of this lecture from October 2020; the material has changed a little since.
Why form differential equations from words?
In practice, nobody hands us the differential equation: we have a description of what makes a quantity change (e.g. a leaf gains water from its plant and loses it by evaporation).
Turning that description into an equation is the first step in building a model, and once we have the equation we can solve it, by hand or numerically.
In this lecture we form differential equations from words, solve them with the methods of lecture 9 and partial fractions, and meet our first second order equations.
What does "proportional to" mean?
y is proportional tox if y=kx for some constant k, called the constant of proportionality.
We write y∝x.
For example, if a leaf absorbs water at a rate proportional to its length y, then the rate is k1y, for some constant k1.
A quantity can also be proportional to a power of another.
For example, the area of a circle is proportional to the square of its radius: A=πr2, so A∝r2.
If y∝w, then their rates of change are proportional too:
y=kw⇒dtdy=kdtdw
Example 1: a growing leaf
Let us try to form a differential equation based on the following information:
The length y cm of a leaf during the period of its growth is proportional to the amount of water it contains.
During this period the leaf retains a similar shape: that is, the ratio of its length to its width remains constant.
The leaf absorbs water from its plant at a rate proportional to y and it loses water by evaporation at a rate proportional to the area of the leaf at the time when its length is y cm.
Assume the length of the leaf is y cm at time t days after it was first observed.
Let the rate the leaf receives water be k1y where k1 is a positive constant.
Area of leaf at time t days is proportional to y2 since it maintains its shape, so the leaf is losing water at a rate of k2y2 where k2 is another positive constant.
The length is proportional to the amount of water, so the rate of growth, dy/dt, is proportional to the rate at which the leaf gains water, less the rate at which it loses it.
This gives us the equation:
dtdy=k1y−k2y2=y(k1−k2y)
We will solve it once we have looked at a second example.
Example 2: solid tumour growth
An avascular tumour tends to grow in a spherical shape, depending on environmental restrictions.
Assuming that the growth rate of the tumour depends only on the availability of oxygen and nutrients, which enter the tumour solely by diffusing through its surface, derive a model for the change in tumour volume over time.
Denote the volume of the tumour at time t by V(t), and its radius by R(t).
Since the tumour is a sphere, its volume V is proportional to R3 and its surface area to R2, so the surface area is proportional to V2/3.
The rate at which the tumour acquires nutrients, and hence the rate at which the volume increases, is thus proportional to V2/3.
This gives us the equation:
dtdV=kV2/3
Solve by separation of variables:
∫V−2/3dV3V1/3V=∫kdt=kt+c=(3kt+c)3
where c is a constant of integration, the value of which will depend upon the initial conditions.
If the volume at t=0 is V0, then c=3V01/3.
When k=1 and V0=10, the solution looks like the solid line below.
For comparison, the dashed line shows exponential growth, dV/dt=rV, from the same volume and at the same initial rate (r=kV0−1/3).
Because the nutrients enter only through the surface, the tumour falls further and further behind: its volume grows like t3, and its radius, which is proportional to V1/3=V01/3+kt/3, grows at a constant rate.
Example 1 again: solving the leaf equation
Let us return to, and solve, our leaf example:
dtdy=k1y−k2y2=y(k1−k2y)
This is a separable differential equation:
∫y(k1−k2y)dy=∫dt.
To integrate the left-hand side, we split it into partial fractions, as in lecture 7.
We want
y(k1−k2y)1=yA+k1−k2yB.
Multiply both sides by y(k1−k2y) to get:
A(k1−k2y)+By=1soAk1+(B−Ak2)y=1
Equate the constant terms (coefficients of y0):
Ak1=1soA=k11
Equate coefficients of y:
B−Ak2=0soB=k1k2
We can check this with SymPy's apart function:
import sympy as sp
y, k1, k2 = sp.symbols('y k_1 k_2')sp.apart(1/(y*(k1 - k2*y)), y)
−k1(−k1+k2y)k2+k1y1
which agrees: A=1/k1 and B=k2/k1.
Thus
∫k1ydy+∫k1(k1−k2y)k2dy=∫dt.
While the leaf is growing, 0<y<k1/k2, so both logarithms are of positive numbers:
k11lny−k11ln(k1−k2y)=t+c
To make y the subject, multiply by k1 and combine the logarithms, writing d=k1c:
ln(k1−k2yy)=k1t+d
Take the exponential of both sides, and multiply by k1−k2y:
y=(k1−k2y)ek1t+dsoy(1+k2ek1t+d)=k1ek1t+d
which gives
y=1+k2ek1t+dk1ek1t+d.
We can get d from the initial condition: if y=y0 at t=0, then ed=y0/(k1−k2y0).
This is the logistic equation from lecture 3 (with k=k1 and b=k2), and we will meet it again in lecture 11.
As t grows, y levels off at k1/k2.
We can check our solution numerically, as in lecture 9:
The two lines lie on top of each other, and the leaf levels off at k1/k2=2.
Second order differential equations
The order of a differential equation is the order of the highest derivative in it.
Example 3
Let us try to solve the following second order equation:
dx2d2y=(dxdy)2
We will use the substitution z=dy/dx.
This implies that
dxdz=dx2d2y.
Substituting into the original equation, to eliminate y, gives
dxdz=z2
This is a separable equation:
∫z−2dz=∫dx⇒−z1=x+A⇒z=−x+A1
where A is an arbitrary constant.
We can then replace z using the original substitution to obtain a first order differential equation:
dxdy=−x+A1
This equation can be solved with a standard integral:
y=−ln(x+A)+B
How do we determine A and B?
There are two constants, so we need two pieces of information.
Determining the values of A and B can be done in several different ways, depending on the kind of information we have.
Case 1
Maybe we know that at x=0, dy/dx=−1 and y=0.
Substitute the first condition into dy/dx=−1/(x+A):
−1=−0+A1soA=1
Then substitute A=1 and the second condition into y=−ln(x+A)+B:
0=−ln1+BsoB=0
So the solution is y=−ln(x+1).
Case 2
Maybe instead we know that y(0)=0 and y(e−1)=−1: two values of y, and no value of dy/dx.
This time both conditions go into the solution y=−ln(x+A)+B.
The first, y(0)=0, gives:
0=−lnA+BsoB=lnA
Then substitute B=lnA and the second condition, y(e−1)=−1:
−1=−ln(e−1+A)+lnA=ln(e−1+AA)
Take the exponential of both sides, and solve for A:
e−1e−1+Ae−1A=e−1+AA=eA=(e−1)A=1
So B=ln1=0, and y=−ln(x+1): the same solution as in case 1.
Introductory problems
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 medicine problems on forming differential equations from words, 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
Find the general solutions of the following differential equations:
dy/dx=x2+ex
dy/dx=y2/x
(1/x)dy/dx=e4x
dy/dx=−2xy
Check your answers by differentiating them.
In each case, C and A are arbitrary constants.
Integrate both sides:
y=∫(x2+ex)dx=3x3+ex+C
Separate the variables:
∫y2dy=∫xdx⇒−y1=ln∣x∣+C⇒y=−ln∣x∣+C1
(Dividing by y2 assumes y=0: y=0 is also a solution.)
Multiply both sides by x and integrate, using integration by parts with u=x and v′=e4x:
y=∫xe4xdx=4xe4x−∫4e4xdx=4xe4x−16e4x+C
Separate the variables:
∫ydy=−∫2xdx⇒ln∣y∣=−x2+C⇒y=Ae−x2
Introductory problems 2
Write down a differential equation for each of the following, defining any symbols and constants you use, and saying whether each constant is positive or negative.
Do not solve them.
A drug is cleared from the blood at a rate proportional to the amount of drug present.
A population of cells grows at a rate proportional to its size, and cells are also removed (harvested) at a constant rate.
A spherical raindrop evaporates at a rate proportional to its surface area.
Write an equation for its volume, and then one for its radius.
A rumour spreads through a group of fixed size at a rate proportional to both the number of people who have heard it and the number who have not.
Let D be the amount of drug in the blood at time t.
The amount is decreasing, so
dtdD=−kD
where k is a positive constant.
Let N be the number of cells at time t.
Growth adds cells at a rate rN and harvesting removes them at a rate h, so
dtdN=rN−h
where r and h are positive constants.
Let V be the volume of the raindrop and r its radius at time t.
Its surface area is 4πr2, and the volume is decreasing, so
dtdV=−k4πr2
where k is a positive constant.
Since V=34πr3, the chain rule gives
dtdV=4πr2dtdr
Setting the two expressions for dV/dt equal and dividing by 4πr2 gives
dtdr=−k
So, the radius of the raindrop shrinks at a constant rate.
Let the group contain M people, and let y be the number who have heard the rumour at time t.
Then M−y people have not heard it, so
dtdy=ky(M−y)
where k is a positive constant.
This has the same form as the leaf equation, dy/dt=y(k1−k2y), from the lecture.
Introductory problems 3
Split each of the following into partial fractions by hand, and check your answers using sp.apart.
Then integrate each one with respect to x.
x(x+1)1
(x−1)(x+2)x+5
Use your answer to part 1. to find the general solution of the differential equation dy/dt=y(y+1).
We want
x(x+1)1=xA+x+1B
Multiplying both sides by x(x+1) gives 1=A(x+1)+Bx.
Setting x=0 gives A=1, and setting x=−1 gives B=−1.
So,
∫x(x+1)dx=∫(x1−x+11)dx=ln∣x∣−ln∣x+1∣+C
We want
(x−1)(x+2)x+5=x−1A+x+2B
Multiplying both sides by (x−1)(x+2) gives x+5=A(x+2)+B(x−1).
Setting x=1 gives 6=3A, so A=2, and setting x=−2 gives 3=−3B, so B=−1.
So,
import sympy as sp
x = sp.symbols('x')print(sp.apart(1/(x*(x +1)), x))print(sp.apart((x +5)/((x -1)*(x +2)), x))
-1/(x + 1) + 1/x
-1/(x + 2) + 2/(x - 1)
For the differential equation, separate the variables and use part 1.:
∫y(y+1)dy=∫dt⇒lny+1y=t+C
Taking the exponential of both sides gives y/(y+1)=Aet, where A is an arbitrary constant.
Then y=Aet(y+1), so y(1−Aet)=Aet and
y=1−AetAet
(Dividing by y(y+1) assumes y=0 and y=−1.
The solution y=0 is the case A=0, and y=−1 is also a solution.)
Main problems
Main problems 1
A circular patch of oil on the surface of some water has a radius r metres at time t minutes.
When t=0 minutes, r=1m and when t=10 minutes, r=2m.
Predict the value T of t when r=4m, using a simple model in which the rate of increase of r is taken to be constant.
Find T for this model.
In a more refined model, the rate of increase of r is taken to be proportional to 1/r.
Express this statement as a differential equation, and find the general solution.
Find T for this model.
Compare the two models used in 1. and 2., by sketching r(t) on the same figure or plotting using Python.
Comment on the differences seen during different time intervals.
If dr/dt is a constant a, then r=at+C.
r(0)=1 gives C=1, and r(10)=2 gives a=0.1, so r=1+0.1t.
Then r=4 when 4=1+0.1T, so T=30 minutes.
The rate of increase is proportional to 1/r:
dtdr=rk
where k is a positive constant.
Separate the variables:
∫rdr=∫kdt⇒2r2=kt+C
so the general solution is r=2kt+2C.
r(0)=1 gives C=1/2, and r(10)=2 gives 2=10k+1/2, so k=3/20.
So, r2=1+0.3t.
Then r=4 when 16=1+0.3T, so T=50 minutes.
Both models agree at t=0 and t=10:
import numpy as np
from matplotlib import pyplot as plt
t = np.linspace(0,60,200)plt.plot(t,1+0.1* t, label='constant rate')plt.plot(t, np.sqrt(1+0.3* t), label='rate proportional to 1/r')plt.xlabel('t (minutes)')plt.ylabel('r (m)')plt.legend()
Between t=0 and t=10, the second model grows faster, as its rate is largest when r is small.
After t=10, it grows more and more slowly, and falls behind the constant-rate model, which is why it takes longer to reach 4m.
Main problems 2
A nuclear installation local to Oxford 'lost' 17g of Cobalt-60 between two inspections 6 months apart.
A spokesperson told a newspaper reporter that the loss was due to 'natural radioactive decay' during that period.
If this explanation was correct, what mass of Cobalt was stored on the site?
(The half life of 60Co = 5.26 years.)
Let M be the mass of Cobalt-60 at the first inspection.
Radioactive decay gives m=Me−λt, with
λ=t1/2ln2=5.26ln2≈0.132year−1
After 6 months, t=0.5 years, and the mass lost is
M−Me−0.5λ=M(1−e−0.5λ)=17
So,
M=1−e−0.5λ17≈0.063817≈267g
If the explanation was correct, about 267g of Cobalt-60 was stored on the site.
Main problems 3
By making a substitution z=dy/dx, solve the equation
dx2d2y=(1−3x2)(dxdy)2withy(2)=0andy′(2)=1/6.
Hint: you will need to use partial fractions for part of this question, to break up
x3−x1=x−1+x+11/2+x−11/2.
With z=dy/dx, we have d2y/dx2=dz/dx, so the equation becomes a first order equation for z:
dxdz=(1−3x2)z2
Separate the variables:
∫z2dz=∫(1−3x2)dx⇒−z1=x−x3+C
y′(2)=1/6 means z=1/6 at x=2, so −6=2−8+C, and C=0.
So,
dxdy=z=−x−x31=x3−x1
Now integrate, using the partial fractions in the hint:
y(2)=0 gives 0=−ln2+21ln3+0+D, so D=ln2−21ln3.
Combining the logs (for x>1, near the starting point x=2):
y=21ln(x2−1)−lnx+ln2−21ln3=21ln(3x24(x2−1))
Main problems 4
Suppose a cell contains a chemical (the solute) dissolved in it at a concentration of c(t), and the concentration of the same substance outside the cell is a constant k.
By Fick's law, if c(t) and k are unequal, solute moves across the cell wall at a rate proportional to the difference between c(t) and k, towards the region of lower concentration.
Write down a differential equation which is satisfied by c(t).
Solve this differential equation with the initial condition c(0)=c0.
Sketch the solutions for c0>k and k>c0.
Blood glucose concentration is 5.1 mM and the concentration inside the cell is at 0.1 mM.
If glucose utilisation within the cell is totally inhibited, it takes 1 min for the intracellular concentration to reach 2.6 mM.
How long would it take for the concentration to reach 5.0 mM?
Calculate the amount of glucose (moles) entering the cell to bring the concentration from 0.1 mM to 5 mM assuming the cell is spherical with a diameter of 10μm.
The rate of change of c is proportional to the difference k−c, and solute moves towards the lower concentration:
dtdc=α(k−c)
where α is a positive constant.
If c<k, then dc/dt>0 and solute moves into the cell; if c>k, it moves out.
Separate the variables:
∫k−cdc=∫αdt⇒−ln∣k−c∣=αt+D⇒k−c=Be−αt
c(0)=c0 gives B=k−c0, so
c=k−(k−c0)e−αt
In both cases c starts at c0 and approaches k exponentially.
If c0>k, c decreases towards k; if c0<k, c increases towards k:
import numpy as np
from matplotlib import pyplot as plt
k =1t = np.linspace(0,5,200)for c0 in[2,0]: plt.plot(t, k -(k - c0)* np.exp(-t), label=f'c0 = {c0}')plt.axhline(k, linestyle='--', color='grey')plt.xlabel('t')plt.ylabel('c')plt.legend()
Here k=5.1 and c0=0.1, so c=5.1−5e−αt.
At t=1 minute, c=2.6:
2.6=5.1−5e−α⇒e−α=0.5⇒α=ln2min−1
The concentration reaches 5.0mM when
5.0=5.1−5e−αt⇒e−αt=501⇒t=ln2ln50≈5.6minutes
The volume of the cell, with radius 5μm=5×10−6m, is
V=34π(5×10−6)3≈5.24×10−16m3=5.24×10−13l
The concentration rises by 5.0−0.1=4.9mM=4.9×10−3mol/l, so the amount of glucose entering the cell is
4.9×10−3×5.24×10−13≈2.57×10−15mol
Extension problems
Extension problems 1
Consider a simple model of the production and degradation of a protein.
The protein is produced at a constant rate k1, and degraded at a rate proportional to its concentration, with constant k2.
Form and solve a differential equation describing the change in protein concentration.
What concentration is reached after 'sufficient' time has elapsed?
Let s be the protein concentration at time t, with s(0)=s0.
It increases at rate k1 and decreases at rate k2s, so