Contour Integral explanation

1. Jan 25, 2010

Char. Limit

I saw a contour integral in a text I was recently reading, but unfortunately a contour integral is beyond my understanding at the moment. As such, I would greatly appreciate it if someone could explain a contour integral to me.

If it helps, I know about derivatives, integrals, partial derivatives, gradients, divergences and curls, and a bit on differential equations.

2. Jan 25, 2010

hamster143

Was it a contour integral over a scalar field or a vector field?

3. Jan 25, 2010

Gerenuk

I'm sure someone will be able more detailed answers than I, but I just want to quickly give an outlook. You also know about complex numbers?

Do you know about the divergence theorem?
Basically contour integrals are used like a 2D divergence theorem. Instead of integrating on a curve over a contour in the complex plane you can sum over some "divergence" of the interiour to get the same result. The trick is that for most "reasonable" functions this divergence is zero at all points except for the points with singularities (like where you'd divide by zero). So you could
1) without changing the value of the contour integral deform the contour as you wish, as long you keep the relevant singularities inside the contour
2) calculate the contour integral by summing over the contributions of the singularities only to get the its value

You usually integrate over a closed loop in the complex planes.
So you write
$$\oint f(z)dz$$
and mean the you go over all values for z on the given path in the complex plane. For example try integrating
$$\oint z^2dz=\int_0^1 zdz+\int_1^{1+i} zdz+\int_{1+i}^{i} zdz+\int_i^0 zdz$$
from z=0 to z=1 to z=1+i to z=i back to z=0 (which is a square in the complex plane). You should get zero.
Now try integrating
$$\oint \frac{1}{z}dz$$
from z=-1-i to z=1-i to z=1+i to z=-1+i back to z=-1-i which is a square about the origin. You could use any other square or arbitrary contour, but as long as you include the origin you will always get the same result for the contour integral. As I said, instead of integrating over the contour you could just sum over the contributions for singularities inside the contour. The function 1/z has only one such contributing singularity at the origin. Maybe you can make sense of
http://en.wikipedia.org/wiki/Residue_theorem

Contour integrals are usually used to calculate normal integrals from $-\infty$ to $+\infty$. In the first step you look at it in the complex plane. The normal integral is the integral along the real axis. Now you add a half-circle of infinite radius above this real axis to form a big closed "half-circle" contour. For the practical cases the half-circle you added has a vanishing contribution for a half-circle of infinite radius. Therefore we equal contour integral and normal integral.
Now we know that to calculate a closed curve integral, all we need is to sum over the residues (contributions from singularities inside). Therefore we effectively calculate the normal infinite integral we needed in the first place.

OK, maybe someone else continue from here. Or just ask questions :)

4. Jan 27, 2010

elibj123

I'll briefly summarize you the theory of calculating such integrals. I guess you're talking about integrals of real fields rather than complex functions, so I'll talk about real integration (which is pretty much like complex integration)

A contour integral is a generalization of the "normal" integral, which is integration over the line segement which contained in the x-axis. To extend this, you need to introduce functions of several variables (scalar fields or vector fields) and its sufficient to do this on a two-dimensional case.

1. Contour Integral of The First Kind

You have a scalar field f(x,y), which represents some distribution, let's say of mass. You'd like to calculate the total mass on a wire which is your contour $$\gamma$$. Observe that a contour is a pair of two functions x(t) & y(t) which accepts a variable a<=t<=b and describe a set of points creating the contour. (x(t),y(t)) is called the parametrization. Each contour has infinitely many parametrizations, and you can do the same with polar coordinates or any legitimate coordinates you'd like to choose. But we'll stick to the cartesian parametrization (also the differentials change when considering other coordinate systems).

You'd like, like in normal integrals, to slice up your contour into really small peaces, evaluate the field at an arbitrary point in the peace, multiply by the length, and sum over all of them. Then you do a limiting process to get a smooth summation.
It can all be done by Reimann Sums but i'll skip this. The important things are that the differential length of the curve at each points can be given formally by the pithagorean theorem: (as the peaces go to zero-length, they approach straight lines)

$$ds=\sqrt{dx^{2}+dy^{2}}=\sqrt{(\frac{dx}{dt})^2+(\frac{dy}{dt})^2}dt$$

Integration is denoted by $$I=\int_{\gamma}f(x,y)ds$$
By change of variables, it reduces to a simple one-dimensional integration:

$$I=\int^{t=b}_{t=a}f(x(t),y(t))\sqrt{\dot{x}^{2}+\dot{y}^{2}}dt$$
(Here dot denotes derivation wrt t)

The integrand here is only a function of t, and your integrate wrt t so you ought to get a numerical result (independent of x,y or t).
The trick here is to get a good parametrization so that your integral will be simple.

A good result from that, is that a length of the curve can be simply calculate by letting f(x,y)=1 and then

$$L(\gamma)=\int^{t=b}_{t=a}\sqrt{\dot{x}^{2}+\dot{y}^{2}}dt$$

Of course notice that the result of the integration must be independent of the parametrization you've chosen to work with (otherwise you've done things wrong).

2. Contour Integral of the Second Kind

This is the equivalent of physical work definition. Here instead of a scalar field (that might represent mass, electric charge), you have a vector field (might represent electric field, gravitational force), and you'd like to calculate it's "effective impact" across some contour $$\gamma$$.

So you have
$$\vec{F}(x,y)=P(x,y)\hat{i}+Q(x,y)\hat{j}$$

(i & j are the unit vectors in the direction of x & y)

And a parametrization

