---
title: Separable equations
heading: Sorting the variables to opposite sides
eyebrow: A8 · Lesson 2 · Separable equations
xp: 40
---

::: hook
A capacitor discharging through a resistor loses charge in proportion to its voltage, and decays exponentially. But discharge it through a device whose current grows as the voltage squared, like some nonlinear loads, and the decay changes character completely: fast at first, then a long, slow tail. Both are **separable** equations, the first kind of differential equation you can solve exactly whatever the nonlinearity: put everything involving the unknown on one side, everything involving time on the other, and integrate both.
:::

::: play
- Two capacitors start at the same voltage $V_0$ with the same initial rate of discharge. One discharges through a resistor ($\dot V = -aV_0V$); the other through a load drawing current proportional to $V^2$ ($\dot V = -aV^2$).
- Which one is lower after a long time? Watch the tails.
- The readouts give the time each takes to reach half of $V_0$.
:::
:::

```sim plot
view: graph
x: t = 0..10 s
y: V = 0..10 V
slider: a = 0.05..1 step 0.05 = 0.2
slider: V0 = 2..10 step 0.5 = 8 V
plot: V0/(1 + a*V0*t) | label: current ∝ V² | samples: 600
plot: V0*exp(-a*V0*t) | label: resistor | color: ch2 | samples: 600
readout: half time, V² load = 1/(a*V0) s | digits: 3
readout: half time, resistor = ln(2)/(a*V0) s | digits: 3
```

::: predict
## Both start at 8 V with the same slope. After a long time, which is lower?

- [x] The resistor: its exponential decay eventually wins
- [ ] The $V^2$ load: it starts just as fast and keeps going
- [ ] They stay together
- [ ] Neither ever gets below 1 V

::: reveal
The resistor. At high voltage the $V^2$ load draws more, but as $V$ falls its current falls even faster, so it slows down: $V = \frac{V_0}{1 + aV_0t}$ decays like $1/t$. The resistor's current falls only in proportion to $V$, giving an exponential, which is eventually far smaller than any $1/t$.
:::
:::

::: nameit
## The method

An equation is **separable** if it can be written

$$\frac{dy}{dt} = g(t)\,h(y)$$

Divide by $h(y)$ and integrate both sides:

$$\int\frac{dy}{h(y)} = \int g(t)\,dt + C$$

then solve for $y$ if you can, and use the starting value to find $C$. The step works because, by the chain rule, $\frac{d}{dt}H(y(t)) = \frac{1}{h(y)}\frac{dy}{dt}$ when $H' = 1/h$.

**Watch for lost solutions.** Dividing by $h(y)$ assumes it isn't zero. Any $y_0$ with $h(y_0) = 0$ gives a constant solution $y = y_0$, an equilibrium, that the integral can miss.

## Examples you'll meet

| Equation | Solution | Where |
|---|---|---|
| $\dot y = ky$ | $y = y_0e^{kt}$ | RC, decay, growth |
| $\dot y = -ay^2$ | $y = \frac{y_0}{1 + ay_0t}$ | quadratic loss |
| $\dot h = -c\sqrt{h}$ | $\sqrt h = \sqrt{h_0} - \frac{c}{2}t$ | a draining tank |
| $\dot P = rP(1 - P/K)$ | $P = \frac{K}{1 + \frac{K - P_0}{P_0}e^{-rt}}$ | logistic growth |

The logistic equation needs partial fractions (A6) for the $y$ integral.
:::

::: example
## Solve $\dot V = -aV^2$ with $V(0) = V_0$.

::: solution
1. **Separate.**
   $$\frac{dV}{V^2} = -a\,dt$$
2. **Integrate.**
   $$-\frac{1}{V} = -at + C$$
3. **Fit the start.** At $t = 0$, $C = -\frac{1}{V_0}$, so
   $$\begin{aligned} \frac{1}{V} &= \frac{1}{V_0} + at \\ V &= \frac{V_0}{1 + aV_0t} \end{aligned}$$
4. **How it halves.** It halves when $aV_0t = 1$, and halves again only after three times as long: each halving takes twice the time of the one before.

**Answer:** $V = V_0/(1 + aV_0t)$, and each halving takes twice as long as the one before.
:::
:::

