Instant PDF download, name-and-email checkout. Complete bundle: every Economics, Statistics and Mathematics book
Mathematics guide, Unit 7, step 24 of 33Previous stepNext step

Step 24: Separable Differential Equations and Slope Fields

SyllabusAP 7.1–7.7 · 9709 P3 3.8 · IB HL 5.18
In 30 seconds
  • A differential equation is an equation for an unknown function that involves its derivative. “The rate of change of \( y \) is proportional to \( y \)” becomes \( \dfrac{dy}{dt} = ky \).
  • To check a solution, substitute it into both sides. A general solution carries a constant \( C \); an initial condition such as \( y(0) = 2 \) fixes \( C \) and gives the particular solution.
  • A slope field draws a short segment of gradient \( \dfrac{dy}{dx} \) at each grid point, so you can see the shape of every solution before solving anything. It is an AP topic; Cambridge 9709 does not include slope fields.
  • Exam point: to solve a separable equation, separate, integrate both sides with \( + C \) at once, use the initial condition, then rearrange to \( y = \ldots \) and state the domain if asked.
Video lesson coming soonA short animated lesson for this step will appear here.

Turning words into a differential equation

Most laws of change are really statements about rates. A balance grows at a rate proportional to its size. A rumour spreads at a rate proportional to the number of people who have not yet heard it. A cup of tea cools faster when it is much hotter than the room. Each of these is a differential equation: an equation whose unknown is a whole function, and which involves that function’s derivative.

Key termDifferential equation: an equation relating an unknown function to one or more of its derivatives. Its order is the order of the highest derivative, so \( \dfrac{dy}{dx} = x-y \) is first order and \( \dfrac{d^2y}{dx^2} + 9y = 0 \) is second order.

Writing one is translation, a phrase at a time. “The rate of change of \( N \)” is \( \dfrac{dN}{dt} \). “The gradient of the curve” is \( \dfrac{dy}{dx} \). “Is proportional to” is “\( = k \times \)”, with a constant \( k \) that you must name. And a quantity that is falling needs a minus sign or a negative \( k \).

WordsSymbols
\( V \) decreases at a rate proportional to \( V \)\( \dfrac{dV}{dt} = -kV \), \( k > 0 \)
the rate of increase of \( A \) is inversely proportional to \( A \)\( \dfrac{dA}{dt} = \dfrac{k}{A} \), \( k > 0 \)
the gradient at \( (x, y) \) is the sum of the coordinates\( \dfrac{dy}{dx} = x + y \)
Worked example

A town has 5000 people. The number \( N \) who have heard a rumour grows at a rate proportional to the number who have not yet heard it. At the start 100 people know, and at that moment the rumour is spreading at 49 people per hour. Write a differential equation for \( N \) and find the constant.

Step 1The number who have not heard is \( 5000-N \). So \( \dfrac{dN}{dt} = k(5000-N) \), where \( t \) is in hours and \( k > 0 \).
Step 2At \( t = 0 \), \( N = 100 \) and \( \dfrac{dN}{dt} = 49 \): \( 49 = k(5000-100) = 4900k \).
Step 3So \( k = 0.01 \) per hour, and \( \dfrac{dN}{dt} = 0.01(5000-N) \).

Sense check: as \( N \) approaches 5000 the right-hand side shrinks towards 0, so the spread slows down as the town runs out of people to tell.

Common mistakeDropping the constant or the sign. “Proportional to \( V \)” is \( kV \), not \( V \); writing \( \dfrac{dV}{dt} = V \) claims something much more specific. And “decreases at a rate proportional to \( V \)” is \( \dfrac{dV}{dt} = -kV \) with \( k > 0 \). Say in a few words what \( k \) is and what sign it has.

Checking a solution: general and particular

To check that a function solves a differential equation, you do not need to know how it was found. Work out each side separately and see whether they agree for every \( x \).

Worked example

Show that \( y = Ce^{2x}-\tfrac{1}{2}x-\tfrac{1}{4} \) is a solution of \( \dfrac{dy}{dx} = 2y + x \) for every constant \( C \). Then find the solution with \( y(0) = 1 \).

