A first-order differential equation is linear if it can be written as
dxdy+Py=Q,
where P and Q are functions of x only (or constants) — crucially, there is no product of y with dxdy, and y and its derivative occur only to the first power. (The mirror form dydx+Px=Q, with P,Q functions of y only, is used when the equation is more naturally linear in x.)
Derivation of the integrating factor. Consider first the associated homogeneous equation dxdy+Py=0. Separating variables and integrating gives ye∫Pdx=C. Differentiating ye∫Pdx using the product rule shows
dxd(ye∫Pdx)=e∫Pdx(dxdy+Py)=Qe∫Pdx
whenever y satisfies the original (non-homogeneous) equation — the left side collapses to an exact derivative. The quantity
I.F.=e∫Pdx
is called the integrating factor.
Solution formula. Multiplying the linear equation through by the integrating factor and integrating both sides with respect to x gives the closed-form general solution
y⋅I.F.=∫Q⋅I.F.dx+C,i.e.ye∫Pdx=∫Qe∫Pdxdx+C.
For the x-dependent-variable mirror form, the analogous solution is xe∫Pdy=∫Qe∫Pdydy+C.
Working steps. …