Linear First Order ODE/y' + (y over x) = k x^n

Theorem
Let $k, n \in \R$ be real numbers.

The linear first order ODE:
 * $(1): \quad \dfrac {\mathrm d y} {\mathrm d x} + \dfrac y x = k x^n$

has the solution:
 * $y = \begin{cases}

\dfrac {k x^{n + 1} } {n + 2} + \dfrac C x & : n \ne -2 \\ & \\ \dfrac {k \ln x} x + \dfrac C x & : n = -2 \end{cases}$

Proof
$(1)$ is in the form:
 * $\dfrac {\mathrm d y}{\mathrm d x} + P \left({x}\right) y = Q \left({x}\right)$

where:
 * $P \left({x}\right) = \dfrac 1 x$
 * $Q \left({x}\right) = k x^n$

Thus:

Thus from Solution by Integrating Factor, $(1)$ can be rewritten as:
 * $\dfrac {\mathrm d} {\mathrm d x} \left({x y}\right) = k x^{n + 1}$

When $n + 1 \ne -1$, Primitive of Power is used to obtain:
 * $x y = \dfrac {k x^{n + 2} } {n + 2} + C$

or:
 * $y = \dfrac {k x^{n + 1} } {n + 2} + \dfrac C x$

When $n + 1 = -1$, we have:
 * $\dfrac {\mathrm d} {\mathrm d x} \left({x y}\right) = \dfrac k x$

and Primitive of Reciprocal is used, yielding:
 * $x y = k \ln x + C$

or:
 * $y = \dfrac {k \ln x} x + \dfrac C x$