Step 1Left side: \( \dfrac{dy}{dx} = 2Ce^{2x}-\tfrac{1}{2} \).
Step 2Right side: \( 2y + x = 2Ce^{2x}-x-\tfrac{1}{2} + x = 2Ce^{2x}-\tfrac{1}{2} \). The two sides agree for every \( x \), whatever \( C \) is.
Step 3Use \( y(0) = 1 \): \( C-\tfrac{1}{4} = 1 \), so \( C = \tfrac{5}{4} \).

The particular solution is \( y = \tfrac{5}{4}e^{2x}-\tfrac{1}{2}x-\tfrac{1}{4} \).

Key termGeneral solution: a family of solutions containing an arbitrary constant, one curve for each value of \( C \). An initial condition \( y(x_0) = y_0 \) picks out one member of the family, the particular solution. An equilibrium solution is a constant solution \( y = c \); for \( \dfrac{dy}{dx} = f(x, y) \) it needs \( f(x, c) = 0 \) for every \( x \).

A first-order equation needs one condition to fix its one constant. AP questions in this area often hand you a candidate function and ask you to verify it, or give you a family such as \( y = Ce^{kx} \) and ask which \( k \) works. Substitution answers both.

Slope fields: seeing solutions before solving

The equation \( \dfrac{dy}{dx} = f(x, y) \) tells you the gradient of the solution curve through every point. Draw a short segment with that gradient at each point of a grid and you have a slope field (also called a direction field). Solution curves are the paths that flow along the segments, like iron filings round a magnet.

Figure 1 is the slope field of \( \dfrac{dy}{dx} = y-x \). Three features are worth spotting. Along the line \( y = x \) the gradient is 0, so the segments are horizontal there. The line \( y = x + 1 \) has gradient 1, and on it \( y-x = 1 \), so this straight line is itself a solution. Solutions above that line bend upwards and run away from it; solutions below it bend downwards. You can confirm this: the general solution is \( y = x + 1 + Ce^{x} \), and the gap \( Ce^{x} \) grows as \( x \) increases.

Slope field of dy/dx = y − x
y = x (horizontal segments)y = x + 1 (straight solution)through (0, 2): y = x + 1 + eˣthrough (0, 0): y = x + 1 − eˣ
−3−2−1123−3−2−11230xy(0, 2)max (0, 0)
Figure 1: segments are horizontal on y = x. Solutions above the straight solution y = x + 1 bend up and away from it; solutions below it bend down and each has a maximum where it crosses y = x.
Worked example

For \( \dfrac{dy}{dx} = y-x \): (a) find the gradient of the solution curves through \( (2, 1) \) and \( (-1, 2) \); (b) find \( \dfrac{d^2y}{dx^2} \) and say where solution curves are concave up; (c) classify the points where solutions have horizontal tangents.

Step 1Substitute the coordinates: at \( (2, 1) \), \( 1-2 = -1 \); at \( (-1, 2) \), \( 2-(-1) = 3 \).
Step 2Differentiate the equation with respect to \( x \), remembering that \( y \) depends on \( x \): \( \dfrac{d^2y}{dx^2} = \dfrac{dy}{dx}-1 = y-x-1 \). This is positive exactly when \( y > x + 1 \), so solutions above the dashed line are concave up and those below it are concave down.
Step 3Horizontal tangents occur where \( y-x = 0 \), on the line \( y = x \). There \( \dfrac{d^2y}{dx^2} = x-x-1 = -1 < 0 \), so every such point is a local maximum.

The teal curve in Figure 1, \( y = x + 1-e^{x} \), has its maximum at \( (0, 0) \), exactly where it meets the line \( y = x \).

When the right-hand side depends on \( y \) only, every horizontal row of segments is identical, and constant solutions show up as rows of flat segments. Figure 2 shows \( \dfrac{dy}{dx} = (y-1)(3-y) \). The equilibrium solutions are \( y = 1 \) and \( y = 3 \). Between them the gradient is positive, so a solution starting at \( y = 2 \) rises towards 3. Above 3 the gradient is negative, so a solution starting at \( y = 4 \) falls towards 3. Below 1 the gradient is negative, so solutions fall away from 1. The line \( y = 3 \) attracts nearby solutions; the line \( y = 1 \) repels them.

