In short

A first-order linear differential equation has the form \dfrac{dy}{dx} + P(x)y = Q(x) — linear because y and y' appear only to the first power. The standard solution method is to multiply both sides by the integrating factor \mu(x) = e^{\int P(x)\,dx}, which turns the left side into (\mu y)'. One integration later, you have y = \frac{1}{\mu}\int \mu Q\,dx. This is the single technique that solves every first-order linear ODE.

A cup of tea sits on a table at 90°\mathrm C. The room is at 20°\mathrm C. Newton's law of cooling says the tea loses heat at a rate proportional to how much hotter it is than the room. Let T(t) be the temperature of the tea at time t. Then

\frac{dT}{dt} = -k(T - 20)

for some positive constant k that depends on the cup. This is a differential equation you can solve by separating variables — but there is a small twist: what if the room itself is warming up? Say T_{\text{room}}(t) = 20 + 2t because sunlight is pouring in. Now the equation becomes

\frac{dT}{dt} = -k\bigl(T - (20 + 2t)\bigr) = -kT + k(20 + 2t)

Rearranging:

\frac{dT}{dt} + kT = k(20 + 2t)

This is not separable anymore. The t on the right side and the T on the left are tangled through an addition rather than a product. You cannot split the variables to opposite sides.

But there is a single trick — clever but mechanical, once you know it — that solves this equation and every other one that has this shape. The shape is called first-order linear, and the trick is called the integrating factor method. This article shows you exactly where the trick comes from and why it always works.

The standard form

Before you can apply the method, write the equation in a standard form.

First-Order Linear Form

A first-order linear differential equation is one that can be written as

\frac{dy}{dx} + P(x)\,y = Q(x)

where P(x) and Q(x) are functions of x alone. The equation is called linear because y and its derivative appear only to the first power — no y^2, no \sin y, no (dy/dx)^2.

How to recognise it. You need dy/dx to appear with a coefficient of 1, a term with y multiplied by something that is purely a function of x, and a right-hand side that is also purely a function of x. Any linear equation can be massaged into this form by dividing through by the coefficient of dy/dx.

Example. Is x\,\frac{dy}{dx} + 3y = x^2 linear? Yes. Dividing by x:

\frac{dy}{dx} + \frac{3}{x}\,y = x

This matches the standard form with P(x) = 3/x and Q(x) = x.

Example. Is \frac{dy}{dx} + y^2 = x linear? No — the y^2 makes it nonlinear. You cannot solve it with the integrating factor method.

The trick: multiply by the right thing

Here is the core idea. Look at the left-hand side:

\frac{dy}{dx} + P(x)\,y

This looks kind of like a derivative of a product — specifically, the derivative of y times something. By the product rule,

\frac{d}{dx}\bigl(\mu(x)\,y\bigr) = \mu'(x)\,y + \mu(x)\,\frac{dy}{dx}

If you multiply the left side of your equation by \mu(x), you get

\mu(x)\frac{dy}{dx} + \mu(x)P(x)\,y

For this to equal \frac{d}{dx}(\mu y) = \mu y' + \mu' y, you need

\mu(x) P(x) = \mu'(x)

That is a differential equation for \mu. And it is a really simple one — it is separable:

\frac{d\mu}{\mu} = P(x)\,dx
\ln|\mu| = \int P(x)\,dx
\mu(x) = e^{\int P(x)\,dx}

This \mu(x) is called the integrating factor. It is the magic function that, when you multiply the original equation by it, turns the left side into a single derivative.

The full method in four steps

Integrating Factor Method

To solve \dfrac{dy}{dx} + P(x)\,y = Q(x):

Step 1. Compute the integrating factor \mu(x) = e^{\int P(x)\,dx}.

Step 2. Multiply both sides of the equation by \mu(x). The left side becomes \dfrac{d}{dx}\bigl(\mu(x)\,y\bigr).

Step 3. Integrate both sides with respect to x:

\mu(x)\,y = \int \mu(x)\,Q(x)\,dx + C

Step 4. Divide by \mu(x):

y = \frac{1}{\mu(x)}\left[\int \mu(x)\,Q(x)\,dx + C\right]

That is the general solution.

Why this always works. The integrating factor \mu(x) = e^{\int P\,dx} was constructed precisely so that \mu' = \mu P. When you multiply the equation by \mu, the left side

\mu y' + \mu P y

is exactly \mu y' + \mu' y, which is (\mu y)' by the product rule. So the equation collapses into

\frac{d}{dx}(\mu y) = \mu Q

and you can integrate directly. No separation, no cleverness beyond the one-time construction of \mu.

The method at work

