Topic · Differential Equations

First-Order ODEs

Equations of the form $y' = f(x, y)$ — one unknown function, one independent variable, one derivative. The technique you use depends entirely on the shape of $f$: separable, linear, exact, or coaxed into one of those by a substitution. Knowing which lens to reach for is more than half the battle.

What you'll leave with

  • A decision rule for which of the four core techniques to try first, based only on the equation's shape.
  • The recipe for separable equations — and the singular-solution trap that comes with dividing.
  • The integrating factor $\mu(x) = e^{\int P\,dx}$ for linear first-order ODEs, and a derivation of why it has to be that expression and nothing else.
  • How to recognize an exact equation via $M_y = N_x$ and reconstruct the potential function $\Psi$.
  • The two classic substitutions — $v = y/x$ for homogeneous-type, $v = y^{1-n}$ for Bernoulli — and what they each linearize.
  • What to do when none of the analytic techniques apply: Euler's method as the numerical fallback.

1. Which technique do I try first?

Before you can solve a first-order ODE, you have to classify it. The four techniques below are roughly ordered by how much work they take: separable is the cheapest, substitution the most involved. The flowchart is a decision rule: walk down it and pick the first match.

Given y' = f(x, y) Does f factor as g(x)·h(y)? Separable? YES Separate & integrate y' + P(x)y = Q(x)? Linear first-order? YES Integrating factor μ M dx + N dy = 0 with M_y = N_x? Exact? YES Find potential Ψ f(y/x)? y' + Py = Qyⁿ? Homogeneous or Bernoulli? YES Substitute v = y/x or v = y^(1−n) NO ANALYTIC FIT Euler's method (numerical) no no no no
Read it as a sieve

Each "no" pushes you further down. In practice most ODEs you'll meet in a first course fall out at the separable or linear stage. Exact and substitution are the second tier; numerical methods are the safety net when symbolic algebra runs out of road.

2. Separable equations

Separable

An equation $\dfrac{dy}{dx} = g(x) h(y)$ in which the right side factors into a function of $x$ alone times a function of $y$ alone.

The point of separability is that the $x$ and $y$ pieces never tangle. You can move all of the $y$ to one side and all of the $x$ to the other, then integrate each side on its own:

$$ \frac{dy}{h(y)} = g(x)\, dx \quad\Longrightarrow\quad \int \frac{dy}{h(y)} \;=\; \int g(x)\, dx + C. $$

That single constant $C$ is doing real work — it carries the entire family of solutions, parameterised by initial condition.

Worked example · $\dfrac{dy}{dx} = xy$

Step 1. The right side already factors as $x \cdot y$, so the equation is separable. Move $y$ to the left:

$$ \frac{dy}{y} = x\, dx. $$

Step 2. Integrate both sides:

$$ \int \frac{dy}{y} = \int x\, dx \quad\Longrightarrow\quad \ln|y| = \frac{x^2}{2} + C. $$

Step 3. Exponentiate and absorb the sign into the constant:

$$ y = A\, e^{x^2 / 2}, \qquad A = \pm e^C. $$

Check. Differentiate: $y' = A \cdot x \cdot e^{x^2/2} = x y$. ✓

Don't divide away a solution

Dividing by $h(y)$ silently assumes $h(y) \neq 0$. For $y' = y^2$, separating gives $\int dy/y^2 = \int dx$, but the constant function $y \equiv 0$ also solves the equation — and you lost it the moment you divided. Always check $h(y) = 0$ as a candidate before you separate.

3. Linear first-order & the integrating factor

Linear first-order ODE

An equation that can be put into the form $\dfrac{dy}{dx} + P(x)\, y = Q(x)$, where $P$ and $Q$ are functions of $x$ only. The unknown $y$ appears to the first power and is not inside any other function.

This is the workhorse case. Almost every "rate plus proportional loss" model in physics, chemistry, and finance fits this template: $Q$ is the input, $P$ is the rate at which the system bleeds.

Why the integrating factor has to be $e^{\int P\,dx}$

Notice what the product rule does to $\mu(x) \cdot y$ for any differentiable $\mu$:

$$ \frac{d}{dx}\big[\mu(x)\, y\big] \;=\; \mu'(x)\, y \;+\; \mu(x)\, y'. $$

Now multiply the ODE through by $\mu$:

$$ \mu\, y' + \mu\, P\, y \;=\; \mu\, Q. $$

If we could just choose $\mu$ so that $\mu P = \mu'$, the left side would collapse exactly into $\frac{d}{dx}(\mu y)$ by the product rule above. So we demand:

$$ \mu'(x) \;=\; P(x)\, \mu(x). $$

That's a separable equation for $\mu$ — and a friendly one. $d\mu/\mu = P\, dx$ gives $\ln|\mu| = \int P\, dx$, so

$$ \boxed{\;\mu(x) \;=\; e^{\int P(x)\, dx}.\;} $$

(No constant of integration needed — any nonzero scalar multiple of $\mu$ works equally well, and the choice $C = 0$ is the simplest.) Once $\mu$ is in hand, the multiplied equation is

$$ \frac{d}{dx}\big[\mu(x)\, y\big] \;=\; \mu(x)\, Q(x), $$

and you finish by integrating both sides and dividing by $\mu$:

$$ y(x) \;=\; \frac{1}{\mu(x)}\left[ \int \mu(x)\, Q(x)\, dx \;+\; C \right]. $$
What this trick really is