Slope field of dy/dx = (y − 1)(3 − y)
equilibria y = 1 and y = 3y(0) = 2: rises to 3y(0) = 4: falls to 3y(0) = 0.8: falls away from 1
−11234−1123450xy
Figure 2: the gradient depends on y only, so each row of segments is identical. y = 3 attracts the solutions near it; y = 1 repels them.
Exam tipTo match a slope field with its equation, look along lines. Segments parallel along every horizontal line mean \( \dfrac{dy}{dx} \) depends on \( y \) only; parallel along every vertical line, on \( x \) only. Then find where the segments are horizontal and check the sign in one region. When you sketch a solution on an AP slope field, pass through the given point, follow the segments in both directions, and never cross an equilibrium line. Slope fields are an AP topic; neither Cambridge 9709 nor IB Analysis and Approaches lists them.

Solving by separating the variables

A slope field shows the shape of the solutions; for many important equations we can also find them as formulas. The key type is the separable equation, where the right-hand side factorises into a function of \( x \) times a function of \( y \):

\[ \frac{dy}{dx} = g(x)\,h(y) \quad\Longrightarrow\quad \int \frac{1}{h(y)}\,dy = \int g(x)\,dx + C. \]

Why is this allowed? You are not really “multiplying by \( dx \)”. If \( y(x) \) is a solution, then \( \dfrac{1}{h(y)}\dfrac{dy}{dx} = g(x) \) for every \( x \). Integrate both sides with respect to \( x \). By the chain rule, the left side is exactly \( \displaystyle\int \frac{1}{h(y)}\,dy \): separation is integration by substitution (Step 22) written compactly. One constant is enough, because constants on both sides combine into one.

Worked example

Solve \( \dfrac{dy}{dx} = y\cos x \), given that \( y(0) = 3 \).

Step 1Separate: \( \displaystyle\int \frac{1}{y}\,dy = \int \cos x\,dx \).
Step 2Integrate, with the constant now: \( \ln|y| = \sin x + C \).
Step 3Exponentiate: \( |y| = e^{C}e^{\sin x} \), so \( y = Ae^{\sin x} \) with \( A = \pm e^{C} \). (The constant solution \( y = 0 \), lost when we divided by \( y \), is the case \( A = 0 \).)
Step 4At \( x = 0 \): \( Ae^{0} = 3 \), so \( A = 3 \).

The solution is \( y = 3e^{\sin x} \), valid for all real \( x \). It oscillates between \( 3e^{-1} \approx 1.10 \) and \( 3e \approx 8.15 \).

Common mistakeAdding \( C \) too late, or in the wrong place. From \( \ln|y| = \sin x + C \) the next line is \( y = Ae^{\sin x} \), not \( y = e^{\sin x} + C \), because \( e^{\sin x + C} = e^{C}e^{\sin x} \): the constant multiplies. Write \( + C \) on the line where you integrate, and never invent it at the end.

When the solution involves a square root, the initial condition also tells you which sign to take.

Worked example

Solve \( \dfrac{dy}{dx} = \dfrac{x}{y} \) with \( y(0) = -2 \), giving \( y \) explicitly in terms of \( x \).

Step 1Separate: \( \displaystyle\int y\,dy = \int x\,dx \), so \( \tfrac{1}{2}y^2 = \tfrac{1}{2}x^2 + C \).
Step 2At \( (0, -2) \): \( 2 = 0 + C \), so \( C = 2 \) and \( y^2 = x^2 + 4 \).
Step 3Choose the root: \( y^2 = x^2 + 4 \) is never 0, so \( y \) can never change sign. It starts negative, so \( y = -\sqrt{x^2 + 4} \).

The positive root \( y = \sqrt{x^2 + 4} \) also satisfies the equation, but not the initial condition. The domain is all real \( x \). In general, the domain is the largest open interval containing the starting \( x \) on which the formula is defined and differentiable: for \( \dfrac{dy}{dx} = y^2 \), \( y(0) = \tfrac{1}{2} \), the solution \( y = \dfrac{1}{2-x} \) is valid only for \( x < 2 \).

