Integrating Factor Calculator: Solving y′ + P(x)y = Q(x) Step by Step
About the Author

An integrating factor calculator has exactly one job that matters: turn a linear first-order equation into something you can integrate in a single step. The trick is old, reliable, and almost never the part students get wrong. What goes wrong is what happens before μ(x) appears at all — the equation isn’t in the right shape yet, so P(x) is misread, and every line after it inherits the error. So that’s where this starts.
Standard Form First, or Everything After It Is Wrong
The integrating factor method is defined for one shape only:
Coefficient of y′ equals 1. Not 2, not x, not cos x. Textbook problems almost never arrive that way, and reading P(x) straight off an unnormalised equation is the single most common way to lose a whole question. Here’s what the division actually does:
| As given | Divide by | P(x) | Q(x) |
|---|---|---|---|
| xy′ + 3y = x² | x | 3/x | x |
| 2y′ − 6y = 8 | 2 | −3 | 4 |
| (x²+1)y′ + 2xy = 1 | x²+1 | 2x/(x²+1) | 1/(x²+1) |
| y′ = 5 − 2y | 1 (rearrange) | 2 | 5 |
Look at the last row. Nothing needed dividing — the y term just had to move left, and moving it flips its sign. P = 2, not −2. A sign error there sends μ to e^(−2x) instead of e^(2x), and the “solution” you get back solves a completely different equation. The calculator above has a dropdown for the a(x)y′ + b(x)y = c(x) case precisely because this step deserves to be mechanical rather than remembered.
Where μ = e^(∫P dx) Actually Comes From
Most sources hand you the formula. It’s worth deriving instead, because the derivation tells you what the method is doing. Multiply the standard form by some unknown function μ(x):
μy′ + μPy = μQ
we want the left side to be (μy)′ = μy′ + μ′y
so we need μ′ = μP
μ′/μ = P → ln μ = ∫P dx → μ = e^(∫P dx)
That’s the whole idea: μ is chosen so the left-hand side becomes a product-rule derivative running backwards. Once it does, integrating both sides is legal in one move, because you’re integrating a derivative. Notice the last line quietly solved a separable differential equation to find μ — the method is separation of variables used as a subroutine.
One consequence people miss: the constant of integration in ∫P dx doesn’t matter. If you keep it, μ becomes e^(C) · e^(∫P dx), a constant multiple. That constant multiplies both sides of μy′ + μPy = μQ and cancels. So drop it. It is the one constant of integration in this entire topic you are allowed to throw away, and the only one.
Six Integrating Factors Worth Recognising on Sight
Roughly nine out of ten exercises use one of these P(x) shapes. Memorising the middle column saves a minute per problem and, more usefully, tells you instantly whether your answer is plausible.
| P(x) | ∫P dx | μ(x) | Typical source |
|---|---|---|---|
| k | kx | e^(kx) | RC circuits, cooling, mixing |
| k/x | k ln|x| | x^k | anything after dividing by x |
| kx | kx²/2 | e^(kx²/2) | Gaussian-type models |
| tan x | −ln|cos x| | sec x | trig-coefficient exercises |
| cot x | ln|sin x| | sin x | trig-coefficient exercises |
| 2x/(1+x²) | ln(1+x²) | 1 + x² | rational-coefficient exercises |
The second row is the one to burn in. Whenever an exponential integrates into a logarithm, the logarithm exponentiates back into a power, not an exponential: e^(3 ln x) = x³. Students who write μ = e^(3 ln x) and leave it there are technically correct and practically stuck, because x³ Q(x) is usually trivial to integrate while e^(3 ln x) Q(x) looks impossible.
Worked: xy′ + 3y = x² with y(1) = 1
Divide by x first: y′ + (3/x)y = x. So P = 3/x and Q = x, and ∫P dx = 3 ln|x|, giving μ = x³. Multiply through:
x³y′ + 3x²y = x⁴
(x³y)′ = x⁴
x³y = x⁵/5 + C
y = x²/5 + C x⁻³
y(1) = 1 → 1/5 + C = 1 → C = 4/5
y = x²/5 + (4/5)x⁻³
Verify line two before trusting anything else: differentiating x³y by the product rule gives x³y′ + 3x²y, which is exactly the left side. That check takes three seconds and catches essentially every algebra slip, because if μ is wrong the product rule will not reproduce your left-hand side. Then sanity-check the answer at x = 1: 1/5 + 4/5 = 1. Correct. And at large x the C x⁻³ term dies, so the solution approaches x²/5 regardless of the initial condition — a useful shape fact you get for free.
Worked: y′ + y = sin x, and Why the Answer Looks Phase-Shifted
P = 1 so μ = eˣ. Multiplying gives (eˣy)′ = eˣ sin x, and that integral needs integration by parts twice — the classic loop where the original integral reappears and you solve for it algebraically:
∫eˣ sin x dx = ½eˣ(sin x − cos x)
eˣy = ½eˣ(sin x − cos x) + C
y = ½(sin x − cos x) + Ce^(−x)
That first term equals (1/√2) sin(x − π/4). The forcing was a pure sine, the response is a sine of the same frequency shifted back by 45° and shrunk by a factor of √2. This is not a coincidence of this example — it is the entire theory of first-order linear filters, and it is why an RC low-pass circuit lags its input. The Ce^(−x) piece is the transient: it depends on the initial condition and decays to nothing, which is why engineers call the other piece the steady state. If you need that by-parts loop broken down on its own, the integration by parts calculator shows the u dv bookkeeping directly.
Which Method Does Your Equation Actually Need?
Integrating factors are not always the fastest route, and sometimes they don’t apply at all. Test in this order — the first match wins.
| If the equation… | Use | Why |
|---|---|---|
| splits as dy/dx = g(x)h(y) | Separation of variables | No μ to build; two direct integrals |
| is linear in y but Q(x) ≠ 0 | Integrating factor | The only elementary method that handles forcing |
| is both linear and separable (Q = 0) | Either — separation is quicker | y = Ce^(−∫P dx) either way |
| has y², √y, sin y anywhere | Not this method | μ only works when y appears linearly |
| reads y′ + P y = Q yⁿ | Bernoulli substitution first | v = y¹⁻ⁿ makes it linear, then use μ |
| has constant coefficients and order 2+ | Characteristic equation | μ is a first-order tool only |
Row four is worth a moment. Linearity here means linear in y and y′, not in x. P(x) can be as ugly as you like — e^(sin x) ln x is fine — and the method still works. But a single y² kills it. If you’re unsure which family an equation belongs to, the general first order differential equation calculator sorts by type before solving.
Three Places This Method Quietly Breaks
The constant lands outside the bracket. After integrating you have μy = F(x) + C. Dividing gives y = [F(x) + C]/μ(x). Writing y = F(x)/μ(x) + C instead is wrong, and in the worked example above it’s the difference between C x⁻³ and a bare C. Substituting back into the original equation exposes it immediately: the constant-only version leaves an unmatched 3C/x term.
The absolute value gets taken seriously. ∫(3/x) dx = 3 ln|x| strictly, so μ = |x|³. On any interval that doesn’t contain 0 the sign is constant and factors out, so x³ is fine — and since solutions can’t cross x = 0 anyway, you never need the bars. Keeping them just makes the algebra harder for no benefit.
The interval of validity gets ignored. Existence and uniqueness for y′ + Py = Q holds on the largest interval containing x₀ where both P and Q are continuous. For P = 3/x that’s (0, ∞) if x₀ > 0, and (−∞, 0) if x₀ < 0. The formula y = x²/5 + (4/5)x⁻³ happily returns a number at x = −2, but that number is not the solution to your initial value problem, because no solution curve crosses the singularity. The calculator flags this rather than letting the graph sail through the break. The standard treatment of integrating factors states the continuity hypothesis explicitly for exactly this reason.
Where Every Integrating Factor Calculator Has to Switch to Numbers
Take y′ + 2xy = 1. Here μ = e^(x²), perfectly elementary, and the equation becomes (e^(x²)y)′ = e^(x²). Now integrate e^(x²). You can’t — not in terms of powers, exponentials, logs and trig functions. Liouville’s theorem says no such antiderivative exists. This is not a gap in your technique.
The correct answer is written as a definite integral with a dummy variable:
That is a complete, exact solution — it just isn’t a formula you can evaluate by hand. Numerical quadrature takes it from there, which is what the calculator switches to automatically, and it says so instead of pretending. Compare with y′ + 2xy = x, which looks nearly identical but is trivial: Q = x is exactly half of P = 2x, so ∫μQ dx = ½∫μP dx = ½μ, giving y = ½ + Ce^(−x²) with no hard integral at all. One coefficient separates a two-line answer from a special function. When you do need numbers rather than symbols, Euler’s method and Runge–Kutta stepping solve the initial value problem directly, and the integral calculator handles the quadrature side on its own.
A closing habit worth building: after every integrating-factor problem, differentiate your answer and substitute it back. It costs thirty seconds and it is the only check that tests the whole chain — standard form, μ, the antiderivative, and the placement of C — in one shot. The calculator automates the equivalent by re-solving your equation with Runge–Kutta and comparing; five-digit agreement means the symbolic work held up.



