Logo
Differential Equations!

Differential Equations!

Chara Chara
January 8, 2026
3 min read
index

Today’s note (Jan 8): first-order linear ODEs, integrating factors, and integration by parts, with every small step shown.

First-order linear ODE

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

where P(x)P(x) and Q(x)Q(x) are known functions.

To solve it, multiply both sides by a function μ(x)\mu(x) so that the left-hand side becomes the derivative of a product.

Definition (Integrating factor)

For y+P(x)y=Q(x)y' + P(x)\, y = Q(x), choose

μ(x)=eP(x)dx.\mu(x) = e^{\int P(x)\,dx}.

Using the chain rule (ef(x))=ef(x)f(x)(e^{f(x)})' = e^{f(x)} f'(x) and the fact that (P(x)dx)=P(x)\bigl(\int P(x)\,dx\bigr)' = P(x), we get

(μ(x)y(x))=μ(x)P(x)y(x)+μ(x)y(x).(\mu(x)\, y(x))' = \mu(x) P(x) y(x) + \mu(x) y'(x).

Multiplying the original equation by μ(x)\mu(x) makes the left side collapse to a single derivative:

(μ(x)y(x))=μ(x)Q(x).(\mu(x)\, y(x))' = \mu(x)\, Q(x).

Integrating both sides then gives

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

We deliberately pick μ(x)\mu(x) so that

μ(x)y(x)+μ(x)P(x)y(x)=(μ(x)y(x)),\mu(x) y'(x) + \mu(x) P(x) y(x) = (\mu(x) y(x))',

turning the left-hand side into one derivative.

Recall (Integration by parts refresher)

Use this when integrating products (like polynomials times exponentials):

udv=uvvdu.\int u\, dv = u\, v - \int v\, du.

Equivalently, the product rule says f(x)g(x)dx+f(x)g(x)dx=f(x)g(x)+C\int f'(x) g(x)\, dx + \int f(x) g'(x)\, dx = f(x) g(x) + C.


Example 1 — y+2y=xexy' + 2y = x\, e^{-x}

Here P(x)=2P(x) = 2, so μ(x)=e2dx=e2x\displaystyle \mu(x) = e^{\int 2\, dx} = e^{2x}.

Multiplying by e2xe^{2x}:

e2xy+2e2xy=xex.e^{2x} y' + 2 e^{2x} y = x\, e^{x}.

Since (e2xy)=(e2x)y+e2xy=2e2xy+e2xy\bigl(e^{2x} y\bigr)' = (e^{2x})' y + e^{2x} y' = 2 e^{2x} y + e^{2x} y', the left side is

(e2xy)=xex.\bigl(e^{2x} y\bigr)' = x\, e^{x}.

Integrate both sides:

e2xy(x)=xexdx.e^{2x} y(x) = \int x\, e^{x} dx.

Use integration by parts with u=xu = x, dv=exdxdv = e^{x} dx:

xexdx=xexexdx=xexex+C=(x1)ex+C.\int x\, e^{x} dx = x e^{x} - \int e^{x} dx = x e^{x} - e^{x} + C = (x - 1) e^{x} + C.

Therefore

e2xy(x)=(x1)ex+C,e^{2x} y(x) = (x - 1) e^{x} + C,

so

y(x)=(x1)ex+Ce2x.y(x) = (x - 1) e^{-x} + C\, e^{-2x}.

Example 2 — y+1xy=x3(x>0)y' + \dfrac{1}{x} y = x^{3} \quad (x > 0)

Here P(x)=1xP(x) = \dfrac{1}{x}, so μ(x)=e1xdx=x\displaystyle \mu(x) = e^{\int \frac{1}{x} dx} = x.

Multiplying by xx gives

xy+y=x4.x\, y' + y = x^{4}.

Check the product derivative: (xy)=xy+y(x y)' = x y' + y, so

(xy)=x4.(x\, y)' = x^{4}.

Integrate:

xy=x4dx=x55+C,x\, y = \int x^{4} dx = \frac{x^{5}}{5} + C,

so

y(x)=x45+Cx.y(x) = \frac{x^{4}}{5} + \frac{C}{x}.

Example 3 — yy=e2xy' - y = e^{2x} with y(0)=1y(0) = 1

Here P(x)=1P(x) = -1, so μ(x)=e1dx=ex\displaystyle \mu(x) = e^{\int -1\, dx} = e^{-x}.

Multiply by exe^{-x}:

exyexy=ex.e^{-x} y' - e^{-x} y = e^{x}.

Using (exy)=(ex)y+exy=exy+exy(e^{-x} y)' = (e^{-x})' y + e^{-x} y' = -e^{-x} y + e^{-x} y', we get

(exy)=ex.(e^{-x} y)' = e^{x}.

Integrate:

exy(x)=exdx=ex+C.e^{-x} y(x) = \int e^{x} dx = e^{x} + C.

So

y(x)=e2x+Cex.y(x) = e^{2x} + C\, e^{x}.

Apply the initial condition y(0)=1y(0) = 1:

1=e0+Ce0C=0,1 = e^{0} + C\, e^{0} \quad \Rightarrow \quad C = 0,

giving the particular solution

y(x)=e2x.y(x) = e^{2x}.