An economics example: constant elasticity of demand. The price elasticity of demand is \( \dfrac{P}{Q}\dfrac{dQ}{dP} \). Suppose market research says it is \( -2 \) at every price. That is a differential equation: \( \dfrac{dQ}{dP} = -\dfrac{2Q}{P} \). Separate: \( \displaystyle\int \frac{1}{Q}\,dQ = \int -\frac{2}{P}\,dP \), so \( \ln Q = -2\ln P + C \) and \( Q = AP^{-2} \). If 400 units sell at a price of $5, then \( A = 400 \times 25 = 10\,000 \) and \( Q = \dfrac{10\,000}{P^2} \). So a constant elasticity forces a power-law demand curve. At $10, demand falls to 100 units: doubling the price cuts quantity to a quarter, exactly what an elasticity of \( -2 \) means.

Constant-elasticity demand Q = 10 000 / P²
Q = 10 000 / P² (elasticity −2 everywhere)
20040060080010002468101214160Q (units)P ($)(400, $5)(100, $10)
Figure 3: solving the elasticity equation dQ/dP = −2Q/P gives a power-law demand curve. Doubling the price from $5 to $10 cuts quantity from 400 to 100 units.
Exam tipSet out every separation question in the same order: separate (on a line of its own), integrate both sides with \( + C \), substitute the initial condition to find \( C \), then solve for \( y \). Cambridge 9709 Paper 3 (topic 3.8) phrases this as “solve the differential equation, obtaining an expression for \( y \) in terms of \( x \)”, so an implicit answer such as \( \ln|y| = \sin x + \ln 3 \) is not finished. In IB, separable equations are HL only (AHL 5.18).

Practise: 6 questions

Try each one on paper first, then check the worked answer.

EasyQ1. Water drains from a tank so that the depth \( h \) falls at a rate proportional to the square root of the depth. Write a differential equation for \( h \). Show worked answer
The rate of change of depth is \( \dfrac{dh}{dt} \).
It is proportional to \( \sqrt{h} \) and the depth is falling, so it is negative.
\( \dfrac{dh}{dt} = -k\sqrt{h} \), where \( k > 0 \) is a constant.
EasyQ2. Show that \( y = 4e^{-3x} + 2 \) satisfies \( \dfrac{dy}{dx} = 6-3y \) and the condition \( y(0) = 6 \). Show worked answer
Left side: \( \dfrac{dy}{dx} = -12e^{-3x} \).
Right side: \( 6-3(4e^{-3x} + 2) = 6-12e^{-3x}-6 = -12e^{-3x} \).
The sides agree for every \( x \), so the function is a solution.
\( y(0) = 4 + 2 = 6 \), as required.
MediumQ3. For \( \dfrac{dy}{dx} = x^2-y \): (a) find the gradient of the solution curves through \( (2, 1) \) and \( (-1, 1) \); (b) describe where the slope-field segments are horizontal; (c) find \( \dfrac{d^2y}{dx^2} \) in terms of \( x \) and \( y \). Show worked answer
(a) At \( (2, 1) \): \( 4-1 = 3 \). At \( (-1, 1) \): \( 1-1 = 0 \).
(b) Horizontal where \( x^2-y = 0 \), that is along the parabola \( y = x^2 \).
(c) \( \dfrac{d^2y}{dx^2} = 2x-\dfrac{dy}{dx} = 2x-(x^2-y) = 2x-x^2 + y \).
MediumQ4. Solve \( \dfrac{dy}{dx} = \dfrac{3x^2}{2y} \), given \( y(1) = 3 \). Give \( y \) in terms of \( x \) and state the domain of the solution. Show worked answer
Separate: \( \displaystyle\int 2y\,dy = \int 3x^2\,dx \).
\( y^2 = x^3 + C \).
At \( (1, 3) \): \( 9 = 1 + C \), so \( C = 8 \) and \( y^2 = x^3 + 8 \).
\( y > 0 \) at the start, so take the positive root: \( y = \sqrt{x^3 + 8} \).
The derivative \( \dfrac{3x^2}{2y} \) needs \( y \neq 0 \), so we need \( x^3 + 8 > 0 \): the domain is \( x > -2 \).
MediumQ5. Solve \( \dfrac{dy}{dx} = e^{x-y} \), given \( y(0) = \ln 2 \). Show worked answer
Write \( e^{x-y} = e^{x}e^{-y} \) and separate: \( \displaystyle\int e^{y}\,dy = \int e^{x}\,dx \).
\( e^{y} = e^{x} + C \).
At \( x = 0 \): \( e^{\ln 2} = 1 + C \), so \( 2 = 1 + C \) and \( C = 1 \).
\( e^{y} = e^{x} + 1 \), so \( y = \ln(e^{x} + 1) \), valid for all real \( x \).
ExamQ6. Consider the differential equation \( \dfrac{dy}{dx} = 2x(1-y) \). (a) Find \( \dfrac{d^2y}{dx^2} \) in terms of \( x \) and \( y \). [2] (b) Is the solution curve through \( (0, 3) \) concave up or concave down at that point? Give a reason. [1] (c) Find the particular solution \( y = f(x) \) with \( f(0) = 3 \). [5] (d) Find \( \displaystyle\lim_{x \to \infty} f(x) \). [1] Show worked answer
(a) Product rule: \( \dfrac{d^2y}{dx^2} = 2(1-y) + 2x\left(-\dfrac{dy}{dx}\right) \). [M1]
\( = 2(1-y)-4x^2(1-y) = 2(1-y)(1-2x^2) \). [A1]
(b) At \( (0, 3) \): \( 2(-2)(1) = -4 < 0 \), so the curve is concave down. [B1]
(c) Separate: \( \displaystyle\int \frac{1}{1-y}\,dy = \int 2x\,dx \). [M1]
\( -\ln|1-y| = x^2 + C \). [A1 A1, one for each side]
At \( (0, 3) \): \( -\ln 2 = C \). [M1]
So \( \ln|1-y| = \ln 2-x^2 \), \( |1-y| = 2e^{-x^2} \). Since \( y > 1 \) at the start, \( y-1 = 2e^{-x^2} \), giving \( f(x) = 1 + 2e^{-x^2} \). [A1]
(d) \( e^{-x^2} \to 0 \), so \( f(x) \to 1 \). [B1]
Total: 9 marks.

