# Evaluate $\int_0^\infty{\frac{\tan x}{x^n}dx}$

For$$PV\int_0^\infty{\frac{\tan x}{x^n}dx}$$ I can prove that it converges when $0<n<2$.
I know the ways to evaluate$$PV\int_0^\infty{\frac{\tan x}{x}dx}=\frac\pi2$$ but both of these 2 ways doesn't work.
First, using contour integration: the path used in evaluating the second integral doesn't fit in with the first one and I can't find a suitable path to the integral.
Second, seperating the integral: I had to calculate $$\sum_{k=0}^{\infty}{\int_0^{\pi /2}{\tan t\left( \frac{1}{\left( k\pi +t \right) ^n}-\frac{1}{\left( \left( k+1 \right) \pi -t \right) ^n} \right) dt}}$$ which is unable to be solved by Mathematica.
I can't go further.

Szeto's computation of a contour integral is not wrong. The true issue is that the contour integral is not exactly the same as the original principal value in general. Here we correct his/her computation and obtain a closed form.

In this answer, I will use $\alpha$ in place of $n$ and save $n$ for other uses.

Step 1. It is conceptually neater to consider the Riemann surface $X$ obtained by joining

$$\color{red}{X^+ = \{ z \in \mathbb{C}\setminus\{0\} : \operatorname{Im}(z) \geq 0 \}} \quad \text{and} \quad \color{blue}{X^- = \{ z \in \mathbb{C}\setminus\{0\} : \operatorname{Im}(z) \leq 0 \}}$$

along the negative real line $(-\infty, 0)$. The resulting surface is almost the same as the punctured plane $\mathbb{C} \setminus \{0\}$ except that there are two copies of $(0, \infty)$, one from $X^+$ and the other from $X^-$. To distinguish them, we write $x + 0^+ i$ when $x \in (0, \infty) \cap X^+$ and $x + 0^- i$ when $x \in (0, \infty) \cap X^-$. This can be visualized as

Then by pasting the complex logarithm on $X^+$ with $\arg \in [0, \pi]$ and the complex logarithm on $X^-$ with $\arg \in [\pi, 2\pi]$, we can create the complex logarithm $\operatorname{Log}$ on $X$ with $\arg \in [0, 2\pi]$. And this is the reason why we want to consider $X$. We also remark that complex analysis is applicable on $X$.

Step 2. For each $n \geq 1$ and $0 < \epsilon \ll 1$ we consider the closed contour $C = C_{n,\epsilon}$ on $X$ specified by the following picture.

Here, the square contour has four corners $\pm n\pi \pm in\pi$ and each circular contour has radius $\epsilon$. Also the marks $\times$ refer to the poles $x_k = (k - \frac{1}{2})\pi$ of $\tan z$ which are all simple. We decompose $C$ into several components.

1. $\Gamma_n$ is the outermost square contour, oriented counter-clockwise (CCW).
2. $\gamma_{\epsilon}$ is the circular contour around $0$, oriented clockwise (CW).
3. $L = L_{n,\epsilon}$ is the union of line segments

$$[\epsilon, z_1 - \epsilon], \quad [x_1 + \epsilon, x_2 - \epsilon], \quad \cdots, \quad [x_{n-1} + \epsilon, x_n - \epsilon], \quad [x_n + \epsilon, n\pi]$$

which are oriented from left to right. To be precise, there are two versions of $L$ depending on which of $X^{\pm}$ is considered. One is $\color{red}{L^+ := L + 0^+ i}$ on $X^+$ and the other is $\color{blue}{L^- := L + 0^- i}$ on $X^-$.

4. $\gamma^{+}_{k,\epsilon} \subset X^+$ denotes the upper-semicircular CW contour of radius $\epsilon$ around $x_k + 0^+ i$.

5. $\gamma^{-}_{k,\epsilon} \subset X^-$ denotes the lower-semicircular CW contour of radius $\epsilon$ around $x_k + 0^- i$.

Then our $C_{n,\epsilon}$ is written as

$$C_{n,\epsilon} = \Gamma_n + \gamma_{\epsilon} + (L^+ + \gamma_{\epsilon,1}^{+} + \cdots + \gamma_{\epsilon,1}^{+}) + (-L^- + \gamma_{\epsilon,1}^{-} + \cdots + \gamma_{\epsilon,1}^{-}).$$

Step 3. We consider the function $f : X \to \mathbb{C}$ defined by

$$f(z) = z^{-\alpha} \tan z$$

where $z^{-\alpha} := \exp(-\alpha \operatorname{Log} z)$. Then the original principal value integral can be written as

$$\mathrm{PV}\int_{0}^{\infty} \frac{\tan x}{x^{\alpha}} \, dx = \lim_{\epsilon \to 0^+} \lim_{n\to\infty} \int_{L_{n,\epsilon}} \frac{\tan x}{x^{\alpha}} \, dx. \tag{1}$$

