Reduction of Order via Substitution 
Suppose $u_1=\sin{x^2}$ is a solution of 
  $$xu''-u'+4x^3u=0\Rightarrow u''-x^{-1}u'+4x^2u=0 \ \ \  \ \ \ \ \ \ \ \ \ \ (1)$$
  I am trying to find a second, linearly independent, solution (say $u_2$) to the above equation using reduction of order.

Now, using the formula 
$$u_2=u_1\int\frac{dx}{u^2_1\text{exp}\left(\int p(x)\ dx\right)} \ \ \ \ ,\ p(x)=-x^{-1}$$
I have found that $$u_2=\frac{\sin{x^2}}{2}\int \text{cosec}^2x \ dx=-\frac{\cos{x^2}}{2}$$
Now I tried to replicate this using the substitution $u_2=u_1v(x)$.
After finding the first and second derivatives of this equation and substituting into $(1)$, I get
$$v''\sin{x^2}+v'\left(4x\cos{x^2}-x^{-1}\sin{x^2}\right)=0$$
Letting $w=v'$,
$$\frac{dw}{dx}\sin{x^2}+w\left(4x\cos{x^2}-x^{-1}\sin{x^2}\right)=0$$
I tried to simplify this using the integrating factor
$$\text{exp}\left(\int 4x\cos{x^2}-x^{-1}\sin{x^2} \ dx\right)$$ but could not compute it.
How can I solve this problem using my suggested substitution?
 A: The ODE for $w$ is actually separable: 
\begin{align*}
\sin(x^2)\frac{dw}{dx} + \left(4x\cos(x^2) - \frac{\sin(x^2)}{x}\right)w & = 0 \\
\int \frac{1}{w}\, dw & = \int \frac{1}{\sin(x^2)}\left(\frac{\sin(x^2)}{x} - 4x\cos(x^2)\right)\, dx \\
\int\frac{1}{w}\, dw & = \int\frac{1}{x} - 4x\cot(x^2)\, dx \\
\end{align*}
Making a change of variable $s = x^2$ on the second integrand, we obtain
\begin{align*}
\int\frac{1}{w}\, dw & = \int \frac{1}{x}\, dx - 2\int\cot(s)\, ds \\
\ln|w| & = \ln|x| - 2\ln|\sin(x^2)| + C
\end{align*}
You may then exponentiate each side and get 
$$ |w| = e^C\frac{|x|}{\sin^2(x^2)} = \frac{A|x|}{\sin^2(x^2)}. $$
A: Here is a solution without the reduction method.  Define the operators $D$ and $X$ by $(D\,h)(x):=h'(x)$ and $(X\,h)(x):=x\,h(x)$.  For any function $\phi$, we also define the operator $\phi(X)$ to be $\big(\phi(X)\,h\big)(x):=\phi(x)\,h(x)$.   Observe that
$$D^2-\frac1X\,D+4X^2=\left(D+2\text{i}\,X-\frac{1}{X}\right)\,(D-2\text{i}\,X)\,,$$
where $\text{i}:=\sqrt{-1}$.  
If $u$ is a solution to $\displaystyle \left(D^2-\frac1X\,D+4X^2\right)\,u=0$, we set $v:=(D-2\text{i}\,X)\,u$, so that
$$\left(D+2\text{i}\,X-\frac{1}{X}\right)\,v=0\,,\text{ or }D\,\left(\frac{\exp(\text{i}\,X^2)}{X}\,v\right)=0\,.$$
Thus, $v(x)=-4\text{i}\,a\,x\,\exp\left(-\text{i}x^2\right)$ for some constant $a$.  Now, $(D-2\text{i}\,X)\,u=v$ gives
$$D\,\big(\exp(-\text{i}\,X^2)\,u\big)=\exp(-\text{i}\,X^2)\,v\,,\text{ whence }u(x)=\exp(+\text{i}\,x^2)\,\int\,\exp(-\text{i}\,x^2)\,v(x)\,\text{d}x\,.$$
Consequently, for some constant $b$, we get
$$u(x)=\exp(+\text{i}\,x^2)\,\int\,(-4\text{i}\,a\,x)\,\exp\left(-2\text{i}\,x^2\right)\,\text{d}x=\exp(+\text{i}\,x^2)\,\big(a\,\exp(-2\text{i}\,x^2)+b\big)\,.$$
That is,
$$u(x)=a\,\exp(-\text{i}\,x^2)+b\,\exp(+\text{i}\,x^2)=(a+b)\,\cos(x^2)-\text{i}\,(a-b)\,\sin(x^2)\,.$$
