# Contour integration

## Homework Statement

$$\int^{\infty}_{0} \frac {\sqrt{x}}{1+x^{2}} dx$$

## The Attempt at a Solution

$$f(z) = \frac {\sqrt{z}}{1+z^{2}} = \frac {\sqrt{z}}{(z-i)(z+i)}$$

$$Res[f,i] = \lim_{z \to i} \frac {\sqrt {z}}{z+i}} = \frac {\sqrt {i}}{2i} = \frac {1}{2i} (\frac {\sqrt {2}}{2}} + i \frac {\sqrt {2}}{2}}) = \frac {\sqrt {2}}{4} - i \frac {\sqrt {2}}{4}$$

$$Res[f,-i] = \lim_{z \to -i} \frac {\sqrt {z}}{z-i}} = \frac {\sqrt {-i}}{-2i} = \frac {1}{-2i} (\frac {\sqrt {2}}{2}} - i \frac {\sqrt {2}}{2}}) = \frac {\sqrt {2}}{4} + i \frac {\sqrt {2}}{4}$$

$$\int^{\infty}_{0} \frac {\sqrt{x}}{1+x^{2}} dx = \frac {2 \pi i}{1-e^{i \pi}} [ \frac {\sqrt {2}}{4} - i \frac {\sqrt {2}}{4} + \frac {\sqrt {2}}{4} + i \frac {\sqrt {2}}{4}] = \frac {2 \pi i}{2}( \frac {\sqrt {2}}{2}) = i \frac {\sqrt {2}}{2} \pi$$

I've done this problem over and over again and I can't figure out where I made a mistake. The answer obviously can't be imaginary.

What contour have you used?
Could it have something to with the choice of brance of the square root function?

jbunniii
Homework Helper
Gold Member
What contour are you using, and how does it relate to the interval for your desired integral (positive real axis)?

Be careful when you apply square roots to complex numbers. There is always some ambiguity present. In this case you have:

$$\sqrt{i} = \pm \frac{2}{\sqrt{2}}\left(1+i\right)$$
$$\sqrt{-i} = \pm \frac{2}{\sqrt{2}}\left(1-i\right)$$

A different sign choice leads to the correct answer. My guess is that if you carefully define the square root as the exponential of a logarithm, with a proper condition on the branch cut of the logarithm, you can avoid this ambiguity. But I haven't checked this.

EDIT:
Yes, you first use:
$$\sqrt{i} = \frac{2}{\sqrt{2}}\left(1+i\right)$$
With this choice you have implicitly defined your choice for the square root function. For the second square root you must apply $$\sqrt{-1} = i$$ or else you run in to inconsistencies (as you noticed). So:
$$\sqrt{-i} = \sqrt{-1}\sqrt{i} = i \sqrt{i} = -\frac{2}{\sqrt{2}}\left(1-i\right)$$

In that case you get the correct answer.

Last edited:
What contour have you used?
Could it have something to with the choice of brance of the square root function?

keyhole contour

Last edited by a moderator:
jbunniii
Homework Helper
Gold Member
keyhole contour

http://en.wikipedia.org/wiki/Methods_of_contour_integration

in particular the non-standard branch cut they choose so that the square root is continuous on and inside the keyhole contour.

Last edited by a moderator:
Because the imaginary unit $i$ is familiar number we can easily make mistakes with the branch cuts. Try to compute the more general integral using the same contour:

$$\int_{0}^{\infty}\frac{x^{-p}}{1+x}dx=\frac{\pi}{\sin(\pi p)}$$

Your integral can transformed into this one by substituting x = sqrt(y).

You can also substitute x = y^2 and then consider the contour from y= 0 to R, a quarter circle to i R and then from i R back to zero.

Be careful when you apply square roots to complex numbers. There is always some ambiguity present. In this case you have:

$$\sqrt{i} = \pm \frac{2}{\sqrt{2}}\left(1+i\right)$$
$$\sqrt{-i} = \pm \frac{2}{\sqrt{2}}\left(1-i\right)$$

A different sign choice leads to the correct answer. My guess is that if you carefully define the square root as the exponential of a logarithm, with a proper condition on the branch cut of the logarithm, you can avoid this ambiguity. But I haven't checked this.

EDIT:
Yes, you first use:
$$\sqrt{i} = \frac{2}{\sqrt{2}}\left(1+i\right)$$
With this choice you have implicitly defined your choice for the square root function. For the second square root you must apply $$\sqrt{-1} = i$$ or else you run in to inconsistencies (as you noticed). So:
$$\sqrt{-i} = \sqrt{-1}\sqrt{i} = i \sqrt{i} = -\frac{2}{\sqrt{2}}\left(1-i\right)$$

In that case you get the correct answer.

Does it matter which root you pick for $$\sqrt {i}$$? And could you pick the root for $$\sqrt {-i}$$ first?

Does it matter which root you pick for $$\sqrt {i}$$? And could you pick the root for $$\sqrt {-i}$$ first?

If you write a complex number z in the form r exp(i theta), then you define sqrt(z) as sqrt(r) exp(i theta/2). So, the only thing there is to choose is what interval for the angle theta to use. You can choose the interval from zero to 2 pi or minus pi to plus pi. But it must be the case that any complex number has a unique value for the polar angle theta for the square root to be defined.

Then, for this contour integration, there is another thing to consider. The square root function must be continuous along the contour. So, you are then forced to choose theta between zero and 2 pi and let the so-called branch cut be along the positive x-axis.

## Homework Statement

$$\int^{\infty}_{0} \frac {\sqrt{x}}{1+x^{2}} dx$$

