the exactness test
Before you go hunting for a hidden potential function F, you would like to know in advance whether one even exists — otherwise you might search for something that is not there. The exactness test is a single, quick calculation that answers this: it tells you whether M dx + N dy = 0 is exact without ever finding F.
The test is: compute partial M / partial y (differentiate M with respect to y) and partial N / partial x (differentiate N with respect to x). The equation is exact exactly when these two are equal: partial M / partial y = partial N / partial x. The reason is the equality of mixed partial derivatives — if F exists with partial F / partial x = M and partial F / partial y = N, then partial M / partial y = partial-squared F / partial y partial x and partial N / partial x = partial-squared F / partial x partial y, and for a nice F these two mixed partials agree. So the test is just the consistency condition that a potential can exist.
This is your first move on any equation in the form M dx + N dy = 0: run the test. If the two partials match, proceed to reconstruct F. If they do not match, the equation is not exact as written, and you reach for an integrating factor — often the difference of the two partials tells you exactly which integrating factor to try.
Test (2xy) dx + (x^2 + 1) dy = 0: partial M / partial y = partial(2xy)/partial y = 2x, and partial N / partial x = partial(x^2 + 1)/partial x = 2x. They match, so the equation is exact. By contrast (2xy) dx + (x^2 + y) dy still gives 2x = 2x and is exact, while y dx + 2x dy has partial M/partial y = 1 but partial N/partial x = 2 — not exact.
One cheap comparison of two partial derivatives decides exactness before any integration.
The test assumes M and N are smooth on a region with no holes (a simply connected domain). On a domain with a hole, partial M / partial y = partial N / partial x can hold yet no single potential exist globally — a subtlety that matters in vector calculus.