<s>[INST] Principal value of integral What is the principal value of the integral $$\int \limits _0^\infty \left( \frac {1}{x^2}-\frac{\cot(x)}{x} \right) dx ?$$ Maple finds $PV \int_0^\infty \tan(x)/x  dx = \pi/2.$ Such integrals arise in physics. I unsuccessfully asked it in SE.
 [/INST] Yes the value $\pi/2$ can be obtained like this.
Let
$$
f(x):=\frac {1}{x^2}-\frac{\cot(x)}{x}
$$
We may compute
$$
\int_0^{\pi/2} f(x)\;dx + \sum_{k=1}^\infty \int_0^{\pi/2}\big(f(k\pi+x)+f(k\pi-x)\big)\;dx=\frac{\pi}{2}
\tag{1}$$
and this converges.  
We can think of (1) as a "rearrangement" of the required integral.  But the integrands in (1) are positive:  Use $\cot x > 0$ for $0 < x < \pi/2$ and $\cot(k\pi+x) = \cot x$ and $\cot(k\pi-x) = -\cot x$.  Also $(1/x) - \cot x$ increases from $0$ on $(0,\pi/2)$, so $f(x) >0$ on $(0,\pi/2)$.  Next
$$
f(k\pi+x)+f(k\pi-x) = \left(\frac{1}{(k\pi+x)^2}+\frac{1}{(k\pi-x)^2}\right) + \left(\frac{-1}{k\pi+x}+\frac{1}{k\pi-x}\right)\cot x
$$
and each of the two halves is positive on $(0,\pi/2)$.  Recall
$$
\sum_{k=1}^\infty \left(\frac{1}{(k\pi+x)^2}+\frac{1}{(k\pi-x)^2}\right) = \csc^2 x - \frac{1}{x^2}
$$
$$
\sum_{k=1}^\infty\left(\frac{-1}{k\pi+x}+\frac{1}{k\pi-x}\right)=\frac{1}{x}-\cot x
$$
$$
\sum_{k=1}^\infty\left(\frac{-1}{k\pi+x}+\frac{1}{k\pi-x}\right)\cot x=\frac{\cot x}{x}-\cot^2 x
$$
Our answer is the sum of three integrals:
$$
\int_0^{\pi/2} \left[\left(\frac{1}{x^2}-\frac{\cot x}{x}\right)+\left(\csc^2 x-\frac{1}{x^2}\right)+\left(\frac{\cot x}{x}-\cot^2 x\right)\right]dx = \int_0^{\pi/2} 1\;dx = \frac{\pi}{2}
$$
</s>