I calculated that $\frac{dP}{dy} = \cos(y) = \frac{dQ}{dx}$
This tells me that the potential function exists, however I can't figure out what it is.
So far I have found that
$\frac{df}{dx} = \sin(y) + 2x \iff f = -x\cos(y) +x^2 + c(y)$
$\frac{df}{dy} = x\cos(y) + 1 \iff f = x\sin(y) = y + c(x)$
But I can't manage to link these two facts together and find out what f(x,y) is.
$\endgroup$2 Answers
$\begingroup$First of all, when integrating
$$\frac{\partial f}{\partial x} = \sin y + 2x, $$
you should get (just treat $y$ as a constant)
$$f = x\sin y + x^2 + c(y), $$
differentiate this (with respect to $y$) gives
$$\frac{\partial f}{\partial y} = x\cos y + c'(y) . $$
Comparing this to $Q = x\cos y +1$, we have
$$c'(y) = 1 \Rightarrow c(y) = y +C.$$
Thus you have
$$f(x, y) = x\sin y + x^2 + y +C.$$
$\endgroup$ 1 $\begingroup$You can find $f$ in one step by evaluating the integral $$\begin{align} \int_0^1xP(xt,yt)+yQ(xt,yt)\;dt&=\int_0^1x(\sin yt+2xt)+y(xt\cos yt+1)\;dt \\ &=x\sin y+x^2+y \end{align}$$plus a constant.
$\endgroup$