Evaluate $\int_{0}^{\infty} \frac{{(1+x)}^{-n}}{\log^2 x+\pi^2} \ dx, \space n\ge1$ Evaluate the integral
$$\int_{0}^{\infty} \frac{{(1+x)}^{-n}}{\log^2 x+\pi^2} \ dx, \space n\ge1$$
 A: Borrowing from the Norberts answers the integral can be written as:
$$ \frac{1}{\pi}\int\limits_{-\infty}^{+\infty}\frac{e^{\pi t}}{(1+e^{\pi t})^n(1+t^2)}dt = \frac{1}{\pi}\left(\int\limits_{-\infty}^{+\infty}\frac{1}{(1+e^{\pi t})^{n-1}(1+t^2)}dt - \int\limits_{-\infty}^{+\infty}\frac{1}{(1+e^{\pi t})^n(1+t^2)}dt \right)$$
Now it's enough to calculate:
$$
g(n)=\frac{1}{\pi}\int\limits_{-\infty}^{+\infty}\frac{1}{(1+e^{\pi t})^n(1+t^2)}dt
$$
We can use integration by residues to write this as:
$$ f(t) = \frac{(1+e^{\pi t})^{-n}}{(1+t^2)}\\
g(n) = \frac{1}{\pi}\int\limits_{-\infty}^{+\infty}f(t)dt = 2i\sum_{k=0}^\infty\mathrm{Res}(f,i(2k+1))
$$
Then the original integral is: $g(n-1)-g(n)$.
I didn't manage to write this in closed form, but Mathematica is able to solve this for some values of $n$.
The values of the original integral for $n = 1,\ldots,9$:
$$
\frac{1}{2},\frac{1}{12},\frac{1}{24},\frac{19}{720},\frac{3}{160},\frac{863}{60480},\frac{275}{24192},\frac{33953}{3628800},\frac{8183}{\
1036800}
$$
Edit:
OEIS sequence A002208 gives formula for $g(n)$.
$$g(n) = -[x^n]\frac{x}{(1-x)\ln(1-x)} = \frac{(-1)^n}{(n-1)!}\sum_{k=1}^n(-1)^{k+1}B_k\frac{s(n,k)}{k}$$
Where $B_n$ is Bernoulli number and $s(n,k)$ is Stirling number of the first kind.
The original integral is: $$g(n-1)-g(n) = \frac{(-1)^{n}}{(n-1)!}\left(\frac{B_n}{n}+\sum_{k=1}^{n-1}(-1)^kB_k\frac{s(n-1,k-1)}{k}\right)$$
A: This is the case $n=1$:
$$
\begin{align}
\int\limits_{0}^{+\infty}\frac{(1+x)^{-1}}{\log^2 x+\pi^2}dx&\stackrel{x=e^{\pi t}}{=}\frac{1}{\pi}\int\limits_{-\infty}^{+\infty}\frac{e^{\pi t}}{(1+e^{\pi t})(1+t^2)}dt\\
&=\frac{1}{\pi}\left(\int\limits_{-\infty}^{0}\frac{e^{\pi t}}{(1+e^{\pi t})(1+t^2)}dt+\int\limits_{0}^{+\infty}\frac{e^{\pi t}}{(1+e^{\pi t})(1+t^2)}dt\right)\\
&=\frac{1}{\pi}\left(\int\limits_{0}^{+\infty}\frac{e^{-\pi t}}{(1+e^{-\pi t})(1+t^2)}dt+\int\limits_{0}^{+\infty}\frac{e^{\pi t}}{(1+e^{\pi t})(1+t^2)}dt\right)\\
&=\frac{1}{\pi}\left(\int\limits_{0}^{+\infty}\frac{1}{(1+e^{\pi t})(1+t^2)}dt+\int\limits_{0}^{+\infty}\frac{e^{\pi t}}{(1+e^{\pi t})(1+t^2)}dt\right)\\
&=\frac{1}{\pi}\int\limits_{0}^\infty\left(\frac{1}{1+e^{\pi t}}+\frac{e^{\pi t}}{1+e^{\pi t}}\right)\frac{1}{t^2+1}dt\\
&=\frac{1}{\pi}\int\limits_{0}^\infty\frac{1}{t^2+1}dt=\frac{1}{2}
\end{align}
$$
A: This is the same integral as $\frac 1 {2 \pi i} \int_{\mathcal{C}} \frac {d x}{(1+x)^n \ln(-x)}$, where the contour $\mathcal{C}$ starts from infinity, below the positive axis and returns to infinity above the positive axis, after going around zero.  Therefore the answer is given by the residue in $x=-1$ which is the coefficient of $y^{n-1}$ in the series expansion of $\frac 1{\ln(1-y)}$.  Not sure if there's a closed form for that, but I guess there should be.
EDIT: Here's the reasoning in more detail.  First, if $x>0$ then $\ln (-x \pm 0 i) = \ln x \pm \pi i$.  Therefore,
$$
  \frac 1 {\ln(x)^2 + \pi^2} = \frac 1 {2 \pi i} \left(\frac 1 {\ln(x)-\pi i} - \frac 1 {\ln(x) + \pi i}\right),
