Skip to main content
Differential equations 2
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

Differential equations 2


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 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?

yy is proportional to xx if y=kxy = kx for some constant kk, called the constant of proportionality. We write y∝xy \propto x.
For example, if a leaf absorbs water at a rate proportional to its length yy, then the rate is k1yk_1y, for some constant k1k_1.
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=πr2A = \pi r^2, so A∝r2A \propto r^2.
If y∝wy \propto w, then their rates of change are proportional too:
y=kw⇒dydt=kdwdty = kw \qquad\Rightarrow\qquad \frac{dy}{dt} = k\frac{dw}{dt}

Example 1: a growing leaf

Let us try to form a differential equation based on the following information:
The length yy 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 yy and it loses water by evaporation at a rate proportional to the area of the leaf at the time when its length is yy cm.
  1. Assume the length of the leaf is yy cm at time tt days after it was first observed.
  2. Let the rate the leaf receives water be k1yk_1y where k1k_1 is a positive constant.
  3. Area of leaf at time tt days is proportional to y2y^2 since it maintains its shape, so the leaf is losing water at a rate of k2y2k_2y^2 where k2k_2 is another positive constant.
  4. The length is proportional to the amount of water, so the rate of growth, dy/dtdy/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:
dydt=k1y−k2y2=y(k1−k2y)\frac{dy}{dt}=k_1y-k_2y^2=y(k_1-k_2y)
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.
  1. Denote the volume of the tumour at time tt by V(t)V(t), and its radius by R(t)R(t).
  2. Since the tumour is a sphere, its volume VV is proportional to R3R^3 and its surface area to R2R^2, so the surface area is proportional to V2/3V^{2/3}.
  3. The rate at which the tumour acquires nutrients, and hence the rate at which the volume increases, is thus proportional to V2/3V^{2/3}.
This gives us the equation:
dVdt=kV2/3\frac{dV}{dt} = kV^{2/3}
Solve by separation of variables:
∫V−2/3 dV=∫k dt3V1/3=kt+cV=(kt+c3)3\begin{aligned} \int V^{-2/3}\,dV &= \int k\,dt \\ 3V^{1/3} &= kt + c \\ V &= \left(\frac{kt+c}{3}\right)^3 \end{aligned}
where cc is a constant of integration, the value of which will depend upon the initial conditions. If the volume at t=0t=0 is V0V_0, then c=3V01/3c = 3V_0^{1/3}.
When k=1k=1 and V0=10V_0=10, the solution looks like the solid line below. For comparison, the dashed line shows exponential growth, dV/dt=rVdV/dt = rV, from the same volume and at the same initial rate (r=kV0−1/3r = kV_0^{-1/3}). Because the nutrients enter only through the surface, the tumour falls further and further behind: its volume grows like t3t^3, and its radius, which is proportional to V1/3=V01/3+kt/3V^{1/3} = V_0^{1/3} + kt/3, grows at a constant rate.
Solution when k=1 and V0=10, against exponential growth from the same volume at the same initial rate

Example 1 again: solving the leaf equation

