# Finding the integrating factor for an ODE through the PDE characterisitc method

To solve an ordinary differential equation (ODE) with the following form:
$a(x,y)dy+b(x,y)dx=0$,
one may look for the integrating factor u(x,y) such that $dg(x,y)=u(x,y)a(x,y)dy+u(x,y)b(x,y)dx=0$,
where $g(x,y)=c$ implicitly defines the solution for the ODE, and c is an arbitrary constant.

However, it is often not straightforward to find u(x,y) by just observing $a(x,y)$ and $b(x,y)$. I am thinking to use the following partial differential equation (PDE):
$\frac{\partial (ua)}{\partial x}=\frac{\partial (ub)}{\partial y}$
or
$a\,u_x-b\,u_y=(b_y-a_x)u$.
The above PDE is first order linear. One can have
$\frac{dx}{ds}=a(x,y)$,
$\frac{dy}{ds}=-b(x,y)$,
$\frac{du}{ds}=(b_y-a_x)u.$
Since $g(x,y)=c$ is the characteristic curve, $\frac{dg(x,y)}{ds}=0$ and $g(x,y)$ is one first integral. I am guessing another first integral could have the form of $\ln u-\ln h(x,y)$ and the general solution for the PDE can be written as $u=h(x,y)f(g(x,y))$, where f is an arbitrary function. If the initial condition for the PDE is defined along the characteristic curve $g(x,y)=c$ and the PDE has infinite solutions with $u=h(x,y)f(c)$, one can then use $h(x,y)$ as an integrating factor to solve the ODE.

I have tried a few specific examples where $g(x,y)$ has closed form and my guess seems correct. I am wondering whether anyone could prove my guess or give me a counter example. In the case $g(x,y)$ or $h(x,y)$ does not have closed form. Are there any numerical methods to find them? Any advice and references would be highly appreciated.