Solution (source code)

= Solution

For an <exact differential> $Mdx+Ndy$, equality of the <mixed partial derivatives> requires $M_y=N_x$. Here these are $\sin x+b\cos y$ and $\sin x+3\cos y$, so $\boxed{b=3}$. Integrating $M$ with respect to $x$ gives $f=-y\cos x+3x\sin y+g(y)$. Comparison with $N$ gives $g'=y^2$, and the specified value fixes the integration constant. Therefore
$$
\boxed{f(x,y)=-y\cos x+3x\sin y+\frac{y^3}{3}-\frac23.}
$$
Differentiating recovers both coefficients, and $f(0,2)=-2+8/3-2/3=0$. The explicit <potential function> also proves exactness globally, without relying only on a local compatibility test.