$$ where in the RHS we have the difference between the value of the function $\frac 1 {\ln(-x)}$ above and below the real axis.

Now consider the contour $\mathcal{C}$ shown above in red.  When integrating along the part under the positive real axis and above the real axis we end up with the discontinuity across the branch cut.  The part at infinity vanishes if $n \geq 1$.  Therefore,
$$
  \frac 1 {2 \pi i} \int_{\mathcal{C}} \frac {d x}{(1+x)^n \ln(-x)} = \frac 1 {2 \pi i} \int_0^\infty \frac {d x}{(1+x)^n} \left(\frac 1 {\ln(-(x+0 i))}-\frac 1 {\ln(-(x-0 i))}\right)= \int_0^\infty \frac {d x}{(1+x)^n (\ln(x)^2 + \pi^2)}.
$$
Now we should compute the contour integral.  We only have on pole at $x=-1$ so we need to compute its residue:
$$
  \operatorname{Res}\left(\frac 1{(1+x)^n \ln(-x)},x=-1\right) = \operatorname{Res}\left(\frac 1{y^n \ln(1-y)},y=0\right),
$$ which is the same as the coefficient of $y^{n-1}$ in the expansion of $\frac 1 {\ln(1-y)}$, which is often denoted as $[y^{n-1}] \frac 1 {\ln(1-y)}$.
The expansion of $\frac 1 {\ln(1-y)}$ around $y=0$ is easy to find by computer.  I find
$$
\frac 1 {\ln(1-y)} = -\frac{1}{y}+\frac{1}{2}+\frac{y}{12}+\frac{y^2}{24}+\frac{19
    y^3}{720}+\frac{3 y^4}{160}+\frac{863 y^5}{60480}+\frac{275
    y^6}{24192}+\frac{33953 y^7}{3628800}+\frac{8183
    y^8}{1036800}+O\left(y^9\right),
$$ but I can't find a closed form for the $n-1$-th coefficient.
EDIT2:
We want to find the coefficient of $y^k$ in the expansion of $\frac 1 {\ln(1-y)}$.  Using Lagrange inversion formula we have that
$$
  k [y^k] \left(\frac 1 {\ln(1-y)}\right) = -[y] (1-e^y)^{-k} = (-1)^{k+1} [y^{k+1}]\left(\frac y {e^y-1}\right)^k.
$$
Now, using the generating function for Stirling polynomials,
$$
  \left(\frac y {e^y-1}\right)^k = \sum_{p=0}^\infty (-1)^p \frac {S_p(k-1)}{p!} t^p,
$$ where $S_p(x)$ are the Stirling polynomials, we have that
$$
  [y^k] \left(\frac 1 {\ln(1-y)}\right)  = \frac {S_{k+1}(k-1)} {k (k+1)!}.
$$
When evaluated at integer coefficients $m>n$, the Stirling polynomial $S_n(m)$ can be expressed in terms of Stirling numbers of first kind, but here we are not in that situation...
Edit3: Thanks to a comment below I found out the rational numbers which appear as the result of the integral are called Gregory coefficients (see here for more details and properties).
