First-Order Linear Equations

Not every first-order ODE is separable — the variables often refuse to come apart. 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.

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.

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.