Separable Equations

Solve differential equations by separating variables and integrating.

A separable differential equation is one of the most friendly kinds of ODEs. It can be rearranged so all terms involving y stay with dy, and all terms involving x stay with dx.

Learning objectives

After this lesson you should be able to:

  • recognize separable equations;
  • rearrange an equation into separated form;
  • integrate both sides and include a constant;
  • apply an initial condition;
  • check a solution by differentiating;
  • notice when dividing by a variable expression may lose constant solutions.

The separable pattern

A separable equation can be written as

dy/dx = g(x)h(y)

When h(y) is not zero, rearrange it as

1/h(y) dy = g(x) dx

Then integrate both sides.

The method in words

Separate, integrate, simplify, use the initial condition, then check.

Step-by-step workflow

  1. Identify the x part and the y part.
  2. Move all y expressions to the side with dy.
  3. Move all x expressions to the side with dx.
  4. Integrate both sides.
  5. Use one constant of integration.
  6. Solve for y if the algebra is reasonable.
  7. Apply the initial condition if one is given.
  8. Differentiate to check.

Worked example 1: exponential growth

Solve

dy/dt = ky

where k is a constant.

Separate variables:

1/y dy = k dt

Integrate:

ln|y| = kt + C

Exponentiate both sides:

|y| = e^(kt+C) = e^C e^(kt)

The constant can absorb the sign and e^C, so we write

y = Ce^(kt)

This is the familiar exponential growth or decay family.

Worked example 2: apply an initial condition

Solve

dy/dx = 2xy,     y(0)=3

Separate:

1/y dy = 2x dx

Integrate:

ln|y| = x^2 + C

Convert to exponential form:

y = C e^(x^2)

Use y(0)=3:

3 = C e^0
C = 3

So the particular solution is

y = 3e^(x^2)

Worked example 3: watch for lost solutions

Solve

dy/dx = x y^2

If y is not zero, divide by y^2:

y^(-2) dy = x dx

Integrate:

-1/y = x^2/2 + C

This gives a family of nonzero solutions. But the original equation also has y=0 as a solution, because both sides become zero. Dividing by y^2 would hide that solution.

WarningImportant

When you divide by an expression involving y, ask whether that expression could equal zero. If yes, check whether a constant solution was lost.

Practice

  1. Is dy/dx = x(1+y^2) separable?

  2. Separate dy/dx = x y^3.

  3. Solve dy/dx = 4y with y(0)=2.

  4. What constant solution might be lost when solving dy/dx = y(5-y) by dividing by y(5-y)?

  1. Yes. It has the form g(x)h(y) with g(x)=x and h(y)=1+y^2.
  2. y^(-3) dy = x dx.
  3. y = Ce^(4x), and y(0)=2 gives C=2, so y=2e^(4x).
  4. Both y=0 and y=5 are equilibrium solutions.

Subtopic guided practice and checkpoints

A separable-equation solution should read like a careful algebra story: classify, separate, integrate, solve for the constant, and check for lost solutions.

Lab 1: recognize separability

Guess first. Is dy/dx = x(1 + y^2) separable?

Guided exercise.

A separable equation can be written as g(x)h(y). Here

dy/dx = x(1 + y^2)

has g(x)=x and h(y)=1+y^2, so it is separable.

Checkpoint. Decide whether each is separable: y' = x^2 y, y' = x + y, and y' = sin(x) e^y.

Lab 2: separate variables without skipping algebra

Guess first. For dy/dx = 3xy, what should be divided away from the right side?

Guided exercise.

dy/dx = 3xy
(1/y) dy/dx = 3x          divide by y, assuming y != 0
(1/y) dy = 3x dx          multiply by dx

Now the y expression is with dy, and the x expression is with dx.

Checkpoint. Separate dy/dx = x^2 y^3. State the value of y that needs special attention before dividing.

Lab 3: integrate and solve for the family

Guess first. When integrating (1/y) dy = 3x dx, which side produces a logarithm?

Guided exercise.

(1/y) dy = 3x dx
∫(1/y) dy = ∫3x dx
ln|y| = (3/2)x^2 + C
y = C e^((3/2)x^2)

The constant changes form after exponentiating; that is normal.

Checkpoint. Solve the separated equation y^{-2} dy = 4x dx for y if possible. Keep a constant of integration.

Lab 4: apply an initial condition and check

Guess first. If y = C e^{x^2} and y(0)=5, what is C?

Guided exercise.

5 = C e^(0^2)
5 = C

So y = 5e^{x^2}. Check by differentiating:

y' = 5e^(x^2) * 2x = 2xy

That matches dy/dx = 2xy.

Checkpoint. Solve dy/dx = -2xy, y(0)=4. Differentiate your answer and substitute it into the original ODE.

Separable equation checkpoint

Using this lesson with edumath and SymPy

SymPy can solve many separable equations with dsolve.

import sympy as sp

x = sp.Symbol("x")
y = sp.Function("y")
ode = sp.Eq(sp.diff(y(x), x), 2 * x * y(x))
sp.dsolve(ode)

\(\displaystyle y{\left(x \right)} = C_{1} e^{x^{2}}\)

You can also build deterministic practice with edumath.

from edumath.differential_equations import separable_solution_exercise

exercise = separable_solution_exercise(seed=2)
exercise.prompt, exercise.expected
('Solve dy/dx = -3y with initial condition y(0) = 1.', exp(-3*x))