2.11   ODE No. 11

\[ f(x) y(x)-g(x)+y'(x)=0 \]

Mathematica : cpu = 0.0275519 (sec), leaf count = 66

DSolve[-g[x] + f[x]*y[x] + Derivative[1][y][x] == 0,y[x],x]
 
\[\left \{\left \{y(x)\to \exp \left (\int _1^x-f(K[1])dK[1]\right ) \int _1^x\exp \left (-\int _1^{K[2]}-f(K[1])dK[1]\right ) g(K[2])dK[2]+c_1 \exp \left (\int _1^x-f(K[1])dK[1]\right )\right \}\right \}\]

Maple : cpu = 0.022 (sec), leaf count = 24

dsolve(diff(y(x),x)+f(x)*y(x)-g(x) = 0,y(x))
 
\[y \left (x \right ) = \left (\int g \left (x \right ) {\mathrm e}^{\int f \left (x \right )d x}d x +c_{1} \right ) {\mathrm e}^{\int -f \left (x \right )d x}\]

Hand solution

\begin{equation} \frac {dy}{dx}+y\left ( x\right ) f\left ( x\right ) =g\left ( x\right ) \tag {1}\end{equation}

Integrating factor \(\mu =e^{\int f\left ( x\right ) dx}\).   Therefore (1) becomes

\[ \frac {d}{dx}\left ( e^{\int f\left ( x\right ) dx}y\left ( x\right ) \right ) =e^{\int f\left ( x\right ) dx}g\left ( x\right ) \]

Integrating

\begin{align*} e^{\int f\left ( x\right ) dx}y\left ( x\right ) & =\int e^{\int f\left ( x\right ) dx}g\left ( x\right ) dx+C\\ y\left ( x\right ) & =e^{-\int f\left ( x\right ) dx}\int e^{\int f\left ( x\right ) dx}g\left ( x\right ) dx+e^{-\int f\left ( x\right ) dx}C\\ & =\left ( \int e^{\int f\left ( x\right ) dx}g\left ( x\right ) dx+C\right ) e^{-\int f\left ( x\right ) dx}\end{align*}