Limit of an integral (coming from random walks and networks) as $n\to\infty$ I have the following integral on hand $$I_n=\int_{0}^\infty\frac1x\left[1-\left(\frac{x-1}{x+1}\right)^n\left(\frac{x-i}{x+i}\right)^{-n}\right]\ \mathrm dx$$
I am trying to find out what $\lim_{n\to\infty} I_n$ evaluates to.
I have a sneaking suspicion that the limit is infinite (which comes from a heuristic argument based on the fact that a uniform random walk on $\mathbb Z^2$ is recurrent), but I am not sure if this particular integral would diverge.
My heuristics is as follows. I model my lattice $\mathbb Z^2$ as a resistance network $G$, and then look at square sublattices $G_n$ centered at the origin. Then $G=\lim_{n\to\infty} G_n$. Let us look at a unit current flow, such that the voltage at the origin is $V$ and at the boundary is $0$. Then the probability of a random walk starting at the origin 'escaping' to the boundary of $G_n$ before returning to the origin is (by a standard theorem in electric networks) given by $$\mathbb P_0=\frac{r(0)}{R^{(n)}_{eff}}$$
where $r(0)$ is the resistance at $0$ (here it is $1/4$) and $R^{(n)}_{eff}$ is the effective resistance between $0$ and the boundary of $G_n$. Since the random walk in $\mathbb Z^2$ is recurrent, this probability must go to $0$, and thus the effective resistance must diverge (That the effective resistance diverges is shown by the fact that $R_{eff}^{(n)}\ge \sum_{k=0}^{n-1}\frac{1}{2k+1}\to \infty$, which is another method of showing the random walk is recurrent).
If we now just try to evaluate the effective resistance between any 2 points $G$ physically, it quickly becomes a mess. Here's a nice walkthrough of how one goes about doing this. A more thorough mathematical treatment is in Probability on Trees and Networks by Russel Lyon and Yuval Peres, section 4.3. Also see this answer. The takeaway is that the effective resistance between the origin and any point $(m,n)\in\mathbb Z^2$ is given by
$$R_{m,n}=\frac{1}{2\pi}\int_{x=0}^\infty\frac1x\left[1-\left(\frac{x-1}{x+1}\right)^{m+n}\left(\frac{x-i}{x+i}\right)^{m-n}\right]\ \mathrm dx$$
(see equation 14 in the walkthrough). I am looking at this integral with $m=0$, and the constant factors stripped way to get my $I_n$. Since the effective resistance should diverge however I look (this is probably not precise, but that is why I am calling this a heuristic), I am expecting this integral to diverge, but I am not sure to proceed.
Any help is appreciated.
 A: This is an elaboration on Svyatoslav's answer using the notation given there. Note that formula $(2)$ actually holds for both even and odd values of $n$, and hence the following derivation does not depend on the parity of $n$. First, with the change of variables $x=\mathrm{e}^{-t}$, we obtain
\begin{align*} 
I_2 & = 2\log 2 - 2\int_0^1 {\frac{{x^n }}{{1 + x}}\cos \left( {2n\arctan \left( {\frac{{1 - x}}{{1 + x}}} \right)} \right){\rm d}x} 
\\ & = 2\log 2 - 2\int_0^{ + \infty } \frac{{{\rm e}^{ - nt} }}{{{\rm e}^t  + 1}}\cos \left( {n\operatorname{gd}(t)}\right){\rm d}t
\\ & = 2\log 2 - 2\operatorname{Re} \int_0^{ + \infty } {\frac{1}{{{\rm e}^t  + 1}}\exp \left( { - n\left( {t - {\rm i}\operatorname{gd}(t)} \right)} \right){\rm d}t} .
\end{align*}
Here $\operatorname{gd}$ is the Gudermannian function. The same substitution, Frullani's integral and the known formula
$$
H_n  = \psi (n + 1) + \gamma  = \log n + \gamma  + \int_0^{ + \infty } {\left( {\frac{1}{t} - \frac{1}{{{\rm e}^t  - 1}}} \right){\rm e}^{ - nt} {\rm d}t} 
$$
leads to
\begin{align*}
I_1  =  2\log n + 2\gamma  + \log 2
 & + 2\operatorname{Re} \int_0^{ + \infty } {{\rm e}^{ - n(1 - {\rm i})t} \frac{{1 - \exp \left( { - n\left( {{\rm i}t - {\rm i}\operatorname{gd}(t)} \right)} \right)}}{t}{\rm d}t} 
\\ & - 2\operatorname{Re} \int_0^{ + \infty } {\left( {\frac{1}{{{\rm e}^t  - 1}} - \frac{1}{t}} \right)\exp \left( { - n\left( {t - {\rm i}\operatorname{gd}(t)} \right)} \right){\rm d}t} .
\end{align*}
Accordingly,
\begin{align*}
I(n) =  2\log n + 2\gamma  &+ 3\log 2
   + 2\operatorname{Re} \int_0^{ + \infty } {{\rm e}^{ - n(1 - {\rm i})t} \frac{{1 - \exp \left( { - n\left( {{\rm i}t - {\rm i}\operatorname{gd}(t)} \right)} \right)}}{t}{\rm d}t} 
