# A strange integral: $\int_{-\infty}^{+\infty} {dx \over 1 + \left(x + \tan x\right)^2} = \pi.$

While browsing on Integral and Series, I found a strange integral posted by @Sangchul Lee. His post doesn't have a response for more than a month, so I decide to post it here. I hope he doesn't mind because the integral looks very interesting to me. I hope for you too. :-)

$$\mbox{How does one prove}\quad \int_{-\infty}^{\infty} {{\rm d}x \over 1 + \left[\,x + \tan\left(\, x\,\right)\,\right]^{2}} = \pi\quad {\large ?}$$

Please don't ask me, I really have no idea how to prove it. I hope users here can find the answer to prove the integral. I'm also interested in knowing any references related to this integral. Thanks in advance.

• Cauchy's integral formula may be the way to go.
– John
Nov 10, 2014 at 19:10
• @John I guess so, but dunno how to use it Nov 10, 2014 at 19:13
• I guess we have to split the integral 'around' the singularities of $\tan(x)$ which leads to an infinite sum... I'm not sure whether it converges... Nov 10, 2014 at 20:27

Here is an approach.

We may use the following result, which goes back to G. Boole (1857) :

$$\int_{-\infty}^{+\infty}f\left(x-\frac{a_1}{x-\lambda_1}-\cdots-\frac{a_n}{x-\lambda_n}\right)\mathrm{d}x=\int_{-\infty}^{+\infty} f(x)\: \mathrm{d}x \tag1$$

with $a_i>0, \lambda_i \in \mathbb{R}$ and $f$ sufficiently 'regular'.

Observe that, for $x\neq n\pi$, $n=0,\pm1,\pm2,\ldots$, we have $$\cot x = \lim_{N\to +\infty} \left(\frac1x+\frac1{x+\pi}+\frac1{x-\pi}+\cdots+\frac1{x+N\pi}+\frac1{x-N\pi}\right)$$ leading to (see Theorem 10.3 p. 14 here and see achille's answer giving a route to prove it)

$$\int_{-\infty}^{+\infty}f\left(x-\cot x\right)\mathrm{d}x=\int_{-\infty}^{+\infty} f(x)\: \mathrm{d}x \tag2$$

with $\displaystyle f(x)=\frac{1}{1+\left(\small{\dfrac\pi2 -x }\right)^2}$.

On the one hand, from $(2)$, \begin{align} \int_{-\infty}^{+\infty}f\left(x-\cot x\right)\mathrm{d}x& =\int_{-\infty}^{+\infty} f(x)\: \mathrm{d}x \\\\ &=\int_{-\infty}^{+\infty}\frac{1}{1+\left(\small{\dfrac\pi2 -x }\right)^2}\: \mathrm{d}x\\\\ &=\int_{-\infty}^{+\infty}\frac{1}{1+x^2}\: \mathrm{d}x\\\\ & =\pi \tag3 \end{align} On the other hand, with the change of variable $x \to \dfrac\pi2 -x$, \begin{align} \int_{-\infty}^{+\infty}\!\!\!f\left(x-\cot x\right)\mathrm{d}x & =\int_{-\infty}^{+\infty} \!\!\!f\left(\dfrac\pi2-x-\tan x\right)\mathrm{d}x \\\\ & =\int_{-\infty}^{+\infty}\frac{1}{1+\left(x+ \tan x \right)^2} \mathrm{d}x \tag4 \end{align} Combining $(3)$ and $(4)$ gives

$$\int_{-\infty}^{+\infty}\frac{1}{1+\left(x+ \tan x \right)^2} \mathrm{d}x=\pi.$$

• Jesus, this is brilliant!! +1 But one question (maybe this is stupid question), like Ron G said, how to prove this one $$\cot x = \lim_{N\to +\infty} \left(\frac1x+\cdots+\frac1{x+N\pi}+\frac1{x-N\pi}\right)$$ Do you have any papers that can support that claim? Nov 11, 2014 at 8:38
• @Venus $$\cot(x)={\Psi(1 - x/\pi) - \Psi(x/\pi) \over \pi} ={1 \over \pi}\,\left(1 - {2x \over \pi}\right)\sum_{n\ =\ 0}^{\infty}{1 \over \left(n + 1 - x/\pi\right)\left(n + x/\pi\right)}$$ Nov 13, 2014 at 19:31
• @Venus Thanks. You may just take the logarithmic derivative of $$\displaystyle \sin x = x \prod_{n=1}^\infty \left( 1 - \frac{x^2}{(n\pi)^2} \right)$$ See here: dlmf.nist.gov/4.22 Nov 13, 2014 at 22:49
• Thanks Oliver & @FelixMarin, very enlightening :-) Nov 14, 2014 at 9:49
• +1, This is exactly how I proved that identity, motivated by @orangekids' answer. And I am glad that finally a reference is available to me! Thank you! Dec 8, 2014 at 23:05

