Evaluation of a definite integral I want to find the best way to show $\int_0^\infty\dfrac{x^{2m}}{x^{2n}+1}\,dx=\dfrac{\pi}{2n}\operatorname{csc}\left(\dfrac{2m+1}{2n}\pi\right)$, where $0\leq m<n$.
It's easy to verify some simple cases when $m$ and $n$ are small, e.g. $\int_0^\infty\dfrac{dx}{1+x^2}=\arctan|_0^{\pi/2}=\dfrac{\pi}{2}$ . In general, one may expect to use residue theorem to sum all the residues on the left hand side with the contour the upper half-disk. However, the calculation seems complicated. Is there some simple way to see it?
 A: Apart from the Beta function approach mentioned by Julien Godawatta, this can be very nicely evaluated using the residue theorem.
The denominator has zeros in
$$\exp\left(\pi i \frac{2k+1}{2n}\right),\quad 0 \leqslant k < n,$$
and is the same on rays an angle of $\frac{\pi}{n}$ apart. The numerator differs by a constant factor of $\exp \left(\pi i\frac{2m}{n}\right)$ on such rays; we get another factor of $e^{\pi i/n}$ integrating over such a ray from the differential $dz$. So if we integrate over the boundary of a sector $\{ z : \lvert z\rvert < R,\; 0 < \arg z < \frac{\pi}{n}$, we find
$$2\pi i \operatorname{Res}\left(\frac{z^{2m}}{z^{2n}+1}; {\large e^{\frac{\pi i}{2n}}}\right) = \left(1 - {\large e^{\pi i\frac{2m+1}{n}}}\right)\int_0^R \frac{x^{2m}}{x^{2n}+1}\,dx + \int_{C_R} \frac{z^{2m}}{z^{2n}+1}\,dz,$$
where $C_R$ is the circular arc closing the contour. Since $m < n$, the integral over $C_R$ tends to $0$ for $R\to\infty$, leaving
$$\int_0^\infty \frac{x^{2m}}{x^{2n}+1}\,dx = \frac{2\pi i}{1 - {\large e^{\pi i\frac{2m+1}{n}}}}\operatorname{Res}\left(\frac{z^{2m}}{z^{2n}+1}; {\large e^{\frac{\pi i}{2n}}}\right).\tag{1}$$
Since the denominator has only simple zeros, the residue in a zero is
$$\operatorname{Res}\left(\frac{z^{2m}}{z^{2n}+1}; \zeta\right) = \frac{\zeta^{2m}}{2n\zeta^{2n-1}} = \frac{\zeta^{1+2m-2n}}{2n},$$
and for $\zeta = e^{\large \frac{\pi i}{2n}}$, we find the residue to be
$$\frac{e^{\pi i\large \frac{1+2m-2n}{2n}}}{2n} = -\frac{1}{2n}e^{\pi i \large\frac{2m+1}{2n}}.$$
Inserting that into $(1)$ yields
$$\int_0^\infty \frac{x^{2m}}{x^{2n}+1}\,dx = \frac{\pi}{2n\sin \left(\pi \frac{2m+1}{2n}\right)},$$
as desired.