On the other hand, by the Cauchy integration formula, we obtain

$$\int_{C_{n,\epsilon}} f(z) \, dz = 2\pi i \sum_{k=1}^{n} \text{[residue of f at -(k-\tfrac{1}{2})\pi]} = -\frac{2\pi i}{\pi^{\alpha} e^{\alpha \pi i}} \sum_{k=1}^{n} \frac{1}{(k-\frac{1}{2})^{\alpha}} \tag{2}$$

Now assume for a moment that $\alpha \in (1, 2)$. Then it is not hard to check that

$$\int_{\gamma_{\epsilon}} f(z) \, dz = \mathcal{O}(\epsilon^{2-\alpha}) \quad \text{and} \quad \int_{\Gamma_n} f(z) \, dz = \mathcal{O}(n^{1-\alpha}).$$

Moreover,

\begin{align*} \int_{L^+} f(z) \, dz &= \int_{L} \frac{\tan x}{x^{\alpha}} \, dx, \\ \int_{-L^-} f(z) \, dz &= -\frac{1}{e^{2\pi i \alpha}}\int_{L} \frac{\tan x}{x^{\alpha}} \, dx \end{align*}

and for each $k \geq 1$,

\begin{align*} \lim_{\epsilon \to 0^+} \int_{\gamma_{k,\epsilon}^{+}} f(z) \, dz &= \frac{\pi i}{\pi^{\alpha} (k-\frac{1}{2})^{\alpha}}, \\ \lim_{\epsilon \to 0^+} \int_{\gamma_{k,\epsilon}^{-}} f(z) \, dz &= \frac{\pi i}{\pi^{\alpha} e^{2\pi i \alpha} (k-\frac{1}{2})^{\alpha}}. \end{align*}

Combining altogether, we find that $\text{(2)}$ simplifies to

\begin{align*} \left(1 - e^{-2\pi i \alpha} \right) \int_{L} \frac{\tan x}{x^{\alpha}} \, dx &= -\pi^{1-\alpha} i \left(1 + 2e^{-\alpha \pi i} + e^{-2\pi i \alpha} \right) \sum_{k=1}^{n} \frac{1}{(k-\frac{1}{2})^{\alpha}} \\ &\qquad + \mathcal{O}(n^{1-\alpha}) + \mathcal{O}(\epsilon^{2-\alpha}). \end{align*}

Therefore, letting $n\to\infty$ and $\epsilon \to 0^+$ yields

$$\mathrm{PV}\int_{0}^{\infty} \frac{\tan x}{x^{\alpha}} \, dx = -\pi^{1-\alpha} i \frac{(1 + e^{-\alpha \pi i})^2}{1 - e^{-2\pi i \alpha}} \sum_{k=1}^{\infty} \frac{1}{(k-\frac{1}{2})^{\alpha}},$$

which simplifies to

$$\mathrm{PV}\int_{0}^{\infty} \frac{\tan x}{x^{\alpha}} \, dx = -\pi^{1-\alpha}\cot\left(\frac{\alpha\pi}{2}\right) (2^{\alpha} - 1)\zeta(\alpha). \tag{*}$$

This extends to all of $\operatorname{Re}(\alpha) \in (0, 2)$ by the principle of analytic continuation. For instance, by taking $\alpha \to 1$ we retrieve the value $\frac{\pi}{2}$ as expected. Also the following is the comparison between the numerical integration of the principal value (LHS of $\text{(*)}$) and the closed form (RHS of $\text{(*)}$):

• Thanks you for providing a correct answer as well as responding to my answer. I’m just a high school student and has had no ‘real’ training in complex analysis. I cannot see where I had a mistake with the principal value in my original solution. Could you please point out? Also, it would be great if you could add to your answer to briefly talk about how you derived your final result. Thanks! – Szeto Mar 19 '18 at 9:04
• nice answer (+1)...but i don't exactly see how you get (*). Namely where does the $\cot$ comes from? can you hint me in the right direction, i'm getting a bit rusty with this stuff – tired Mar 19 '18 at 21:19
• @Szeto, The issue here is that the principal value integral is not the ordinary integral. It takes cares of simple poles of $\tan$ at $(k-\frac{1}{2})\pi$ for $k = 1, 2, 3, \cdots$ by excising the $\epsilon$-neighborhood around each pole, integrating $x^{-n}\tan x$ on the resulting excised domain, and then letting $\epsilon \to 0^+$. Comparing this procedure with your contour integral, you can find that you owe extra terms which come from the contour wrapping the poles of $\tan$. Taking account of those contributions corrects your computation. – Sangchul Lee Mar 20 '18 at 9:48
• @tired, I rewrote my answer so that it is mostly self-contained. I hope that this clarifies your question. – Sangchul Lee Mar 20 '18 at 10:29

I found a solution to this problem which is not so rigorous, so I'm not very confident and might delete it if some fatal errors are found.

My solution only applies for $n>1$.

