How evaluate $ \int_0^\infty \frac{\ln^2\;\left|\;\tan\left(\frac{ax}{2}-\frac{\pi}{4}\right)\;\right|}{1+x^2} \;dx$

Using OP's series expansion, we have

\begin{align*} I &= 2 \sum_{m, n \geq 0} \frac{(-1)^{m+n}}{(2m+1)(2n+1)} \int_{0}^{\infty} \frac{\sin[(2m+1)ax]\sin[(2n+1)ax]}{1+x^2} \, dx \\ &= \pi \sum_{m, n \geq 0} \frac{(-1)^{m+n}}{(2m+1)(2n+1)} \left( e^{-a|2m-2n|} - e^{-a(2m+2n+2)} \right). \end{align*}

We will split the sum into several parts and analyze them separately.

  • It is straightforward that

    $$ \sum_{m, n \geq 0} \frac{(-1)^{m+n}}{(2m+1)(2n+1)} e^{-a(2m+2n+2)} = \arctan^2(e^{-a}). $$

  • Using the identity $\frac{1}{(2m+1)(2n+1)} = \frac{1}{(2m-2n)(2n+1)} + \frac{1}{(2n-2m)(2m+1)}$, we have

    \begin{align*} \sum_{m, n \geq 0} \frac{(-1)^{m+n}}{(2m+1)(2n+1)} e^{-a|2m-2n|} &= \sum_{m = 0} \frac{1}{(2m+1)^2} + \sum_{\substack{m, n \geq 0 \\ m \neq n }} \frac{(-1)^{m-n}}{(m-n)(2n+1)} e^{-a|2m-2n|} \\ &= \frac{\pi^2}{8} + \sum_{n \geq 0} \frac{1}{2n+1} \sum_{\substack{k \geq -n \\ k \neq 0}} \frac{(-1)^k}{k} e^{-2a|k|}. \end{align*}

  • The last sum can be simplified further: using the fact that $\frac{(-1)^k}{k}e^{-2a|k|}$ is an odd function of $k$,

    \begin{align*} \sum_{n \geq 0} \frac{1}{2n+1} \sum_{\substack{k \geq -n \\ k \neq 0}} \frac{(-1)^k}{k} e^{-2a|k|} &= \sum_{n \geq 0} \frac{1}{2n+1} \sum_{k = n+1}^{\infty} \frac{(-1)^k}{k} e^{-2a|k|} \\ &= \sum_{k = 1}^{\infty} \left( \sum_{n=0}^{k-1} \frac{1}{2n+1} \right) \frac{(-1)^k}{k} e^{-2a|k|}. \end{align*}

    Symmetrizing the inner sum, we find that

    \begin{align*} \sum_{n=0}^{k-1} \frac{1}{2n+1} = \frac{1}{2} \sum_{\substack{i, j \geq 0 \\ i+j = k-1}} \left( \frac{1}{2i+1} + \frac{1}{2j+1} \right) = \sum_{\substack{i, j \geq 0 \\ i+j = k-1}} \frac{k}{(2i+1)(2j+1)}. \end{align*}

    Plugging this back,

    \begin{align*} \sum_{n \geq 0} \frac{1}{2n+1} \sum_{\substack{k \geq -n \\ k \neq 0}} \frac{(-1)^k}{k} e^{-2a|k|} &= \sum_{i, j \geq 0} \frac{1}{(2i+1)(2j+1)} (-1)^{i+j+1} e^{-a(2i+2j+2)} \\ &= - \arctan^2(e^{-a}). \end{align*}

Combining altogether, we obtain the desired answer.


