Integrating a function $f: \mathbb{C} \to \mathbb{R}$ over a closed curve. Is there a general result pertaining to the intergral of a real valued function of a complex variable $f: \mathbb{C} \to \mathbb{R}$ over a closed contour? For instance, integrating $|z|$ over a circle or a rectangle centered at the origin gives $0$, but I don't know how to check if this is true for an arbitrary closed curve. None of the theorems of complex analysis work since such a function is never analytic (except maybe in the origin).
 A: Yes; the result is called Green's theorem. Before stating it in complex notation, I'll go on a brief detour: 
The various flavors of the fundamental theorem of calculus  apply not to integral of functions, but to integrals of differential forms such as $f\,dz$ (or $f\,dx$, or $f\,dz+g\,d\bar z$, or $f\,dx+g\,dy$, etc). Under the hood, all of them are the same thing, called the Stokes theorem: $$\int_M d \omega = \int_{\partial M} \omega$$ To apply the theorem, we need one of two things: either


*

*a form that we can recognize as $d\omega$ for some $\omega$, or 

*a region of integration that we can recognize as $\partial M$ for some $M$ 



In your situation, the second case applies: the region of integration is the boundary of some domain $U$. Thus, 
$$\int_{\partial U} f\,dz = \int_U d(f\,dz)$$
We can calculate $d(f\,dz)$ in complex notation:
$$d(f\,dz) = df\wedge dz = (f_z \,dz+f_{\bar z}d\bar z)\wedge dz =f_{\bar z}d\bar z \wedge dz $$
Hence
$$\int_{\partial U} f\,dz = \int_U f_{\bar z}\,d\bar z \wedge dz\tag1$$
For practical computations you probably want to write
$$d\bar z \wedge dz =(dx-idy)\wedge (dx+idy) = 2i(dx\wedge dy) \tag2$$
where $dx\wedge dy$ is the familiar $dx\,dy$.

Let's illustrate (1)  with a concrete example: $|z|\,dz$ integrated over the circle $|z-1|=1$. Here, $f(z)=z^{1/2}\bar z^{1/2}$, hence $f_{\bar z}(z) =  \frac12 z^{1/2}\bar z^{-1/2}=\dfrac{z}{2|z|}$. Using also (2), you end up with the ordinary double integral
$$ i \int_{|z-1|<1} \dfrac{x+iy}{\sqrt{x^2+y^2}}\,dx\,dy$$
The part with $iy$ cancels out by symmetry. The rest can be handled with polar coordinates:
$$  \int_{|z-1|<1} \dfrac{x}{\sqrt{x^2+y^2}}\,dx\,dy
=  \int_{-\pi/2}^{\pi/2} \int_0^{2\cos\theta} r\cos\theta \,dr\,d\theta=4$$
The final answer is 
$$\int_{|z-1|=1}|z|\,dz=4i$$
Does this answer look reasonable? Yes. Along the far-away part of the circle, where $|z|$ is largest, the term $dz$ points up (has positive imaginary part). 