To evaluate $\int^\infty_0\frac{\tan x}{x^n}dx$, we consider the contour integral $$\oint_C\frac{\tan z}{z^n}dz$$ where the branch cut is taken along the positive real axis and a keyhole contour is used. We can decompose $C$ into 4 parts:

(1) Small loop about $0$, expected to approach zero as the loop size tends to zero. This is the part which I'm not certain about.

(2) Straight line integral on the upper real axis $$\int^R_0\frac{\tan t}{t^n}dt$$

(3) Large loop about $0$, which should also vanish as its radius($R$) tends to infinity.

(4)Straight line integral on the lower real axis $$\int^0_R \frac{\tan t}{e^{2\pi ni}t^n}dt$$

There are poles at $\pi(-\frac{1}{2}-k)$ ($k$ is positive integer) of residue $-1$ at each.

By residue theorem, we obtain $$\int^\infty_0\frac{\tan t}{t^n}dt + e^{-2\pi ni}\int^0_\infty \frac{\tan t}{t^n}dt= 2\pi i \sum^\infty_{k=0}\frac{-1}{[{(\frac{\pi}{2}+k\pi)e^{\pi i}]}^n}$$

Thus, $$(1-e^{-2\pi ni})\int^\infty_0 \frac{\tan t}{t^n}dt= 2\pi i \sum^\infty_{k=0}\frac{-1}{[{(\frac{\pi}{2}+k\pi)e^{\pi i}]}^n}$$

After some messy algebra, $$\int^\infty_0 \frac{\tan t}{t^n}dt= -\frac{2^n}{\pi^{n-1}}\csc(n\pi)\sum^\infty_{k=0}\frac{1}{(2k+1)^n}$$ which the sum clearly converges only when $n>1$.

The result makes me think of the Riemann Zeta function, so I conjecture that we might able to extend the region of convergence of the summation by analytic continuation.

Indeed, I believe there are some flaws in my solution, since in no way does the answer approach $\frac{\pi}{2}$ when $n \to 1$.

• By exploiting the symmetry of the "Hurwitz" decomposition of $\tan(z)$ I got that the principal value of $\int_{0}^{+\infty}\frac{\tan x}{x}\,dx$ is exactly $\frac{\pi}{2}$, and $$\text{PV}\int_{0}^{+\infty}\frac{\tan t}{t^\alpha}\,dt$$ cannot be convergent for $\alpha\geq 2$ due to the non-integrable (and non-eliminable through symmetry) singularity at $t=0$. – Jack D'Aurizio Mar 18 '18 at 19:29

By applying $\frac{d}{dz}\log(\cdot)$ to the Weierstrass product for the cosine function we have $$\tan(z) = \sum_{n\geq 0}\frac{8z}{(2n+1)^2 \pi^2-4z^2}=-\sum_{n\geq 0}\left(\frac{1}{z-(2n+1)\frac{\pi}{2}}+\frac{1}{z+(2n+1)\frac{\pi}{2}}\right)$$ uniformly over any compact subset of $\mathbb{C}\setminus\left\{\ldots,-\frac{3\pi}{2},-\frac{\pi}{2},\frac{\pi}{2},\frac{3\pi}{2},\ldots\right\}$. Similarly, $$\cot(z) = \frac{1}{z}+\sum_{n\geq 1}\left(\frac{1}{z-n\pi}+\frac{1}{z+n\pi}\right)$$ uniformly over any compact subset of $\mathbb{C}\setminus\pi\mathbb{Z}$. We may notice that $$\text{PV}\int_{0}^{+\infty}\frac{\tan x}{x}\,dx = \sum_{n\geq 0}\text{PV}\int_{n\pi}^{(n+1)\pi}\frac{\tan x}{x}\,dx=\int_{0}^{\pi/2}\cot(x)\sum_{n\geq 0}\frac{8x}{(2n+1)^2\pi^2-4x^2}\,dx$$ and the RHS clearly equals $\int_{0}^{\pi/2}\cot(x)\tan(x)\,dx = \int_{0}^{\pi/2}1\,dx = \frac{\pi}{2}$. Similarly $$\text{PV}\int_{0}^{+\infty}\frac{\tan x}{x^\alpha}\,dx = \sum_{n\geq 0}\text{PV}\int_{-\pi/2}^{\pi/2}\frac{-\cot x}{\left(x+(2n+1)\frac{\pi}{2}\right)^{\alpha}}\,dx\\=\int_{0}^{\pi/2}\cot(x)\sum_{n\geq 0}\left(\frac{1}{\left((2n+1)\frac{\pi}{2}-x\right)^{\alpha}}-\frac{1}{\left((2n+1)\frac{\pi}{2}+x\right)^{\alpha}}\right)\,dx$$ for any $\alpha\in(0,2)$, but I do not believe this is an elementary integral (even by including the $\Gamma,\psi$ and Bessel functions among the elementary functions) if $\alpha\neq 1$.