How to show that $ PV \int_{-\infty}^{\infty} \frac{\tan x}{x}dx = \pi$ In a recent question, it was stated in a comment, without proof, that
$$ PV \int_{-\infty}^{\infty} \frac{\tan x}{x}dx = \pi$$
What is the easiest way to prove this? I was able to show that 
$$
PV \int_{-\infty}^{\infty} \frac{\tan x}{x}dx = -PV\int_{-\infty}^{\infty} \frac{1}{x \tan x}dx \\
PV \int_{-\infty}^{\infty} \frac{1}{x \sin x}dx = 0 \\
\int_{-\infty}^{\infty} \frac{\sin x}{x}dx = \pi
$$
but failed to compute the original integral from this.
 A: The
 question is : What would be a right way to define the principal value 
of this integral, knowing that it has infinitely many singularities at 
the points $\frac{\pi}{2}+\pi\Bbb{Z}$ ?  I will propose the following
$$
PV\int_0^\infty\frac{\tan x}{x}dx~\buildrel{\rm def}\over{=}~ 
\lim_{\lambda\to0}\int_0^{\infty}\frac{\sin 
x\cos x}{x(\cos^2 x+\lambda^2)}dx
$$
Next I will show that the limit in this definition does exist and that 
its value   is $\frac{\pi}{2}$.
First, note that the convergence of the integral 
$\int_0^{\infty}\frac{\sin x\cos x}{x(\cos^2 x+\lambda^2)}dx$ is easy to prove 
using integration by parts. Now
$$\eqalign{
\int_0^{\infty}\frac{\sin x\cos x}{x(\cos^2 x+\lambda^2)}dx
&=\frac{1}{2}\lim_{n\to\infty}\int_{-\pi n}^{\pi (n+1)}\frac{\sin 
x\cos x}{x(\cos^2 x+\lambda^2)}dx\cr
&=\frac{1}{2}\lim_{n\to\infty}\sum_{k=-n}^{n}\int_{\pi 
k}^{\pi(k+1)}\frac{\sin x\cos x}{x(\cos^2 x+\lambda^2)}dx\cr
&=\frac{1}{2}\lim_{n\to\infty}\sum_{k=-n}^{n}\int_{0}^{\pi}\frac{\sin
 x\cos x}{(x+ \pi k)(\cos^2 x+\lambda^2)}dx\cr
&=\frac{1}{2}\lim_{n\to\infty}\int_{0}^{ \pi}\left(\sum_{k=-n}^{n}\frac{1}{x+ \pi
 k}\right)
\frac{\sin x\cos x}{ \cos^2x+\lambda^2}dx\cr
&=\frac{1}{2}\lim_{n\to\infty}\int_{0}^{ \pi}U_n(x)
\frac{ \cos^2 x}{ \cos^2x+\lambda^2}dx\cr
}
$$
where
$$
U_n(x)=\tan(x)\left(\sum_{k=-n}^{n}\frac{1}{x+ \pi
 k}\right)
$$
But using the well-known expansion of the cotangent function, it is easy to see that
$\{U_n \}_n$ converges point-wise to $1$, and that this sequence is bounded uniformely on the interval $[0,\pi]$. Thus, we can interchange the signs of integral and limit in the above formula to get
$$
\int_0^{\infty}\frac{\sin x\cos x}{x(\cos^2 x+\lambda^2)}dx
=\frac{1}{2} \int_{0}^{ \pi} 
\frac{ \cos^2 x}{ \cos^2x+\lambda^2}dx
=  \int_{0}^{ \pi/2} 
\frac{ \cos^2 x}{ \cos^2x+\lambda^2}dx
$$
Finally, taking the limit as $\lambda\to0$ we get
$$
PV\int_0^\infty\frac{\tan x}{x}dx~=~ 
\lim_{\lambda\to0}\int_0^{\infty}\frac{\sin 
x\cos x}{x(\cos^2 x+\lambda^2)}dx=\frac{\pi}{2}.
$$
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{\pp\int_{-\infty}^{\infty}{\tan\pars{x} \over x}\,\dd x = \pi:\ {\large ?}}$