Let us return to, and solve, our leaf example:
dydt=k1y−k2y2=y(k1−k2y)\frac{dy}{dt}=k_1y-k_2y^2=y(k_1-k_2y)
This is a separable differential equation:
∫dyy(k1−k2y)=∫dt.\int \frac{dy}{y(k_1-k_2y)} =\int dt.
To integrate the left-hand side, we split it into partial fractions, as in lecture 7. We want
1y(k1−k2y)=Ay+Bk1−k2y.\frac{1}{y(k_1-k_2y)}=\frac{A}{y}+\frac{B}{k_1-k_2y}.
Multiply both sides by y(k1−k2y)y(k_1-k_2y) to get:
A(k1−k2y)+By=1soAk1+(B−Ak2)y=1A(k_1-k_2y)+By=1 \qquad\text{so}\qquad Ak_1 + (B - Ak_2)y = 1
Equate the constant terms (coefficients of y0y^0):
Ak1=1soA=1k1Ak_1 = 1 \qquad\text{so}\qquad A=\frac{1}{k_1}
Equate coefficients of yy:
B−Ak2=0soB=k2k1B - Ak_2 = 0 \qquad\text{so}\qquad B=\frac{k_2}{k_1}
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)
−k2k1(−k1+k2y)+1k1y- \frac{k_{2}}{k_{1} \left(- k_{1} + k_{2} y\right)} + \frac{1}{k_{1} y}
which agrees: A=1/k1A=1/k_1 and B=k2/k1B=k_2/k_1. Thus
∫dyk1y+∫k2k1(k1−k2y) dy=∫dt.\int \frac{dy}{k_1y}+\int \frac{k_2}{k_1(k_1-k_2y)}\,dy =\int dt.
While the leaf is growing, 0<y<k1/k20 < y < k_1/k_2, so both logarithms are of positive numbers:
1k1ln⁡y−1k1ln⁡(k1−k2y)=t+c\frac{1}{k_1}\ln y-\frac{1}{k_1}\ln(k_1-k_2y)=t + c
To make yy the subject, multiply by k1k_1 and combine the logarithms, writing d=k1cd = k_1c:
ln⁡(yk1−k2y)=k1t+d\ln\left(\frac{y}{k_1-k_2y}\right)=k_1t + d
Take the exponential of both sides, and multiply by k1−k2yk_1-k_2y:
y=(k1−k2y)ek1t+dsoy(1+k2ek1t+d)=k1ek1t+dy = (k_1-k_2y)e^{k_1t+d} \qquad\text{so}\qquad y\left(1 + k_2e^{k_1t+d}\right) = k_1e^{k_1t+d}
which gives
y=k1ek1t+d1+k2ek1t+d.y=\frac{k_1 e^{k_1t+d}}{1+ k_2 e^{k_1t + d}}.
We can get dd from the initial condition: if y=y0y = y_0 at t=0t = 0, then ed=y0/(k1−k2y0)e^d = y_0/(k_1-k_2y_0).
This is the logistic equation from lecture 3 (with k=k1k = k_1 and b=k2b = k_2), and we will meet it again in lecture 11. As tt grows, yy levels off at k1/k2k_1/k_2.
We can check our solution numerically, as in lecture 9:
import numpy as np from scipy.integrate import solve_ivp k1 = 1.0 k2 = 0.5 y0 = 0.1 t = np.linspace(0, 10, 100) d = np.log(y0 / (k1 - k2*y0)) y_exact = (k1*np.exp(k1*t + d) / (1 + k2*np.exp(k1*t + d))) def dydt(t, y): return k1*y - k2*y**2 solution = solve_ivp(dydt, [0, 10], [y0], t_eval=t) y_numerical = solution.y[0]
When k1=1k_1 = 1 and k2=0.5k_2 = 0.5, the solution looks like:
Plot of the numerical vs exact solution of the leaf equation, when k1 = 1 and k2 = 0.5
The two lines lie on top of each other, and the leaf levels off at k1/k2=2k_1/k_2 = 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:
d2ydx2=(dydx)2\frac{d^2y}{dx^2} = \left(\frac{dy}{dx}\right)^2
We will use the substitution z=dy/dxz = dy/dx. This implies that
dzdx=d2ydx2.\frac{dz}{dx} = \frac{d^2y}{dx^2}.
Substituting into the original equation, to eliminate yy, gives
dzdx=z2\frac{dz}{dx} = z^2
This is a separable equation:
∫z−2 dz=∫dx⇒−1z=x+A⇒z=−1x+A\int z^{-2}\,dz = \int dx \qquad\Rightarrow\qquad-\frac{1}{z} = x + A \qquad\Rightarrow\qquad z = -\frac{1}{x+A}
where AA is an arbitrary constant.
We can then replace zz using the original substitution to obtain a first order differential equation:
dydx=−1x+A\frac{dy}{dx} = -\frac{1}{x+A}
This equation can be solved with a standard integral:
y=−ln⁡(x+A)+By = -\ln(x+A) + B
How do we determine AA and BB? There are two constants, so we need two pieces of information. Determining the values of AA and BB can be done in several different ways, depending on the kind of information we have.

Case 1

Maybe we know that at x=0x=0, dy/dx=−1dy/dx = -1 and y=0y=0.
Substitute the first condition into dy/dx=−1/(x+A)dy/dx = -1/(x+A):
−1=−10+AsoA=1-1 = -\frac{1}{0+A} \qquad\text{so}\qquad A=1
Then substitute A=1A=1 and the second condition into y=−ln⁡(x+A)+By = -\ln(x+A) + B:
0=−ln⁡1+BsoB=00 = -\ln 1 + B \qquad\text{so}\qquad B=0
So the solution is y=−ln⁡(x+1)y = -\ln(x+1).

