Confusion regarding Residue Theorem

So I ran into residue theorem recently and found it to be pretty amazing, and have been trying to get some of the more fundamental aspects of Laurent series and contour integrals down to make sure I understand it properly, but there's still one big aspect that keeps confusing me majorly.

According to the theorem, a contour integral on the complex plane around a set of singularities (I'm paraphrasing) like (x, y) = (0, 1) or (0, -1) in z = 1/(1 + (x + i y)^2) is 2 i pi [Sigma on i] Res(z, point i), but that implies it's constant no matter the size or shape of the chosesn contour (given the set of singularities it encircles does not change), and that any closed contour integral which does not circle a singularity must be zero?

The first part is mindblowing if it's true, but it doesn't contradict in too obvious a fashion with my logic, the last point does. If you take a contour integral about a circle, each point in which has a positive z value (ie. where the surface is above the x, y plane for all of the circle) then there is no negative part to cancel anything and the integral should have a non-zero, positive value...

Where am I going wrong in my thinking or understanding of the theorem? Is it to do with conflating closed contour integrals over the complex plane too closely with generalised line/path integrals? I've always understood them to essentially be synonyms, so my physical intuition of the former derives from that of the latter.
 PhysOrg.com science news on PhysOrg.com >> Galaxies fed by funnels of fuel>> The better to see you with: Scientists build record-setting metamaterial flat lens>> Google eyes emerging markets networks
 Recognitions: Science Advisor Suppose you have a constant (real valued) vector field in 2 dimensions. A contour integral around a circle measures the net flux coming out of the circle due to the vector field and this is zero. That's the analogy you should make. Don't visualize a z-coordinate. Visualize f(x,y) = constant as a vector field in the complex plane which has a constant real component and a constant imaginary component. Things cancel out because the contour integration assigns different signs depending on whether this constant field is pointing into or out-of the curve.
 Thanks for your response, that does poke a hole that needed to be poked in my previous attempts to understand, but it doesn't fill it back up as far as I'd hoped - what I'm trying to visualise now is so abstract... Do you (or anyone else reading this) have any other ways to suggest thinking about it?

Recognitions:
Homework Help

Confusion regarding Residue Theorem

Maybe you have seen a picture like this one from wikipedia http://en.wikipedia.org/wiki/File:Stokes_patch.svg before. Two paths can be thought of as a closed contour with one positively weighted and the other negatively weighted. We can break a contour into many small pieces. On a small contour if the function is well behaved (analytic like a constant) the opposite signs causes the integral to vanish. If the function behaves badly (has a singularity as 1/z does when z=0) the opposite signs do not cancel.
 Recognitions: Science Advisor If two loops surround the same poles then there are no poles between them. So the meromorphic function is actually holomorphic in the region between the two loops. So the line integrals must be equal.

 Quote by Mr. Heretic any closed contour integral which does not circle a singularity must be zero?
Yes, this is the content of the Cauchy Integral Theorem.

 Quote by Mr. Heretic If you take a contour integral about a circle, each point in which has a positive z value (ie. where the surface is above the x, y plane for all of the circle) then there is no negative part to cancel anything and the integral should have a non-zero, positive value.
In an integral over a closed countour in the complex plane ##\int_γ f(z)dz##, it is not only the ##f(z)##:s that can cancel each other out, but also the ##dz##:s. At two opposite points on the circle, the ##dz##:s have opposite directions. If we parametrize the integral to, say, ##\int_0^1 f(z(t))\frac{dz}{dt}dt##, then these opposite directions for opposite points are seen in ##\frac{dz}{dt}##, which is now part of the integrand.

Recognitions:
 Quote by Mr. Heretic Where am I going wrong in my thinking or understanding of the theorem? Is it to do with conflating closed contour integrals over the complex plane too closely with generalised line/path integrals? I've always understood them to essentially be synonyms, so my physical intuition of the former derives from that of the latter.
I'd say that a contour integral in complex analysis is analgous to a very specific line integral, not a generalised line integral. It is analagous to the type of integration you do to compute the flux of a 2-D real valued vector field through a 2-D curve ( which is, in turn, the 2-D analogy for computing the flux of a 3-D vector field through a 3-D surface).

I don't recall the details, but you must think of the complex valued function being integrated as a 2-D vector field with the real and imaginary values being orthogonal components of the field. The algebraic expression for a contour integral doesn't look like an integral that computes flux, but if you break up the expression into real and imaginary parts, it becomes like one. A pole in a complex valued function behaves like a source or sink for flux. This is why contour integrals that enclose poles can have non-zero values. (There is a book on complex analysis by Polya and Latta that emphasizes the analogy between contour integrals and computing flux.)
 Thanks guys, it all makes more sense now.
 Recognitions: Science Advisor To elaborate on what Stephen was saying, I think this is how it works - correct me if there is a mistake. If u and v are the real and complex parts of an analytic function then one proves that there is a potential function w such that $\partial$w/$\partial$x = u and $\partial$w/$\partial$y = -v This means that the line integral over a closed loop of the form udx -vdy is zero. This is just the fundamental theorem of calculus. Intuitively the integral of a potential field along a loop equals the change in potentntial between the endpoints. The change in potential is by definition independent of path and in particular is zero for a closed loop. If one thinks of (u,-v) as tangent to a fluid flow in the plane then the flow is called irrotational. It has zero circulation around any closed loop. You can also verify this by seeing that the curl of (u,-v) zero. This vector field is also divergence free which means that the integral of vdx + udy around a closed loop is also zero. (v,u) is the 90 degree rotation of (u,-v) so its line integral is the same as the flux of the field outside of the region that the loop encloses. The easiest way to see this is to parameterize the curve by arc length then rotate the vector field and the unit tangent to the curve 90 degrees counterclockwise to see that it equals the flux of the vector field. If u + iv has a pole inside a region then its flux may not be zero. This happens with a pole of order 1. For higher order poles the flow lines loop away and towards the singularity in equal amounts to net a total flux of zero.

 Tags complex analysis, contour integral, line integral, residue theorem