# A test for exactness of second order ODEs $N(x,y,y')y''+M(x,y,y')=0$

The ODE \begin{align} N(x,y)p+M(x,y)=0;\quad [p=y'_x] \end{align} can be tested for exactness by checking if $$N_x=M_y$$. This test is found by assuming a first integral of the form $$U(x,y)=C$$ with derivative $$U_yp+U_x=0$$. If $$U$$ is a nice function then $$U_{yx}=U_{xy}$$, and if $$U$$ is indeed a first integral it must be that $$N_x=M_y$$.

Consider now the second order ODE \begin{align} N(x,y,p)p'_x+M(x,y,p)=0. \end{align} To see if this equation is exact we assume a first integral of the form $$U(x,y,p)=C$$ with derivative $$U_{p}p'+U_yp+U_x=0$$. If $$U$$ is indeed a first integral we are left with the conditions \begin{align}\tag{1} U_{p}=N,\quad U_yp+U_x=M. \end{align} If I take two partial derivatives w.r.t $$p$$ to eliminate $$U$$ I find the equation \begin{align}\tag{2}\label{2} pN_{yp}+2N_y+N_{xp}=M_{pp}. \end{align} It seems to me, though, that this equation is necessary but not sufficient for arbitrary $$N$$ and $$M$$. Consider the ODE $$p'_x+f(x,y)p+g(x,y)=0$$, which is obviously exact only if $$f_x=g_y$$ but satisfies equation (2). Is there a correct way to eliminate $$U$$ in equations (1)? Or perhaps equation (2) works if we add some restrictions on $$N$$ and $$M$$? I imagine taking several derivatives of equation (1) is to blame for this.