I've seen a remarkable Ansatz in solving an ODE with non constant coefficients and I am wondering: Why does this Ansatz work so well? Here is the description of the problem, the Ansatz and why I think it is remarkable: Consider the homogeneous linear ODE $$xy''+y'+xy = 0.$$ This equation has a solution space spanned by Bessel functions $Y_0$ (diverging for $x\rightarrow 0$) and $J_0$ (finite for the same limit). One can obtain an integral representation of $J_0$ by using the following Ansatz: $$y(x) = \int_C e^{xz}P(z) \mathrm{d}z,$$ where $C$ is an appropriately chosen contour in the complex plane. Of course, with such an Ansatz one wants to reduce the ODE to an algebraic equation, but normally, one achieves this via a Fourier or a Laplace transform. However, in both those approaches the contour is by definition fixed and I am wondering, where the insight comes from to set hopes in a Fourier style Ansatz with an unfixed contour. Are there other ODEs solveable by cooking up a solution using this Ansatz? What are the typical features of such ODEs?
Let me show how the Ansatz is employed to find $J_0$, because this could help in answering my question. It is employed in two steps: Firstly, using the ODE, one obtains an equation that provides a simple ODE, secondly, this solution's boundary condition fixes the contour. One starts by plugging in the Ansatz to obtain $$\int_C (xz^2 + z + x)e^{xz}P(z) \mathrm{d}z = 0$$ Then one assumes that there is an $S(z)$ such that the integrand equals the total derivative of $e^{xz}S(z)$. This requirement then yields the condition that $e^{xw}S(w)$ vanishes for $w$ in the boundary of the contour and relates $S$ and $P$ as follows: $$(xz^2 + z + x)P = x S + S'$$ This eqn holds for all x and thus we can compare the coefficients in front of $x^{0}$ and $x^{1}$ From those two conditions, we can divide out $P$ (assume $P$ to be non vanishing on the contour) to obtain a good ODE for $S$ reading $$ \frac{S'}{S} = \frac{z}{z^2 + 1},$$ whose solution provides us with $S = \sqrt{z^2 + 1}$ from which we can infer a contour running from $-i$ to $i$, e.g. a straight line (due to the boundary condition on $e^{xw}S(w)$). Massaging $y$ a bit further, one ends up with the desired $J_0$.