The integrating factor turns an awkward derivative ($y'$ tangled up with a $y$ term) into a clean derivative of a single product. You're not solving a different equation — you're rewriting the same equation in a form whose left side is visibly the derivative of something.

Worked example · $y' + 2y = e^x$

Step 1. Read off $P(x) = 2$ and $Q(x) = e^x$. The integrating factor is

$$ \mu(x) = e^{\int 2\, dx} = e^{2x}. $$

Step 2. Multiply the equation by $\mu$:

$$ e^{2x} y' + 2 e^{2x} y = e^{2x} \cdot e^x \;=\; e^{3x}. $$

The left side is exactly $\dfrac{d}{dx}\!\left(e^{2x}\, y\right)$, by construction. So:

$$ \frac{d}{dx}\big(e^{2x}\, y\big) \;=\; e^{3x}. $$

Step 3. Integrate both sides:

$$ e^{2x}\, y \;=\; \tfrac{1}{3} e^{3x} + C. $$

Step 4. Divide through by $e^{2x}$:

$$ y(x) \;=\; \tfrac{1}{3} e^{x} \;+\; C\, e^{-2x}. $$

Check. $y' = \tfrac{1}{3} e^x - 2C e^{-2x}$, so $y' + 2y = \tfrac{1}{3} e^x - 2C e^{-2x} + \tfrac{2}{3} e^x + 2C e^{-2x} = e^x$. ✓

4. Exact equations

Write the ODE in differential form:

$$ M(x, y)\, dx \;+\; N(x, y)\, dy \;=\; 0. $$

If — and this is a real "if" — there exists a function $\Psi(x, y)$ such that

$$ \frac{\partial \Psi}{\partial x} = M, \qquad \frac{\partial \Psi}{\partial y} = N, $$

then the differential form is literally $d\Psi = 0$, and the implicit solution is just $\Psi(x, y) = C$. We say the equation is exact.

The test: does $\Psi$ exist?

By Clairaut's theorem, mixed partials of a smooth $\Psi$ agree: $\Psi_{xy} = \Psi_{yx}$. So if the equation is exact, then

$$ \frac{\partial M}{\partial y} \;=\; \frac{\partial N}{\partial x}. $$

On a simply connected region, the converse also holds — the equality of these partials is both necessary and sufficient for $\Psi$ to exist. So that one check decides the whole game.

Reconstructing $\Psi$

Once you've confirmed exactness, build $\Psi$ in two passes:

  1. Integrate $M$ with respect to $x$, treating $y$ as constant. The "constant" of integration is an unknown function $g(y)$: $$ \Psi(x, y) = \int M(x, y)\, dx + g(y). $$
  2. Differentiate the result with respect to $y$ and set it equal to $N$. That pins down $g'(y)$, which you integrate to recover $g$.

Worked example · $(2x + y)\, dx + (x + 2y)\, dy = 0$

Step 1. Read off $M = 2x + y$, $N = x + 2y$. Check exactness:

$$ M_y = 1, \qquad N_x = 1. \quad\checkmark $$

Step 2. Integrate $M$ with respect to $x$:

$$ \Psi(x, y) = \int (2x + y)\, dx = x^2 + xy + g(y). $$

Step 3. Differentiate with respect to $y$ and match $N$:

$$ \Psi_y = x + g'(y) \stackrel{!}{=} x + 2y \quad\Longrightarrow\quad g'(y) = 2y \quad\Longrightarrow\quad g(y) = y^2. $$

Step 4. Assemble:

$$ \Psi(x, y) \;=\; x^2 + xy + y^2 \;=\; C. $$

That implicit relation is the family of solutions. (You usually leave it implicit — solving for $y$ here would mean using the quadratic formula and choosing a branch.)

Not exact? Try an integrating factor

If $M_y \neq N_x$, you're not stuck — sometimes a factor $\mu(x, y)$ multiplied through makes the equation exact. When $(M_y - N_x)/N$ depends only on $x$, an integrating factor $\mu(x)$ exists, and you find it by solving $\mu'/\mu = (M_y - N_x)/N$. This is the same idea as the linear case, generalised.

5. Substitution: homogeneous-type & Bernoulli

Sometimes the equation isn't separable, linear, or exact — but a clever change of variables turns it into one of those. Two substitutions cover most of the cases you'll meet.

Homogeneous-type · $y' = f(y/x)$

If the right side depends only on the ratio $y/x$, substitute $v = y/x$, so $y = v x$ and

$$ y' = v + x\, v'. $$

The equation becomes $v + x v' = f(v)$, i.e. $x v' = f(v) - v$, which is now separable in $v$ and $x$.

Worked example · $\dfrac{dy}{dx} = \dfrac{x^2 + y^2}{x y}$

Step 1. Divide numerator and denominator by $x^2$ to expose the ratio:

$$ \frac{dy}{dx} \;=\; \frac{1 + (y/x)^2}{y/x}. $$

So the equation is homogeneous-type with $f(v) = (1 + v^2)/v = 1/v + v$.

Step 2. Substitute $y = vx$, $y' = v + x v'$:

$$ v + x v' \;=\; \frac{1}{v} + v \quad\Longrightarrow\quad x v' \;=\; \frac{1}{v}. $$

Step 3. Separate and integrate:

$$ v\, dv = \frac{dx}{x} \quad\Longrightarrow\quad \frac{v^2}{2} \;=\; \ln|x| + C. $$

Step 4. Back-substitute $v = y/x$:

$$ \frac{y^2}{2 x^2} \;=\; \ln|x| + C \quad\Longrightarrow\quad y^2 \;=\; 2 x^2 \big(\ln|x| + C\big). $$

Bernoulli · $y' + P(x)\, y = Q(x)\, y^n$

This is "linear, but for the rogue $y^n$ on the right." For $n \neq 0, 1$, the substitution

$$ v = y^{1-n} $$

linearises it. The chain rule gives $v' = (1 - n)\, y^{-n}\, y'$, so dividing the original equation by $y^n$ and rewriting in terms of $v$ produces a linear ODE in $v$, which you solve with an integrating factor.

Worked example · $y' + y = x\, y^2$

Step 1. Here $n = 2$, so substitute $v = y^{1-2} = y^{-1}$. Then

$$ v' = -y^{-2}\, y' \quad\Longrightarrow\quad y' = -y^2\, v'. $$

Step 2. Divide the original equation by $y^2$ and rewrite:

$$ \frac{y'}{y^2} + \frac{1}{y} \;=\; x \quad\Longrightarrow\quad -v' + v \;=\; x \quad\Longrightarrow\quad v' - v \;=\; -x. $$

This is linear in $v$.

Step 3. Solve with integrating factor $\mu = e^{-x}$. Multiplying through:

$$ \frac{d}{dx}\!\left(e^{-x}\, v\right) \;=\; -x\, e^{-x}. $$

Integration by parts on the right gives $\int -x e^{-x}\, dx = x e^{-x} + e^{-x} + C_1$, so

$$ e^{-x}\, v \;=\; x e^{-x} + e^{-x} + C_1 \quad\Longrightarrow\quad v \;=\; x + 1 + C_1\, e^{x}. $$

Step 4. Back-substitute $y = 1/v$:

$$ y \;=\; \frac{1}{x + 1 + C_1\, e^{x}}. $$

6. When all else fails: Euler's method

Most first-order ODEs from real models don't fit any of the templates above. When the equation refuses to be solved symbolically, you settle for an approximation — numerically march forward from the initial condition in small steps. The simplest such scheme is Euler's method.

Euler's method

Given $y' = f(x, y)$ with $y(x_0) = y_0$, choose a step size $h$ and iterate:

$x_{n+1} = x_n + h, \qquad y_{n+1} = y_n + h \cdot f(x_n, y_n).$

Each step uses the slope at the current point to estimate where the solution will be one step ahead.

One step, worked

Consider $y' = x + y$ with $y(0) = 1$. Take $h = 0.1$. The slope at $(0, 1)$ is $f(0, 1) = 0 + 1 = 1$, so

$$ y_1 = y_0 + h \cdot f(x_0, y_0) = 1 + 0.1 \cdot 1 = 1.1, \qquad x_1 = 0.1. $$

That's the next point on the approximate solution curve. Repeat: at $(0.1, 1.1)$ the slope is $0.1 + 1.1 = 1.2$, so $y_2 = 1.1 + 0.1 \cdot 1.2 = 1.22$. Keep going.

Why Euler is only the start

Euler's method has global error proportional to $h$ — halve the step, halve the error. That's mediocre. Production-grade ODE solvers (Runge–Kutta 4, adaptive RK45, implicit methods for stiff systems) achieve far better accuracy for the same work. Euler matters as the conceptual prototype: every more sophisticated method is a refinement of "look at the slope, take a step."

7. Common pitfalls

Mis-classifying the equation

The single most expensive mistake is reaching for the wrong technique. Always rewrite the ODE in standard form ($y' = \ldots$ or $M\, dx + N\, dy = 0$) before classifying, and walk the flowchart in order — separable first, then linear, then exact, then substitution.

Integrating $Q$ instead of $P$ in $\mu$

The integrating factor for $y' + P y = Q$ is $\mu = e^{\int P\, dx}$, not $e^{\int Q\, dx}$. $P$ is the coefficient of $y$; $Q$ is the forcing term. Mixing them gives an entirely wrong $\mu$ that doesn't make the left side a clean derivative.

Forgetting the constant of integration

Every indefinite integral introduces a $+C$. Drop it on the linear-equation step and you'll get one particular solution instead of the whole family. The single constant is what lets you fit an initial condition later.

Losing singular solutions when you divide

Separating by dividing through by $h(y)$ silently throws out any $y$ where $h(y) = 0$ — but those constant functions can themselves be solutions. For $y' = y^2$, $y \equiv 0$ is a perfectly good solution that dividing by $y^2$ erases. Check $h = 0$ as a candidate before separating.

Bernoulli with $n = 0$ or $n = 1$

The substitution $v = y^{1-n}$ assumes $n \neq 0, 1$. When $n = 0$, the equation is already linear; when $n = 1$, it collapses to $y' = (Q - P) y$, which is separable. Both edge cases are easier than the substitution would be — don't reach for a hammer when the problem isn't a nail.

Sources & further reading

The classification above is standard across every first ODE course; what differs is the depth of worked examples and the proofs of why each method works. The references below complement this page from different angles — primary text, worked-example archive, formal reference, and broad overview.

Test your understanding

A quiz that builds from easy to hard. Pick an answer to get instant feedback and a worked explanation. Your progress is saved in this browser — come back anytime to continue.

Question 1 of 24
0 correct