# How to evaluate the definite integral $\int _{0}^{\frac{\pi }{2}}\frac{\ln(\tan x)}{1-\tan x+\tan^{2} x}\mathrm{d} x$?

I am struggling with this integral:

$$\displaystyle \int _{0}^{\frac{\pi }{2}}\frac{\ln(\tan x)}{1-\tan x+\tan^{2} x}\mathrm{d} x$$

What I tried so far:

$$\displaystyle \int _{0}^{\frac{\pi }{2}}\frac{\ln(\tan x)}{1-\tan x+\tan^{2} x}\mathrm{d} x$$ $$\displaystyle =\int _{0}^{\frac{\pi }{2}}\frac{\cos^{2} x\ln(\tan x)}{1-\sin x\cos x}\mathrm{d} x$$ $$\displaystyle =\int _{0}^{\frac{\pi }{2}}\frac{-\sin^{2} x\ln(\tan x)}{1-\sin x\cos x}\mathrm{d} x$$ $$\displaystyle =\frac{1}{2}\int _{0}^{\frac{\pi }{2}}\frac{\cos 2x\ln(\tan x)}{1-\sin x\cos x}\mathrm{d} x$$

The answer should come out to be $$\dfrac{-7\pi^2}{72}$$.

Any help will be appreciated.

• For the record, wolfram alpha can't solve the indefinite integral nor can it find an exact form for the definite integral (although it agrees when you ask it if it's $\frac{-7\pi^2}{72}$) Apr 11, 2022 at 1:06
• Seriously, unless someone gives you sufficient incentive, you'd have several better things to do with your time than to worry about this. There are endless calculus questions of similar nature, with no serious mathematical significance. To exaggerate, it's like asking for the product of two 15-digit integers: sure, we know the algorithm, but... no one actually cares about the outcome. The genuine question is about the algorithm, not about the specific answer. Apr 11, 2022 at 1:21
• After making the substitution $u = \tan x$, one can evaluate the integral using a standard trick in contour integration: Evaluate $\int_{\Gamma_\epsilon} \frac{\log^2 u \,dt}{(1 - u + u^2) (1 + u^2)}$ over an appropriate family $\{\Gamma_{\epsilon}\}$ of keyhole contours then take the limit $\epsilon \searrow 0$ and split the result into real and imaginary parts. Apr 11, 2022 at 2:38
• See this excellent solution for an example of applying this method to a similar integral: math.stackexchange.com/a/621665/155629 Apr 11, 2022 at 2:41

Substitute $$t=\tan x$$\begin{align} &\int _{0}^{\frac{\pi }{2}}\frac{\ln(\tan x)}{1-\tan x+\tan^{2} x}\mathrm{d} x \\ =&\int_0^1\frac{\ln t}{(1 - t + t^{2})(1 + t^{2})}dt + \int_1^\infty \frac{\ln t}{(1 - t + t^{2})(1 + t^{2})}\overset{t\to 1/t}{dt}\\ =& \int_0^1\frac{(1-t^2)\ln t}{(1 - t + t^{2})(1 + t^{2})}dt = \int_0^1\frac{2t\ln t}{1 + t^{2}}\>\overset{ibp}{dt} -\int_0^1\frac{(2t-1)\ln t}{1 - t + t^{2}}\>\overset{ibp}{dt}\\ =& \>-\int_0^1 \frac{\ln (1+t^2)}{t}\>\overset{t^2\to t}{dt} +\int_0^1 \frac{\ln (1+t^3)}t \>\overset{t^3\to t}{dt}-\int_0^1 \frac{\ln (1+t)}tdt\\ =& \>-\frac76 \int_0^1 \frac{\ln (1+t)}tdt= -\frac76 \cdot\frac{\pi^2}{12}=-\frac{7\pi^2}{72} \end{align} where $$\int_0^1 \frac{\ln (1+t)}tdt=\frac{\pi^2}{12}$$

• I think you mean $\frac{-7\pi^2}{72}$ on the last step. This is a nice method indeed and works with problems of similar type! Apr 11, 2022 at 3:03
• @Nothingspecial - Right, thanks. I will correct. Apr 11, 2022 at 3:29

