Calculus of a real integral using complex analysis I'm trying to compute $$I = \int_{-\infty}^{+\infty} \frac{t^{m}}{1+t^{2n}},$$ where $n$ and $m$ are integers such that $2n - m \geq 2$.
Let's denote $$F(t) = \frac{t^{m}}{1+t^{2n}}$$ for $t \in \mathbf{R}$.
In this case ($2n - m \geq 2$), it is known that if $(a_k)_{k=0}^{n-1}$ is the family of the poles with a positive imaginary part, then $$I = 2i \pi \sum\limits_{k=0}^{n-1}{\text{Res}(F,a_k)}.$$
Here, we know that the poles of $F$ are the $$a_k = e^{i \pi \frac{2k+1}{2n}},$$ where $k \in [\![0,n-1]\!]$. Since these are simple ones, and $F$ is of the form $\frac{g}{h}$, we have, for all $k$, $$\text{Res}(F,a_k) = \frac{g(a_k)}{h'(a_k)}.$$
I know I should find $$\text{Res}(F,a_k) = -\frac{1}{2n}a_k^{m+1}$$ but I can't understand how. I tried the following computation : $$\begin{array}{r c l} \text{Res}(F,a_k) &=& \frac{a_k^m}{2na_k^{2n-1}}\\
&=& \frac{e^{i\frac{m(2k+1)\pi}{2n}}}{2ne^{i(2n-1)\frac{(2k+1)\pi}{2n}}}\\
&=& \frac{1}{2n}e^{i\frac{m(2k+1)\pi - (2n-1)(2k+1)\pi}{2n}}\\
&=& \frac{1}{2n}e^{i\frac{(m-(2n-1))(2k+1)\pi}{2\pi}} \end{array}$$
and I can't see how to simplify...
Then the thing is unfortunately not over... We could stop at the expression with the sum of the exponentials (assuming that we managed to simplify this ugly thing I found), but I have been said I should find at the end $$I = \frac{\pi\left[1 - (-1)^{m+1}\right]}{2n \sin \left(\frac{(m+1)\pi}{n}\right)}...,$$ which of course I didn't.
Here is what I tried. First I assumed I had the right expression for the $\text{Res}(F,ak)$. Then I computed $$\begin{array}{r c l} I &=& 2i\pi \sum \limits_{k=0}^{n-1}{-\frac{1}{2n} a_k}\\
&=& - \frac{2i\pi}{2n} \sum\limits_{k=0}^{n-1}{\left(e^{\frac{2ik\pi}{2n}}e^{\frac{i\pi}{2n}}\right)^{m+1}}\\
&=& -\frac{2i\pi}{2n} \times e^{i\frac{\pi(m+1)}{2n}} \times \frac{1 - e ^{i\pi}}{1 - e^{i\frac{\pi}{n}}}\\
&=& - \frac{2i\pi}{2n} \times e^{\frac{i\pi(m+1)}{2n}} \times \frac{2}{1 - e^{i\frac{\pi}{n}}}
\end{array},$$ which, obviously, is not what I expected...
Thank you in advance for your help!
 A: Starting from @DanielFischer's suggestion, indeed you have
$$\text{Res}(F,a_k) = \frac{g(a_k)}{h'(a_k)} = \frac{a_k^m}{2n a_k^{2n-1}} =  \frac{a_k^m}{- 2n a_k^{-1}} =  -\frac{1}{2n}a_k^{m+1}.$$
I think you were almost there with your calculation, but here's a full answer:
$$
\begin{array}{r c l} I &=& 2i\pi \sum \limits_{k=0}^{n-1}{-\frac{1}{2n} a_k}\\
&=& -\frac{2i\pi}{2n} \sum \limits_{k=0}^{n-1}{\exp{\left[ i\pi \left(\frac{m+1}{n}k + \frac{m+1}{2n} \right)\right]} } \\
&=& -\frac{2i\pi}{2n} \exp{\left[ i\left(\frac{(m+1)\pi}{2n} \right) \right]} \sum \limits_{k=0}^{n-1}{\exp{\left[ i \left(\frac{(m+1)\pi}{n} \right)k\right]} } \\
&=& -\frac{2i\pi}{2n} \exp{\left[ i\left(\frac{(m+1)\pi}{2n} \right) \right]} \frac{1 - \exp{\left[ i\pi (m+1)\right]} }{1 - \exp{\left[ i\pi \frac{m+1}{n} \right] }} \\
&=& -\frac{2i\pi}{2n}  \frac{1 - (-1)^{m+1}}{\exp{\left[ -i\left(\frac{(m+1)\pi}{2n} \right) \right]} - \exp{\left[ i\pi \frac{m+1}{2n} \right] }} \\
&=& \frac{\pi\left[1 - (-1)^{m+1}\right]}{2n \sin \left(\frac{(m+1)\pi}{n}\right)}.
\end{array}
$$
In the last line I used $\sin{z} = \frac{e^{iz} - e^{-iz}}{2i}$.
