Compute the integral $\int_{0}^{\infty} \frac{(1 + x + x^2)}{(1+x^4)} dx $ with a residue on suitable contour. I believe that I could try to compute the same integral with limits from $-\infty$ to $\infty$ using residue on a half circle and then let the radius tend off to infinity, and once I have that value I should be able to take half of that integral. However, my colleagues have told me that I am wrong. I am not sure how to approach this, with residues, otherwise.
 A: It is easier to deal first with the piece:
$$\int_{0}^{+\infty}\frac{x}{1+x^4}\,dx = \left.\frac{1}{2}\,\arctan(x^2)\right|_{0}^{+\infty}=\frac{\pi}{4}\tag{1}$$
then compute $\int_{0}^{+\infty}\frac{1+x^2}{1+x^4}\,dx$ through the residue theorem, leading to:
$$\int_{0}^{+\infty}\frac{1+x+x^2}{1+x^4}\,dx = \frac{\pi}{4}+\frac{\pi}{\sqrt{2}}. \tag{2}$$
A: If you accept proofs other than based on the residue theorem, it is known (using Euler's $B$ function; let me know if you want details) that $$\int \limits _0 ^\infty \frac {x^m} {1+x^n} \mathbb{d}x = \frac \pi {n \sin \frac {\pi (m+1)} n}$$. Then if you split your integral in three integrals like the one I am showing,  you will get $\frac {{\sqrt 2} \pi} 4 + \frac \pi 4 + \frac {{\sqrt 2} \pi} 4 = \frac \pi 4 + \frac \pi {\sqrt 2}$.
EDIT: To clarify the above integral, one can immediately compute the even more general $$\int \limits _0 ^\infty \frac {x^m} {(1+x^n)^p} \mathbb{d}x = B(\frac {m+1} n, p - \frac {m+1} n)$$ by making the change of variables $t = \frac {x^n} {1+x^n}$. If $p$ has a nice form (for instance if it is natural), the expression can be further simplified by using Beta's recursion properties and the fact that $B(x,1-x) = \frac \pi {\sin \pi x}$. The important point to make here is that all these results involving Euler's functions can be obtained by purely elementary methods, with no need for contour integration in the complex plane.
A: We will use the contour $\gamma$ avoiding the positive real axis,

Change variables $x\mapsto x^{1/4}$ to get
$$
\int_0^\infty\frac{1+x+x^2}{1+x^4}\,\mathrm{d}x=\frac14\int_0^\infty\frac{x^{-3/4}+x^{-1/2}+x^{-1/4}}{1+x}\,\mathrm{d}x\tag{1}
$$
Then, as in this answer, handle the three integrals
$$
\int_0^\infty\frac{x^{-\alpha}}{1+x}\,\mathrm{d}x\tag{2}
$$
using $\log(z)=\log(x)$ on the top of the real axis and $\log(z)=\log(x)+2\pi i$ on the bottom. This gives
$$
\int_\gamma\frac{z^{-\alpha}}{1+z}\,\mathrm{d}z=\left(1-e^{-2\pi i\alpha}\right)\int_0^\infty\frac{x^{-\alpha}}{1+x}\,\mathrm{d}x\tag{3}
$$
since the integral along the large and small circular contours vanish.
We can now use contour integration to say that the contour integral above is equal to the residue at $z=-1$. That is,
$$
\int_\gamma\frac{z^{-\alpha}}{1+z}\,\mathrm{d}z=2\pi i\,e^{-\pi i\alpha}\tag{4}
$$
Combine $(3)$ and $(4)$ to get
$$
\begin{align}
\int_0^\infty\frac{x^{-\alpha}}{1+x}\,\mathrm{d}x
&=\frac{2\pi i}{e^{\pi i\alpha}-e^{-\pi i\alpha}}\\
&=\frac{\pi}{\sin(\pi\alpha)}\tag{5}
\end{align}
$$
Use $(5)$ to evaluate the three pieces in $(1)$:
$$
\frac14\left(\frac\pi{1/\sqrt2}+\frac\pi{1}+\frac\pi{1/\sqrt2}\right)
=\pi\,\frac{1+2\sqrt2}{4}\tag{6}
$$
