Solution (source code)

= Solution

For the first-order <linear ordinary differential equation>, seek an <integrating factor> $M(x)$ that makes its left side a <product rule> <derivative>. Multiplying by $M$ gives $My'+MPy$, and comparison with $(My)'=My'+M'y$ requires $M'=PM$. On an interval where $P$ is continuous choose
$$
M(x)=\exp\!\left(\int_{x_0}^xP(t)\,dt\right),\qquad M(x_0)=1.
$$
This factor is never zero. The transformed equation is $(My)'=MQ$, so integration from $x_0$ to $x$ yields
$$
\boxed{y(x)=\frac{1}{M(x)}\left[C+\int_{x_0}^x M(t)Q(t)\,dt\right].}
$$
Here $C=y(x_0)$ for an <initial value problem>. The <indefinite integral> version is $y=e^{-\int Pdx}[C+\int Qe^{\int Pdx}dx]$, with any constant choices inside the <integrating factor> absorbed into $C$. Continuity of $P,Q$ is a convenient sufficient hypothesis for a classical differentiable <solution of a differential equation>.