First-Order Linear Equations
The hook: a bank account that both earns and spends
Picture a savings account with balance y(t) that earns continuous
interest at rate r — so left alone it would grow like
y' = ry — while you simultaneously deposit or withdraw money at
some outside rate d(t) (positive for a deposit, negative for a
withdrawal). The balance obeys both effects at once:
\frac{dy}{dt} = r\,y + d(t) \quad\Longleftrightarrow\quad y' - r\,y = d(t).
The two influences — the account's own exponential growth and your outside interference — are
hopelessly tangled together on the right; there is no way to shuffle y
and t onto separate sides. This exact shape, "the unknown's own rate of
change plus a multiple of itself, driven by an outside term," is the first-order linear
equation, and it turns out to have a clean trick of its own.
Not every first-order ODE is
separable
— the variables often refuse to come apart, exactly as in the bank-account equation above. The next
class we can always crack is the
first-order linear equation, recognisable because
y and y' appear only to the first power and
are never multiplied together:
\frac{dy}{dx} + P(x)\,y = Q(x).
"Linear" means linear in the unknown y and its derivative; the
coefficients P and Q may be any functions of
x. The trouble is that the left side,
y' + Py, is almost but not quite the derivative of a product. The
whole method is one clever multiplication that fixes that.
The integrating factor, line by line
The idea: multiply the whole equation by a cunning function
\mu(x) chosen so the left side collapses into a single
product derivative (\mu y)'. Then one integration finishes the job.
Step 1 — multiply through by an unknown factor
\mu(x):
\mu\,y' + \mu P\,y = \mu Q.
Step 2 — demand the left side be a product derivative. By the product rule,
(\mu y)' = \mu y' + \mu' y. Comparing with the left side above, the two
match provided
\mu' = \mu P.
Step 3 — solve that little separable ODE for \mu.
The condition \mu' = P\mu is itself separable
(d\mu/\mu = P\,dx), giving \ln\mu = \int P\,dx,
hence the integrating factor
\mu(x) = e^{\int P(x)\,dx}.
Step 4 — rewrite the equation as a single derivative. With this
\mu the left side is exactly (\mu y)':
\big(\mu(x)\,y\big)' = \mu(x)\,Q(x).
Step 5 — integrate both sides in x. The left side
integrates trivially (it is already a derivative); the right side carries the constant:
\mu(x)\,y = \int \mu(x)\,Q(x)\,dx + C.
Step 6 — divide by \mu to isolate
y:
\boxed{\,y = \frac{1}{\mu(x)}\left(\int \mu(x)\,Q(x)\,dx + C\right).}
A worked example: y' + y = x
Here P(x) = 1 and Q(x) = x. Run the recipe.
Step 1 — compute the integrating factor.
\mu = e^{\int 1\,dx} = e^{x}.
Step 2 — multiply through and recognise the product derivative.
e^{x}y' + e^{x}y = x\,e^{x} \quad\Longrightarrow\quad \big(e^{x}y\big)' = x\,e^{x}.
Step 3 — integrate both sides. The right side needs integration by parts
(\int x e^x\,dx = (x-1)e^x):
e^{x}y = (x - 1)e^{x} + C.
Step 4 — divide by e^{x}:
\boxed{\,y = x - 1 + C\,e^{-x}.}
Step 5 — sanity check. Then y' = 1 - Ce^{-x}, and
y' + y = (1 - Ce^{-x}) + (x - 1 + Ce^{-x}) = x. \quad\checkmark
Notice the structure of the answer: a particular solution
x - 1 (which alone satisfies y' + y = x) plus
C e^{-x}, the general solution of the homogeneous equation
y' + y = 0. The transient Ce^{-x} fades as
x \to \infty, leaving the steady line x - 1 —
a pattern that recurs everywhere linear systems appear.
The first-order linear ODE y' + P(x)\,y = Q(x) is solved as follows.
-
Form the integrating factor
\mu(x) = e^{\int P(x)\,dx} (any one antiderivative of
P will do — the constant cancels).
-
Multiplying by \mu turns the left side into a single product
derivative: (\mu y)' = \mu Q.
-
Integrating gives the general solution
y = \frac{1}{\mu(x)}\left(\int \mu(x)\,Q(x)\,dx + C\right).
-
It is the sum of one particular solution and the
homogeneous solution C/\mu(x) = C\,e^{-\int P}; an
initial condition fixes C.
First-order linear ODEs are the equations of things filling and draining. Pour brine into
a tank holding V litres at r L/min with
concentration c_{\text{in}}, draining at the same rate. The amount of
salt y(t) obeys "rate in minus rate out":
\frac{dy}{dt} = r\,c_{\text{in}} - \frac{r}{V}\,y \quad\Longleftrightarrow\quad y' + \frac{r}{V}\,y = r\,c_{\text{in}},
textbook first-order linear with P = r/V constant. The solution
relaxes exponentially to the equilibrium salt content V c_{\text{in}} —
the Ce^{-rt/V} transient dies, the steady state survives.
The same equation runs an RC circuit. A resistor and capacitor in series with a
source voltage V(t) give, by Kirchhoff's law,
R\,q' + q/C = V(t), i.e.
q' + \tfrac{1}{RC}q = V(t)/R. The capacitor charges toward
CV with the famous time constant \tau = RC:
one integrating factor, two textbooks' worth of applications.
A second worked example: y' + 2y = e^{-x}
Here P(x) = 2 (a constant) and Q(x) = e^{-x}.
Step 1 — the integrating factor.
\mu = e^{\int 2\,dx} = e^{2x}.
Step 2 — multiply through by \mu
— every term, including Q:
e^{2x}y' + 2e^{2x}y = e^{2x}\cdot e^{-x} \quad\Longrightarrow\quad \big(e^{2x}y\big)' = e^{x}.
Step 3 — integrate both sides:
e^{2x}y = e^{x} + C.
Step 4 — divide by e^{2x}:
\boxed{\,y = e^{-x} + C\,e^{-2x}.}
Check: y' = -e^{-x} - 2Ce^{-2x}, so
y' + 2y = (-e^{-x} - 2Ce^{-2x}) + 2(e^{-x} + Ce^{-2x}) = e^{-x}. ✓
Once again the answer splits into a forced piece e^{-x} and a
homogeneous transient Ce^{-2x} that dies out.
A third worked example: a mixing tank, with real numbers
A tank holds V = 200 litres of brine; it starts with
y(0) = 20 kg of dissolved salt. Fresh brine flows in at
r = 5 L/min with concentration c_{\text{in}} = 0.4
kg/L (so salt arrives at r c_{\text{in}} = 2 kg/min), and the well-stirred
mixture drains out at the same rate, carrying salt away at
\tfrac{r}{V}y = \tfrac{5}{200}y = 0.025\,y kg/min. "Rate in minus rate
out" gives
y' = 2 - 0.025\,y \quad\Longleftrightarrow\quad y' + 0.025\,y = 2.
Integrating factor: \mu = e^{0.025t}. Multiplying
through and collapsing the left side:
\big(e^{0.025t}y\big)' = 2\,e^{0.025t} \;\Longrightarrow\; e^{0.025t}y = 80\,e^{0.025t} + C \;\Longrightarrow\; y = 80 + C\,e^{-0.025t}.
Apply y(0) = 20: 20 = 80 + C, so
C = -60, giving
\boxed{\,y(t) = 80 - 60\,e^{-0.025t}\ \text{kg}.}
As t \to \infty the salt content creeps up to
80 kg and stays there — exactly V c_{\text{in}} = 200 \times
0.4, the equilibrium the vignette above predicted, reached by decaying away from the
starting imbalance of 60 kg.
These two mistakes are the most common way to wreck an otherwise correct calculation:
-
The coefficient of y' must be exactly 1 before you read off
P(x). Given 3y' + 6y = e^{x}, it is
tempting to say "P = 6." Wrong — first divide every term by
the leading coefficient 3: y' + 2y = \tfrac{1}{3}e^{x}. Only now is
P = 2 and Q = \tfrac{1}{3}e^{x} — note
Q got divided too.
-
The integrating factor multiplies every term, including Q(x).
A common slip is to multiply the left side by \mu and forget the right
side, leaving an equation that is no longer true. The whole point of Step 1 was multiplying the
entire equation — left and right — by \mu.
The integrating-factor trick is old. Gottfried Leibniz worked out how to solve exactly this class of
equation in 1694, trading letters with Johann Bernoulli about the general "linear"
differential equation — barely a decade after he and Newton had invented calculus itself.
Three centuries later the same equation quietly runs the electronics in your pocket. Charging a
capacitor C through a resistor R toward a
supply voltage V obeys q' + \tfrac{1}{RC}q = V/R
— constant P = 1/RC, exactly like the mixing tank's constant
P = r/V above. Swap "salt" for "charge" and "litres" for "coulombs" and
it is the identical differential equation, right down to the exponential approach to equilibrium.
The transient fading, live
Below is the solution y = x - 1 + Ce^{-x} of
y' + y = x. Slide the constant C (set by the
initial value): no matter where the curve starts, the Ce^{-x} transient
decays and every solution is drawn toward the same particular solution, the dashed line
y = x - 1.