$$\vec{\gamma}(t)=x(t)\hat{i}+y(t)\hat{j}$$

Effective impact means that at each differential slice of the curve, you collect the component of the field which is parallel to the curve. The tangent of the curve is:

$$\vec{ds}=dx\hat{i}+dy\hat{j}$$

And therefore the parallel component\the projection is given by:

$$\vec{F}.\vec{ds}=Pdx+Qdy$$

The notations of the integral are:

$$\int_{\gamma}\vec{F}.\vec{ds}=\int_{\gamma}Pdx+Qdy$$

And by a similiar change of variables you get:

$$I=\int^{t=b}_{t=a}(P(x(t),y(t))\dot{x}(t)+Q(x(t),y(t))\dot{y}(t))dt$$

Which is again a simple integral wrt t.

P.S. I worked under the assumptions that your contours are smooth enough. Notice that some contours are not smooth, and may be defined only piecewise.
You can also use the fact that integrals are additive: the integral over a contour which is made of two contours united together, is the sum of integrals over each contour seperately.

Also, there's the matter of direction. In the first kind, direction doesn't matter, since we are talking about scalars. Of course $$\int^{t=b}_{t=a}=-\int^{t=a}_{t=b}$$ But if you've chosen to start integrating from t=b, then your parametrization must change also, keeping the integral itself unchanged.

In second kind integration, direction is important (it alters the result by a minus sign) so you must know from where to where you perform the integration.

And finally, once you've done the leap from one to two dimensions, you'll probably easily understand how to generalize to 3,4 and n-dimensions.

I hope I've helped, yet I think a more rigorous establishment (justifying all change of variables) will be in literature rather than in here.

5. Jan 27, 2010

Char. Limit

All right, I think I get it. I'd like just one more thing: a simple example of each. Perhaps put the solution in spoilers so that I can try to work it out first?

6. Jan 27, 2010

hamster143

For the first kind, try to compute the integral of x^2+y^2 over the unit circle (the circle with center (0,0) and radius 1).

7. Jan 28, 2010

elibj123

For the second kind try calculating the integral of the field
$$\vec{F}(x,y)=\frac{x}{x^{2}+y^{2}}\hat{i}-\frac{y}{x^{2}+y^{2}}\hat{j}$$

Over the unit circle counter-clockwise (remember that direction is important?)

This is an interesting vector field :)

8. Jan 28, 2010

Char. Limit

So far, I'm having difficulty with one part of this. I figured that the parametrization of the unit circle is:
$$x(t)=cos(t),y(t)=sin(t)$$

So... here's what I've done...

$$\int_0^{2\pi} f(cos(t),sin(t))\sqrt{(-sin(t))^2+(cos(t))^2}dt$$

That radical should reduce to one. So, do I do this?

$$\int_0^{2\pi} cos(t)^2+sin(t)^2 dt = \int_0^{2\pi} dt$$

But that just equals 2pi. The answer seems too simple, I must have done something wrong.

9. Jan 28, 2010

hamster143

2 pi is correct.

10. Jan 28, 2010

Char. Limit

Over the same contour?

First, I can see the usefulness of working with the unit circle. Getting rid of half of the problem... good idea.

So, the integral will go out to 1+cos^2(x)...

Let's see what we can do...
Cosine squared of a number is equal to sine squared of a number minus twice the number...

1-cos(2x)+sin^2(x)

which equals

1-cos(2x)+.5-.5cos(2x)

which simplifies to

.5 -1.5cos(2x)

So, the integral of that is

.5x+.75sin(2x)

which from zero to 2pi is...

just pi. Right?

11. Jan 28, 2010

hamster143

No. The answer should obviously be greater than 2 pi.

12. Jan 28, 2010

Char. Limit

Where did I go wrong?

13. Jan 28, 2010

hamster143

Simple arithmetical error. .5 -1.5cos(2x) should be 1.5 -1.5cos(2x).

Here's how you can get the same results without any trigonometry at all.

The first integral is of a function that is constant along the entire contour. So, its value is just the value of the function (1) times length of the contour (2 pi).

Symmetry tells us that $\oint x^2 dl = \oint y^2 dl = 1/2 \oint (x^2+y^2) dl = \pi$.

Therefore $\oint (x^2+2y^2) dl = \pi + 2\pi = 3\pi$.

14. Jan 28, 2010

Char. Limit

Oh my god, I can't believe I made that error.

So, in general, the contour integral for $$ax^2+by^2$$ with the contour being the unit
circle is equal to $$(a+b)\pi$$?

15. Jan 29, 2010

Char. Limit

OK, so I think I get the first kind of contour (line, path) integral. The second kind is confusing me though. How do you parametrize a vector?

16. Jan 30, 2010

elibj123

You parametrize the curve like in the first kind (in both kinds the parametrization will be off course identical for the same curve).

But instead of taking the differential length of the curve, you now need to take the differential direction of the curve=the tangent vector.

if your curve is parametrized by (x(t),y(t)) then at each point the tangent vector will be

$$\vec{dr}=dx\hat{i}+dy\hat{j}$$

Now at each point you need to take the dot product of the vector field you're integrating, with the tangent direction. So you integral is

$$\int_{\gamma}\vec{F}.\vec{dr}=\int_{\gamma}Pdx+Qdy$$
(Here F(x,y)=( P(x,y), Q(x,y) ))
Now you need to change variables. From (x,y) to (x(t),y(t)) and what you get is

$$=\int^{b}_{t=a}(P\dot{x}+Q\dot{y})dt$$

And simply integrate.