Chapter 4: Introduction to Differential Equations
4.5 First-order Linear Equations
Study guide for Calculus Volume 2 (Gilbert Strang, 2016 edition)
Independent study guide. Not affiliated with OpenStax or Rice University.
Big idea
Separation solves a large class of equations, but it fails as soon as the unknown and the independent variable are tangled additively. The equation $\frac{dy}{dx} + \frac{2}{x}y = 4x^2$ cannot be factored into a function of $x$ times a function of $y$, so there is nothing to separate. It is, however, linear in $y$, and linear first-order equations have their own method that works every time.
The trick is to make the left side into a derivative. If you could multiply the whole equation by some function $\mu(x)$ chosen so that $\mu y' + \mu p y$ is exactly $(\mu y)'$, then the equation would read $(\mu y)' = \mu q$, and a single antidifferentiation would finish it. The product rule says $(\mu y)' = \mu y' + \mu' y$, so the requirement on $\mu$ is just $\mu' = p\mu$. That is a separable equation for $\mu$, and it has the explicit solution $\mu = e^{\int p\,dx}$.
So the method is not a trick pulled from nowhere; it is the product rule read backwards, with one auxiliary separable equation solved along the way. That is worth internalizing, because the same idea reappears for systems and for higher-order equations, and because remembering where $e^{\int p}$ comes from is easier than memorizing it.
The procedural cost is that the equation must be in standard form first. The coefficient of $y'$ has to be $1$ before you read off $p$, and skipping that division is the single most common way to get a wrong integrating factor. Everything after that step is integration.
Decoder
Multiplying a first-order linear equation in standard form by the exponential of an antiderivative of the coefficient of the unknown turns the left side into the derivative of a single product.
The phrase “in standard form” is load-bearing. The coefficient $p(x)$ is defined only after the equation reads $y' + p(x)y = q(x)$ with a bare $y'$. If the equation arrives as $x y' + 2y = 4x^3$, then $p$ is $2/x$, not $2$, and the integrating factor is $x^2$, not $e^{2x}$.
The word “exponential” explains why no absolute value or constant survives. Any antiderivative of $p$ will do, since changing it by a constant multiplies $\mu$ by a nonzero constant, and that constant cancels from both sides of $(\mu y)' = \mu q$. So take the simplest antiderivative and drop its constant. When $\int p$ involves a logarithm, a factor like $e^{2\ln x}$ simplifies to $x^2$ on the interval where $x > 0$, and you work on that interval.
The standard failure mode is to integrate only one side, or to forget that after writing $\mu y = \int \mu q\,dx + C$ you must divide the constant through by $\mu$ as well. The $C$ ends up attached to $1/\mu$, and that term is exactly the solution of the equation with zero on the right.
Definitions and results
Standard form. A first-order linear equation is
$$ \frac{dy}{dx} + p(x)\,y = q(x) $$
Any equation $a(x)y' + b(x)y = c(x)$ becomes this after dividing by $a(x)$, on an interval where $a$ does not vanish.
Integrating factor. The function
$$ \mu(x) = e^{\int p(x)\,dx} $$
taken with any single antiderivative and no constant. It is never zero, so multiplying by it does not create or destroy solutions.
Why it works. By the chain rule $\mu' = p\,\mu$, so by the product rule
$$ \frac{d}{dx}\big[\mu(x)y\big] = \mu y' + \mu' y = \mu\left(y' + p y\right) = \mu\, q $$
The left side of the equation has been packaged into one derivative.
The solution formula. Antidifferentiating the packaged equation and dividing by $\mu$,
$$ y = \frac{1}{\mu(x)}\left(\int \mu(x)\,q(x)\,dx + C\right) $$
The procedure. Put the equation in standard form; read off $p$; compute $\mu = e^{\int p}$; multiply through; recognize the left side as $(\mu y)'$; integrate both sides; divide by $\mu$; then impose an initial condition if one is given.
Structure of the answer. The general solution is always one particular solution plus $C/\mu(x)$. The second piece is the general solution of $y' + py = 0$, which is why every linear problem has that same additive shape.
Overlap with separation. If $q$ is zero the equation is also separable, and both methods give $y = C/\mu$. If $p$ and $q$ are both constant the equation is separable as well. The integrating factor is the method that survives when $q$ is a genuine function of $x$.
Existence. If $p$ and $q$ are continuous on an interval containing $x_0$, the initial-value problem with $y(x_0) = y_0$ has exactly one solution on that whole interval. Linear equations do not produce the sudden blowups that nonlinear ones can.
Worked examples
A constant coefficient with an exponential forcing term
Solve $\dfrac{dy}{dx} + 3y = e^{-x}$.
The equation is already in standard form with $p = 3$, so $\int p\,dx = 3x$ and $\mu = e^{3x}$. Multiply:
$$ e^{3x}y' + 3e^{3x}y = e^{3x}e^{-x} = e^{2x} $$
The left side is $\left(e^{3x}y\right)'$. Integrate both sides:
$$ e^{3x}y = \tfrac12 e^{2x} + C \quad \Longrightarrow \quad y = \tfrac12 e^{-x} + Ce^{-3x} $$
Check: $y' = -\tfrac12 e^{-x} - 3Ce^{-3x}$, and $y' + 3y = -\tfrac12 e^{-x} - 3Ce^{-3x} + \tfrac32 e^{-x} + 3Ce^{-3x} = e^{-x}$.
An equation that must be divided first
Solve $x\dfrac{dy}{dx} + 2y = 4x^3$ for $x > 0$.
Divide by $x$ to reach standard form:
$$ \frac{dy}{dx} + \frac{2}{x}\,y = 4x^2 $$
Now $p = 2/x$, so $\int p\,dx = 2\ln x$ and $\mu = e^{2\ln x} = x^2$ on $x > 0$. Multiplying gives $x^2 y' + 2xy = 4x^4$, whose left side is $\left(x^2 y\right)'$. Integrate:
$$ x^2 y = \tfrac45 x^5 + C \quad \Longrightarrow \quad y = \tfrac45 x^3 + \frac{C}{x^2} $$
Check: $y' = \tfrac{12}{5}x^2 - 2Cx^{-3}$, so $y' + \frac2x y = \tfrac{12}{5}x^2 - 2Cx^{-3} + \tfrac85 x^2 + 2Cx^{-3} = 4x^2$. Had you skipped the division and used $\mu = e^{2x}$, the left side would not have collapsed into a derivative and nothing would have simplified.
An initial-value problem
Solve $\dfrac{dy}{dx} - y = e^{2x}$ with $y(0) = 3$.
Here $p = -1$, so $\mu = e^{-x}$. Multiplying gives $\left(e^{-x}y\right)' = e^{-x}e^{2x} = e^{x}$, and integrating gives $e^{-x}y = e^{x} + C$. Divide:
$$ y = e^{2x} + Ce^{x} $$
The condition $y(0) = 1 + C = 3$ forces $C = 2$, so $y = e^{2x} + 2e^{x}$. Check both requirements: $y' - y = \left(2e^{2x} + 2e^{x}\right) - \left(e^{2x} + 2e^{x}\right) = e^{2x}$, and $y(0) = 1 + 2 = 3$.
Salt in a well-stirred tank
A tank holds $100$ liters of pure water. Brine containing $0.4$ kilograms of salt per liter runs in at $5$ liters per minute, the mixture is stirred continuously, and the solution drains at $5$ liters per minute, so the volume stays at $100$ liters. Find the amount of salt $S(t)$ after $t$ minutes.
Salt enters at $5(0.4) = 2$ kilograms per minute. The concentration in the tank is $S/100$, so salt leaves at $5\left(S/100\right) = 0.05S$ kilograms per minute. The balance gives
$$ \frac{dS}{dt} = 2 - 0.05S, \qquad \text{that is} \qquad \frac{dS}{dt} + 0.05S = 2 $$
with $S(0) = 0$. The integrating factor is $e^{0.05t}$, and multiplying gives $\left(Se^{0.05t}\right)' = 2e^{0.05t}$. Integrate and divide:
$$ Se^{0.05t} = 40e^{0.05t} + C \quad \Longrightarrow \quad S(t) = 40 + Ce^{-0.05t} $$
Then $S(0) = 40 + C = 0$ gives $C = -40$, so $S(t) = 40\left(1 - e^{-0.05t}\right)$.
Two checks. At $t = 0$ the formula gives $0$, matching the pure water. As $t$ grows, $S \to 40$ kilograms, which is $100$ liters at the incoming concentration of $0.4$ kilograms per liter. The tank ends up matching what flows in, as it must once the transient dies.
Practice
One skill here, covering the whole procedure. Expect equations that need dividing into standard form, integrating factors that simplify from an exponential of a logarithm into a power, and initial conditions that fix the constant at the end.
Practice
Generated problems for this section, graded instantly.
Quiz
Five items on standard form, constructing and applying the integrating factor, and solving first-order linear initial-value problems.
Quiz
5 problems with a score at the end.