Evaluate $$A=\int_{0}^{\infty}\frac{\ln^2(x)\cdot\sin(x)}{x^2+1}dx$$
I rewrote it as $$A=\int_{0}^{\infty}\Im\left(\frac{\ln^2(x)\cdot e^{ix}}{x^2+1}\right)dx$$$$A=\Im\left(\int_{0}^{\infty}\frac{\ln^2(x)\cdot e^{ix}}{x^2+1}dx\right)$$Now, I defined a complex funtion $$f(z)=\frac{\ln^2(z)\cdot e^{iz}}{z^2+1}$$ where $z$ is a complex variable, and $\ln(z)$ is the principal branch of the logarithm (with a branch cut along the negative real axis).
I used a keyhole contour in the complex plane, consisting of
- A large semicircle $C_R$ of radius $R$ in the upper half-plane.
- A small semicircle $C_{\epsilon}$ of radius $\epsilon$ around the origin.
- Two straight lines just above and below the positive real axis.
The function $f(z)$ has simple poles at $z=i$ and $z=−i$. Only $z=i$ lies inside the contour. The residue at $z=i$ is $$\textrm{Res}(f,i)=-\frac{\pi^2}{8ei}$$ where I used $\ln(i)=\frac{i\pi}{2}$
Now $$\oint_{C}f(z)\:\:dz=2\pi i\cdot \textrm{Res}(f,i)=-\frac{\pi^3}{4e}$$ Now we have $$A=\Im\left(-\frac{\pi^3}{4e}\right)=0$$ But we all know that this cannot be true. I think my mistake lies in taking the wrong branch cut.
Any help is greatly appreciated.