---
title: Separable differential equations
heading: Moving each variable to its own side and integrating
eyebrow: A6 · Lesson 17 · Separable differential equations
xp: 50
---

::: hook
A tank drains faster when it's full, because the pressure at the outlet is higher. A capacitor leaking through a part whose current grows with the square of the voltage slows its discharge in a way no exponential describes. Both are equations of the form $\frac{dy}{dt} = g(t)h(y)$, where the rate splits into a part that depends on time and a part that depends on the quantity itself. Those equations can be solved with two ordinary integrals.
:::

::: play
- The solid curve is the water level in a draining tank, $h(t) = \left(\sqrt{h_0} - \frac{ct}{2}\right)^2$. The dashed curve is an exponential decay with the same starting slope.
- The tank empties completely, in a finite time, and the exponential never does.
- Change the outlet constant $c$ and watch the emptying time move.
:::

```sim plot
view: graph
x: t = 0..60 s
y: h = 0..1.1 m
slider: c = 0.02..0.1 = 0.05
plot: (1 - c*t/2)^2*step(2/c - t) | samples: 400 | label: tank level
plot: exp(-c*t) | dashed | color: ch2 | label: exponential, same start
marker: t = 2/c | label: empty
readout: empty after, s = 2/c | digits: 4
```

::: predict
## A tank's level obeys $h' = -c\sqrt h$. Does it empty in a finite time?

- [x] Yes, at $t = 2\sqrt{h_0}/c$
- [ ] No, it approaches empty exponentially
- [ ] Only if $c > 1$
- [ ] It empties instantly

::: reveal
Yes. Separating, $\frac{dh}{\sqrt h} = -c\,dt$, so $2\sqrt h = 2\sqrt{h_0} - ct$, which reaches zero at $t = 2\sqrt{h_0}/c$. An exponential's rate is proportional to $h$ itself, so it slows to nothing as $h$ shrinks; this rate goes as $\sqrt h$, which falls more slowly than $h$, so the level keeps draining fast enough to finish.
:::
:::

::: nameit
## Separating the variables

If $\frac{dy}{dt} = g(t)\,h(y)$, divide by $h(y)$ and multiply by $dt$:

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

Integrate both sides, then use the starting value to find $C$, and solve for $y$ if you can.

## Three examples worth knowing

- **Exponential:** $y' = ky$ gives $\ln|y| = kt + C$, so $y = y_0e^{kt}$.
- **Quadratic decay:** $y' = -ky^2$ gives $-\frac1y = -kt + C$, so $y = \frac{y_0}{1 + ky_0t}$. It falls like $1/t$ for large $t$, much more slowly than an exponential.
- **Draining tank (Torricelli):** $h' = -c\sqrt h$ gives $\sqrt h = \sqrt{h_0} - \frac{ct}{2}$, empty in finite time.

## Watch out for

- **Lost solutions:** dividing by $h(y)$ assumes it isn't zero. If $h(y_*) = 0$, the constant $y = y_*$ is a solution too (here, $y = 0$).
- **Checking:** differentiate your answer and put it back into the equation, and check the starting value.
:::

::: example
## Solve $y' = -0.2y^2$ with $y(0) = 2$. What is $y$ at $t = 10$?

::: solution
1. **Separate and integrate.**
   $$\begin{aligned} \frac{dy}{y^2} &= -0.2\,dt \\ -\frac1y &= -0.2t + C \end{aligned}$$
2. **Use the starting value.** At $t = 0$, $C = -\frac12$:
   $$\frac1y = 0.5 + 0.2t \quad\text{so}\quad y = \frac{2}{1 + 0.4t}$$
3. **Evaluate at $t = 10$.**
   $$\begin{aligned} y &= \frac{2}{5} \\ &= 0.4 \end{aligned}$$
4. **Check.** Differentiate $y$ and compare with $-0.2y^2$:
   $$\begin{aligned} y' &= -\frac{0.8}{(1 + 0.4t)^2} \\ -0.2y^2 &= -0.2 \cdot \frac{4}{(1 + 0.4t)^2} \end{aligned}$$
   the same.

**Answer:** $y = \frac{2}{1 + 0.4t}$, so $y = 0.4$ at $t = 10$.
:::
:::

::: example
## A tank 1 m deep drains as $h' = -0.05\sqrt h$ (with $h$ in m and $t$ in s). When is it empty, and how deep is it after 20 s?

::: solution
1. **Solve.** Separating and starting from $h = 1$ m gives
   $$\sqrt h = 1 - 0.025t$$
2. **When it's empty.** $\sqrt h$ reaches 0 at $t = 40$ s.
3. **Depth after 20 s.**
   $$\sqrt h = 0.5 \quad\text{so}\quad h = 0.25\ \text{m}$$
   Half the time has drained three quarters of the water, because it drains fastest when full.

**Answer:** the tank is empty at 40 s, and after 20 s it is 0.25 m deep.
:::
:::

::: example
## A 100 µF capacitor at 12 V discharges through a part that conducts $i = kv^2$ with $k$ = 5 mA/V². What is its voltage after 10 ms?

::: solution
1. **Recognize quadratic decay.** $C\frac{dv}{dt} = -kv^2$ is quadratic decay with rate constant $k/C$:
   $$v = \frac{v_0}{1 + kv_0t/C}$$
2. **Put in the numbers.**
   $$\begin{aligned} \frac{kv_0t}{C} &= \frac{0.005 \times 12 \times 0.01}{10^{-4}} \\ &= 6 \end{aligned}$$
3. **Find the voltage.**
   $$\begin{aligned} v &= \frac{12}{7} \\ &= 1.71\ \text{V} \end{aligned}$$
   It falls fast while the voltage is high, then lingers, since the part conducts less and less.

