Some differential equations can be solved exactly by integrating. The simplest family is the separable equations, where the right side splits into a factor with only $x$ and a factor with only $y$: $\frac{dy}{dx} = g(x)\,h(y)$. You will use integrals that give logarithms often.
💡 Why it works
Divide by $h(y)$ (where it is not 0): $\frac{1}{h(y)}\frac{dy}{dx} = g(x)$. Integrate both sides with respect to $x$. On the left, the substitution rule turns $\int \frac{1}{h(y)}\frac{dy}{dx}\,dx$ into $\int \frac{dy}{h(y)}$. So
$$\int \frac{dy}{h(y)} = \int g(x)\,dx.$$
Writing "$\frac{dy}{h(y)} = g(x)\,dx$" is shorthand for exactly this use of the chain rule.
🔑 Key idea
(1) Separate: all $y$'s with $dy$, all $x$'s with $dx$. (2) Integrate both sides and add one constant right away. (3) Solve for $y$ if you can. (4) Use the initial condition. (5) Check any constant solutions you divided away.
✏️ Worked example: Exponential growth
Solve $\frac{dy}{dx} = 2xy$, $y(0) = 3$.
Separate: $\frac{dy}{y} = 2x\,dx$.
Integrate: $\ln|y| = x^{2} + C$.
Exponentiate: $|y| = e^{C}e^{x^{2}}$, so $y = Ke^{x^{2}}$ with $K = \pm e^{C}$; $K = 0$ gives $y = 0$, which is also a solution.
$y(0) = 3$ gives $K = 3$: $y = 3e^{x^{2}}$.
Answer: $y = 3e^{x^{2}}$
⚠️ Common mistake
Adding the constant at the end instead of right after integrating. For $\frac{dy}{dx} = xy^{2}$: integrating gives $-\frac{1}{y} = \frac{x^{2}}{2} + C$, so $y = \frac{-1}{x^{2}/2 + C}$. If you solve $-\frac{1}{y} = \frac{x^{2}}{2}$ first and then write $y = -\frac{2}{x^{2}} + C$, you get a family that does not satisfy the equation. Also watch for lost solutions: dividing by $y^{2}$ assumed $y \ne 0$, but $y = 0$ is a solution too. Check by substituting into the original equation.
$y(0) = 2 > 0$, so take the positive root: $y = \sqrt{x^{2} + 4}$.
Answer: $y = \sqrt{x^{2} + 4}$
The slope field of $y' = \frac{x}{y}$. The solution through $(0, 2)$ is the upper branch of the hyperbola $y^{2} - x^{2} = 4$. Drag the starting point to see other solutions.
✏️ Worked example: Newton's law of cooling
Coffee at $90^\circ$C cools in a $20^\circ$C room by $\frac{dT}{dt} = -0.1(T - 20)$, with $t$ in minutes. Find $T(t)$.