<s>[INST] Complex part of a contour integration not using contour integration A propos of a user's comment on this question, quoting Feynman to the effect that some integrals are only possible using contour integration, I wonder what the simplest example of such an integral might be. In particular, he spoke of integrals that were the complex part of a solution, divorced from the rest of the solution.
For me, something like 
$$I = \int_0^\infty \frac{\ln x}{x^2+1}dx, $$
seems hard; it falls out as the complex part of contour integration using the residue theorem in the problem,
$$J = \int_0^\infty \frac{(\ln x)^2}{x^2+1}dx  . $$ That is, we can use contour integration to evaluate J and end up with something like
$J + iI = \frac{\pi^3}{8}$ so we conclude $I = 0.$
Perhaps it is hard but I don't know that it can't be done without complex analysis [edit: Robjohn has shown it can be done without complex analysis]. So I would like to see one good example of the sort of thing Feynman might have had in mind.
Here is the original quote: "So Paul puts up this tremendous damn integral he had obtained by starting out with a complex function that he knew the answer to, taking out the real part of it and leaving only the complex part. He had unwrapped it so it was only possible by contour integration!" 
In terms of this quote, do we have an example of what Paul did? 
Thanks. 
 [/INST] A change of variables yields
$$
\begin{align}
\int_0^\infty\frac{\log(x)^2}{1+x^2}\,\mathrm{d}x
&=\int_{-\infty}^\infty\frac{t^2}{1+e^{-2t}}e^-t\,\mathrm{d}t\\
&=2\int_0^\infty\frac{t^2}{1+e^{-2t}}e^{-t}\,\mathrm{d}t\\
&=2\int_{-\infty}^\infty t^2\left(e^{-t}-e^{-3t}+e^{-5t}-e^{-7t}+\dots\right)\,\mathrm{d}t\\
&=4\left(1-\frac{1}{3^3}+\frac{1}{5^3}-\frac{1}{7^3}+\dots\right)\tag{1}
\end{align}
$$
Define
$$
\xi(n)=\sum_{k=0}^\infty(-1)^k\frac{1}{(2k+1)^n}\tag{2}
$$
and consider the generating function of $\xi(n)$ for odd $n$:
$$
\begin{align}
\sum_{n=0}^\infty\sum_{k=0}^\infty(-1)^k\frac{z^{2n+1}}{(2k+1)^{2n+1}}
&=\sum_{k=0}^\infty(-1)^k\frac{\frac{z}{2k+1}}{1-\left(\raise{1pt}{\frac{z}{2k+1}}\right)^2}\\
&=\frac{z}{2}\sum_{k=0}^\infty(-1)^k\left(\frac{1}{z+2k+1}-\frac{1}{z-2k-1}\right)\\
&=\frac{z}{2}\sum_{k=-\infty}^\infty\left(\frac{1}{z+4k+1}-\frac{1}{z+4k-1}\right)\\
&=\frac{z}{8}\sum_{k=-\infty}^\infty\left(\frac{1}{k+\frac{z+1}{4}}-\frac{1}{k+\frac{z-1}{4}}\right)\\
&=\frac{z}{8}\left(\pi\cot\left(\pi\frac{z+1}{4}\right)-\pi\cot\left(\pi\frac{z-1}{4}\right)\right)\\
&=\frac{\pi z}{4}\sec\left(\frac{\pi z}{2}\right)\\
&=\frac{\pi z}{4}+\frac{\pi^3z^3}{32}+\frac{5\pi^5z^5}{1536}+\dots\tag{3}
\end{align}
$$
where we used $(7)$ from this answer.
Putting together $(1)$, $(2)$, and $(3)$ yields
$$
\int_0^\infty\frac{\log(x)^2}{1+x^2}\,\mathrm{d}x=\frac{\pi^3}{8}\tag{4}
$$

Here is another method using contour integration.
In order to define $\log(z)$, consider the path $\gamma$ that runs from $0$ to $\infty$ just north of the real axis, circles the complex plane counter-clockwise, then returns from $\infty$ to $0$ just south of the real axis.
Adding the residues at $z=i$ and $z=-i$ gives
$$
\begin{align}
\int_\gamma\frac{\log(z)^3}{1+z^2}\mathrm{d}z
&=2\pi i\left(\frac{\left(\frac\pi2i\right)^3}{2i}+\frac{\left(\frac{3\pi}2i\right)^3}{-2i}\right)\\
&=\frac{13\pi^4}{4}i\tag{5}
\end{align}
$$
Computing the integral along the real axis yields
$$
\begin{align}
\int_\gamma\frac{\log(z)^3}{1+z^2}\mathrm{d}z
&=\int_0^\infty\frac{\log(x)^3-(\log(x)+2\pi i)^3}{1+x^2}\mathrm{d}x\\
&=\int_0^\infty\frac{-3\log(x)^22\pi i+\color{#C00000}{3\log(x)4\pi^2}+\color{#00A000}{8\pi^3i}}{1+x^2}\mathrm{d}x\\
&=-6\pi i\int_0^\infty\frac{\log(x)^2}{1+x^2}\mathrm{d}x+\color{#C00000}{0}+\color{#00A000}{4\pi^4i}\tag{6}
\end{align}
$$
Equating the real and imaginary parts of $(5)$ and $(6)$ gives
$$
\int_0^\infty\frac{\log(x)}{1+x^2}\mathrm{d}x=0\tag{7}
$$
and
$$
-6\pi i\int_0^\infty\frac{\log(x)^2}{1+x^2}\mathrm{d}x=-\frac{3\pi^4}{4}i\tag{8}
$$
which yields
$$
\int_0^\infty\frac{\log(x)^2}{1+x^2}\mathrm{d}x=\frac{\pi^3}{8}\tag{9}
$$
</s>