Differential Equations: Step-by-Step Worked Examples (4)

easy 2 min read

Question

Solve the differential equation:

dydx+2y=ex\frac{dy}{dx} + 2y = e^{-x}

with initial condition y(0)=1y(0) = 1.

Solution — Step by Step

This is a linear first-order ODE: dydx+P(x)y=Q(x)\frac{dy}{dx} + P(x) y = Q(x) with P=2P = 2, Q=exQ = e^{-x}.

μ(x)=ePdx=e2dx=e2x\mu(x) = e^{\int P \, dx} = e^{\int 2 \, dx} = e^{2x} e2xdydx+2e2xy=e2xex=exe^{2x} \frac{dy}{dx} + 2 e^{2x} y = e^{2x} \cdot e^{-x} = e^{x}

Left side is ddx(e2xy)\frac{d}{dx}(e^{2x} y).

e2xy=exdx=ex+Ce^{2x} y = \int e^x \, dx = e^x + C

So y=ex+Ce2xy = e^{-x} + C e^{-2x}.

y(0)=1+C=1C=0y(0) = 1 + C = 1 \Rightarrow C = 0.

Final answer: y=exy = e^{-x}.

Why This Works

The integrating factor turns a linear ODE into something we can write as a single derivative — that’s the only trick. Once the LHS is ddx(μy)\frac{d}{dx}(\mu y), integration handles the rest.

The choice μ=ePdx\mu = e^{\int P \, dx} works because dμdx=Pμ\frac{d\mu}{dx} = P \mu, which is exactly what we need to make the product rule fold the LHS into one derivative.

Alternative Method

Recognize this as a non-homogeneous linear ODE. Particular solution: try yp=Aexy_p = A e^{-x}. Substituting: Aex+2Aex=exA=1-A e^{-x} + 2 A e^{-x} = e^{-x} \Rightarrow A = 1. General solution: y=ex+Ce2xy = e^{-x} + C e^{-2x}. Apply initial condition: C=0C = 0, so y=exy = e^{-x}.

For linear ODEs, the integrating factor method always works. Memorise: μ=ePdx\mu = e^{\int P \, dx}, then μy=μQdx+C\mu y = \int \mu Q \, dx + C.

Common Mistake

Forgetting to multiply QQ by μ\mu when integrating. Some students do Qdx\int Q \, dx instead of μQdx\int \mu Q \, dx — gives wrong answers immediately.

Sign errors in the exponent. 2dx=2x\int 2 \, dx = 2x, so μ=e2x\mu = e^{2x}, not e2xe^{-2x}. Always re-check the sign of PP before computing μ\mu.

Want to master this topic?

Read the complete guide with more examples and exam tips.

Go to full topic guide →

Try These Next