::: example
## A tank drains through a hole, with $\dot h = -0.2\sqrt{h}$ ($h$ in m, $t$ in s). Starting at 1 m, when is it empty?

::: solution
1. **Separate.**
   $$\frac{dh}{\sqrt h} = -0.2\,dt$$
2. **Integrate.**
   $$2\sqrt h = -0.2t + C$$
   and the start at 1 m gives $C = 2$.
3. **Find when it's empty.**
   $$\sqrt h = 1 - 0.1t$$
   which reaches zero at $t = 10$ s.
4. **Why it gets there.** Unlike an exponential, this solution actually reaches zero in a finite time, because the outflow doesn't vanish fast enough as $h \to 0$.

**Answer:** the tank is empty at $t = 10$ s.
:::
:::

::: example
## Solve $\dot y = ty$ with $y(0) = 2$, and find $y(1)$.

::: solution
1. **Separate.**
   $$\frac{dy}{y} = t\,dt$$
2. **Integrate.**
   $$\ln|y| = \frac{t^2}{2} + C$$
   so $y = Ae^{t^2/2}$, and $y(0) = 2$ gives $A = 2$.
3. **Evaluate at $t = 1$.**
   $$\begin{aligned} y(1) &= 2e^{0.5} \\ &= 3.297 \end{aligned}$$
4. **Compare with an exponential.** The growth rate is proportional to $t$ itself, so the solution grows faster than any exponential with a fixed rate.

**Answer:** $y = 2e^{t^2/2}$, and $y(1) = 3.297$.
:::
:::

::: check
given: y0 = 2 | 5; k = -0.5 | 0.3; t = 2 | 4
answer: y0*exp(k*t)
tolerance: 0.5%

## Solve $\dot y = \given{k}y$ with $y(0) = \given{y0}$. What is $y(\given{t})$?

::: right
Right. $y = y_0e^{kt}$ = {answer}.
:::

::: misses
- [y0*(1 + k*t)] That's the tangent line. The solution is exponential.
- [y0*exp(-k*t)] Keep the sign of $k$.
- [any] Not yet. Separate: $\frac{dy}{y} = k\,dt$.
:::
:::

::: check
given: y0 = 4 | 10; a = 0.1 | 0.5; t = 1 | 3
answer: y0/(1 + a*y0*t)
tolerance: 0.5%

## Solve $\dot y = -\given{a}y^2$ with $y(0) = \given{y0}$. What is $y(\given{t})$?

::: right
Right. $\frac{1}{y} = \frac{1}{y_0} + at$, so $y$ = {answer}.
:::

::: misses
- [y0*exp(-a*y0*t)] That's the exponential with the same starting slope. The $y^2$ equation decays like $1/t$.
- [y0/(1 + a*t)] Integrating gives $\frac{1}{y} = \frac{1}{y_0} + at$; multiply through carefully.
- [any] Not yet. Separate: $\frac{dy}{y^2} = -a\,dt$.
:::
:::

::: check
given: y0 = 3 | 5; x = 4 | 12
answer: sqrt(x^2 + y0^2)
tolerance: 0.5%

## Solve $\dfrac{dy}{dx} = \dfrac{x}{y}$ with $y(0) = \given{y0}$ ($y > 0$). What is $y(\given{x})$?

::: right
Right. $y\,dy = x\,dx$ gives $y^2 = x^2 + y_0^2$, so $y$ = {answer}.
:::

::: misses
- [x + y0] Integrate both sides: $\frac{y^2}{2} = \frac{x^2}{2} + C$.
- [any] Not yet. Separate: $y\,dy = x\,dx$.
:::
:::

::: check
given: h0 = 1 | 9; c = 0.1 | 0.2
answer: 2*sqrt(h0)/c
unit: s
tolerance: 0.5%

## A tank obeys $\dot h = -\given{c}\sqrt h$ and starts at {h0} m. How long until it's empty?

::: right
Right. $\sqrt h = \sqrt{h_0} - \frac{c}{2}t$ reaches zero at $t = \frac{2\sqrt{h_0}}{c}$ = {answer}.
:::

::: misses
- [sqrt(h0)/c] Integrating $h^{-1/2}$ gives $2\sqrt h$.
- [h0/c] The rate depends on $\sqrt h$, not $h$.
- [any] Not yet. Separate: $\frac{dh}{\sqrt h} = -c\,dt$.
:::
:::

