Real integral of $\sqrt{x}/(x^4+1)$ over the positive real axis computed as a contour complex integral I'm asking to evaluate the following integral
$$ \int_0^{+\infty} \frac{\sqrt{x}}{x^4+1}dx$$
And my idea was to compute it on the half upper disk of radius $R$ with a little smaller half disk around the origin. I make a branch cut on the negative imaginary axis which means that I restrict the arguments to $(-\pi/2,3/2\pi)$
According to the solution provided the result is $$\frac{\pi \cos(\pi/8)}{2+\sqrt{2}}$$
but I get $\frac{\pi}{2}(\sin(\frac{\pi}{8})+\cos(\frac{\pi}{8}))$. Here is my attempt: 
We have two simple poles in our domain, $e^{i\pi/4}$ and $e^{i3/4\pi}$, and their residues are $-\frac{1}{4}e^{i 3/8\pi}$ and $-\frac{1}{4}e^{i \pi/8}$. Hence by the Residue theorem the integral along the circuit must be equal to $$ 2\pi i (-\frac{1}{4}e^{i 3/8\pi}-\frac{1}{4}e^{i \pi/8})$$ which is equal to $$-\frac{i\pi}{2}(\cos(\pi/8)+\sin(\pi/8)+i(\cos(\pi/8)+\sin(\pi/8)))$$
Now by ML estimates I believe I can show that the integrals along the two semicircles are going both to $0$, while the integral along the negative real axis is $i$-times the one along the positive real axis, hence purely imaginary. By taking the real part the result is $$ \frac{\pi}{2}(\cos(\pi/8)+\sin(\pi/8))$$ which sadly is not the result given. Am I making any conceptual error? (maybe with the branch cut?) what's wrong? I've double checked my computations but I can't find the error
 A: The approach taken in the OP is to analyze a contour integral that is comprised of the entire real axis.  Hence, the OP should end up with 
$$\begin{align}
\int_{-\infty}^0\frac{\sqrt x}{x^4+1}\,dx+\int_0^\infty\frac{\sqrt x}{x^4+1}\,dx&=(1+e^{i\pi/2})\int_0^\infty\frac{\sqrt x}{x^4+1}\,dx\\\\
&=2\pi i \left(\frac{\sqrt{e^{i\pi/4}}}{4(e^{i\pi/4})^3}+\frac{\sqrt{e^{i3\pi/4}}}{4(e^{i3\pi/4})^3}\right)\\\\
&=2\pi i\left(\frac14 e^{-i5\pi/8}+\frac14 e^{i\pi/8}\right)\tag 1
\end{align}$$
Solving $(1)$ for the integral of interest yields
$$\int_0^\infty\frac{\sqrt x}{x^4+1}\,dx=\frac{\pi \cos(3\pi/8)}{\sqrt 2}=\frac{\pi}{4\cos(\pi/8)}$$
In that which follows, we present a slightly more efficient approach.

