using contour integration I am trying to understand using contour integration to evaluate definite integrals. I still don't understand how it works for rational functions in $x$. So can anyone please elaborate this method using any particular function like say $\int_0^{\infty} \frac {1}{1+x^3} \ dx$. I'ld appreciate that.
I meant I know what I should be doing but am having problems applying them. So, basically I am interested in how to proceed rather than "Take this contour and so on". 
I'ld appreciate any help you people can give me. Thanks.
 A: What we really need for contour integration by residues to work is a closed contour.  An endpoint of $\infty$ doesn't matter so much because we can treat it as a limit as $R \to \infty$, but an endpoint of $0$ is a problem.  Fortunately, this integrand is symmetric under rotation by $2 \pi/3$ radians.  So we consider a wedge-shaped contour $\Gamma = \Gamma_1 + \Gamma_2 + \Gamma_3$ going in a straight line $\Gamma_1$ from $0$ to $R$ on the real axis, then a circular arc $\Gamma_2$ on $|z|=R$ to $R e^{2\pi i/3}$, then a straight line $\Gamma_3$ back to $0$.

We have
$$\eqalign{\int_{\Gamma_1} \dfrac{dz}{1+z^3} &= \int_0^R \dfrac{dx}{1+x^3} \cr
          \int_{\Gamma_3} \dfrac{dz}{1+z^3} &= -e^{2\pi i/3} \int_0^R \dfrac{dx}{1+x^3} 
= \dfrac{1 - \sqrt{3}i}{2}  \int_0^R \dfrac{dx}{1+x^3} 
\cr \left|\int_{\Gamma_2} \dfrac{dz}{1+z^3} \right| &\le \dfrac{CR}{R^3 - 1} \to 0\ \text{as $R \to \infty $}}$$ for some constant $C$.  Now $f(z) = \dfrac{1}{1+z^3} = \dfrac{1}{(z+1)(z-e^{\pi i/3})(z-e^{-\pi i/3})}$ has one singularity inside $\Gamma$, namely at $z = e^{\pi i/3}$ (if $R > 1$), a simple pole with residue $$\dfrac{1}{(e^{\pi i/3}+1)(e^{\pi i/3} - e^{-\pi i/3})} = -\dfrac{1}{6} - \dfrac{\sqrt{3}}{6} i $$
Thus 
$$ \dfrac{3 - \sqrt{3}i}{2} \int_0^\infty f(x)\ dx = \lim_{R \to \infty} \oint_\Gamma f(z)\ dz = 2 \pi i \left(-\dfrac{1}{6} - \dfrac{\sqrt{3}}{6} i\right)$$
$$ \int_0^\infty f(x)\ dx = \dfrac{4 \pi i}{3 - \sqrt{3} i} \left(-\dfrac{1}{6} - \dfrac{\sqrt{3}}{6} i\right) = \dfrac{2 \sqrt{3} \pi}{9} $$
A: There really is an art to using contour integration for evaluating real integrals, but eventually you'll get the hang of it after doing a lot of different examples.  I'll work through your suggested example in horrifying detail then maybe offer some "general" tips.
The first thing I always do is give the real integral a name ($I$) so I can refer to it later:
$$ I=\int_0^\infty \frac{1}{1+x^3}dx$$
Then, I always check if the integrand is even.  It's not.  Why did we check?  It usually ends up being easier to evaluate "doubled" integral i.e. from $-\infty$ to $\infty$ using a semi-circle.  Next we complexify the integrand, and give the new integral a different name: 
$$ I_C=\int_{C}\frac{1}{1+z^3}dz$$
What contour $C$ should we pick?  This is the hardest part, and it depends a) on the singularities of your integrand and b) sometimes on "cancellation" properties. So, we need the contour to include a portion along the positive real axis.  The "classic" contour to choose is the quarter-circle in the first quadrant.  Why?  Because the "radial" part will usually disappear, and the section along the imaginary axis will either disappear or contribute "constructively" to your final result.  However, (you can try to work out the details yourself), if we choose this contour, we'll end up with the following situation: 
$$
I_C=\int_0^R\frac{1}{1+x^3}dx+\int_0^{\pi/4}f(Re^{i\theta})iRe^{i\theta}d\theta+\int_R^0\frac{i}{1-iy^3}dy
$$
Why is this crappy?  The first integral is the one we want, the second integral will go to zero as $R\rightarrow\infty$, but the third...we don't know what to do with.  So, we have to get more clever!  What we need is a "magical cancellation", i.e. we pick a contour so that what we end up with is exactly what we need.  This sounds vague, but you just have to see it in action.  I know that it's the $z^3$ that is giving me issues, so I pick a contour whose parametrization gets nicer when I cube it.  That contour happens to be the "two-thirds-circle", parametrized as follows (traveling counter-clockwise, as usual): 
$$
C=C_1+C_R+C_2\\
C_1: z=x,\;0\leq x\leq R,\; dz=dx\\
C_R: z=Re^{i\theta},\;0\leq\theta\leq\frac{2\pi}{3},\; dz=iRe^{i\theta}d\theta\\
C_2: z=re^{2\pi i/3},\;R\geq r\geq 0,\;dz=e^{2\pi i/3}dr
$$
Notice how I travel along $C_2$ from $R$ to $0$; this matters!  Now, I write down my parametrized complex integral, splitting it up into my three parts: 
$$
I_C=\int_{C_1}f(z)dz+\int_{C_R}f(z)dz+\int_{C_2}f(z)dz\\
=\int_0^R\frac{1}{1+x^3}dx+\int_{0}^{2\pi/3}\frac{1}{1+(Re^{i\theta})^3}iRe^{i\theta}d\theta+\int_R^0\frac{1}{1+(re^{2\pi i/3})^3}e^{2\pi i/3}dr\\
=I_1+I_R+I_2
$$
The first integral is the one I want, the second (we will show) goes to zero, and the last...well, magically: 
$$
I_2=e^{2\pi i/3}\int_R^0\frac{1}{1+r^3e^{2\pi i}}dr=e^{2\pi i/3}\int_R^0\frac{1}{1+r^3}dr=-e^{2\pi i/3}\int_0^R\frac{1}{1+r^3}dr=-e^{2\pi i/3}I_1
$$
So $I_3$ turns out to a multiple of $I_1$!  This is exactly the "cancellation" I was talking about.  Summary: 
$$
I_C=(1-e^{2\pi i/3})\int_0^R\frac{1}{1+x^3}dx+I_R
$$
Okay, so now all I have to do is show that $\lim_{R\rightarrow\infty}I_R=0$, compute my residue, and I'm done!  To show (properly) that $I_R$ goes to zero, we use some nice inequalities: 
$$
\vert I_R\vert=\left\vert\int_0^{2\pi/3}\frac{iRe^{i\theta}}{1+R^3e^{3i\theta}}d\theta\right\vert\leq\int_0^{2\pi/3}\left\vert\frac{iRe^{i\theta}}{1+R^3e^{3i\theta}}\right\vert d\theta=\int_0^{2\pi/3}\frac{R}{\vert 1+R^3e^{3i\theta}\vert}d\theta\\
\leq\int_0^{2\pi/3}\frac{R}{1-R^3}d\theta=\frac{2\pi R}{3(1-R^3)}
$$ And so, $\vert I_R\vert\rightarrow 0$ as $R\rightarrow\infty$!  I first used the triangle inequality for integrals and second the reverse triangle inequality for complex numbers.
Summary again (you should do this frequently):
$$
\lim_{R\rightarrow\infty} I_C=\lim_{R\rightarrow\infty}(I_1+I_R+I_2)=\lim_{R\rightarrow\infty}\left((1-e^{2\pi i/3})\int_0^R \frac{1}{1+x^3}dx+I_R\right)\\
=(1-e^{2\pi i/3})\int_0^\infty\frac{1}{1+x^3}dx+0=(1-e^{2\pi i/3})I
$$
Where $I$ is the original integral we want.  We're almost done - now we just invoke the residue theorem: 
$$
I_C=2\pi i\sum(\text{Residues inside $C$})=2\pi i\text{Res}[f(z),e^{i\pi/3}]=2\pi i\left(\frac{-e^{\pi i/3}}{3}\right)
$$
Since the only singularity inside $C$ is at $z=e^{i\pi/3}$.  So finally, we get (skipping some complex number arithmetic): 
$$
I=-\frac{1}{1-e^{2\pi i/3}}\frac{2\pi i e^{\pi i/3}}{3}=\frac{2\pi}{3\sqrt{3}}
$$
Let me try to give some general tips:


*

*Picking the right contour is hard.  Try the most natural thing first, see what goes wrong, and then try to fix it.  Look for cancellation by using trivial identities like $(e^{2\pi i/n})^n=1$.  Draw a picture and label your singularities!  This might help you avoid choosing a contour that runs through a pole.

*Be very very very deliberate and careful when writing out your work.  I have spent countless hours tracking down rogue $i$'s and $\pi$'s.  Save yourself the trouble by being neat - there is nothing worse than feeling like you know what you're doing but keep getting the wrong answer.

*Good luck!