\\ & - 2\operatorname{Re}\int_0^{ + \infty } {\left( {\frac{1}{{{\rm e}^t  + 1}} + \frac{1}{{{\rm e}^t  - 1}} - \frac{1}{t}} \right)\exp \left( { - n\left( {t - {\rm i}\operatorname{gd}(t)} \right)} \right){\rm d}t} .
\end{align*}
Looking at Svyatoslav's answer, we see that the leading order behaviour of $I(n)$ has been extracted out and the two integrals are $o(1)$ for large $n$. Now in the first integral, we make the substitution $t=s/n$ and expand the second factor (the fraction) of the integrand about $s=0$. Integrating term by term then yields
\begin{multline*}\tag{$\star$}
2\operatorname{Re} \int_0^{ + \infty } {{\rm e}^{ - (1 - {\rm i})s} \frac{{1 - \exp \left( { - {\rm i}s + n{\rm i}\operatorname{gd}(s/n)} \right)}}{s}{\rm d}s} 
  \\ \sim - \frac{1}{{6n^2 }} - \frac{1}{{4n^4 }} - \frac{{169}}{{126n^6 }} - \frac{{1145}}{{72n^8 }} -  \ldots 
\end{multline*}
as $n\to +\infty$. For the second integral, we apply Laplace's method:
\begin{multline*}
 - 2\operatorname{Re} \int_0^{ + \infty } {\left( {\frac{1}{{{\rm e}^t  + 1}} + \frac{1}{{{\rm e}^t  - 1}} - \frac{1}{t}} \right)\exp \left( { - n\left( {t - {\rm i}\operatorname{gd}(t)} \right)} \right){\rm d}t} 
