TExcelTAD
Home › Calculus in Depth › Separable Equations

Separable Equations

A separable equation is a first-order differential equation whose right-hand side factors into a function of xx times a function of yy. Moving every yy to one side and every xx to the other turns the equation into two ordinary integrals. This lesson justifies the method, shows where it silently loses solutions, and applies it to mixing tanks and orthogonal trajectories.

For a gentler first pass, see Separable Equations in the survey course.

Definition and the method

An equation dydx=f(x,y)\frac{dy}{dx} = f(x, y) is separable when f(x,y)=g(x)⋅h(y)f(x, y) = g(x) \cdot h(y). Where h(y)≠0h(y) \ne 0:

dydx=g(x)⋅h(y)1h(y) dy=g(x) dx∫dyh(y)=∫g(x) dx+C\begin{aligned} \frac{dy}{dx} &= g(x) \cdot h(y) \\ \frac{1}{h(y)}\,dy &= g(x)\,dx \\ \int \frac{dy}{h(y)} &= \int g(x)\,dx + C \end{aligned}

The middle line treats dydy and dxdx like numbers, which looks suspicious. Here is why it is correct. Let HH be an antiderivative of 1/h1/h and GG one of gg. If y(x)y(x) solves the equation, the chain rule gives

ddxH(y(x))=H′(y)⋅y′=y′h(y)=g(x)=ddxG(x)\frac{d}{dx} H(y(x)) = H'(y) \cdot y' = \frac{y'}{h(y)} = g(x) = \frac{d}{dx} G(x)

so H(y(x))−G(x)H(y(x)) - G(x) has zero derivative on an interval and is constant: H(y)=G(x)+CH(y) = G(x) + C. That implicit solution is exactly what the integration step produces. Running the argument backwards shows every differentiable yy satisfying H(y)=G(x)+CH(y) = G(x) + C (with h(y)≠0h(y) \ne 0) is a solution.

Lost solutions and non-uniqueness

Dividing by h(y)h(y) assumed h(y)≠0h(y) \ne 0. Every root y0y_0 of hh gives a constant solution y(x)=y0y(x) = y_0 (an equilibrium), and the formula often misses it. For y′=y2−1y' = y^2 - 1 the constant solutions y=1y = 1 and y=−1y = -1 are not in the family obtained with partial fractions for any finite CC.

Uniqueness can also fail. The Picard–Lindelöf theorem guarantees one solution through (x0,y0)(x_0, y_0) when ff and ∂f/∂y\partial f/\partial y are continuous near that point. For y′=3y2/3y' = 3y^{2/3}, ∂f/∂y=2y−1/3\partial f/\partial y = 2y^{-1/3} blows up at y=0y = 0, and both y=0y = 0 and y=x3y = x^3 pass through the origin.

python · try it yourself
import sympy as sp

x = sp.symbols("x", real=True)
y = sp.Function("y")

sol = sp.dsolve(sp.Eq(y(x).diff(x), x * y(x)**2), y(x), ics={y(0): 1})
print(sol)
print("blows up where the denominator is 0:", sp.solve(sp.denom(sol.rhs), x))

# two different solutions of y' = 3 y^(2/3) through (0, 0)
for cand in (sp.Integer(0), x**3):
    residual = sp.simplify(cand.diff(x) - 3 * sp.cbrt(cand**2))
    print(f"y = {cand}: residual {residual} (check at x=2: {residual.subs(x, 2)})")
Eq(y(x), -2/(x**2 - 2))
blows up where the denominator is 0: [-sqrt(2), sqrt(2)]
y = 0: residual 0 (check at x=2: 0)
y = x**3: residual 0 (check at x=2: 0)

SymPy prints −2/(x2−2)-2/(x^2 - 2), which is 2/(2−x2)2/(2 - x^2). Declaring xx real lets SymPy simplify (x6)1/3(x^6)^{1/3} to x2x^2, so both residuals vanish. The first solution exists only on −2<x<2-\sqrt{2} < x < \sqrt{2}: a perfectly smooth equation can drive its solution to infinity in finite xx. Solutions of nonlinear equations live on intervals you have to find, not on all of R\mathbb{R}.

Mixing problems

A tank holds 200 L of brine with 30 kg of dissolved salt. Brine with 0.05 kg/L flows in at 4 L/min, and the well-stirred mixture flows out at the same rate. If S(t)S(t) is the salt in kg:

dSdt=(rate in)−(rate out)=4⋅0.05−4⋅S200=0.2−S50=−S−1050∫dSS−10=−∫dt50⇒S(t)=10+20e−t/50\begin{aligned} \frac{dS}{dt} &= (\text{rate in}) - (\text{rate out}) = 4 \cdot 0.05 - 4 \cdot \frac{S}{200} = 0.2 - \frac{S}{50} = -\frac{S - 10}{50} \\ \int \frac{dS}{S - 10} &= -\int \frac{dt}{50} \quad \Rightarrow \quad S(t) = 10 + 20e^{-t/50} \end{aligned}

The salt decays toward the equilibrium 10 kg, the amount a tank full of inflow brine holds. A numerical solver agrees:

python · try it yourself
import math
from scipy.integrate import solve_ivp

sol = solve_ivp(lambda t, S: [0.2 - S[0] / 50], (0, 120), [30.0],
                t_eval=[0, 30, 60, 120], rtol=1e-10, atol=1e-12)
for t, S in zip(sol.t, sol.y[0]):
    exact = 10 + 20 * math.exp(-t / 50)
    print(f"t = {t:5.0f} min   numeric {S:.6f}   exact {exact:.6f}")
t =     0 min   numeric 30.000000   exact 30.000000
t =    30 min   numeric 20.976233   exact 20.976233
t =    60 min   numeric 16.023884   exact 16.023884
t =   120 min   numeric 11.814359   exact 11.814359

Orthogonal trajectories

Curves that meet every member of a family at right angles are its orthogonal trajectories. For the parabolas y=kx2y = kx^2, eliminate kk: y′=2kx=2y/xy' = 2kx = 2y/x. Orthogonal slopes are negative reciprocals, so the trajectories solve y′=−x/(2y)y' = -x/(2y), which is separable:

2y dy=−x dx⇒y2+x22=C2y\,dy = -x\,dx \quad \Rightarrow \quad y^2 + \frac{x^2}{2} = C

a family of ellipses. Electric field lines and equipotentials, or heat flow lines and isotherms, are pairs like this.

python · try it yourself
import numpy as np
import matplotlib.pyplot as plt

xs = np.linspace(-2, 2, 400)
plt.figure(figsize=(5, 5))
for k in (-2, -1, -0.5, 0.5, 1, 2):
    plt.plot(xs, k * xs**2, color="tab:blue", lw=1)
t = np.linspace(0, 2 * np.pi, 400)
for C in (0.25, 0.75, 1.5, 2.5):
    plt.plot(np.sqrt(2 * C) * np.cos(t), np.sqrt(C) * np.sin(t), color="tab:orange", lw=1)
plt.xlim(-2, 2); plt.ylim(-2, 2); plt.gca().set_aspect("equal")
plt.title("y = kx² (blue) and y² + x²/2 = C (orange)")
plt.show()
print("plotted 6 parabolas and 4 orthogonal ellipses")
plotted 6 parabolas and 4 orthogonal ellipses

In software

  • Closed forms as test oracles: when you write an ODE integrator (see Integrators), separable equations with known solutions such as S(t)=10+20e−t/50S(t) = 10 + 20e^{-t/50} are the cheapest unit tests for its accuracy.
  • Blow-up detection: y′=xy2y' = xy^2 shows why numerical solvers need step-size control and overflow checks; solve_ivp reports failure instead of returning garbage when a solution escapes to infinity.
  • Cooling and decay: thermal models of CPUs, cache-entry decay scores and "half-life" ranking formulas (e.g. hot-post scores) are all solutions of y′=−k(y−y∞)y' = -k(y - y_\infty).

Exercises

Exercise 1: A trigonometric factor

Solve dydx=y⋅cos⁡x\frac{dy}{dx} = y \cdot \cos x with y(0)=2y(0) = 2.

Answer

y=2esin⁡xy = 2e^{\sin x}

Solution
dyy=cos⁡x dx⇒ln⁡∣y∣=sin⁡x+C⇒y=A⋅esin⁡xy(0)=A=2⇒y=2esin⁡x\begin{aligned} \frac{dy}{y} = \cos x\,dx \quad &\Rightarrow \quad \ln\lvert y \rvert = \sin x + C \quad \Rightarrow \quad y = A \cdot e^{\sin x} \\ y(0) = A = 2 \quad &\Rightarrow \quad y = 2e^{\sin x} \end{aligned}

(y=0y = 0 is the equilibrium that the division by yy set aside; it does not meet the initial condition.)

Exercise 2: Choosing the branch

Solve dydt=t/y\frac{dy}{dt} = t/y with y(0)=−3y(0) = -3.

Answer

y=−t2+9y = -\sqrt{t^2 + 9}, valid for all tt.

Solution
y dy=t dt⇒y22=t22+C⇒y2=t2+9(from y(0)=−3)y\,dy = t\,dt \quad \Rightarrow \quad \frac{y^2}{2} = \frac{t^2}{2} + C \quad \Rightarrow \quad y^2 = t^2 + 9 \quad (\text{from } y(0) = -3)

Both ±t2+9\pm\sqrt{t^2 + 9} satisfy the implicit equation; the initial value is negative, so the solution is the negative branch.

Exercise 3: Newton's law of cooling

Coffee at 90 °C sits in a 20 °C room and is 70 °C after 5 minutes. With T′=−k(T−20)T' = -k(T - 20), find kk and the time at which the coffee reaches 40 °C.

Answer

k=ln⁡(7/5)/5≈0.06729k = \ln(7/5)/5 \approx 0.06729 per minute; 40 °C after about 18.6218.62 minutes.

Solution
T−20=70e−kt70−20=50=70e−5k⇒k=ln⁡(7/5)/540−20=20=70e−kt⇒t=ln⁡(3.5)/k=5⋅ln⁡3.5/ln⁡1.4\begin{aligned} T - 20 &= 70e^{-kt} \\ 70 - 20 = 50 &= 70e^{-5k} && \Rightarrow \quad k = \ln(7/5)/5 \\ 40 - 20 = 20 &= 70e^{-kt} && \Rightarrow \quad t = \ln(3.5)/k = 5 \cdot \ln 3.5 / \ln 1.4 \end{aligned}
python · try it yourself
import math

k = math.log(7 / 5) / 5
t = math.log(3.5) / k
print(f"k = {k:.5f}, t = {t:.2f} min")
k = 0.06729, t = 18.62 min

Exercise 4: Where does it blow up?

Solve y′=x⋅y2y' = x \cdot y^2 with y(0)=2y(0) = 2, find the largest interval around 0 on which the solution exists, and confirm with SymPy.

Answer

y=2/(1−x2)y = 2/(1 - x^2), which exists on −1<x<1-1 < x < 1.

Solution
−1y=x22+C,y(0)=2⇒C=−121y=1−x22⇒y=21−x2\begin{aligned} -\frac{1}{y} &= \frac{x^2}{2} + C, && y(0) = 2 \quad \Rightarrow \quad C = -\tfrac{1}{2} \\ \frac{1}{y} &= \frac{1 - x^2}{2} && \Rightarrow \quad y = \frac{2}{1 - x^2} \end{aligned}

The denominator vanishes at x=±1x = \pm 1, and the solution through x=0x = 0 cannot cross those points.

python · try it yourself
import sympy as sp

x = sp.symbols("x")
y = sp.Function("y")
sol = sp.dsolve(sp.Eq(y(x).diff(x), x * y(x)**2), y(x), ics={y(0): 2})
print(sp.simplify(sol.rhs), sp.solve(sp.denom(sp.together(sol.rhs)), x))
-2/(x**2 - 1) [-1, 1]

Test yourself

Which equation is separable?

  1. y′=x+yy' = x + y
  2. y′=ex+yy' = e^{x+y}
  3. y′=sin⁡(xy)y' = \sin(xy)
  4. y′=x2+y2y' = x^2 + y^2

Separating y′=y(y−4)y' = y(y - 4) by dividing by y(y−4)y(y - 4) can lose which solutions?

  1. None
  2. Only y=4y = 4
  3. y=0y = 0 and y=4y = 4
  4. All solutions with y<0y < 0

Why can y′=3y2/3y' = 3y^{2/3} have two solutions through (0,0)(0, 0)?

  1. Because ∂f/∂y\partial f/\partial y is not continuous at y=0y = 0, so the uniqueness theorem does not apply
  2. Because the equation is not separable
  3. Because sympy rounds
  4. Because the solution blows up