Not getting $-\frac{\pi}{4}$ for my integral. Help with algebra Evaluate $$\int_0^\infty \dfrac {\log{x}}{(x^2+1)^2}dx$$
I've been working on this problem for half the day. I'm not getting anywhere.
1) I first changed the integral from negative infinity to positive infinity
2) Then I'm using the fact that 
$\int_{-\infty}^\infty \dfrac {P(x)}{Q(x)}dx = 2\pi i $ $\sum$ {residues of $P/Q$ in upper half plane} 
3) I'm calculating residues in the upper half plane which are x=+i
4) After I calculate residue and multiply by $2\pi i$, I do not get the answer -$\pi/4$
5) I'm under the impression I have to convert $logx$ to something else.
Any help will be appreciated. Thank you
 A: This is not the usual contour integral with simple poles.  The log term has a branch point at zero and must be treated with care.  The usual way to treat integrals with such branch points is to use something called a keyhole contour, which goes up and back a branch cut (here, the positive real axis) and makes use of the multivaluedness of the integrand.

In general, the way to attack integrals such as the one you have is to exploit the multivaluedness of the log to extract the integral from $[0,\infty)$ in terms of residues of the integrand.  In this case, however, there is already a log in the integrand, so we need to add another factor of log to extract the desired integral.  To wit, consider
$$\oint_C dz \frac{\log^2{z}}{(z^2+1)^2}$$
where $C$ is the keyhole contour illustrated above.  This integral is equal to the integral over the four segments of $C$:
$$\oint_C dz \frac{\log^2{z}}{(z^2+1)^2} = \left [\int_{C_+} + \int_{C_R} + \int_{C_-} + \int_{C_{\epsilon}} \right] dz \frac{\log^2{z}}{(z^2+1)^2}$$
The integrals over $C_R$ and $C_{\epsilon}$ vanish as $R \to \infty$ and $\epsilon \to 0$, respectively:
$$\int_{C_R} dz \frac{\log^2{z}}{(z^2+1)^2} = i R \int_0^{2 \pi} d\phi\, e^{i \phi} \frac{\log^2{(R e^{i \phi})}}{(1+R^2 e^{i 2 \phi})^2} \sim \frac{\log^2{R}}{R^3} \quad (R \to \infty)$$
$$\int_{C_{\epsilon}} dz \frac{\log^2{z}}{(z^2+1)^2} = i \epsilon \int_{2 \pi}^0 d\phi e^{i \phi} \frac{\log^2{(\epsilon e^{i \phi})}}{(1+\epsilon^2 e^{i 2 \phi})^2} \sim \epsilon \, \log^2{\epsilon} \quad (\epsilon \to 0) $$
This leaves the integrals up and down the real axis, $C_+$ and $C_-$, respectively. The integral over $C_+$ is simply the usual integral over the $x$ axis:
$$\int_{C_+} dz \frac{\log^2{z}}{(z^2+1)^2} = \int_0^{\infty} dx \frac{\log^2{x}}{(x^2+1)^2}$$
(I am assuming that the above limits have been taken.)  The integral over $C_-$, however, reflects the fact that $z$ has advanced in argument by $2 \pi$.  Normally, with single-valued functions, this doesn't matter. With multi-valued functions, however, this is crucial, as $\log{(x\,e^{i 2 \pi})} = \log{x} + i 2 \pi$.  Thus we have
$$\int_{C_-} dz \frac{\log^2{z}}{(z^2+1)^2} = \int_{\infty}^0 dx \frac{(\log{x}+i 2 \pi)^2}{(x^2+1)^2}$$
Putting this altogether:
$$\begin{align}\oint_C dz \frac{\log^2{z}}{(z^2+1)^2} &= \int_0^{\infty} dx \frac{\log^2{x}}{(x^2+1)^2} - \int_0^{\infty} dx \frac{(\log{x}+i 2 \pi)^2}{(x^2+1)^2}\\ &= -i 4 \pi \int_0^{\infty} dx \frac{\log{x}}{(x^2+1)^2} + 4 \pi^2 \int_0^{\infty} dx \frac{1}{(x^2+1)^2} \end{align}$$
This is equal to $i 2 \pi$ times the sum of the residues of the poles of the integrand.  The poles are at $z = \pm i$ and are double poles.  Because these are double poles, the sum of the residues is given by
$$\begin{align}\lim_{z \to i} \frac{d}{dz}\left [ (z-i)^2 \frac{\log^2{z}}{(z^2+1)^2} \right ] \\+ \lim_{z \to -i} \frac{d}{dz}\left [ (z+i)^2 \frac{\log^2{z}}{(z^2+1)^2} \right ]\\ &= \frac{d}{dz}\left [\frac{\log^2{z}}{(z+i)^2} \right]_{z=i}+\frac{d}{dz}\left [\frac{\log^2{z}}{(z-i)^2} \right]_{z=-i}\\ &= \left [ \frac{2 \log (z)}{z (z+i)^2}-\frac{2 \log ^2(z)}{(z+i)^3} \right]_{z=i} + \left [ \frac{2 \log (z)}{z (z-i)^2}-\frac{2 \log ^2(z)}{(z-i)^3} \right]_{z=-i}\\ &= \frac{i\pi}{i (-4)} - \frac{2 (-\pi^2/4)}{-8 i} + \frac{i 3\pi}{(-i) (-4)} - \frac{2 (-9 \pi^2/4)}{8 i}\\ &= \frac{\pi}{2} - i \frac{\pi^2}{2}\end{align}$$
In that next-to-last line, I used $\arg{-i} = 3 \pi/2$; this is crucial to get right so we are consistent with how we defined the contour integral.
We may now write
$$-i 4 \pi \int_0^{\infty} dx \frac{\log{x}}{(x^2+1)^2} + 4 \pi^2 \int_0^{\infty} dx \frac{1}{(x^2+1)^2} = i 2 \pi \left (\frac{\pi}{2} - i \frac{\pi^2}{2}\right) = i \pi^2 +\pi^3$$
To finish this off, we need to evaluate the latter integral:
$$\int_0^{\infty} dx \frac{1}{(x^2+1)^2} = \frac12 \int_{-\infty}^{\infty} dx \frac{1}{(x^2+1)^2}$$
In this case, we can simply use a semicircular contour in the upper half-plane; the integral is (details left to reader):
$$i 2 \pi \frac12 \frac{d}{dz}\left [\frac{1}{(z+i)^2} \right ]_{z=i} = i \pi \frac{-2}{(2 i)^3} = \frac{\pi}{4}$$
Thus the integral we seek is
$$\int_0^{\infty} dx \frac{\log{x}}{(x^2+1)^2} = \frac{( i \pi^2 +\pi^3) - 4 \pi^2 (\pi/4)}{-i 4 \pi}$$
or
$$\int_0^{\infty} dx \frac{\log{x}}{(x^2+1)^2} = -\frac{\pi}{4}$$
A: $\newcommand{\+}{^{\dagger}}
 \newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack}
 \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\down}{\downarrow}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\fermi}{\,{\rm f}}
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\isdiv}{\,\left.\right\vert\,}
 \newcommand{\ket}[1]{\left\vert #1\right\rangle}
 \newcommand{\ol}[1]{\overline{#1}}
 \newcommand{\pars}[1]{\left(\, #1 \,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\sech}{\,{\rm sech}}
 \newcommand{\sgn}{\,{\rm sgn}}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}
 \newcommand{\wt}[1]{\widetilde{#1}}$
$\ds{\int_{0}^{\infty}{\ln\pars{x} \over \pars{x^{2} + 1}^{2}}\,\dd x:\ {\large ?}}$

${\large\tt\mbox{Short Solution:}}$
  \begin{align}
&\color{#c00000}{\int_{0}^{\infty}{\ln\pars{x} \over \pars{x^{2} + 1}^{2}}\,\dd x}
=\left.-\,\partiald{}{\mu}\int_{0}^{\infty}{\ln\pars{x} \over x^{2} + \mu}\,\dd x\,
\vphantom{\Huge A^{a}}\right\vert_{\ \mu\ = 1}
\\[3mm]&=-\,\partiald{}{\mu}\bracks{%
\mu^{-1/2}\int_{0}^{\infty}{\ln\pars{\mu^{1/2}x} \over x^{2} + 1}\,\dd x}
_{\ \mu\ = 1}
\\[3mm]&=-\,\partiald{}{\mu}\bracks{%
\half\,\mu^{-1/2}\ln\pars{\mu}\,{\pi \over 2}
+\mu^{-1/2}\ \overbrace{\int_{0}^{\infty}{\ln\pars{x} \over x^{2} + 1}
\,\dd x}^{\ds{=\ 0}}}_{\ \mu\ = 1}
\end{align}
  The vanishing integral can be divided in two integrals over $\pars{0,1}$ and over $\pars{1,+\infty}$: They are of equal magnitude but they have different signs.
  \begin{align}
&\color{#00f}{\large\int_{0}^{\infty}{\ln\pars{x} \over \pars{x^{2} + 1}^{2}}\,\dd x}
=-\,{\pi \over 4}\bracks{-\,\half\,\mu^{-3/2}\ln\pars{\mu} + \mu^{-3/2}}_{\ \mu\ =\ 1} = \color{#00f}{\large\,-{\pi \over 4}} 
\end{align} 

$$
\vphantom{\large a}
$$

${\large\tt\mbox{Long Solution:}}$
  
  With $\ds{t \equiv {1 \over 1 + x^{2}}\quad\imp\quad x = \pars{{1 \over t} - 1}^{1/2}}$:
  \begin{align}
&\color{#c00000}{\int_{0}^{\infty}{\ln\pars{x} \over \pars{x^{2} + 1}^{2}}\,\dd x}
=\lim_{\mu \to 0}\partiald{}{\mu}
\int_{0}^{\infty}{x^{\mu} \over \pars{x^{2} + 1}^{2}}\,\dd x
\\[3mm]&=\lim_{\mu \to 0}\partiald{}{\mu}
\int_{1}^{0}t^{2}\pars{{1 \over t} - 1}^{\mu/2}\,
\bracks{\half\,\pars{{1 \over t} - 1}^{-1/2}\,\pars{-\,{1 \over t^{2}}}\,\dd t}
\\[3mm]&=\half\lim_{\mu \to 0}\partiald{}{\mu}\int_{0}^{1}t^{\pars{1 - \mu}/2}
\pars{1 - t}^{\pars{\mu - 1}/2}\,\dd t
\\[3mm]&=\half\lim_{\mu \to 0}\partiald{}{\mu}\bracks{%
\Gamma\pars{3/2 - \mu/2}\Gamma\pars{\mu/2 + 1/2} \over \Gamma\pars{2}}
\\[3mm]&=\half\lim_{\mu \to 0}\partiald{}{\mu}\bracks{%
\pars{\half - {\mu \over 2}}\Gamma\pars{\half - {\mu \over 2}}
\Gamma\pars{{\mu \over 2} + \half}}
\\[3mm]&=\half\lim_{\mu \to 0}\partiald{}{\mu}\bracks{%
\pars{\half - {\mu \over 2}}\,{\pi \over \sin\pars{\pi\bracks{\mu/2 + 1/2}}}}
\\[3mm]&=\half\,\pi\lim_{\mu \to 0}\partiald{}{\mu}\bracks{%
\pars{\half - {\mu \over 2}}\sec\pars{\pi\mu \over 2}}
\\[3mm]&=\half\,\pi\ \overbrace{\lim_{\mu \to 0}\bracks{%
-\,\half\,\sec\pars{\pi\mu \over 2}
+ \half\pars{\half - {\mu \over 2}}\pi\sec\pars{\pi\mu \over 2}
\tan\pars{\pi\mu \over 2}}}^{\ds{=\ -\,\half}}
\end{align}

$$\color{#00f}{\large%
\int_{0}^{\infty}{\ln\pars{x} \over \pars{x^{2} + 1}^{2}}\,\dd x = -\,{\pi \over 4}}
$$
A: It is an improper integral. You must take the limit $$\lim_{t-> +\infty} \int_{0}^{t}{\frac{logx}{(x^2 + 1)^2}}dx$$