Case 2

Maybe instead we know that y(0)=0y(0)=0 and y(e−1)=−1y(e-1)=-1: two values of yy, and no value of dy/dxdy/dx.
This time both conditions go into the solution y=−ln⁡(x+A)+By = -\ln(x+A) + B. The first, y(0)=0y(0)=0, gives:
0=−ln⁡A+BsoB=ln⁡A0 = -\ln A + B \qquad\text{so}\qquad B=\ln A
Then substitute B=ln⁡AB = \ln A and the second condition, y(e−1)=−1y(e-1)=-1:
−1=−ln⁡(e−1+A)+ln⁡A=ln⁡(Ae−1+A)-1 = -\ln(e-1+A) + \ln A = \ln\left(\frac{A}{e-1+A}\right)
Take the exponential of both sides, and solve for AA:
e−1=Ae−1+Ae−1+A=eAe−1=(e−1)AA=1\begin{aligned} e^{-1} &= \frac{A}{e-1+A} \\ e-1+A &= eA \\ e-1 &= (e-1)A \\ A &= 1 \end{aligned}
So B=ln⁡1=0B = \ln 1 = 0, and y=−ln⁡(x+1)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:
  1. dy/dx=x2+exdy/dx = x^2 + e^x
  2. dy/dx=y2/xdy/dx = y^2/x
  3. (1/x) dy/dx=e4x(1/x)\,dy/dx = e^{4x}
  4. dy/dx=−2xydy/dx = -2xy
Check your answers by differentiating them.

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.
  1. A drug is cleared from the blood at a rate proportional to the amount of drug present.
  2. A population of cells grows at a rate proportional to its size, and cells are also removed (harvested) at a constant rate.
  3. A spherical raindrop evaporates at a rate proportional to its surface area. Write an equation for its volume, and then one for its radius.
  4. 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.

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 xx.
  1. 1x(x+1)\frac{1}{x(x+1)}
  2. x+5(x−1)(x+2)\frac{x+5}{(x-1)(x+2)}
Use your answer to part 1. to find the general solution of the differential equation dy/dt=y(y+1)dy/dt = y(y+1).

Main problems

Main problems 1

A circular patch of oil on the surface of some water has a radius rr metres at time tt minutes. When t=0t=0 minutes, r=1 r=1\,m and when t=10t=10 minutes, r=2 r=2\,m.
  1. Predict the value TT of tt when r=4 r=4\,m, using a simple model in which the rate of increase of rr is taken to be constant. Find TT for this model.
  2. In a more refined model, the rate of increase of rr is taken to be proportional to 1/r1/r. Express this statement as a differential equation, and find the general solution. Find TT for this model.
  3. Compare the two models used in 1. and 2., by sketching r(t)r(t) on the same figure or plotting using Python. Comment on the differences seen during different time intervals.

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 60^{60}Co = 5.265.26 years.)

Main problems 3

By making a substitution z=dy/dxz = dy/dx, solve the equation
d2ydx2=(1−3x2)(dydx)2withy(2)=0andy′(2)=1/6.\frac{d^2y}{dx^2} = (1-3x^2)\left(\frac{dy}{dx}\right)^2\quad\text{with}\quad y(2) = 0\quad\text{and}\quad y'(2) = 1/6.
Hint: you will need to use partial fractions for part of this question, to break up
1x3−x=−1x+1/2x+1+1/2x−1.\frac{1}{x^3-x} = \frac{-1}{x} + \frac{1/2}{x+1} + \frac{1/2}{x-1}.

Main problems 4

Suppose a cell contains a chemical (the solute) dissolved in it at a concentration of c(t)c(t), and the concentration of the same substance outside the cell is a constant kk. By Fick's law, if c(t)c(t) and kk are unequal, solute moves across the cell wall at a rate proportional to the difference between c(t)c(t) and kk, towards the region of lower concentration.
  1. Write down a differential equation which is satisfied by c(t)c(t).
  2. Solve this differential equation with the initial condition c(0)=c0c(0)=c_0.
  3. Sketch the solutions for c0>kc_0 > k and k>c0k > c_0.
  4. 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?
  5. 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 μ10\,\mum.

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 k1k_1, and degraded at a rate proportional to its concentration, with constant k2k_2.
  1. Form and solve a differential equation describing the change in protein concentration.
  2. What concentration is reached after 'sufficient' time has elapsed?