$$
\mbox{Note that}\quad
\pp\int_{-\infty}^{\infty}{\tan\pars{x} \over x}\,\dd x
=2\lim_{\epsilon \to 0^{+}}\int_{\epsilon}^{\infty}{\tan\pars{x} \over x}\,\dd x
=2\int_{0}^{\infty}{\tan\pars{x} \over x}\,\dd x\tag{1}
$$

With $\ds{N \in {\mathbb N}}$, let's consider the following integral:
\begin{align}
&\color{#c00000}{\int_{0}^{N\pi}{\tan\pars{x} \over x}\,\dd x}
=\int_{0}^{\pi}{\tan\pars{x} \over x}\,\dd x
+\int_{\pi}^{2\pi}{\tan\pars{x} \over x}\,\dd x + \cdots
+\int_{\pars{N - 1}\pi}^{N\pi}{\tan\pars{x} \over x}\,\dd x
\\[3mm]&=\int_{0}^{\pi}\tan\pars{x}\sum_{n = 0}^{N - 1}{1 \over x + n\pi}\,\dd x
={1 \over \pi}\int_{0}^{\pi}\tan\pars{x}
\color{#00f}{\sum_{n = 0}^{N - 1}{1 \over n + x/\pi}}\,\dd x\tag{2}
\end{align}

\begin{align}
&\color{#00f}{\sum_{n = 0}^{N - 1}{1 \over x + n\pi}}
=\sum_{n = 0}^{\infty}\pars{{1 \over n + x/\pi} - {1 \over n + N + x/\pi}}
=N\sum_{n = 0}^{\infty}{1 \over \pars{n + x/\pi}\pars{n + N + x/\pi}}
\\[3mm]&=N\,{\Psi\pars{x/\pi} - \Psi\pars{N + x/\pi}
\over \pars{x/\pi} - \pars{N + x/\pi}}
=\color{#00f}{\Psi\pars{N + {x \over \pi}} - \Psi\pars{x \over \pi}}\tag{3}
\end{align}
  where $\ds{\Psi\pars{z}}$ is the
  Digamma Function and we used
  A&S table formula ${\bf\mbox{6.3.16}}$.

We replace $\pars{3}$ in $\pars{2}$:
\begin{align}
&\color{#c00000}{\int_{0}^{N\pi}{\tan\pars{x} \over x}\,\dd x}
={1 \over \pi}\int_{0}^{\pi}\tan\pars{x}\bracks{%
\Psi\pars{N + {x \over \pi}} - \Psi\pars{x \over \pi}}\,\dd x
\\[3mm]&=\int_{0}^{1}\tan\pars{\pi x}\bracks{\Psi\pars{N + x} - \Psi\pars{x}}\,\dd x
\\[3mm]&=\int_{-1/2}^{1/2}\bracks{-\cot\pars{\pi x}}\bracks{%
\Psi\pars{N + x + \half} - \Psi\pars{x + \half}}\,\dd x
\\[3mm]&=-\int_{0}^{1/2}\!\!\!\!\!\!\!\cot\pars{\pi x}\bracks{%
\Psi\pars{N + x + \half} - \Psi\pars{x + \half} - \Psi\pars{N - x + \half} + \Psi\pars{-x + \half}}\,\dd x
\end{align}
Hoever ( see A&S table identity ${\bf\mbox{6.3.7}}$ ):
$$
-\Psi\pars{x + \half} + \Psi\pars{-x + \half}
=\pi\cot\pars{\pi\bracks{x + \half}} = -\pi\tan\pars{\pi x}
$$

such that
  \begin{align}
&\color{#c00000}{\int_{0}^{N\pi}{\tan\pars{x} \over x}\,\dd x}
={\pi \over 2}-\
\overbrace{\int_{0}^{1/2}\cot\pars{\pi x}\bracks{%
\Psi\pars{N + x + \half} - \Psi\pars{N - x + \half}}\,\dd x}
^{\ds{\to 0\quad\mbox{when}\quad N \to \infty}} 
\end{align}
  Since ( see A&S table asymptotic expansion ${\bf\mbox{6.3.18}}$ )
  $$
\Psi\pars{z} \sim \ln\pars{z} - {1 \over 2z} - {1 \over 12z^{2}} + \cdots\,,
\qquad \verts{z} \gg 1\,,\quad \verts{{\rm arg}\pars{z}} < \pi
$$
  we'll have $\ds{\int_{0}^{\infty}{\tan\pars{x} \over x}\,\dd x = {\pi \over 2}}$
  and from $\pars{1}$:

$$\color{#00f}{\large%
\pp\int_{-\infty}^{\infty}{\tan\pars{x} \over x}\,\dd x = \pi}
$$
A: I found a solution, but it is not a very satisfying one, because I am not really able to justify applying the below theorem to the non-convergent integral.
Theorem
If $f$ is an odd function with period $a$, then 
$$\int_0^{\infty} \frac{f(x)}{x}dx= \frac{\pi}{a} \int_0^{a/2} \frac {f(x)} {\tan(\pi x / a)} dx
$$
This theorem follows from Frullani's theorem and the power series expansion of $\tan$.
Because $\tan$ is odd and periodic with period $\pi$, the above theorem immediately yields $$\int_0^{\infty} \frac{\tan x}{x}dx = \frac{\pi}{2}$$
If someone knows with a better (i.e. more rigorous) or otherwise interesting solution, I would love to hear it.
A: By Lobachevsky Integral Formula:If $f(x)$ meet $$f(x+\pi)=-f(x)$$
and $$f(-x)=f(x)$$then we have
$$\int_0^\infty f(x)\cdot \frac{\sin x}{x}dx=\int_0^\frac{\pi}{2}f(x)\cos xdx$$
so let $f(x)=\frac{1}{\cos x}$,then
$$PV\int_{-\infty}^\infty\frac{\tan x}{x}=2\int_0^\infty\frac{\tan x}{x}dx=2\int_0^\infty\frac{1}{\cos x}\cdot\frac{\sin x}{x}dx=\int_0^\frac{\pi}{2}\frac{\cos x}{\cos x}dx=2\cdot \frac{\pi}{2}2=\pi$$
A: $$I=\int_{-\infty}^\infty \frac{\tan(x)}{x}dx=\sum_{n=-\infty}^\infty \int_{-\frac{\pi}{2}+n\pi}^{\frac{\pi}{2}+n\pi} \frac{\tan(x)}{x}dx$$
Substitution: $z=x-n\pi$
Note, $\tan(z+n\pi)=\tan(z)$
$$I=\sum_{n=-\infty}^\infty \int_{-\frac{\pi}{2}}^{\frac{\pi}{2}} \frac{\tan(z)}{n\pi+z}dz=\int_{-\frac{\pi}{2}}^{\frac{\pi}{2}} \sum_{n=-\infty}^\infty \frac{\tan(z)}{n\pi+z}dz=\int_{-\frac{\pi}{2}}^{\frac{\pi}{2}} \tan(z)\left(\sum_{n=-\infty}^\infty \frac{1}{n\pi+z}\right)dz$$
Use the series,
$$\sum_{n=-\infty}^\infty \frac{1}{n\pi+z}=\cot(z)$$
So we have,
$$I=\int_{-\frac{\pi}{2}}^{\frac{\pi}{2}} \tan(z)\cot(z)dz=\int_{-\frac{\pi}{2}}^{\frac{\pi}{2}} 1dz=\pi$$
