Integrating Factor Method

April 13, 2026

Problem

Solve dy/dx + (1/x) y = x using the integrating factor mu(x) = x. Animate the multiplication step that collapses the left side into a single derivative.

Explanation

The idea in one sentence

The integrating factor μ(x)\mu(x) is a clever multiplier that turns the left side of a first-order linear ODE dydx+P(x)y=Q(x)\frac{dy}{dx} + P(x) \, y = Q(x) into an exact derivative — a single ddx[μy]\dfrac{d}{dx}[\mu \, y] — so you can integrate once and be done.

This is the same machinery as problem #174, but here we'll derive μ\mu from scratch rather than just applying it.

Why μ(x)=ePdx\mu(x) = e^{\int P\, dx} works

We want μ(x)\mu(x) to make the left side collapse: μy+μPy  =  ddx[μy]  =  μy+μy\mu \, y' + \mu P \, y \;=\; \frac{d}{dx}\bigl[\mu \, y\bigr] \;=\; \mu \, y' + \mu' \, y

Matching the coefficient of yy on both sides forces μ=μPdμμ=Pdxlnμ=Pdx\mu' = \mu \, P \quad\Longrightarrow\quad \frac{d\mu}{\mu} = P \, dx \quad\Longrightarrow\quad \ln \mu = \int P \, dx μ(x)=exp ⁣(P(x)dx)\boxed{\, \mu(x) = \exp\!\left( \int P(x) \, dx \right) \,}

No integration constant is needed — any non-zero μ\mu that satisfies μ=μP\mu' = \mu P does the job, and the simplest choice is the one with constant of integration zero.

The given equation

dydx+1xy=x\frac{dy}{dx} + \frac{1}{x} \, y = x

Here P(x)=1/xP(x) = 1/x and Q(x)=xQ(x) = x.

Step-by-step solution

Step 1 — Compute the integrating factor. μ(x)=e1xdx=elnx=x\mu(x) = e^{\int \frac{1}{x}\, dx} = e^{\ln|x|} = |x|

Working on an interval where x>0x > 0 (e.g. x>0x > 0), take μ(x)=x\mu(x) = x.

Step 2 — Multiply through by μ\mu. xy+x1xy=xxx \cdot y' + x \cdot \frac{1}{x} \, y = x \cdot x xy+y=x2x \, y' + y = x^{2}

Step 3 — Recognize the collapse. The left side is exactly ddx[xy]\dfrac{d}{dx}[x \, y] by the product rule: ddx[xy]=xy+1y=xy+y\frac{d}{dx}[x \, y] = x \, y' + 1 \cdot y = x \, y' + y \quad\checkmark

So the equation becomes ddx[xy]=x2\frac{d}{dx}[x \, y] = x^{2}

This is the whole point of the method — the left side is now a single derivative.

Step 4 — Integrate both sides with respect to xx. xy=x2dx=x33+Cx \, y = \int x^{2} \, dx = \frac{x^{3}}{3} + C

Step 5 — Solve for yy. y(x)=x23+Cx\boxed{\, y(x) = \frac{x^{2}}{3} + \frac{C}{x} \,}

Structure of the solution

Two pieces again, like every first-order linear ODE:

  • Particular piece: yp=x2/3y_p = x^{2}/3. One specific solution of the full equation (no free constant).
  • Homogeneous piece: yh=C/xy_h = C/x. The general solution of y+y/x=0y' + y/x = 0 — these are the solutions you can add without breaking the equality, because the equation is linear.

General solution = particular + homogeneous: y=yp+yhy = y_p + y_h.

Verification

y=x23+Cx    y=2x3Cx2y = \frac{x^{2}}{3} + \frac{C}{x} \;\Longrightarrow\; y' = \frac{2x}{3} - \frac{C}{x^{2}}

Plug into the left side y+y/xy' + y/x: (2x3Cx2)+1x(x23+Cx)=2x3Cx2+x3+Cx2=x\left(\frac{2x}{3} - \frac{C}{x^{2}}\right) + \frac{1}{x}\left(\frac{x^{2}}{3} + \frac{C}{x}\right) = \frac{2x}{3} - \frac{C}{x^{2}} + \frac{x}{3} + \frac{C}{x^{2}} = x \quad\checkmark

Initial value problem

Say y(1)=2y(1) = 2. Plug in: 2=13+C    C=532 = \frac{1}{3} + C \implies C = \frac{5}{3} y(x)=x23+53xy(x) = \frac{x^{2}}{3} + \frac{5}{3 x}

The full recipe (memorize this)

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

  1. μ(x)=exp ⁣(P(x)dx)\mu(x) = \exp\!\left(\displaystyle\int P(x) \, dx\right)
  2. Multiply: ddx[μy]=μ(x)Q(x)\dfrac{d}{dx}[\mu \, y] = \mu(x) \, Q(x)
  3. Integrate: μy=μ(x)Q(x)dx+C\mu \, y = \displaystyle\int \mu(x) \, Q(x) \, dx + C
  4. Divide: y(x)=1μ(x) ⁣[μ(x)Q(x)dx+C]y(x) = \dfrac{1}{\mu(x)}\!\left[\displaystyle\int \mu(x) \, Q(x) \, dx + C\right]

Three common choices of PP:

  • P(x)=kP(x) = k (constant) → μ=ekx\mu = e^{kx}.
  • P(x)=1/xP(x) = 1/xμ=x\mu = x (or μ=1/x\mu = 1/x for P-P).
  • P(x)=tanxP(x) = -\tan xμ=cosx\mu = \cos x (integral of tanx-\tan x is lncosx\ln|\cos x|).

Knowing these by heart will speed you up on exams.

Common mistakes

  • Not putting the equation in standard form first. If it's 3y+6y=12x3 y' + 6 y = 12 x, divide by 33 before reading PP: y+2y=4xy' + 2y = 4x, so P=2P = 2, not 66.
  • Adding a constant when computing μ\mu. You don't need one — any non-zero μ\mu works, and the clean choice has C=0C = 0.
  • Forgetting to divide by μ\mu at the end. Easy to leave the answer as μy=\mu y = \ldots and call it done.
  • Domain slip with μ=x\mu = |x|. Choose a side of 00 and stick with it; solutions rarely cross x=0x = 0 anyway because PP is singular there.

Try it in the visualization

Animate the multiplication y+1xy×x(xy)y' + \dfrac{1}{x} y \xrightarrow{\times\, x} (x y)': watch the left side of the equation physically collapse into a single derivative panel. Sweep the initial condition to see the C/xC/x tail change sign and magnitude.

Interactive Visualization

Parameters

1.50
5.00
10.00
6.00
2.00
Your turn

Got your own math or physics problem?

Turn any problem into an interactive visualization like this one — powered by AI, generated in seconds. Free to try, no credit card required.

Sign Up Free to Try It30 free visualizations every day
Integrating Factor Method | MathSpin