\\  \sim \sum\limits_{k = 2}^\infty  {\frac{{a_k }}{{n^{2k} }}}  =  - \frac{{13}}{{120n^4 }} - \frac{{13}}{{24n^6 }} - \frac{{19381}}{{2880n^8 }} -  \ldots 
\end{multline*}
as $n\to +\infty$, where
$$
a_k  =  - 2\operatorname{Re} \frac{{{\rm d}^{2k - 1} }}{{{\rm d}t^{2k - 1} }}\left[ {\left( {\frac{1}{{{\rm e}^t  + 1}} + \frac{1}{{{\rm e}^t  - 1}} - \frac{1}{t}} \right)\left( {\frac{{ t}}{{t - {\rm i}\operatorname{gd}(t)}}} \right)^{2k} } \right]_{t = 0} .
$$
Thus, in summary,
$$\boxed{
I(n) \sim 2\log n + 2\gamma  + 3\log 2 - \frac{1}{{6n^2 }} - \frac{{43}}{{120n^4 }} - \frac{{949}}{{504n^6 }} - \frac{{21727}}{{960n^8 }} -  \ldots\, }
$$
as $n\to+\infty$.
Remark. With some work, it can be shown that the coefficient $b_k$ of $n^{-2k}$ in the expansion $(\star)$ is
$$
b_k= - \frac{2}{k!}\operatorname{Re} \int_0^{ + \infty } {{\rm e}^{ - (1 - {\rm i})s} s^{2k - 1} B_k\! \left( {{\rm i}\frac{{1!}}{{3!}}E_2 s, \ldots ,{\rm i}\frac{{k!}}{{(2k + 1)!}}E_{2k} s} \right){\rm d}s} 
$$
where $B_k$ denotes the complete exponential Bell polynomial and $E_k$ are the Euler numbers.
A: The integral is real and by means of the substitution $t=\frac{1}{x}$ can be presented in the form
$$I(n)=\int_0^\infty\frac{dx}{x}\bigg(1-(-1)^n\Big(\frac{x-1}{x+1}\Big)^n\cos(2n\arctan x)\bigg)$$
The integral converges for both even and odd $n$; for the convenience we will consider the first case (even $n$):
$$I(n)=\int_0^\infty\frac{dx}{x}\bigg(1-\Big(\frac{x-1}{x+1}\Big)^n\cos(2n\arctan x)\bigg)\tag{1}$$
Splitting the interval of integration $[0;1];[1;\infty)$ and making the substitution $t=\frac{1}{x}$ in the second part, also using $\cos(2n\arctan \frac{1}{t})=\cos(2n\arctan t)$ for even $n$,
$$I(n)=2\int_0^1\frac{dt}{t}\bigg(1-\Big(\frac{1-t}{1+t}\Big)^n\cos(2n\arctan t)\bigg)\tag{2}$$
Making the substitution $\displaystyle x=\frac{1-t}{1+t}$
$$I(n)=2\int_0^1\Big(\frac{1}{1-x}+\frac{1}{1+x}\Big)\Big(1-x^n\cos(2n\arctan\frac{1-x}{1+x})\Big)dx=I_1+I_2\tag{3}$$
where
$$I_2=2\int_0^1\frac{1}{1+x}\Big(1-x^n\cos(2n\arctan\frac{1-x}{1+x})\Big)dx=2\ln 2+O\Big(\frac{1}{n}\Big)\tag{4}$$
because
$$\Big|\int_0^1\frac{x^n}{1+x}\cos(2n\arctan\frac{1-x}{1+x})dx\Big|<\int_0^1\frac{x^n}{1+x}dx=O\Big(\frac{1}{n}\Big)$$
To evaluate $I_1$, we present it in the form ($H_n$ denotes the n-th harmonic number)
$$I_1=2\int_0^1\frac{1-x^n}{1-x}dx+2\int_0^1\frac{x^n}{1-x}\Big(1-\cos(2n\arctan\frac{1-x}{1+x})dx\Big)$$
$$=2H_n+4\int_0^1\frac{x^n}{1-x}\sin^2(n\arctan\frac{1-x}{1+x})dx$$
At $n\to\infty$ the second term contributes only in the narrow region near $x=1$, and with the accuracy up to vanishing terms we can write
$$I_1\sim 2H_n+4\int_0^1\frac{x^n}{1-x}\sin^2(n\frac{1-x}{1+x})dx$$
Making the change $t=1-x$,
$$I_1\sim 2H_n+4\int_0^1 \frac{(1-t)^n}{t}\sin^2\frac{nt}{2}dt\sim 2H_n+2\int_0^1 \frac{e^{-nt}}{t}\big(1-\cos (nt)\big)dt$$
Making the substitution $x=nt$, expanding integration to $\infty$ and using the Frullani integral
$$I_1\sim 2H_n+2\Re\int_0^\infty\frac{e^{-x}-e^{-x+ix}}{x}dx=2H_n+2\Re\ln(1-i)=2H_n+\ln2$$
Using the asymptotic $\displaystyle H_n=\ln n+\gamma+O\Big(\frac{1}{n}\Big)$
$$I_1=2\ln n+2\gamma+\ln2+O\Big(\frac{1}{n}\Big)\tag{5}$$
Putting (4) and (5) in (3),
$$\boxed{\,\,I(n)=2\ln n+2\gamma+3\ln2+O\Big(\frac{1}{n}\Big)\sim 2\ln n\,+\, 3.233872... \,\,}$$
$\bf{Appendix}$
Heuristic consideration - quick evaluation of the leading term.
The integral is real and by means of the substitution $t=\frac{1}{x}$ can be presented in the form
$$I(n)=\int_0^\infty\frac{dx}{x}\bigg(1-(-1)^n\Big(\frac{x-1}{x+1}\Big)^n\cos(2n\arctan x)\bigg)$$
The integral converges for both even and odd $n$; for the convenience we consider the first case (even $n$):
$$I(n)=\int_0^\infty\frac{dx}{x}\bigg(1-\Big(\frac{x-1}{x+1}\Big)^n\cos(2n\arctan x)\bigg)\tag{a}$$
At $ x<\frac{1}{n}$ we choose some $\alpha<1$;
$$ I_1(n)\sim\int_0^\frac{\alpha}{n}\frac{dx}{x}\bigg(1-\Big(\frac{1-x}{1+x}\Big)^n\cos(2n\arctan x)\bigg)\sim\int_0^\frac{\alpha}{n}\frac{dx}{x}\Big(1-(1-2nx)\cos(2nx)\Big)$$
Keeping only the main term
$$I_1(n)\sim \int_0^\frac{\alpha}{n}2n\,dx=2n\frac{\alpha}{n}=2\alpha$$
We see that the main term does not depends on $n$ and has some constant value at $x\to 0$. In the similar way we can evaluate the integral at $x\to\infty\,(x\in [\beta n;\infty), \beta>1)$ and get a constant as a main term as well.
Evaluating the remaining part of the integral, we can drop the second term in (a).
At $x\in[\frac{\alpha}{n};\beta n]$
$$I_3(n)\sim\int_{\frac{\alpha}{n}}^{\beta n}\frac{dx}{x}=\ln(\alpha\beta n^2)=const+2\ln n$$
If we change $\alpha, \beta$, we get only an additional constant term; therefore, the main term is $2\ln n$, and we can conclude that
$$I(n)=a+b\ln n=a+2\ln n$$
In fact I found that $b=2$ and $a\approx3.234$ from a couple of numeric evaluations (please see the comment and evaluations by @KStarGamer; I also checked $I(n)$ for $n=30, 40, 50$)