Check yourself

1. Which is the general solution of \( \dfrac{dy}{dx} = 3y \)?

Separating gives \( \ln|y| = 3x + C \), so \( y = Ae^{3x} \): the constant multiplies. Check: \( \dfrac{d}{dx}(Ce^{3x}) = 3Ce^{3x} = 3y \).

2. In a slope field, the segments along every horizontal line are parallel to each other. Which equation could it be?

Along a horizontal line \( y \) is fixed, so the gradient is the same all along it only if it depends on \( y \) alone. \( x^2 \) gives parallel segments along vertical lines instead.

3. Which of these is an equilibrium solution of \( \dfrac{dy}{dx} = (y-2)(y + 1) \)?

A constant solution needs \( \dfrac{dy}{dx} = 0 \) for every \( x \): \( (y-2)(y + 1) = 0 \), so \( y = 2 \) or \( y = -1 \).

Your score: 0 out of 3

The short version

  • A differential equation is an equation for an unknown function involving its derivative. Translate words phrase by phrase, and name the constant of proportionality and its sign.
  • Verify a solution by substituting it into both sides. The general solution has a constant \( C \); an initial condition gives the particular solution.
  • A slope field shows the gradient \( f(x, y) \) at grid points. Solutions follow the segments and never cross an equilibrium line \( y = c \). (AP only: not in 9709 or IB AA.)
  • Separable equations \( \dfrac{dy}{dx} = g(x)h(y) \): \( \displaystyle\int \frac{1}{h(y)}\,dy = \int g(x)\,dx + C \). Put in \( C \) as you integrate, use the initial condition, then write \( y = \ldots \).
  • The initial condition also picks the sign of a square root and the interval on which the solution is valid.
  • The full chapter in Mathematics Made Simple has many more worked examples and a full set of practice questions with a complete answer key.
Want more questions like these, with worked answers?
The practice book has hundreds more, graded from easy to exam level.
Next: step 25 of 33Exponential and Logistic Models and Euler's Method