Studying for qualifying exams, I came across the following problem: using complex analysis, compute $$\int_{-\infty}^{\infty}\frac{x^2\sin(\pi x)}{x^3-1}dx $$ I decided to use the integrand $f(z)=\frac{z^2e^{i\pi z}}{z^3-1}$ (the goal is to take the imaginary part in the end), and I found that $f$ has a removable singularity at $1$. Now, it seems to me that $|f(Re^{i\theta})|=O(e^R/R)$, so a semicircle countour won't work. I also tried to use a rectangular contour (with height $2\pi$) and the sides do vanish as $R\to\infty$, but since there are quadratic terms in the integrand, I am not able to get a simple result and conclude via the residue theorem. Any ideas?
Edit: With help from the comment, I think I have a solution. Taking $f(z)$ as before, we see that $f(z)=e^{i\pi z}\cdot g(z)$, where $g(z)=\frac{z^2}{z^3-1}$, and since $|g(Re^{i\theta})|\leq \frac{C}{R}$, we invoke Jordan's lemma to say that $\lim_{R\to\infty}\int_{\Gamma_R}f(z)=0$, where $\Gamma_R$ is the upper semi-circle of radius $R$ centered at $0$. Therefore, we get: $$\int_{-\infty}^{\infty}\frac{xe^{i\pi x}}{x^3-1}=2\pi i Res_{e^{2\pi i/3}}f $$ Now, $$Res_{e^{2\pi i/3}}f=\lim_{z\to e^{2\pi i/3}}\frac{ze^{i\pi z}}{(z-1)(z-e^{4i\pi /3})}=\frac{e^{2\pi i/3}exp\{i\pi e^{2\pi i/3}\}}{(e^{2\pi i/3}-1)(e^{2\pi i/3}-e^{4\pi i/3})} $$ This will simplify (using the fact that the roots of unity sum to $0$) to $exp\{i\pi( e^{2\pi i/3}-2/3)\}$ Now, $Im\{2\pi i \exp\{i\pi( e^{2\pi i/3}-2/3)\}\}=2\pi e^{-\pi \sin(2\pi/3)}\cos[\cos(2\pi/3)-2/3]$. I don't think this should be the answer, but I am unable to figure out where I went wrong.
As suggested by Mark Viola, the contour to consider is (for small $r>0$ and large $R>0$) $$C_{r,R}=[-R,1-r]\cup\gamma_r\cup[1+r,R]\cup\Gamma_R,$$ where $\gamma_r$ is the upper semicircle of radius $r$ centered at $1$ (oriented clockwise), and $\Gamma_R$ is the upper semicircle of radius $R$ centered at $0$ (oriented counterclockwise).
As you (already) know, for $f(z)=z^2 e^{\mathrm{i}\pi z}/(z^3-1)$, \begin{align} \int_{C_{r,R}}f(z)\,dz&=2\mathrm{i}\pi\operatorname*{Res}_{z=e^{2\pi\mathrm{i}/3}}f(z);\\ \lim_{R\to\infty}\int_{\Gamma_R}f(z)\,dz&=0;\qquad(\text{Jordan's lemma})\\ \lim_{r\to 0}\int_{\gamma_r}f(z)\,dz&=-\mathrm{i}\pi\operatorname*{Res}_{z=1}f(z), \end{align} which gives the value of your integral, and the v.p. of the corresponding cosine integral for free: $$\int_{-\infty}^\infty\frac{x^2\sin\pi x}{x^3-1}\,dx=-\frac\pi3,\qquad\mathrm{v.p.}\int_{-\infty}^\infty\frac{x^2\cos\pi x}{x^3-1}\,dx=\frac{2\pi}{3}e^{-\pi\sqrt{3}/2}.$$
And, as noted by Claude Leibovici, your integral is easy to compute via real methods: \begin{align} \int_{-\infty}^\infty\frac{x^2\sin\pi x}{x^3-1}\,dx&=\frac13\left(\underbrace{\int_{-\infty}^\infty\frac{\sin\pi x}{x-1}\,dx}_{x-1=t}+\underbrace{\int_{-\infty}^\infty\frac{(2x+1)\sin\pi x}{x^2+x+1}\,dx}_{2x+1=t}\right) \\&=-\frac13\left(\underbrace{\int_{-\infty}^\infty\frac{\sin\pi t}{t}\,dt}_{=\pi}+2\underbrace{\int_{-\infty}^\infty\frac{t\cos(\pi t/2)}{t^2+3}\,dt}_{=0}\right)=-\frac\pi3. \end{align}