I encountered the following ode in the attempt to solve the cauchy problem of Liouville equation. I have tried for a long time to give it a solution but failed.


$(K e^f h + f'h'-2h'')^2=g^2((h')^2-\frac{K}{2}h^2 e^f)$
where $K$ is a given constant, $f,g$ are known smooth functions. The problem is to solve $h$ from this equation.



Solution of a second order nonlinear ode
Solving the linear first-order
$$
h'=h K^{1/2}e^{f/2}/\sqrt 2
\tag{$\ast$}$$
makes the rhs to vanish. We get then
\begin{align}
2h''-f'h'-Ke^f h&=h' K^{1/2}e^{f/2}\sqrt 2+h K^{1/2}e^{f/2}f'(\sqrt 2)^{-1}-f'h K^{1/2}e^{f/2}(\sqrt 2)^{-1}-Ke^f h
\\
&=
h' K^{1/2}e^{f/2}\sqrt 2-Ke^f h=h K^{1/2}e^{f/2}(\sqrt 2)^{-1} K^{1/2}e^{f/2}\sqrt 2-hKe^f=0.
\end{align}
As a result, if $F$ is an antiderivative of $K^{1/2}e^{f/2}/\sqrt 2$, $h=e^F$ solves your equation.


