Solution (source code)

= Solution

If the form is $dF$ for a <scalar> <function> with continuous second <partial derivatives>, then $p=F_x$ and $q=F_y$. Equality of the mixed <partial derivatives> therefore requires
$$
\boxed{\frac{\partial p}{\partial y}=\frac{\partial q}{\partial x}.}
$$
This is necessary for an <exact differential>. For continuously <differentiable> <coefficients> on a simply connected open domain it is also sufficient; on a domain with holes, the equality alone need not give a single-valued global potential.