<s>[INST] Contour integration getting wrong result. 
By means of contour integration, evaluate
  $$
\int_0^\infty \frac{(\log_e(u))^2}{u^2+1} \, du \, .
$$

When we apply Cauchy Residue theorem, we get $+i$ as a valid pole. 
The residue for this pole is $\frac{(i(\pi)^2)}{8}$. 
The final answer is $2(\pi)i *$ (sum of residues), which gives answer as $\frac{(-(\pi)^3)}{4}$.
Changing limits to $0$ to infinity, we get $\frac{(-(\pi)^3)}{8}$. 
But the answer from other the regular integration is $\frac{(\pi^3)}{8}$.
Why am I getting an extra minus ($-$)?
 [/INST] As far as I can see, you've accurately calculated the integral 
$$\int_{-\infty}^\infty{\frac{\log^2{u}}{u^2+1}du} = -\frac{\pi^3}{4}$$
I suspect the problem comes because you're assuming that 
$$\int_{-\infty}^\infty{\frac{\log^2{u}}{u^2+1} du} = 2 \int_{0}^\infty{\frac{\log^2{u}}{u^2+1}du} $$
This is not true since, for positive $u$, $$\log(-u) = \log(u)+i\pi$$.
Using this, we can get the answer you need by realising that
$$\int_{-\infty}^\infty{\frac{\log^2{u}}{u^2+1}du}  = \int_{0}^\infty{\frac{\log^2{u}}{u^2+1}du} + \int_{0}^\infty{\frac{(\log{u}+i\pi)^2}{u^2+1}du}$$
Expanding, this gives us 
$$2 \int_{0}^\infty{\frac{\log^2{u}}{u^2+1}du} - \pi^2 \int_0^\infty \frac{1}{u^2 + 1}du + 2 \pi i \int_0^\infty \frac{\log u}{u^2 + 1}du = -\frac{\pi^3}{4}$$
Clearly, the RHS is real, and so even without evaluating it you can be sure that the imaginary part of the LHS should integrate out to be zero (you could verify this if you want). Furthermore, the integral
$$\int_0^\infty \frac{1}{u^2 + 1}du  = \frac{\pi}{2}$$
Thus, we have that 
$$2 \int_{0}^\infty{\frac{\log^2{u}}{u^2+1}du} = \frac{\pi^3}{2} -\frac{\pi^3}{4} = \frac{\pi^3}{4}$$
Or in other words,
$$\int_{0}^\infty{\frac{\log^2{u}}{u^2+1}} = \frac{\pi^3}{8}$$
</s>