Integrating Factor Calculator - Solve Linear ODEs Fast

Try a classic equation

Examples: 3 · 2/x · 2x · sin(x) · tan(x)

Examples: 0 · 5 · x^3 · e^(2x) · x*cos(x)

Standard form

y′ + (2/x)y = x³

Integrating factor μ(x)

General solution

y = x⁴/6 + C/x²

Particular solution — C = 5/6

y = x⁴/6 + 5/(6x²)

∫ μQ dx

x⁶/6

y(2)

2.8750

y′(2)

5.1250

The antiderivative of μ(x)Q(x) was found in closed form, so every line above is exact.

Worked solution, line by line

  1. 1

    Standard form

    y′ + (2/x)y = x³

  2. 2

    Integrate P(x) — no constant needed, it cancels

    ∫ P dx = 2 ln|x|

  3. 3

    Build the integrating factor

    μ(x) = e^(∫ P dx) = x²

  4. 4

    Multiply through — the left side becomes a single derivative

    [x²·y]′ = x⁵

  5. 5

    Integrate both sides

    x²·y = x⁶/6 + C

  6. 6

    Apply y(1) = 1 to pin C

    C = μ(1)·1 − [∫μQ]ₓ₌1 = 5/6

  7. 7

    Divide by μ(x)

    y = x⁴/6 + 5/(6x²)

Solution curve through (1, 1)

0.501.953.414.860.751.131.501.882.25

Horizontal axis: x. Vertical axis: y. The dot marks the initial condition.

Solution values

xy(x)y′(x)
11.0000-1.0000
1.166670.92100.0091
1.333330.99550.8771
1.51.21411.7562
1.666671.58602.7264
1.833332.13083.8376
22.87505.1250

Independent check

The same initial-value problem was re-solved with fourth-order Runge–Kutta, which never touches the integrating factor at all.

Formula

2.8750

RK4

2.8750

Relative difference 4.3e-13 — the closed form checks out.

How to Use This Calculator

  1. Check whether your equation already reads y′ + P(x)y = Q(x). If something multiplies y′, switch the dropdown to a(x)y′ + b(x)y = c(x) and let the calculator divide for you.
  2. Type P(x) into the coefficient-of-y field and Q(x) into the right-hand-side field. Use^ for powers,e^(2x) for exponentials, andsin(x)-style names for trig.
  3. Enter x₀ and y₀ for your initial condition. If you only want the general solution, ignore the C value and read the line that still contains C.
  4. Set the evaluation point to the x you actually care about — the table, the graph and the Runge–Kutta check all key off it.
  5. Read the seven numbered steps to see exactly where μ(x) came from, then compare the formula value against the RK4 value. Agreement to five or more digits means the antiderivatives are right.

Share this calculator

Help others solve their calculations

Found this calculator helpful? Share it with your friends, students, or colleagues who might need it!

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

About the Author

Marko Šinko - Co-Founder & Lead Developer

Marko Šinko

Co-Founder & Lead Developer, AI Math Calculator

Lepoglava, Croatia
Advanced Algorithm Expert

Croatian developer with a Computer Science degree from University of Zagreb and expertise in advanced algorithms. Co-founder of award-winning projects, ensuring precise mathematical computations and reliable calculator tools.

📅 Published:
Integrating factor calculator showing μ(x) multiplied through a linear first-order ODE so the left side becomes one derivative

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:

y′ + P(x) y = Q(x)

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 givenDivide byP(x)Q(x)
xy′ + 3y = x²x3/xx
2y′ − 6y = 82−34
(x²+1)y′ + 2xy = 1x²+12x/(x²+1)1/(x²+1)
y′ = 5 − 2y1 (rearrange)25

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
kkxe^(kx)RC circuits, cooling, mixing
k/xk ln|x|x^kanything after dividing by x
kxkx²/2e^(kx²/2)Gaussian-type models
tan x−ln|cos x|sec xtrig-coefficient exercises
cot xln|sin x|sin xtrig-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…UseWhy
splits as dy/dx = g(x)h(y)Separation of variablesNo μ to build; two direct integrals
is linear in y but Q(x) ≠ 0Integrating factorThe only elementary method that handles forcing
is both linear and separable (Q = 0)Either — separation is quickery = Ce^(−∫P dx) either way
has y², √y, sin y anywhereNot this methodμ only works when y appears linearly
reads y′ + P y = Q yⁿBernoulli substitution firstv = 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:

y(x) = e^(−x²) [ y₀e^(x₀²) + ∫x₀x e^(t²) dt ]

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.

Frequently Asked Questions

Still Have Questions?

The detailed content on this page provides comprehensive explanations and examples to help you understand better.