::: check
given: K = 1000 | 500; P0 = 100 | 50; r = 0.5 | 1; t = 2 | 4
answer: K/(1 + (K - P0)/P0*exp(-r*t))
tolerance: 0.5%

## A population follows $\dot P = \given{r}P(1 - P/\given{K})$ with $P(0) = \given{P0}$. What is $P(\given{t})$?

::: right
Right. The logistic solution gives {answer}.
:::

::: misses
- [P0*exp(r*t)] That's unlimited growth. The logistic levels off at $K$.
- [any] Not yet. $P = \frac{K}{1 + \frac{K - P_0}{P_0}e^{-rt}}$.
:::
:::

::: check
kind: choice

## Which equation is separable?

- [x] $\dot y = t^2\cos y$
- [ ] $\dot y = t + y$
- [ ] $\dot y = \sin(ty)$
- [ ] $\dot y = t^2 + y^2$

::: right
Right. It's $g(t)h(y)$ with $g = t^2$ and $h = \cos y$.
:::

::: misses
- [2] A sum $t + y$ can't be split into a product. It's linear, though (lesson 4).
- [3] $\sin(ty)$ doesn't factor into a function of $t$ times a function of $y$.
- [4] A sum, not a product.
- [any] Can the right side be written as (function of $t$) × (function of $y$)?
:::
:::

::: check
kind: parts
given: y0 = 1 | 2 | 3; t = 0.5 | 1

## Solve $\dot y = 2ty$ with $y(0)$ = {y0}.

::: part
answer: y0*exp(t^2)
tolerance: 0.5%

### What is $y$ at $t$ = {t}?

::: misses
- [y0*exp(2*t)] Integrate $2t$: it's $t^2$.
- [any] $\ln y = t^2 + C$.
:::
:::

::: part
answer: 2*t*y0*exp(t^2)
tolerance: 0.5%

### What is $\dot y$ there?

::: misses
- [any] Use the equation: $2ty$.
:::
:::
:::

::: check
kind: derivation
vars: a = 0.5..3, V = 1..5, t = 0..2

## Solve $\dot V = -aV^2$ with $V(0) = V$ by separation.

::: step
answer: 1/V + a*t

### Separating gives $\frac{1}{V(t)} = \frac1V + at$. What is $\frac{1}{V(t)}$ at time $t$? (Enter the right side.)
:::

::: step
answer: V/(1 + a*V*t)

### What is $V(t)$?
:::

::: right
Right. $V(t) = \frac{V_0}{1 + aV_0t}$: quadratic loss slows down as the quantity shrinks.
:::
:::

::: explain
## When you separate $\frac{dy}{dt} = g(t)h(y)$ by dividing by $h(y)$, which solutions might you lose, and why?

::: model
Dividing by $h(y)$ is only allowed where $h(y) \ne 0$. If $h(y_0) = 0$ for some value $y_0$, then $y(t) = y_0$ for all time satisfies the equation, since both sides are zero: it's an equilibrium. The integration step assumed $h$ was never zero, so these constant solutions may not appear in the formula. You have to check for them separately by solving $h(y) = 0$.
:::
:::

::: practice

::: check
given: y0 = 8 | 20; a = 0.2 | 1
answer: 1/(a*y0)
unit: s
tolerance: 0.5%

## For $\dot y = -\given{a}y^2$ starting at {y0}, how long until $y$ halves?

::: misses
- [ln(2)/(a*y0)] That's for an exponential with the same starting slope.
- [any] Solve $\frac{y_0}{1 + ay_0t} = \frac{y_0}{2}$.
:::
:::

::: check
given: k = 0.01 | 0.02 | 0.05 | 0.1 | 0.2 | 0.5
answer: ln(2)/k
unit: s
tolerance: 0.5%

## A quantity grows as $\dot y = \given{k}y$. How long does it take to double?

::: misses
- [1/k] That's the time constant; doubling takes $\ln 2$ times as long.
- [any] Solve $e^{kt} = 2$.
:::
:::

::: check
given: K = 100 | 200 | 500 | 800 | 1000 | 5000
answer: K/2

## For the logistic equation with capacity {K}, at what population is the growth rate largest?

::: misses
- [K] At $K$ the growth stops.
- [any] Maximize $rP(1 - P/K)$.
:::
:::
:::