## The Attempt at a Solution

$$f(z) = \frac {\sqrt{z}}{1+z^{2}} = \frac {\sqrt{z}}{(z-i)(z+i)}$$

$$Res[f,i] = \lim_{z \to i} \frac {\sqrt {z}}{z+i}} = \frac {\sqrt {i}}{2i} = \frac {1}{2i} (\frac {\sqrt {2}}{2}} + i \frac {\sqrt {2}}{2}}) = \frac {\sqrt {2}}{4} - i \frac {\sqrt {2}}{4}$$

$$Res[f,-i] = \lim_{z \to -i} \frac {\sqrt {z}}{z-i}} = \frac {\sqrt {-i}}{-2i} = \frac {1}{-2i} (\frac {\sqrt {2}}{2}} - i \frac {\sqrt {2}}{2}}) = \frac {\sqrt {2}}{4} + i \frac {\sqrt {2}}{4}$$

$$\int^{\infty}_{0} \frac {\sqrt{x}}{1+x^{2}} dx = \frac {2 \pi i}{1-e^{i \pi}} [ \frac {\sqrt {2}}{4} - i \frac {\sqrt {2}}{4} + \frac {\sqrt {2}}{4} + i \frac {\sqrt {2}}{4}] = \frac {2 \pi i}{2}( \frac {\sqrt {2}}{2}) = i \frac {\sqrt {2}}{2} \pi$$

I've done this problem over and over again and I can't figure out where I made a mistake. The answer obviously can't be imaginary.

You're calculating the residue at -i incorrectly for the branch you're using. Your branch is defined as:

$$\sqrt{z}=r^{1/2}e^{i/2(\arg(z))},\quad 0\leq arg(z)<2\pi$$

then the argument of -i is what?

You're calculating the residue at -i incorrectly for the branch you're using. Your branch is defined as:

$$\sqrt{z}=r^{1/2}e^{i/2(\arg(z))},\quad 0\leq arg(z)<2\pi$$

then the argument of -i is what?

$$\frac {3}{2} \pi$$

Ok then:

$$\mathop\text{Res}_{z=-i} \frac{\sqrt{z}}{(z+i)(z-i)}=\frac{\sqrt{-i}}{-2i}$$

and then calculate $$\sqrt{-i}$$ using that argument.

Or, if you are lazy, change the contour into a half circle.

$$Res[f,-i] = \lim_{z \to -i} \frac {\sqrt {z}}{z-i}} = \frac {\sqrt {-i}}{-2i} = \frac {1}{-2i}(cos (\frac {3 \pi}{4}) + i sin (\frac {3 \pi}{4}) ) = \frac {1}{-2i} ( \frac {-\sqrt {2}}{2}} + i \frac {\sqrt {2}}{2}}) = \frac {-\sqrt {2}}{4} - i \frac {\sqrt {2}}{4}$$

then $$\int^{\infty}_{0} \frac {\sqrt{x}}{1+x^{2}} dx = \frac {2 \pi i}{1-e^{i \pi}} [ \frac {\sqrt {2}}{4} - i \frac {\sqrt {2}}{4} - \frac {\sqrt {2}}{4} - i \frac {\sqrt {2}}{4}] = \frac {2 \pi i}{2}( -i \frac {\sqrt {2}}{2}) = \frac {\sqrt {2}}{2} \pi$$

Thanks. I was using $$-\frac {\pi}{2}$$ for the argument.

Or, if you are lazy, change the contour into a half circle.

What branch would be used for $$\sqrt {z}$$ ?

What branch would be used for $$\sqrt {z}$$ ?

Take the contour from z = epsilon to R, then a half circle in the upper half plane to minus R, then to minus epsilon, and then half a circle in the upper half plane to plus epsilon.
You can then put the branch cut anywhere in the lower half of the complex plane. If I is the integral from epsilon to R, then the integral from minus R to minus epsilon is i I. The Contour integral in the limit epsilon to zero and R to infinite becomes:

(1+i) I

Residue theorem gives the contour integral as

2 pi i *exp(pi i/4)/(2i) = pi/sqrt(2) (1+i)

So, it follows that I = pi/sqrt(2).

This is then easier as there is only one pole in the contour. Also, the choice of te branch cut is less critical. The integral from minus R to minus epsilon is i I, essentially because -1 = exp(pi i) and not e.g. exp(- pi i), but in this case it is hard to get this wrong.

$$Res[f,-i] = \lim_{z \to -i} \frac {\sqrt {z}}{z-i}} = \frac {\sqrt {-i}}{-2i} = \frac {1}{-2i}(cos (\frac {3 \pi}{4}) + i sin (\frac {3 \pi}{4}) ) = \frac {1}{-2i} ( \frac {-\sqrt {2}}{2}} + i \frac {\sqrt {2}}{2}}) = \frac {-\sqrt {2}}{4} - i \frac {\sqrt {2}}{4}$$

then $$\int^{\infty}_{0} \frac {\sqrt{x}}{1+x^{2}} dx = \frac {2 \pi i}{1-e^{i \pi}} [ \frac {\sqrt {2}}{4} - i \frac {\sqrt {2}}{4} - \frac {\sqrt {2}}{4} - i \frac {\sqrt {2}}{4}] = \frac {2 \pi i}{2}( -i \frac {\sqrt {2}}{2}) = \frac {\sqrt {2}}{2} \pi$$

Thanks. I was using $$-\frac {\pi}{2}$$ for the argument.

One more thing Random: If you really want to get good at these, learn to draw them. It then becomes crystal clear what's going on with the branches and also, it's quite a programming challenge to draw the complicated ones.