I am trying to evaluate $$\oint _C \frac{-ydx+xdy}{x^2+y^2}$$
clockwise around the square with vertices (−1,−1), (−1,1), (1,1), and (1,−1).
So from the question, $$\vec{F}=<\frac{-y}{x^2+y^2},\frac{x}{x^2+y^2}>$$
I first conducted the gradient test $\frac{\partial F_2}{\partial x}=\frac{\partial F_1}{\partial y}$ to see whether the field is conservative. And indeed, I found out that
$$\frac{\partial F_2}{\partial x}=\frac{\partial F_1}{\partial y}=\frac{y^2-x^2}{(x^2+y^2)^2}$$
Thus, $$\vec\nabla \times\vec F=0$$
In this case, since the domain(the square) is simply connected, I thought that the answer was: $$\oint _C \frac{-ydx+xdy}{x^2+y^2}=0$$
However, apparently this is wrong and the solution is
$$\oint _C \frac{-ydx+xdy}{x^2+y^2}=2\pi$$
I don't know which of my logic is flawed.. Please help!
The reason that Stokes' Theorem does not apply directly here is that $F$ is not continuous (and thus, not differentiable) throughout the region bounded by $C$. The singularity at the origin is the source the issue.
METHOD 1: Brute Force
The integration is comprised of the sum of integrals over the 4 line segments. From symmetry considerations, each contribution is identical and we therefore only need to carry out the integration over one of the four segments and multiply by $4$.
Thus,
$$\begin{align} \oint_C \ \frac{-ydx+xdy}{x^2+y^2}&=4\int_{-1}^{1} \frac{(-1)dx+x(0)}{x^2+(1)^2}\\\\ &=\left. -4\arctan(x)\right|_{-1}^{1}\\\\ &=-2\pi \end{align}$$
METHOD 2: Change Contour
Since $\nabla \times \vec F =0$ for $(x,y)\ne (0,0)$, we can deform the contour to any shape that encloses the origin. Let's choose a unit circle as the new contour $C'$. Then, we have
$$\begin{align} \oint_C \ \frac{-ydx+xdy}{x^2+y^2}&=\oint_{C'} \ \frac{-ydx+xdy}{x^2+y^2}\\\\ &=-\int_{-\pi}^{\pi} \frac{-\sin \phi (-\sin \phi) d\phi+\cos \phi (\cos \phi)d\phi}{\cos^2 \phi +\sin^2 \phi}\\\\ &=-2\pi \end{align}$$
METHOD 3: Complex Plane Analysis Interestingly, this problem is identical to the imaginary part of the complex plane contour integration of $1/z$
$$\begin{align} \text{Im}\left(\oint_C \frac{dz}{z}\right)&=\text{Im}\left(\oint_C \bar z \frac{dz}{|z|^2}\right)\\\\ &=\text{Im}\left(\oint_C \frac{xdx+ydy}{x^2+y^2}+i\oint_C \frac{-ydx+xdy}{x^2+y^2}\right)\\\\ &=\oint_C \frac{-ydx+xdy}{x^2+y^2}\\\\ &=-2\pi \end{align}$$
from the residue theorem recalling that $C$ is traversed clockwise.