I want to evaluate the integral $$\mathrm{p.v.}\int_0^1\tan(\pi x)x\,dx$$ with the Cauchy principal value $\mathrm{p.v}$. This integral converges, but just to be sure I also looked at the much simpler integral $$\mathrm{p.v.}\int_0^1\tan(\pi x)x\,dx<\mathrm{p.v.}\int_0^1\frac{x}{\pi}\frac{2}{1-2x}=-\frac{1}{\pi},$$ this confirms the initial integral to be finite (in the Cauchy sense). To find the antiderivative I tried using Leibniz's formula on $$\int\tan(ax)\,dx=-\frac{\ln\lvert\cos(ax)\rvert}{a}$$ to arrive at $$\int\tan(\pi x)x\,dx=\frac{d}{da}\left.\int\tan(ax)\,dx\right|_{a=\pi}=\frac{\ln\lvert \cos(\pi x)\rvert}{\pi^2} + \frac{x \tan(\pi x))}{\pi}.$$ Using the definition of the Cauchy principal value, namely \begin{align} \mathrm{p.v.}\int_0^1\tan(\pi x)x\,dx &=\lim_{\varepsilon\to0^+}\left[\int_0^{\frac{1}{2}-\varepsilon}\tan(\pi x)x\,dx+\int_{\frac{1}{2}+\varepsilon}^1\tan(\pi x)x\,dx\right]\\[5pt] &=\lim_{\varepsilon\to0^+}\left[\frac{\ln\cos\left\lvert\pi (\frac{1}{2}-\varepsilon)\right\rvert}{\pi^2} + \frac{(\frac{1}{2}-\varepsilon) \tan\left(\pi (\frac{1}{2}-\varepsilon)\right)}{\pi}\right.\\[5pt] &\phantom{=\lim_{\varepsilon\to0^+}\left[\right.}\left.-\frac{\ln\cos\left\lvert\pi (\frac{1}{2}+\varepsilon)\right\rvert}{\pi^2} - \frac{(\frac{1}{2}+\varepsilon) \tan\left(\pi (\frac{1}{2}+\varepsilon)\right)}{\pi}\right] \end{align} the limit diverges for $\varepsilon\to0^+$. I then also tried to manipulate the integral to become $$\mathrm{p.v.}\int_0^1\tan(\pi x)x\,dx=\int_0^{\frac{1}{2}}\tan(\pi x)(2x-1)\,dx\approx-0.22063560.$$ The value seems to be right, as I tried to evaluate the integral graphically, but I'd like to have the exact result. The other problem I encountered was that the antiderivative of the right integral also diverges for the upper limit: $$\int_0^{\frac{1}{2}}\tan(\pi x)(2x-1)\,dx=\left[2\left(\frac{\ln\lvert \cos(\pi x)\rvert}{\pi^2} + \frac{x \tan(\pi x))}{\pi}\right)+\frac{\ln\lvert \cos(\pi x)\rvert}{\pi} \right]_0^{\frac{1}{2}}\to\infty.$$ I really don't understand where things went wrong and any help is highly appreciated.
Edit: I forgot to differentiate $\tan(a x)$ -.-, so the antiderivative isn't correct. Therefore my next question would be, if $$\int_0^{\frac{1}{2}}\tan(\pi x)(2x-1)\,dx$$ has a nice result.
Edit2: After consulting computer algebra systems I got a result for the integral: $$\mathrm{p.v.}\int_0^1\tan(\pi x)x\,dx=\int_0^{\frac{1}{2}}\tan(\pi x)(2x-1)\,dx=-\frac{\ln(2)}{\pi}.$$ I don't know how it did the evaluation, but it seems consistent with the numerics.
Edit3: Ok I got it. If we start from $$\int_0^z\pi x\tan(\pi x)\,dx,$$ after recognizing that $\pi\tan(\pi x)=-\frac{d}{dx}\ln\cos(\pi x)$, we can do integration by parts to arrive at $$-z\ln\cos(\pi z)+\int_0^z\ln\cos(\pi x)\,dx.$$ After some manipulations, we can recognize the Clausen function: \begin{align}&-z\ln(2\cos(\pi z))+\int_0^z\ln(2\cos(\pi x))\,dx\\=&-z\ln(2\cos(\pi z))+\frac{1}{2\pi}\int_0^{2\pi z}\ln\left(2\cos\Big(\frac{x}{2}\Big)\right)\,dx\\=&-z\ln(2\cos(\pi z))+\frac{1}{2\pi}\mathrm{Cl}_2(\pi-2\pi z).\end{align} Now going back to the original integral, we have \begin{align}\int_0^{z}\tan(\pi x)(2x-1)\,dx&=2\int_0^{z}\tan(\pi x)x\,dx-\int_0^{z}\tan(\pi x)\,dx\\&=-\frac{2z}{\pi}\ln(2\cos(\pi z))+\frac{1}{\pi^2}\mathrm{Cl}_2(\pi-2\pi z)+\frac{\ln\cos(\pi z)}{\pi},\end{align} which in the limit $z\to\frac{1}{2}$ gives $-\frac{\ln(2)}{\pi}$.