**Answer:** after 10 ms the capacitor is at 1.71 V.
:::
:::

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

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

::: right
Right. $y = \frac{y_0}{1 + ky_0t}$ = {answer}.
:::

::: misses
- [y0*exp(-k*t)] That's for $y' = -ky$. Here the rate goes as $y^2$.
- [y0/(1 + k*t)] The $y_0$ appears in the denominator too: $\frac{1}{y} = \frac{1}{y_0} + kt$.
- [any] Not yet. Separate: $\frac{dy}{y^2} = -k\,dt$.
:::
:::

::: check
given: h0 = 2 | 4 | 9; c = 0.02 | 0.05
answer: 2*sqrt(h0)/c
unit: s
tolerance: 0.5%

## A tank {h0} m deep drains as $h' = -\given{c}\sqrt h$. When is it empty?

::: right
Right. $2\sqrt{h_0}/c$ = {answer}.
:::

::: misses
- [sqrt(h0)/c] Integrating $h^{-1/2}$ gives $2\sqrt h$.
- [2*h0/c] It's $\sqrt{h_0}$, from integrating $dh/\sqrt h$.
- [any] Not yet. Separate and integrate: $2\sqrt h = 2\sqrt{h_0} - ct$.
:::
:::

::: check
given: C = 10 | 100; k = 1 | 5; v0 = 5 | 12; t = 5 | 20
answer: v0/(1 + k*1e-3*v0*t*1e-3/(C*1e-6))
unit: V
tolerance: 0.5%

## A {C} µF capacitor at {v0} V discharges through a part conducting $kv^2$, $k$ = {k} mA/V². What is its voltage after {t} ms?

::: right
Right. $v = \frac{v_0}{1 + kv_0t/C}$ = {answer}.
:::

::: misses
- [v0*exp(-k*1e-3*t*1e-3/(C*1e-6))] An exponential would need a resistor, current proportional to $v$.
- [any] Not yet. $C\,dv/dt = -kv^2$ is quadratic decay.
:::
:::

::: check
given: a = 1 | 3; b = 0.5 | 3
answer: exp(b*a^2/2)
tolerance: 0.5%

## Solve $y' = \given{b}\,t\,y$ with $y(0) = 1$. What is $y$ at $t$ = {a}?

::: right
Right. $\ln y = \frac{b}{2}t^2$, so $y = e^{bt^2/2}$ = {answer}.
:::

::: misses
- [exp(b*a)] Integrate $bt$ with respect to $t$: it gives $bt^2/2$.
- [any] Not yet. Separate: $\frac{dy}{y} = bt\,dt$.
:::
:::

::: check
kind: parts
given: h0 = 1 | 2; c = 0.04 | 0.08; f = 0.25 | 0.5

## A tank {h0} m deep drains as $h' = -\given{c}\sqrt h$.

::: part
answer: 2*(sqrt(h0) - sqrt(f*h0))/c
unit: s
tolerance: 0.5%

### When has its level fallen to {f} of the start?

::: misses
- [2*sqrt(h0)/c*(1 - f)] It's $\sqrt h$ that falls linearly, not $h$.
- [any] $\sqrt h = \sqrt{h_0} - ct/2$.
:::
:::

::: part
answer: -c*sqrt(h0)
unit: m/s
tolerance: 0.5%

### How fast is it falling at the start, in m/s?

::: misses
- [any] Put $h_0$ into the equation.
:::
:::
:::

::: check
kind: derivation
vars: k = 0.1..2, y0 = 0.5..5, t = 0..10, y = 0.1..5

## Solve $y' = -ky^2$ with $y(0) = y_0$.

::: step
answer: 1/y

### Separate and integrate $\int\frac{-dy}{y^2}$. What do you get (without the constant)?
:::

::: step
answer: 1/y0 + k*t

### The other side integrates to $kt + C$. Using $t = 0$, write $\frac1y$ in terms of $t$.
:::

::: step
answer: y0/(1 + k*y0*t)

### Solve for $y$.
:::

::: right
Right. $y = \frac{y_0}{1 + ky_0t}$: a $1/t$ tail, much slower than an exponential's.
:::
:::

::: explain
## Why does a draining tank empty in finite time, while an RC circuit never quite discharges?

::: model
The difference is how the rate depends on what's left. In an RC circuit the current is proportional to the voltage, so the rate of fall is proportional to the remaining voltage: each time constant removes the same fraction, and a fixed fraction of a positive number is always positive. In a tank, the outflow is proportional to $\sqrt h$, which shrinks more slowly than $h$ as the tank empties: near the bottom, the remaining water is tiny but the outflow is still relatively large. Separating the variables shows it: $\sqrt h$ falls linearly in time and reaches zero at a definite moment. Any rate that goes as $y^p$ with $p < 1$ finishes in finite time; $p = 1$ gives the exponential; $p > 1$ gives an even slower tail.
:::
:::

::: practice

::: check
given: k = 0.01..2; y0 = 0.1..10; t = 0.1..50
answer: y0/(1 + k*y0*t)
tolerance: 0.5%

## $y' = -\given{k}y^2$, $y(0)$ = {y0}: $y$ at $t$ = {t}?

::: misses
- [any] $\frac{y_0}{1 + ky_0t}$.
:::
:::

::: check
given: h0 = 0.1..10; c = 0.001..0.5
answer: 2*sqrt(h0)/c
tolerance: 0.5%

## Tank empty time: $h_0$ = {h0}, $c$ = {c}?

::: misses
- [any] $2\sqrt{h_0}/c$.
:::
:::
:::