part(1) $$first\ part\\ I=\int_{0}^{\infty }\frac{ln^2(tan(\frac{ax}{2}-\frac{\pi }{4}))}{x^2+1}dx=\int_{0}^{\infty }\frac{ln^2(cot(\frac{ax}{2}-\frac{\pi }{4}))}{x^2+1}dx\\ \\ we\ have\ ln^2(cot(\frac{ax}{2}-\frac{\pi }{4})=-2\sum_{n,m=1}^{\infty }(-1)^{m+n}\frac{sin(2m-1)ax.sin(2n-1)ax}{(2m-1)(2n-1))}\\ \\ =2\sum_{n,m=1}^{\infty }\frac{(-1)^{m+n}[cos(2m-2n)ax-cos(2m+2nax))]}{(2m-1)(2n-1)}\\ \\ \therefore I=\frac{\pi }{2}\sum_{m,n=1}^{\infty }\frac{(-1)^{m+n}}{(2m-1)(2n-1)}[e^{-2a(2m-2n)}-e^{-2a(2m+2n-2)}]\\ \\ note\ \sum_{m,n=1}^{\infty }\frac{(-1)^{m+n}}{(2m-1)(2n-1)}e^{-2a(2n+2m-2)}\\ \\ =\sum_{m=1}^{\infty }\frac{(-1)^{m-1}}{(2m-1)}e^{-2a(2m-1)}.\sum_{n=1}^{\infty }\frac{(-1)^{n-1}}{(2n-1)}e^{-2a(2n-1)}=arctan^2(e^{-2a})$$

second part $$second\ part \\ \because \sum_{m,n=1}^{\infty }\frac{(-1)^{m+n}}{(2m-1)(2n-1)}e^{-2a(2m-2n)}=\sum_{n=1}^{\infty }\frac{1}{(2n-1)^2}+\sum_{n,m=1}^{\infty }\frac{(-1)^{m-n}}{(2m-1)(2n-1)}e^{-2a(2m-2n)}\\ \\ =\frac{\pi ^{3}}{8}+\sum_{m,n=1}^{\infty }\frac{(-1)^{m-n}}{(m-n)(2n-1)}e^{-2a(2m-2n)}=\frac{\pi ^{3}}{8}+\sum_{n>=1}^{\infty }\frac{1}{(2n-1)}.\sum_{n,m>=1}^{\infty }\frac{(-1)^{m-n}}{(m-n)}e^{-2a|2m-2a}\\ \\ =\frac{\pi ^{3}}{8}+\sum_{n=1}^{\infty }\frac{1}{2n-1}.\sum_{k=n}^{\infty }e^{-4a|k|}\Rightarrow k=m-n\\ \\ =\frac{\pi ^{3}}{8}+\sum_{k=n}^{\infty }\sum_{n=1}^{\infty }\frac{1}{2n-1}\frac{(-1)^{k}}{k}e^{-4ak}=\frac{\pi ^{3}}{8}+\sum_{k=1}^{\infty }[\sum_{n=1}^{k}\frac{1}{2n-1}]\frac{(-1)^{k}}{k}e^{-4ak}$$

part(3) $$third \ part\\ but\ 2\sum_{n=1}^{k}\frac{1}{2n-1}=\sum_{i=1}^{k}\frac{1}{2i-1}+\sum_{g=1}^{k}\frac{1}{2g-1}\\ \\ =\sum _{i+g=k+1}(\frac{1}{2i-1}+\frac{1}{2g-1})=\sum _{i+g=k+1}\frac{2(i+g-1)}{(2i-1)(2g-1))}\\ \therefore \sum_{n=1}^{k}\frac{1}{2n-1}=\sum _{i+g=k+1}\frac{k}{(2i-1)(2g-1))}\\ \therefore \sum _{k>=1}[\sum _{i+g=k+1}\frac{k}{(2g-1)(2i-1)}]e^{-2a(2m-2n)}=-\sum _{i,g>=1}\frac{(-1)^{i-g}}{(2i-1)(2g-1)}e^{-2a(2i+2g-2)}\\ \\ =-arctan^2(e^{-2a})\ \ \ \ \ \ so \ we \ have\ I=\int_{0}^{\infty }\frac{ln^2(cot(\frac{ax}{2}))-\frac{\pi }{4})}{x^2+1}dx\\ \\ =\frac{\pi ^{3}}{16}-\pi arctan^2(e^{-2a})\\ \\ \therefore I=\int_{0}^{\infty }\frac{ln^2(cot(\frac{ax}{2})-\frac{\pi }{4})}{x^2+4}dx =\frac{\pi ^{3}}{8}-2\pi arctan^2 (e^{-2a})\\ \\ \ \ \ \ \ \ \ \ \ \ ahmed\ hegazi$$