I will derive a sufficient condition on the meromorphic function involved which allow one to apply a result similar to that in Olivier's answer.

Let $\phi(z)$ be any meromorphic function over $\mathbb{C}$ which

1. preserve the extended real line $\mathbb{R}^* = \mathbb{R} \cup \{ \infty \}$ in the sense: $$\begin{cases}\phi(\mathbb{R}) \subset \mathbb{R}^*\\ \phi^{-1}(\mathbb{R}) \subset \mathbb{R}\end{cases} \quad\implies\quad P \stackrel{def}{=} \phi^{-1}(\infty) = \big\{\, p \in \mathbb{C} : p \text{ poles of }\phi(z)\,\big\} \subset \mathbb{R}$$

2. Split $\mathbb{R} \setminus P$ as a countable union of its connected components $\,\bigcup\limits_{n} ( a_n, b_n )\,$. Each connected component is an open interval $(a_n,b_n)$ and on such an interval, $\phi(z)$ increases from $-\infty$ at $a_n^{+}$ to $\infty$ at $b_n^{-}$.

3. There exists an ascending chain of Jordan domains $D_1, D_2, \ldots$ that cover $\mathbb{C}$, $$\{ 0 \} \subset D_1 \subset D_2 \subset \cdots \quad\text{ with }\quad \bigcup_{k=1}^\infty D_k = \mathbb{C}$$ whose boundaries $\partial D_k$ are "well behaved", "diverge" to infinity and $| z - \phi(z)|$ is bounded on the boundaries. More precisely, let $$\begin{cases} R_k &\stackrel{def}{=}& \inf \big\{\, |z| : z \in \partial D_k \,\big\}\\ L_k &\stackrel{def}{=}& \int_{\partial D_k} |dz| < \infty\\ M_k &\stackrel{def}{=}& \sup \big\{\, |z - \phi(z)| : z \in \partial D_k \,\big\} \end{cases} \quad\text{ and }\quad \begin{cases} \lim\limits_{k\to\infty} R_k = \infty\\ \lim\limits_{k\to\infty} \frac{L_k}{R_k^2} = 0\\ M = \sup_k M_k < \infty \end{cases}$$

Given such a meromorphic function $\phi(z)$ and any Lebesgue integrable function $f(x)$ on $\mathbb{R}$, we have following identity: $$\int_{-\infty}^\infty f(\phi(x)) dx = \int_{-\infty}^\infty f(x) dx \tag{*1}$$

In order to prove this, we split our integral into a sum over the connected components of $\mathbb{R} \setminus P$. $$\int_\mathbb{R} f(\phi(x)) dx = \int_{\mathbb{R} \setminus P} f(\phi(x)) dx = \sum_n \int_{a_n}^{b_n} f(\phi(x)) dx$$ For any connected component $( a_n, b_n )$ of $\mathbb{R} \setminus P$ and $y \in \mathbb{R}$, consider the roots of the equation $\phi(x) = y$. Using properties $(1)$ and $(2)$ of $\phi(z)$, we find there is a unique root for the equation $y = \phi(x)$ over $( a_n, b_n )$. Let we call this root as $r_n(y)$. Change variable to $y = \phi(x)$, the integral becomes

