What technique to use for $\int_0^\infty\frac{t^{-n/2}}{1+t}dt $? I tried to change the integral $$I(n)=\int_0^\infty\frac{t^{-\frac n 2}}{1+t}dt$$ by $t=u^2$ to be $$I(n)=2\int_0^\infty\frac{u^{1-n}}{1+u^2}dt.$$ If we choose upper half plane and there will be pole(s) depending on $n>1$ or $n\le1$. When $n\le1$ $\operatorname{Res}\limits_{z=i}f(z)=i^{-n}$, so $I(n)=2\pi e^{\frac{i\pi} 2 (1-n)}=2\pi\csc(\frac \pi 2n)$. But I was stuck in $n>1$ where the two poles $z=0$ and $z=i$ puzzled me.
Would it be possible to derive it by other method instead of contour integral?
 A: Convergence requires $\Re n\in(0,\,2)$. With $x=\frac{t}{1+t}$,$$I(n)=\int_0^1x^{-n/2}(1-x)^{n/2-1}dx=\operatorname{B}\left(1-\tfrac{n}{2},\,\tfrac{n}{2}\right)=\pi\csc\tfrac{\pi n}{2}$$by the Gamma function's reflection formula.
A: If we want to do this with the Residue Theorem, it is best to keep the integral in its original form.  This would seem to introduce a branch cut, but the Residue Theorem actually uses that to advantage.
First if we render the integral as the sum
$\int_0^a\dfrac{t^{-n/2}}{1+t}dt+\int_a^{\infty}\dfrac{t^{-n/2}}{1+t}dt$
($a$ real, positive), then by comparison with $\int(dt/t)$ the first term diverges when $\Re(n)\ge 2$ and the second term diverges when $\Re(n)\le 0$.  All calculations that follow will assume that $n$ is within the bounds $0<\Re(n)<2$ for convergence, and as we shall see the calculation itself will also generate the same bounds.
First we need to define the integrand, which means defining the branch cut that must exist if $n$ is not an even integer.  Not only do the bounds defined above thereby guarantee the cut, but (we will see the reason below) the cut must exist in order to succeed with the integration.  In such a case a good practice is to match the branch cut with the range of integration, therefore the positive real axis.  Calling the integrand function $f$, we render the following for $t>0$ and $\delta\to0^+$:
$f(t+i\delta)\to\dfrac{t^{-n/2}}{1+t}$
$f(t-i\delta)\to\dfrac{t^{-n/2}\exp(-in\pi)}{1+t}$
$t^{-n/2}$ is the usual real-domain function value.
We now define the contour as the usual cut-disc boundary:
Segment 1:  from $i\delta$ along the positive real axis to $R+i\delta$ where $R\to+\infty$.
Segment 2:  from $R+i\delta$ to $R-i\delta$ counterclockwise on a circle centered at zero.
Segment 3:  from $R-i\delta$ to $-i\delta$ along the positive real axis.
Segment 4:  from $-i\delta$ to $+i\delta$ along a semecircle centered at zero, closing the contour.
We now render the contour integral along each segment:
$\oint\dfrac{z^{-n/2}}{1+z}dz=I_1+I_2+I_3+I_4$
$I_1=\int_0^{\infty}\dfrac{t^{-n/2}}{1+t}dt$
$I_2=O(R)$ from the length of the path
$\text{    }×O(R^{-n/2}/R)$ from the integrand function
$\text{    }=O(R^{-n/2})\to0$ if $\Re(n)>0$
$I_3=-\exp(-in\pi)\int_0^{\infty}\dfrac{t^{-n/2}}{1+t}dt$
$I_4=O(\delta)$ from the length of the contour
$\text{    }×O(\delta^{-n/2}$ from the integrand function
$\text{    }=O(\delta ^{1-n/2})\to0$ if $\Re(n)<2$
Note that the bounds necessary to zero out the integrals at the limit points are the same as the bounds for convergence above.  Typically in contour integration, convergence correlates with this zeroing.  Also note that the difference between $I_1$ and $-I_3$, which is necessary to define the original integral in terms of the contour integral, would be lost without the branchnpoint and thus the original integral cannot be defined for any even integer $n$.
Therefore
$\oint\dfrac{z^{-n/2}}{1+z}dz=(1-\exp(-in\pi))\int_0^{\infty}\dfrac{t^{-n/2}}{1+t}dt$
$\int_0^{\infty}\dfrac{t^{-n/2}}{1+t}dt=\dfrac{\oint\dfrac{z^{-n/2}}{1+z}dz}{1-\exp(in\pi)}$
The contour integral is evaluated in the usual way via the Residue Theorem.  There is one first-order pole inside the contour at $-1$ with residue $(-1)^{-n/2}=\exp(-in\pi/2)$ (the branch cut definition forces $0<\arg z<2\pi$ in the cut plane).  The branch cut, flanked by Segments 1 and 3, is not actually inside the contour.  Thereby
$\int_0^{\infty}\dfrac{t^{-n/2}}{1+t}dt=\dfrac{i(2\pi)\exp(in\pi/2)}{1-\exp(-in\pi)}$
$\int_0^{\infty}\dfrac{t^{-n/2}}{1+t}dt=\dfrac{i(2\pi)}{\exp(in\pi/2)-\exp(-in\pi/2)}=\dfrac{\pi}{\sin(n\pi/2)}\text{ from Euler's formula}.$
This is of course the same result as JG obtained via the gamma-function reflection formula.  The combination of the two answers may be construed as a proof of this reflection formula.
