Solution (source code)

= Solution

Write the <differential one-form> as $M\,dx+N\,dy$. An <exact differential form> must satisfy equality of mixed <partial derivatives>, $M_y=N_x$. Here
$$
M_y=x-2y,\qquad N_x=x-ay.
$$
Equality at every $(x,y)$ holds precisely when $\boxed{a=2}$. Since these <polynomials> are smooth on the simply connected <plane>, the closed-form condition is also sufficient for exactness; the explicit <potential of a conservative vector field> constructed in (c) verifies that sufficiency directly.