$$\sum_n \int_{-\infty}^\infty f(y) \frac{d r_n(y)}{dy} dy = \int_{-\infty}^\infty f(y) \left(\sum_n \frac{d r_n(y)}{dy}\right) dy$$ We can use the obvious fact $\frac{d r_n(y)}{dy} \ge 0$ and dominated convergence theorem to justify the switching of order of summation and integral.

This means to prove $(*1)$, one only need to show $$\sum_n \frac{d r_n(y)}{dy} \stackrel{?}{=} 1\tag{*2}$$

For any $y \in \mathbb{R}$, let $R(y) = \phi^{-1}(y) \subset \mathbb{R}$ be the collection of roots of the equation $\phi(z) = y$.

Over any Jordan domain $D_k$, we have following expansion

$$\frac{\phi'(z)}{\phi(z) - y} = \sum_{r \in R(y) \cap D_k} \frac{1}{z - r} - \sum_{p \in P \cap D_k} \frac{1}{z - p} + \text{something analytic}$$

This leads to $$\sum_{r \in R(y)\cap D_k} r - \sum_{ p \in P \cap D_k} p = \frac{1}{2\pi i}\int_{\partial D_k} z \left(\frac{\phi'(z)}{\phi(z) - y}\right) dz$$

As long as $R(y) \cap \partial D_k = \emptyset$, we can differentiate both sides and get

\begin{align} \sum_{r_n(y) \in D_k} \frac{dr_n(y)}{dy} &= \frac{1}{2\pi i}\int_{\partial D_k} z \left(\frac{\phi'(z)}{(\phi(z) - y)^2}\right) dz = -\frac{1}{2\pi i}\int_{\partial D_k} z \frac{d}{dz}\left(\frac{1}{\phi(z)-y}\right) dz\\ &= \frac{1}{2\pi i}\int_{\partial D_k}\frac{dz}{\phi(z) - y} \end{align} For those $k$ large enough such that $R_k > 2(M+|y|)$, we can expand the integrand in last line as

$$\frac{1}{\phi(z) - y} = \frac{1}{z - (y + z - \phi(z))} = \frac{1}{z} + \sum_{j=1}^\infty \frac{(y + z - \phi(z))^j}{z^{j+1}}$$ and obtain a bound

$$\left|\left(\sum_{r_n(y) \in D_k} \frac{dr_n(y)}{dy} \right) - 1\right| \le \frac{1}{2\pi}\sum_{j=1}^\infty \int_{\partial D_k} \frac{(|y| + |z-\phi(z)|)^j}{|z|^{j+1}} |dz|\\ \le \frac{(M + |y|)L_k}{2\pi R_k^2}\sum_{j=0}^\infty\left(\frac{M+|y|}{R_k}\right)^j \le \frac{M + |y|}{\pi}\frac{L_k}{R_k^2}$$ Since $\lim\limits_{k\to\infty} \frac{L_k}{R_k^2} = 0$, this leads to

$$\sum_n \frac{dr_n(y)}{dy} = \lim_{k\to\infty} \sum_{r_n(y) \in D_k} \frac{dr_n(y)}{dy} = 1$$

This justifies $(*2)$ and hence $(*1)$ is proved. Notice all the $\frac{dr_n(y)}{dy}$ are positive, there is no issue in rearranging the order of summation in last line.

Back to the original problem of evaluating

$$\int_{-\infty}^\infty \frac{1}{1+(x+\tan x)^2} dx$$

One can take $\phi(z)$ as $z + \tan z$ and $f(x)$ as $\frac{1}{1+x^2}$. It is easy to see $\phi(z)$ satisfies:

• Condition $(1)$ - For any $y \in \mathbb{R}$ and $u + iv \in \mathbb{C} \setminus \mathbb{R}$, we have \begin{align} \Im (\phi(u + iv) - y ) &= v + \Im\tan(u+iv) = v + \Im\frac{\tan u + i\tanh v}{1 - i\tan u\tanh v}\\ &= v + \tanh v\frac{1 + \tan^2 u}{1 + \tan^2 u\tanh^2 v} \ne 0 \end{align}

• Condition $(2)$ - obvious.

• Condition $(3)$. - Let $D_k$ to be the square $$D_k = \big\{\, u + v i \in \mathbb{C} : |u|, |v| \le k \pi \,\big\}$$ It is not hard to show $|z - \phi(z)| = |\tan z|$ is bounded above by $\frac{1}{\tanh k\pi}$ on $\partial D_k$.

Combine these, we can apply $(*1)$ and deduce

$$\int_{-\infty}^\infty \frac{1}{1+(x+\tan x)^2} dx = \int_{-\infty}^\infty \frac{1}{1+x^2} dx = \pi$$

• To be honest, I don't understand almost all of your answer, but it looks very cool, so +1. :-) Nov 11, 2014 at 14:21
• as a physicist i really have to get used to this "pure math style" proof, but after doing so i have to say: Really nice work! Nov 11, 2014 at 15:59
• I'm thinking this theorem to solve my homework's problem: math.stackexchange.com/q/1017074/146687 Is it possible? Nov 11, 2014 at 17:05
• @Venus, I don't think so. To apply this theorem, the integrand need to have the form of composition of two function $f \circ \phi$. Furthermore, $\phi(x)$ need to looks like $x +$ something... Nov 11, 2014 at 17:22
• Oh no... I'm in trouble now :-( Nov 11, 2014 at 17:24

The Inverse Function Theorem gives us $$\int_{-\infty}^{+\infty}f(g(x))\,\mathrm{d}x=\int_{-\infty}^{+\infty}\sum_{g(x)=\alpha}\frac1{\left|g'(x)\right|}\,f(\alpha)\,\mathrm{d}\alpha\tag{1}$$ If we integrate along squares, centered at the origin, whose sides are parallel to the $x$ and $y$ axes with length $2k\pi$, as $k\to\infty$, we get \begin{align} \sum_{x+\tan(x)=\alpha}\frac1{1+\sec^2(x)} &=\frac1{2\pi i}\oint\frac{\mathrm{d}z}{z+\tan(z)-\alpha}\\[6pt] &=1\tag{2} \end{align} Letting $g(x)=x+\tan(x)$, $(1)$ and $(2)$ give $$\int_{-\infty}^{+\infty}f(x+\tan(x))\,\mathrm{d}x=\int_{-\infty}^{+\infty}f(x)\,\mathrm{d}x\tag{3}$$ Therefore, applying $(3)$ to $f(x)=\frac1{1+x^2}$ yields \begin{align} \int_{-\infty}^{+\infty}\frac{\mathrm{d}x}{1+(x+\tan(x))^2} &=\int_{-\infty}^{+\infty}\frac{\mathrm{d}x}{1+x^2}\\[6pt] &=\pi\tag{4} \end{align}

• Could you elaborate on the origin of the 1st line? I cannot figure out how to derive it from inverse function theorem. Aug 20, 2017 at 6:58
• Anyway, this is a very ingenious answer. It is interesting to see what happens when $g(x) = x - \tan x$, my method and your method both fail at some point, perhaps that integral does not admit a simple closed form. Aug 20, 2017 at 7:03
• @pisco125: break the real line into pieces where $g(x)$ is monotonic and apply the inverse function theorem on each piece. Each piece gives a term in the sum where $g(x)=\alpha$.
– robjohn
Aug 20, 2017 at 15:49
• @pisco125: Did you have a specific question using $g(x)=x-\tan(x)$? Note that $\frac1{|g'(x)|^2}=\frac1{\tan^2(x)}$. I haven't computed the corresponding sum for the integral, but I think it should be possible. It won't be $1$ in this case.
– robjohn
Aug 20, 2017 at 21:29
• In (1), the corresponding root of $g(x)=\alpha$ has to be real. However, $x-\tan x = \alpha$ in general has two complex roots. When using contour integration to calculate the sum in (2), those complex roots are involved. So the sum in (1) really involves the inverse of $x-\tan x$ to some extend, this complicated the matter. The above problem does not happen for $x+\tan x = \alpha$ because all its root are real. Aug 21, 2017 at 3:31

This integral can also be evaluated by standard residue calculus.

Denote $$f(z)=i- \tan z - z$$, then $$g(z) :=\frac{1}{(z+\tan z)^2+1} = \frac{-1}{f(z)f(-z)}$$ Using the identity: $$\tan(x+yi) = \frac{\sin(2x)}{\cosh(2y)+\cos(2x)} + \frac{\sinh(2y)}{\cosh(2y)+\cos(2x)}i$$ it can be seen that $$f(z) = 0$$ has no root in the lower half plane. Also note that all zeroes of $$f(z)$$ are simple.

Denote roots of $$f$$ by $$z_1,z_2,\cdots$$, they all lie in upper plane, note that $$f(-z_i)=2i$$.

Let $$R_n$$ denote the rectangle with vertices $$-n\pi, n\pi, n\pi (1+i), n\pi (-1+i)$$. $$\tan z$$ is uniformly bounded on $$R_n$$ except the real axis. Denote the inside of the rectangle by $${R_n}'$$. We have $$\int_{R_n} g(z) dz \to I:=\int_{-\infty}^{\infty} \frac{1}{(x+\tan x)^2+1} dx \quad \text{ as }\quad n\to \infty$$

Thus $$\tag{1} I = 2\pi i \lim_{n\to\infty}\left[\sum_{z_n\in R_n'} \frac{-1}{f'(z_n)f(-z_n)} \right] = -\pi i \lim_{n\to\infty}\left[\sum_{z_n\in R_n'} \frac{1}{f'(z_n)} \right]$$

Let $$S_n$$ denote the square with vertices $$n\pi(\pm 1 \pm i)$$. Then $$\int_{S_n} \frac{1}{f(z)} dz = \int_{S_n} \frac{1}{i-\tan z-z} dz = 2\pi i \sum_{z_n\in R_n'} \frac{1}{f'(z_n)}$$

Hence $$\int_{S_n} \left( \frac{1}{i-\tan z -z }+\frac{1}{z} \right) dz = 2\pi i \left[1 + \sum_{z_n\in R_n'} \frac{1}{f'(z_n)}\right]$$ Because $$\tan z$$ is uniformly bounded on $$S_n$$, the integrand in the LHS is of $$O(1/z^2)$$, so it approaches $$0$$ as $$n\to\infty$$. Hence $$\lim_{n\to\infty}\sum_{z_n\in R_n'} \frac{1}{f'(z_n)} = -1$$ plug back in $$(1)$$ gives $$I=\pi$$.

• Could you please elaborate a little more on why the integrand on the last step approaches to $0$ as $n \to \infty$ ? Jun 20, 2021 at 0:20
• @CLBJ_23 Since the integrand is of $O(1/z^2)$, and the length of $4n$, so $$\left|\int_{S_n} \left( \frac{1}{i-\tan z -z }+\frac{1}{z} \right) dz\right| \leq 4n O(\frac{1}{n^2}) \to 0$$ Jun 20, 2021 at 7:33
• First, thanks for taking the time to reply. The part I don't quite get is how from the fact that $\tan z$ is uniformly bounded on $S_n$, we deduce that the LHS is of $O(1/z^2)$ order. Would you mind shed some light here too? Thanks a lot. Jun 21, 2021 at 20:32
• @CLBJ_23 $$\frac{1}{i-\tan z -z }+\frac{1}{z} = \frac{i-\tan z}{z(i-\tan z -z)}$$ note the denominator has degree $2$ in $z$, and $\tan z$ is bounded, so it's $O(1/z^2)$. Jun 21, 2021 at 21:22
• All clear now - much appreciated! Jun 21, 2021 at 21:27