Question
Solve the linear differential equation dxdy+2y=e−x, with y(0)=1.
Solution — Step by Step
This is a linear first-order ODE of the form dxdy+P(x)y=Q(x) with P(x)=2 and Q(x)=e−x.
IF=e∫Pdx=e∫2dx=e2x
e2xdxdy+2e2xy=e2x⋅e−x=ex
The LHS is exactly dxd(y⋅e2x). So:
dxd(ye2x)=ex
ye2x=∫exdx=ex+C
y=e−x+Ce−2x
Apply y(0)=1: 1=1+C⟹C=0.
Final answer: y=e−x.
Why This Works
The integrating factor turns the LHS into a perfect derivative of a product. After multiplying by e∫Pdx, the equation becomes (y⋅IF)′=Q⋅IF, which is directly integrable.
This trick works for any linear first-order ODE — find P(x), compute the IF, multiply, integrate. No guessing.
For dxdy+P(x)y=Q(x):
IF =e∫P(x)dx
Solution: y⋅IF=∫Q(x)⋅IFdx+C
Alternative Method
Try y=u(x)e−2x as an ansatz (this is the form of the general solution of the homogeneous part).
Compute y′=u′e−2x−2ue−2x. Substitute:
u′e−2x−2ue−2x+2ue−2x=e−x
u′e−2x=e−x⟹u′=ex⟹u=ex+C
So y=(ex+C)e−2x=e−x+Ce−2x. Same.
When Q(x) has a simple form (like eax, sin(ax), polynomial), method of undetermined coefficients can be even faster than integrating factors. Practice both and pick the quickest.
Common Mistake
Students forget to multiply both sides by the integrating factor before recognising the LHS as a perfect derivative. They write dxd(y⋅e2x) on the LHS but leave Q(x)=e−x alone on the RHS. Wrong — the IF must multiply both sides.
Another classic: integrating e2x as e2x/2 versus ∫2dx=2x versus ∫2dx becoming the IF exponent. Keep them straight: the IF is e∫Pdx, not ∫Pdx itself.