Let $n \in \mathbb{Z}$ and $X \colon \mathbb{R}^2\backslash\{(0,0)\} \rightarrow\mathbb{R}^2$ be the vector field $$ X( x, y) = \begin{pmatrix}-y(x^2 + y^2)^n, x(x^2 + y^2)^n \end{pmatrix}.$$
a) For which $n \in \mathbb{Z}$ does there exist a function $f: \mathbb{R}^2\backslash\{(0,0)\} \rightarrow\mathbb{R}$ with $\nabla f(p)=X(p)$ for all p $\in \mathbb{R}^2\backslash\{(0,0)\}$?
b) For which $n \in \mathbb{Z}$ does a function $f: \mathbb{R}× \mathbb R_{> 0}\rightarrow\mathbb{R} $ with $\nabla f(p)=X(p)$ for all $p \in \mathbb{R}×\mathbb{R}_{>0}$ exist ?
Now for a) I came to the conclusion that it was only a gradient field for $n = 0$, since for $n \ge |1|$ the chain rule would have been applied and there was no factor that when multiplied by the inner partial for $x = -y$ and for $y = x$, but for $n = 0$ everything in the parentheses becomes a constant and so I can use the product rule.
Now for b) I was able to use the poincaré lemma and came to the conclusion that there was no $n$ for which $ \frac{\partial a}{\partial y} = \frac{\partial b}{\partial x} $ since $$ \frac{\partial a}{\partial y} = -(x^2 + y^2)^n - 2ny^2(x^2 + y^2)^{n-1}$$ and $$ \frac{\partial a}{\partial y} = (x^2 + y^2)^n + 2nx^2(x^2 + y^2)^{n-1}$$
For $0$ I get $-1$ and $1$. Now I'm not sure where I'm going wrong. I was already a bit hesitant on a) since it didn't seem very systematic and there are some weird integrals out there and then that the poincaré lemma contradicts my solution for a)... Have I missed something, got something wrong or misunderstood something? Is there a better way of doing this? Any help would be greatly appreciated.