Let $\epsilon>0$ and $R>1$.  
Let $C$ be the closed contour comprised of the $(1)$  real line segment from $\epsilon$ to $R$, $(2)$ imaginary line segment from $iR$ to $i\epsilon$, $(3)$ circular arc in the first quadrant with radius $\epsilon$ from $i\epsilon$ to $\epsilon$, and $(4)$ circular arc in the first quadrant with radius $R$ from $R$ to $iR$.  (i.e., $C$ is a quarter circle in Quadrant $1$).
Define $\sqrt z$ using the branch cut on which $-\pi <\arg(z)\le \pi$.
Then, we have
$$\begin{align}
\oint_C \frac{\sqrt z}{z^4+1}\,dz&=\int_{\epsilon}^R \frac{\sqrt x}{x^4+1}\,dx+\int_R^\epsilon \frac{e^{i\pi/4}\sqrt x}{x^4+1}\,i\,dx\\\\
&+\int_{\pi/2}^0 \frac{\sqrt{\epsilon e^{i\phi}}}{(\epsilon e^{i\phi})^4+1}\,i\epsilon e^{i\phi}\,d\phi+\int_0^{\pi/2} \frac{\sqrt{R e^{i\phi}}}{(R e^{i\phi})^4+1}\,iR e^{i\phi}\,d\phi\tag 2
\end{align}$$
As $\epsilon \to 0$ and $R\to \infty$, the third and fourth integrals on the right-hand side of $(2)$ vanish.
Using the residue theorem, we find from $(1)$ that 
$$\begin{align}
(1-e^{i3\pi/4})\int_0^\infty \frac{\sqrt x}{x^4+1}\,dx&=2\pi i\text{Res}\left(\frac{\sqrt z}{z^4+1}, z=e^{i\pi/4}\right)\\\\
&=2\pi i \left(\frac{\sqrt{e^{i\pi/4}}}{4(e^{i\pi/4})^3}\right)\tag 3
\end{align}$$
whereupon solving $(3)$ for the integral of interest yields
$$\int_0^\infty \frac{\sqrt x}{x^4+1}\,dx=\frac{\pi}{4\cos(\pi/8)}$$
as expected!
A: One way or another, it is more practical to remove the branch point through the substitution $x=z^2$, leading to
$$ 2\int_{0}^{+\infty}\frac{z^2}{z^8+1}\,dz = 2\int_{0}^{1}\frac{z^2+z^4}{z^8+1}\,dz=2\int_{0}^{1}\frac{z^2+z^4-z^{10}-z^{14}}{1-z^{16}}\,dz\\ =2\sum _{k=0}^{+\infty } \left(\frac{1}{16k+3}+\frac{1}{16k+5}-\frac{1}{16k+11}-\frac{1}{16k+13}\right).$$
Now I can show you a very fast way for tackling such series. By the reflection formula for the $\psi$ function we have
$$ \sum_{k=0}^{+\infty}\left(\frac{1}{16k+3}-\frac{1}{16k+13}\right)=\frac{\pi}{16}\cot\frac{3\pi}{16},$$
$$\sum_{k=0}^{+\infty}\left(\frac{1}{16k+5}-\frac{1}{16k+11}\right)=\frac{\pi}{16}\cot\frac{5\pi}{16} $$
hence
$$ \int_{0}^{+\infty}\frac{\sqrt{x}}{x^4+1}\,dx = \frac{\pi}{4}\sec\frac{\pi}{8}=\color{red}{\frac{\pi}{2}\sqrt{1-\frac{1}{\sqrt{2}}}}.$$
A: I do not know where it went wrong, I think where you take the real part, because one must be really careful when doing such things. It may be ironic, but I will use an approach where one needs to take the imaginary part. It is a slightly different approach. Consider the following (more general) integral:
\begin{align}
\int^\infty_0 \frac{x^\mu}{x^2-i}\,dx
\end{align}
where $\mu\in (-1,1)$. Your integral is just a specific value ($\mu=1/2$) of this integral after taking the imaginary part:
\begin{align}
\int^\infty_0 \frac{x^\mu}{x^4+1}\,dx=\Im\left(\int^\infty_0 \frac{x^\mu}{x^2-i}\,dx\right)
\end{align} 
We consider now the following (complex) integral:
\begin{align}
\oint_C \frac{(-z)^\mu}{z^2-i}\,dz
\end{align}
Where $C$ is the keyhole contour with the key hole on the positive axis. The radius of the circle is $R$ etc. The logarithm to define $(-z)^\mu$ is the principal logarithm. Doing the regular stuff (i.e. showing with ML lemma that some have no contribution etc etc) and taking the limit of $R\to \infty$ we get:
\begin{align}\tag{1}
\oint_C \frac{(-z)^\mu}{z^2-i}\,dz =-\left( e^{i\pi \mu}-e^{-i\pi\mu}\right)\int^\infty_0 \frac{x^\mu}{x^2-i}\,dx = -2i\sin(\mu\pi)\int^\infty_0 \frac{x^\mu}{x^2-i}\,dx
\end{align}
To show $(1)$  you must remember that we have the principal logarithm and see how the contour changes the value of our integrand when we approach the positive real line from above and from below. All straightforward. 
By the Residue Theorem we have:
\begin{align}
\oint_C \frac{(-z)^\mu}{z^2-i}\,dz =2\pi i\left( \text{Res}_{z=e^{i\pi/4}}\frac{(-z)^\mu}{z^2-i} +\text{Res}_{z=-e^{i\pi/4}}\frac{(-z)^\mu}{z^2-i} \right)
\end{align}
The residues:
\begin{align}
\text{Res}_{z=e^{i\pi/4}}\frac{(-z)^\mu}{z^2-i}=\frac{1}{2}e^{-i3\mu \pi/4}e^{-i\pi/4}
\end{align}
and:
\begin{align}
\text{Res}_{z=-e^{i\pi/4}}\frac{(-z)^\mu}{z^2-i}=-\frac{1}{2}e^{i\mu \pi/4}e^{-i\pi/4}
\end{align}
Putting this all toghether yields:
\begin{align}
\oint_C \frac{(-z)^\mu}{z^2-i}\,dz=2\pi e^{-i(\mu+1)\pi/4}\sin(\mu\pi/2)
\end{align}
So:
\begin{align}
\int^\infty_0 \frac{x^\mu}{x^2-i}\,dx=i\frac{\pi e^{-i(\mu+1)\pi/4}\sin(\mu\pi/2)}{\sin(\mu\pi)}
\end{align}
Taking the imaginary part:
\begin{align}
\Im \left( \int^\infty_0 \frac{x^\mu}{x^2-i}\,dx\right) = \int^\infty_0 \frac{x^\mu}{x^4+1}\,dx = \pi \frac{\cos[(\mu+1)\pi/4]\sin(\mu\pi/2)}{\sin(\mu\pi)}
\end{align}
Putting $\mu=1/2$ gives us:

\begin{align}
\int^\infty_0 \frac{\sqrt[]{x}}{x^4+1}\,dx=\pi\frac{\sqrt[]{2}}{2}\cos\left(\frac{3\pi}{8}\right)
\end{align}
  This is just the expected result in another form.

