Solve the differential equation $\;$ $\dfrac{dy}{dx} + \dfrac{2y}{x} = e^x$
The given differential equation is $\;$ $\dfrac{dy}{dx} + \dfrac{2y}{x} = e^x$ $\;\;\; \cdots \; (1)$
Equation $(1)$ is a linear differential equation in the form $\;$ $\dfrac{dy}{dx} + P \left(x\right)y = Q \left(x\right)$
Here $P \left(x\right) = \dfrac{2}{x}$ $\;\;\; \cdots \; (2a)$; $\;\;$ $Q \left(x\right) = e^{x}$ $\;\;\; \cdots \; (2b)$
Integrating Factor (I.F) $= e^{\int P \left(x\right) \; dx}$
$\begin{aligned}
\text{i.e. I.F} = e^{\int \frac{2}{x} \; dx} & = e^{2 \log \left|x\right|} \\\\
& = e^{\log \left|x^2\right|} \\\\
& = x^2 \;\;\; \cdots \; (3)
\end{aligned}$
According to the general solution,
$y \; e^{\int P \left(x\right) \; dx} = \displaystyle \int Q \left(x\right) \; e^{\int P \left(x\right) \; dx} \; dx$
$\therefore$ $\;$ In view of equations $(2a)$, $(2b)$ and $(3)$, the general solution of equation $(1)$ is
$y \; x^2 = \displaystyle \int e^x \; x^2 \; dx$ $\;\;\; \cdots \; (4)$
$\begin{aligned}
\text{Now, } \int x^2 \; e^x \; dx & = x^2 \int e^x \; dx - \int \left\{\int e^x \; dx \times \dfrac{d}{dx} \left(x^2\right) \right\} \; dx \\\\
& = x^2 \; e^x - \int 2 \; x \; e^x \; dx \\\\
& = x^2 \; e^x - 2 \left[x \int e^x \; dx - \int \left\{\int e^x \; dx \times \dfrac{d}{dx} \left(x\right) \right\} \; dx\right] \\\\
& = x^2 \; e^x - 2 \left[x \; e^x - \int e^x \; dx\right] \\\\
& = x^2 \; e^x - 2 \; x \; e^x + 2 \; e^x + c \;\;\; \cdots \; (5)
\end{aligned}$
$\therefore$ $\;$ In view of equation $(5)$, equation $(4)$ becomes
$y \; x^2 = x^2 \; e^x - 2 \; x \; e^x + 2 \; e^x + c$
i.e. $y \; x^2 = e^x \left(x^2 - 2 \; x + 2\right) + c$ $\;\;\; \cdots \; (6)$
Equation $(6)$ is the general solution of the given differential equation.