Derivation (reduction of order by substitution)

We let $$ y_2(x) = \nu(x) y_1(x). $$ Computing the derivatives, $$\begin{align*} y_2' &= \nu y_1' + \nu'y_1 \\ y_2'' &= \nu y_1'' + 2\nu'y_1' + \nu''y_1 \end{align*}$$ then substituting into the ODE, $$\begin{align*} (\nu y_1'' + 2\nu'y_1' + \nu ''y_1) + (p\nu y_1' + p\nu' y_1) + q\nu y_1 &= 0 \\ \nu''y_1 + \nu'(2y_1' + py_1) + \nu\underbrace{(y_1'' + py_1' + qy_1)}_{0 \text{ since } y_1 \text{ is a solution}} &= 0 \end{align*}$$ Letting $u = v'$ makes this a first-order ODE of $u$, $$\begin{align*} u' y_1 + u(2y_1' + py_1) & = 0\\ \frac{u'}{u} &= -\Big(2\frac{y_1'}{y_1} + p\Big) \\ \ln u &= -\Big(2\ln y_1 + \int^x p(w)\,dw\Big) \\ v' = u &= \frac{1}{y_1^2 }\exp\Big(-\int^x p(w)\,dw\Big). \end{align*}$$ Then integrate to get $v$ and then get $y_2$.