Evaluate $\int_0^\infty \frac{\ln^2(z)}{1+z^2}$dz by contour integration [duplicate]

This question already has an answer here:

Background: This is part b of problem 12.4.3 from Arfken, Weber, Harris Math Methods for Physicists to show that $\int_0^\infty \frac{\ln^2(z)}{1+z^2}$dz$=4(1-\frac{1}{3^3}+\frac{1}{5^3}-\frac{1}{7^3}+\dots)$.

Part b of the question asks to show that this series evaluates to $\frac{\pi^3}{8}$ by contour integration. Where is my mistake: $\lim_{z \to 0}zf(z)=0$ and $\lim_{z \to \infty}zf(z)=0$ so the big and little circle equal 0.$ Drawing a branch cut along the positive x axis and integrating counterclockwise along the positive x-axis around a big circle the negative x-axis from infinity and the little circle: Assume$I=\int_0^\infty \frac{\ln^2(x)}{1+x^2}\text{dx}$We can add the components of along the contour and set that equal to the value of$2\pi i \text{Res}[f(z),i]$evaluated at the poles$\pm i$$$\int_0^\infty \frac{\ln^2(z)}{1+z^2}\text{dz}+\int_{\infty}^0 \frac{\ln^2(z)}{1+z^2}\text{dz}=2\pi i \text{Res}[f(z),\pm i]\tag{1}$$ $$\int_0^\infty \frac{(\ln^2 \mid x\mid}{1+x^2}\text{dx}-\int_0^{\infty} \frac{(\ln\mid x\mid+2i\pi)^2}{1+x^2}\text{dx}=2\pi i \left (\lim_{z \to i}\frac{\ln^2(z)}{2z}+\lim_{z \to -i}\frac{\ln^2(z)}{2z}\right )\tag{2}$$ $$\int_0^\infty \frac{(\ln^2\mid x\mid}{1+x^2}\text{dx}-\int_0^{\infty} \frac{(\ln^2\mid x\mid+\color{red}{4\ln|x|i\pi}-4\pi^2)}{1+x^2}\text{dx}=2\pi i \left (\lim_{z \to i}\frac{\ln^2(z)}{2z}+\lim_{z \to -i}\frac{\ln^2(z)}{2z}\right )\tag{3}$$ $$0I+\color{red}{0}-\left[\tan^{-1}(x)\right]\mid^{\infty}_0(4\pi^2)\text{dx}=(2\pi i) \left (\frac{-\pi^2/4+9\pi^2/4}{2i}\right )\tag{4}$$ $$0I+2\pi^3=\frac{8\pi^3}{4}\tag{5}$$ For explanation of the red integral see here, here or here. I found my error. It was a negative sign, and the two sides cancel to zero so you can't evaluate it this way, but I found an answer which evaluates it from negative to positive infinity so I'm marking the question as a duplicate. See dustin's answer at the link for the contour integration. marked as duplicate by user5389726598465, Community♦May 2 '17 at 4:49 This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. • Instead of dropping lots of formulas down, perhaps you can write down in words your thought process. Either you're making a mistake in a calculation or you're mistakenly using a result you know, but it is hard to tell. For example, do not forget that$\log z$is holomorphic in the slit plane only, so the countour you're using might not be the best choice. – Pedro Tamaroff May 2 '17 at 1:27 • I'm adding details so all the wrong things will be more obviously wrong. Give me a moment. – user5389726598465 May 2 '17 at 1:33 • What kind of log are you taking of a negative number here with the second integral? – Paul May 2 '17 at 1:36 • @paul I I'm not sure if that's wrong, it's a complex log until it's evaluated along the branch cut, and then becomes equal to the real log plus i times the angle ... – user5389726598465 May 2 '17 at 1:48 • @user135711 That's not how complex logarithms work! – Pedro Tamaroff May 2 '17 at 2:13 1 Answer$\newcommand{\bbx}{\,\bbox[8px,border:1px groove navy]{\displaystyle{#1}}\,} \newcommand{\braces}{\left\lbrace\,{#1}\,\right\rbrace} \newcommand{\bracks}{\left\lbrack\,{#1}\,\right\rbrack} \newcommand{\dd}{\mathrm{d}} \newcommand{\ds}{\displaystyle{#1}} \newcommand{\expo}{\,\mathrm{e}^{#1}\,} \newcommand{\ic}{\mathrm{i}} \newcommand{\mc}{\mathcal{#1}} \newcommand{\mrm}{\mathrm{#1}} \newcommand{\pars}{\left(\,{#1}\,\right)} \newcommand{\partiald}[]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\root}[]{\,\sqrt[#1]{\,{#2}\,}\,} \newcommand{\totald}[]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}} \newcommand{\verts}{\left\vert\,{#1}\,\right\vert}$The contour is a key-hole$\ds{\,\mc{C}}$which takes into acount the$\ds{\ln}$-branch cut $$\ln\pars{z} = \ln\pars{\verts{z}} + \,\mrm{arg}\pars{z}\ic\,;\qquad z \not= 0\,,\quad 0 < \,\mrm{arg}\pars{z} < 2\pi$$ when an integration of$\ds{I \equiv \oint_{\mc{C}}{\ln^{3}\pars{z} \over 1 + z^{2}}\,\dd z}$is performed. The integrand has single poles at, according to the above branch cut,$\ds{\expo{\pi\ic/2}}$and$\ds{\expo{3\pi\ic/2}}\$.

\begin{align} I & = 2\pi\ic\,\bracks{{\pars{3\pi\ic/2}^{3} \over -\ic - \ic} + {\pars{\pi\ic/2}^{3} \over \ic + \ic}} = {13 \over 4}\,\pi^{4}\ic\label{1}\tag{1} \end{align}
\begin{align} I & = \int_{0}^{\infty}{\ln^{3}\pars{x} \over 1 + x^{2}}\,\dd x + \int_{\infty}^{0}{\bracks{\ln\pars{x} + 2\pi\ic}^{\,3} \over 1 + x^{2}}\,\dd x \\[5mm] & = \int_{0}^{\infty}{\ln^{3}\pars{x} \over 1 + x^{2}}\,\dd x - \int_{0}^{\infty}{\ln^{3}\pars{x} + 3\ln^{2}\pars{x}\pars{2\pi\ic} + 3\ln\pars{x}\pars{2\pi\ic}^{2} + \pars{2\pi\ic}^{3} \over 1 + x^{2}}\,\dd x \\[5mm] & = -6\pi\ic\int_{0}^{\infty}{\ln^{2}\pars{x} \over 1 + x^{2}}\,\dd x + {1 \over 12}\,\pi^{2}\ \underbrace{\int_{0}^{\infty}{\ln\pars{x} \over 1 + x^{2}}\,\dd x}_{\ds{=\ 0}}\ +\ 8\pi^{3}\ic\ \underbrace{\int_{0}^{\infty}{\dd x \over 1 + x^{2}}} _{\ds{=\ {\pi \over 2}}} \\[5mm] & = -6\pi\ic\int_{0}^{\infty}{\ln^{2}\pars{x} \over 1 + x^{2}}\,\dd x + 4\pi^{4}\ic \label{2}\tag{2} \end{align}
With \eqref{1} and \eqref{2}: \begin{align} {13 \over 4}\,\pi^{4}\ic & = -6\pi\ic\int_{0}^{\infty}{\ln^{2}\pars{x} \over 1 + x^{2}}\,\dd x + 4\pi^{4}\ic \\[5mm] \implies & \bbx{\int_{0}^{\infty}{\ln^{2}\pars{x} \over 1 + x^{2}}\,\dd x = {\phantom{^{3}}\pi^{3} \over 8}} \end{align}