Since $$\displaystyle \int _{0}^{\frac{\pi }{2}}\frac{\ln(\tan x)}{1-\tan x+\tan^{2} x}\mathrm{d} x=\int_0^{\infty} \frac{\ln t}{(1-t+t^2)(1+t^2)}dt,$$ consider \begin{aligned} \mathscr{I}(s)&=\int_0^{\infty} \frac{t^s}{(1-t+t^2)(1+t^2)}dt \\&=\int_0^{\infty} \frac{t^{s-1}}{1-t+t^2}dt-\int_0^{\infty} \frac{t^{s-1}}{1+t^2}dt \\&=\int_0^{\infty} \frac{t^{s-1}}{1+t^3}dt+\int_0^{\infty} \frac{t^{s}}{1+t^3}dt-\int_0^{\infty} \frac{t^{s-1}}{1+t^2}dt. \end{aligned} With Beta function, we have $$\int_{0}^{\infty}\frac{t^{s-1}}{1+t^{a}}dt=\frac{\pi \csc(\frac{\pi s}{a})}{a}$$ thus $$\mathscr{I}(s)=\frac{\pi \csc(\frac{\pi s}{3})}{3}+\frac{\pi \csc(\frac{1}{3} \pi (s+1))}{3}-\frac{\pi \csc(\frac{\pi s}{2})}{2}.$$ In conclusion,

\begin{aligned} \int_0^{\frac{\pi}{2}}\frac{\ln \tan x}{1-\tan x+\tan^2 x}dx&=\lim_{s\to 0}\frac{\partial }{\partial s}\mathscr{I}(s) \\&=\lim_{s\to 0}\left(-\frac{\pi^{2} \csc(\frac{\pi s}{3}) \cot(\frac{\pi s}{3})}{9}-\frac{\pi^{2} \csc(\frac{1}{3} \pi s+\frac{1}{3} \pi) \cot(\frac{1}{3} \pi s+\frac{1}{3} \pi)}{9}+\frac{\pi^{2} \csc(\frac{\pi s}{2}) \cot(\frac{\pi s}{2})}{4}\right) \\&=-\frac{7 \pi^{2}}{72} \end{aligned}

\begin{align*} I &= \int_0^\tfrac\pi2 \frac{\ln(\tan x)}{1-\tan x+\tan^{2} x} \, dx \\ &= \int_0^\infty \frac{\ln t}{(1-t+t^2)(1+t^2)} \, dt \tag1 \\ &= \int_0^1 \frac{1-t^2}{(1-t+t^2)(1+t^2)} \ln t \, dt \tag2 \\ &= \int_0^1 \left(\frac{2t}{1+t^2} + \frac{1-t-2t^2}{1+t^3}\right) \ln t \, dt \tag3 \\ &= \sum_{n=0}^\infty (-1)^n \int_0^1 \left(2t^{2n+1} + t^{3n} - t^{3n+1} - 2t^{3n+2}\right) \ln t \, dt \tag4 \\ &= \sum_{n=0}^\infty (-1)^{n+1} \left(\frac2{(2n+2)^2} + \frac1{(3n+1)^2} - \frac1{(3n+2)^2} - \frac2{(3n+3)^2}\right) \tag5 \\ &= \frac5{18} \sum_{n=1}^\infty \frac{(-1)^n}{n^2} + \frac19 \sum_{n=1}^\infty (-1)^n \left(\frac1{\left(n-\frac23\right)^2} - \frac1{\left(n-\frac13\right)^2}\right) \\ &= -\frac{5\pi^2}{216} + \frac1{36} \sum_{k=1}^\infty \left(\frac1{\left(k-\frac13\right)^2} - \frac1{\left(k-\frac16\right)^2} + \frac1{\left(k-\frac23\right)^2} - \frac1{\left(k-\frac56\right)^2}\right) \tag6 \\ &= -\frac{5\pi^2}{216} + \frac1{36} \left[\psi^{(1)}\left(\frac23\right) - \psi^{(1)}\left(\frac56\right) + \psi^{(1)}\left(\frac13\right) - \psi^{(1)}\left(\frac16\right)\right] \tag7 \\ &= -\frac{5\pi^2}{216} + \frac1{36} \left(\frac{4\pi^2}3 - 4\pi^2\right) = \boxed{-\frac{7\pi^2}{72}} \tag8 \end{align*}

• $$(1)$$ : substitute $$t=\tan x$$
• $$(2)$$ : split the integral at $$t=1$$, substitute $$t\mapsto\dfrac1t$$ for $$t\ge1$$, and recombine
• $$(3)$$ : partial fractions; introduce a factor of $$1+t$$ to get a nicer denominator in the second term
• $$(4)$$ : invoke Macluarin series of $$\dfrac1{1-t}$$
• $$(5)$$ : integrate by parts and shift index of summation
• $$(6)$$ : the first sum is well-known; expand the latter summand into cases of even and odd $$n$$
• $$(7)$$ : trigamma function
• $$(8)$$ : trigamma reflection formula,

$$\psi^{(1)}\left(z\right) + \psi^{(1)}\left(1-z\right) = \pi^2 \csc^2\left(\pi z\right)$$