Back to the cup of tea with k = 0.1 (so the equation is T' + 0.1 T = 2 + 0.2 t):

Step 1. Compute \mu(t). Here P(t) = 0.1 (a constant), so \int P\,dt = 0.1 t and \mu(t) = e^{0.1 t}.

Step 2. Multiply:

e^{0.1t}\,T' + 0.1\,e^{0.1 t}\,T = (2 + 0.2t)e^{0.1 t}

The left side is \frac{d}{dt}(e^{0.1 t}\,T).

Step 3. Integrate:

e^{0.1 t}\,T = \int (2 + 0.2 t)e^{0.1 t}\,dt + C

The right-hand integral: by parts or direct antidifferentiation,

\int 2\,e^{0.1 t}\,dt = 20\,e^{0.1 t}
\int 0.2 t\,e^{0.1 t}\,dt = 2t e^{0.1 t} - 20 e^{0.1 t}

(the second uses integration by parts: u = 0.2 t, dv = e^{0.1 t}\,dt). Adding:

\int(2 + 0.2 t)e^{0.1 t}\,dt = 2t\,e^{0.1 t} + C

So e^{0.1 t}\,T = 2t\,e^{0.1 t} + C.

Step 4. Divide by e^{0.1 t}:

T(t) = 2t + C\,e^{-0.1 t}

At t = 0 the tea is 90°C, so 90 = 0 + C, giving C = 90. The solution:

T(t) = 2t + 90\,e^{-0.1 t}

As t \to \infty, the exponential decays and T(t) tracks 2t — the tea's temperature eventually matches the linearly-rising room. The starting 90° slowly bleeds away; after that, the tea follows the room.

The tea temperature $T(t) = 2t + 90e^{-0.1t}$ (solid) and the rising room temperature $T_{\text{room}} = 20 + 2t$ (dashed red). The tea starts at $90°\mathrm C$, cools rapidly, and eventually tracks just above the rising room line because of the $2t$ term from the particular solution.

This is the kind of problem you cannot solve by separation. The integrating factor method handles it in one pass.

Worked examples

Example 1: Solve dy/dx + 2y = e^x

Step 1. Identify P and Q.

The equation is already in standard form: P(x) = 2, Q(x) = e^x.

Why: the left side is y' + 2y, matching \frac{dy}{dx} + P(x)y with P(x) = 2 (a constant). The right side is e^x, so Q(x) = e^x. The equation is linear.

Step 2. Compute the integrating factor.

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

Why: \int 2\,dx = 2x + C, and any constant in the exponent just multiplies \mu by a harmless constant factor, so drop it. The integrating factor is e^{2x}.

Step 3. Multiply both sides by \mu.

e^{2x}\frac{dy}{dx} + 2e^{2x}y = e^{2x}\cdot e^x = e^{3x}

The left side collapses to a derivative:

\frac{d}{dx}\bigl(e^{2x}\,y\bigr) = e^{3x}

Why: by construction, multiplying by \mu makes the left side equal to (\mu y)'. You should always verify this mentally or on paper: (e^{2x}y)' = 2e^{2x}y + e^{2x}y', which matches what is on the left.

Step 4. Integrate both sides with respect to x.

e^{2x}\,y = \int e^{3x}\,dx = \frac{e^{3x}}{3} + C

Why: the integral of e^{3x} is \frac{e^{3x}}{3}. The constant of integration C records all the possible particular solutions.

Step 5. Solve for y.

y = e^{-2x}\left(\frac{e^{3x}}{3} + C\right) = \frac{e^x}{3} + C e^{-2x}

Why: dividing by e^{2x} is the same as multiplying by e^{-2x}. The e^{3x} and e^{-2x} combine to give e^x.

Result: y = \dfrac{e^x}{3} + C\,e^{-2x} where C is arbitrary.

The solution family $y = \frac{e^x}{3} + Ce^{-2x}$. The red curve is the particular solution $y_p = \frac{e^x}{3}$ (the "forced" response). Each other curve differs from it by $Ce^{-2x}$, a decaying exponential — the "transient" response that dies away as $x$ grows. All curves converge toward $\frac{e^x}{3}$.

The structure of the answer — particular solution plus decaying transient — is typical of linear ODEs. You will see this pattern everywhere in physics and engineering: the long-term behaviour is the particular solution, and the initial conditions only affect the transient.

Example 2: Solve x·dy/dx − 3y = x³, with y(1) = 0

Step 1. Put the equation in standard form.

Divide both sides by x (assuming x \neq 0):

\frac{dy}{dx} - \frac{3}{x}\,y = x^2

Now P(x) = -3/x and Q(x) = x^2.

Why: the standard form requires a coefficient of 1 in front of dy/dx. Dividing through by x achieves this and reveals the true P and Q.

Step 2. Compute the integrating factor.

\int P\,dx = \int -\frac{3}{x}\,dx = -3\ln|x| = \ln|x|^{-3} = \ln x^{-3}
\mu(x) = e^{\ln x^{-3}} = x^{-3}

Why: using the log identity a\ln b = \ln b^a lets you collapse the logarithm inside the exponential. e^{\ln u} = u, so the integrating factor is x^{-3}. This is much cleaner than leaving it as e^{-3\ln|x|}.

Step 3. Multiply through by \mu.

x^{-3}\frac{dy}{dx} - 3 x^{-4} y = x^{-3} \cdot x^2 = x^{-1}

The left side equals \frac{d}{dx}(x^{-3}y):

\frac{d}{dx}(x^{-3}\,y) = \frac{1}{x}

Why: by the product rule, (x^{-3}y)' = -3x^{-4}y + x^{-3}y', which matches the left side of the equation after multiplication. The integrating factor has done its job.

Step 4. Integrate both sides.

x^{-3}\,y = \int\frac{1}{x}\,dx = \ln|x| + C

Why: the integral of 1/x is \ln|x|. The constant of integration appears on the right.

Step 5. Solve for y and apply the initial condition.

y = x^3\bigl(\ln|x| + C\bigr)

At x = 1: y = 1 \cdot (\ln 1 + C) = C. The initial condition y(1) = 0 gives C = 0.

Particular solution: y = x^3 \ln|x|.

Why: the initial condition pins down one specific member of the solution family. Substituting the condition into the general solution and solving for C is the standard last step of every IVP.

Result: y = x^3 \ln|x|.

The solution family $y = x^3(\ln|x| + C)$. The solid curve is the particular solution $y = x^3 \ln|x|$ passing through $(1, 0)$. Every other curve in the family is this curve plus a multiple of $x^3$. All members have the same long-term shape, differing only by a polynomial correction.

Common confusions

Going deeper

If you can execute the integrating factor method on any linear ODE you meet, you have the essentials. The rest of this section connects the technique to the wider theory of linear operators and explains why the method is not really a trick at all.

The linear operator view

Define L to be the operator "take the derivative and then add P(x) times the original": L[y] = y' + Py. Then the equation is simply L[y] = Q.

The key property of L: it is linear. That means for any two functions y_1 and y_2 and any constants a and b,

L[a y_1 + b y_2] = a L[y_1] + b L[y_2]

This is exactly the property that makes superposition work. If y_p is any particular solution to L[y] = Q, and y_h is any solution to the homogeneous equation L[y] = 0, then

L[y_p + y_h] = L[y_p] + L[y_h] = Q + 0 = Q

So y_p + y_h is also a solution. And every solution is of this form. The general solution to L[y] = Q is

y = y_p + y_h

For first-order linear equations, y_h is the solution to y' + Py = 0 — which is separable. Its general solution is y_h = Ce^{-\int P\,dx}. And a particular solution y_p can be found by the variation-of-parameters formula (which the integrating factor method is essentially a shortcut for). This structure — general = particular + homogeneous — generalises to higher-order linear equations and systems.

Where the exponential comes from

Why an exponential integrating factor? Because the homogeneous equation y' + Py = 0 is solved by y = e^{-\int P\,dx}, and multiplying through by the reciprocal of this is what turns the left side of the original equation into a perfect derivative.

Another way to see it: the integrating factor \mu is a change of variable. Setting u = \mu y, the equation becomes u' = \mu Q, which is a trivial integration. The integrating factor is the change of variable that trivialises the equation.

Integrating factor for equations in differential form

Linear equations are sometimes written as M(x, y)\,dx + N(x, y)\,dy = 0. In this form, linearity means M and N have specific shapes: M = P(x)y - Q(x) and N = 1, so the equation is

(Py - Q)\,dx + dy = 0

The integrating factor method can be rephrased: multiply by \mu(x) = e^{\int P\,dx}, and the equation becomes exact (the subject of a later article). So the integrating factor method for linear equations is a special case of the integrating factor method for exact equations — which you will meet soon. All roads lead to exact equations eventually.

Existence and uniqueness

A foundational theorem for ODEs guarantees that the initial value problem y' + Py = Q, y(x_0) = y_0 has a unique solution on any interval where P and Q are continuous. This is the Picard-Lindelöf theorem applied to the linear case. The integrating factor method not only finds the solution — it finds the unique solution, and proves it exists by explicit construction.

The full Picard theorem applies to nonlinear first-order equations too, but existence is only guaranteed locally (in a small interval around x_0) and the proof uses an iterative method that rarely produces a closed-form answer. Linear equations are the best-behaved family of ODEs, and the integrating factor method exploits their structure completely.

Where this leads next

You now have a complete method for first-order linear ODEs. The next few articles extend this power in two directions: to equations that look nonlinear but can be reduced to linear form, and to equations that are not linear at all but still admit closed-form solutions.