Contour integral of $\frac{x^{p-1}}{1+x}$ I am trying to find the integral $$\int_0^\infty\frac{x^{p-1}}{1+x}\;\mathbb{d}x$$
I know that this is easily expressible in terms of beta function. But i need to prove that it's value is $\dfrac{\pi}{\sin{p\pi}}$ using a good contour I guess.
I tried of taking a counter like that of a keyhole having.
Sorry for bad drawing.
But I have no idea how to continue.
P.S.: I am little weak at complex integrals.
The contour has 1 semicircle of $\epsilon_1$ radius around $x=-1$ and two of those at $x=0$ where $R\to\infty$ and $\epsilon_1,\epsilon_2,\epsilon_3 \to 0$
 A: This is an integral on which we can work with its principal value. So let's evaluate
$$\text{P.V.}\int_0^{+\infty}\frac{x^p}{x(1+x)}\ \text{d}x$$
In which $$0 < p < 1$$
The function
$$f(z) = \frac{z^p}{z(1+z)}$$ has nonzero pole at $z = -1$ and the denominator has a zero of order at most $1$ (exactly one) at the origin. With residues we find:
$$\text{res}(f(z), z = -1) = \lim_{z\to -1} (1+z)f(z) = \frac{(-1)^p}{-1} = \frac{(e^{i\pi})^p}{-1}$$

Important Theorem, necessary for the continuation
Let $P(x)$ and $Q(x)$ be polynomials of degree $m$ and $n$ respectively, where $n\geq m+2$. If $Q(x)\neq 0$ for $x > 0$, and $Q(x)$ has a zero of order at most $1$ at the origin, and you have
$$f(z) = \frac{z^{\alpha}P(z)}{Q(z)}$$
where $0 < \alpha < 1$, thence:
$$\text{P.V.}\int_0^{+\infty} \frac{x^{\alpha}P(x)}{Q(x)}\ \text{d}x = \frac{2\pi i}{1 - e^{2\pi i p}}\sum_j\text{Res}(f(z), z_j)$$
Where $z_j$ are nonzero poles of $\frac{P(z)}{Q(z)}$.

Applying now the theorem we have:
$$\text{P.V.}\int_0^{+\infty}\frac{x^p}{x(1+x)}\ \text{d}x = \frac{2\pi i}{1 - e^{2\pi i p}}\sum_j\text{Res}(f(z), z_j)$$
Namely
$$\frac{2\pi i}{1 - e^{2\pi i p}}\text{Res}(f(z), z = -1) = \frac{2\pi i}{1 - e^{2\pi i p}}\cdot\frac{e^{i\pi p}}{-1} = \frac{2\pi i}{e^{ip\pi} - e^{-ip\pi}}$$
Which becomes after simple algebra of exponentials
$$\frac{\pi}{\frac{e^{ip\pi} - e^{-ip\pi}}{2i}} = \frac{\pi}{\sin(p\pi)}$$
The contour
The image sucks, but it's the best I could find

A: Allow  me to use $x$ instead of $p$.
\begin{eqnarray*}
  \int_0^{\infty} \frac{s^{x-1} d s}{s+1} =  \frac{\pi}{\sin \pi x}
\end{eqnarray*}
We use the contour shown in Figure below

The singularities are a pole at $s=-1$ and a branch point at $s=0$ where
the function is multivalued. We can use the positive $x$ axis as a branch
cut. The contour encloses the pole, so the integral along the contour 
$C=C_1 \cup C_2 \cup C_3 \cup C_4$ is given by
\begin{eqnarray*}
  \int_C  \frac{s^{x-1} ds}{s+1} =  2 \pi \mathrm{i} (-1)^{x-1}
  = 2 \pi \mathrm{i} \,  \mathrm{e}^{ \mathrm{i} \pi (x-1)}.
\end{eqnarray*}
since $(-1)^{x-1}=\mathrm{e}^{- \mathrm{i} \pi (x-1)}$ is the only residue of the 
integrand.
We now evaluate the four individual integrations for the four paths in the figure.
Let us call $I_i = \int_{C_i} s^{x-1}/(1+s) ds$.
We start with the integrals along the circular paths. For the small circle
we can write $s= \epsilon \mathrm{e}^{\mathrm{i} \theta}$ where $\theta \in[ \delta,
2 \pi - \delta]$ with $\epsilon$ the radius of the disk, and $\delta$ the initial
angle of integration. We then change variables  from $s$ to $\theta$ with
$ds = \mathrm{i} \epsilon  \mathrm{e}^{\mathrm{i} \theta}$. That is,
\begin{eqnarray*}
  |I_4| = 
  \left |  \int_ 
  {2 \pi - \delta_{\epsilon}}^ 
  {\delta_{\epsilon}}
  \frac{\mathrm{i} \epsilon^x \mathrm{e}^{\mathrm{i} \theta (x+1) } d \theta }
  {\epsilon \mathrm{e}^{\mathrm{i} \theta} -1 } \right |
  \le 
  \int_{\delta_{\epsilon}}^{2 \pi - \delta_{\epsilon}} 
   \frac{|\epsilon^x|  d \theta }
  {1 - \epsilon }
  = (2 \pi - 2 \delta_{\epsilon} )  \frac{|\epsilon^x| }
  {1 - \epsilon } 
\end{eqnarray*}
which goes to $0$ as $\epsilon, \delta_{\epsilon} \to 0$, since $0 < x < 1$.
Likewise along the big circle $s  = R \mathrm{e}^{\mathrm{i} \theta}$ and 
$ds = \mathrm{i} R \mathrm{e}^{\mathrm{i} \theta} d \theta$, and so
\begin{eqnarray*}
  |I_2| = 
  \left |  \int_{\delta_{R}}^{2 \pi - \delta_{R}} 
  \frac{\mathrm{i} R^x \mathrm{e}^{\mathrm{i} \theta (x+1) } d \theta }
  {R \mathrm{e}^{\mathrm{i} \theta} -1 } \right |
  \le 
  \int_{\delta_{R}}^{2 \pi - \delta_{R}} 
   \frac{|R^x|  d \theta }
  {R-1 }
  = (2 \pi - 2 \delta_{R} )  \frac{R^x }
  {R-1 } 
\end{eqnarray*}
We use the L'H\^{o}pital rule to find that
\begin{eqnarray*}
  \lim_{R \to \infty} |I_2| = \lim_{R \to \infty} 2 (\pi - \delta_R) \frac{x R^{x-1}}{1} =
  \lim_{R \to \infty} \frac{x}{R^{1-x}} = 0
\end{eqnarray*}
since $1 >  1-x > 0$.
We are left with the integrals along $C_1$ and $C_3$. If in the  integral along $C_1$ 
we take the limit as $\epsilon \to 0 , R \to \infty$, is the original 
integral (1). On the other hand, the integral over $C_3$ has the 
argument shifted by $2 \pi$ with respect to the original integral. That is, 
\begin{eqnarray*}
  \lim_{\epsilon \to 0, R \to \infty} \int_{C_3} \frac{s^{x-1} ds}{s+1}
  = \int_{\infty}^0 \frac{ \mathrm{e}^{2 \pi \mathrm{i} (x-1)} s^{x-1} ds}{\mathrm{e}^{2 \pi
    \mathrm{i}} s+ 1} = -\mathrm{e}^{2 \pi \mathrm{i} ( x-1)} \int_0^{\infty} 
    \frac{s^{x-1} ds }{s+1}
\end{eqnarray*}
Putting all integrals together we find that
\begin{eqnarray*}
  (1 - \mathrm{e}^{2 \mathrm{i} \pi ( x-1) }) 
  \int_0^{\infty} \frac{s^{x-1} ds}{s+1} = 
  2 \pi \; \mathrm{i} \; \mathrm{e}^{ \mathrm{i} \pi ( x-1)}.
\end{eqnarray*}
Hence
\begin{eqnarray*}
 \int_0^{\infty} \frac{s^{x-1} ds}{s+1} = 
 \frac{2 \pi \mathrm{i} \mathrm{e}^{ \mathrm{i} \pi ( x-1)}}{
   1 - \mathrm{e}^{2 \mathrm{i} \pi(x-1)}} 
   = \frac{\pi}{( -\mathrm{e}^{- \pi x} + \mathrm{e}^{\mathrm{i} \pi x})/2 i}
   = \frac{\pi}{\sin \pi x}
\end{eqnarray*}
A: There is no contour for the function as it is in the question, since
$p-1$ is a real number in the interval $(-1,0).$ If $p-1$ is rational we
have a multivalue function with as many values as the denominator of $p-1$ and this implies to create some brunch cuts on the contour. If $p-1$ is
irrational then there are an infinte number of multivalues. Hence we want to change the integrand to somethig more friendly. This is the case of substitution by exponentials as shown here:
It is interesting that
\begin{eqnarray*}
  \Gamma(x) \Gamma(1-x) = 
  \mathrm{B}(x, 1-x) = \int_0^{\infty} \frac{s^{x-1} ds}{s+1}
\end{eqnarray*}
This identity is key to show the Euler's reflection formula
We show, by using contour integration,  that 
\begin{eqnarray*}
  \mathrm{B}(x, 1-x) = \frac{\pi}{\sin \pi x}.
\end{eqnarray*}
Observe that the
Beta Function
 with  $y=1-x$ yields the equation above.
Here is where we need to use contour integrals.   We first make the substitution
$s=e^t$, $ ds = e^t dt$, and $t \in (-\infty, \infty)$. So we need to compute
We compute
\begin{eqnarray*}
  \mathrm{B}(x, 1-x) = \int_{-\infty}^{\infty} \frac{\mathrm{e}^{t(x-1)} 
  \mathrm{e}^t dt}{\mathrm{e}^t+1} =
  \mathrm{B}(x, 1-x) = \int_{-\infty}^{\infty} 
  \frac{\mathrm{e}^{tx} dt}{\mathrm{e}^t+1} \quad , \quad 0 < x < 1.
\end{eqnarray*}
Let us consider the contour integral
\begin{eqnarray}
  I = \int_C f(z) dz,
  \label{intC}
\end{eqnarray}
with 
\begin{eqnarray*}
  f(z) = \frac{\mathrm{e}^{zx}}{\mathrm{e}^z+1} \quad , \quad 0 < x < 1.
\end{eqnarray*}
and  $C$  is the contour that we need to determine. In the complex plane, the
poles of the integrand are the roots of $e^z+1$, that is 
$\mathrm{e}^z = -1 = \mathrm{e}^{(2k+1) \mathrm{i} \pi}$ so the roots are
$z_k= (2k+1) \mathrm{i} \pi$, for $k=0, \pm 1, \pm 2, \cdots$.
Then $f(z)$ as an infinite number of poles all lying on the imaginary axis.
We will select a contour that has only one pole as shown in the figure below.
The contour $C$ can be seen as the union of $C=C_1 \cup C_2 \cup C_3 \cup C_4$,
where $C_1$ and $C_3$ are horizontal lines from $-R$ to $R$ with opposite orientation.
We want to let $R$ grow to $\infty$. The paths $C_2$ and $C_4$ are vertical lines
between $0$ and $2 \pi \mathrm{i}$ with opposite orientations showed in the figure below

From the 
Residue Theorem we evaluate the integral over $C$. The residue corresponding to the
pole $z_0= \pi \mathrm{i}$, is computed using the exprsession
\begin{eqnarray*}
  \lim_{z \to  z_0} (z-z_0) \, f(z) = \lim_{z \to z_0} \frac{ (z-z_0)  \mathrm{e}^{z x}}
  {\mathrm{e}^z + 1} = 
  \lim_{z \to z_0} \frac{\mathrm{e}^{zx} + (z-z_0) \mathrm{e}^{zx}}{e^z} =
  \mathrm{e}^{z_0 (x-1)}.
\end{eqnarray*}
where we use L'H\^{o}pital's rule.
Hence  $I = 2 \pi \mathrm{i} \; \mathrm{e}^{\pi i (x-1)}$
since the only residue inside the contour is at $z=\mathrm{i} \pi$ .  That is,
\begin{eqnarray*}
  2 \pi \; \mathrm{i} \; \mathrm{e}^{ \mathrm{i} \pi (x-1)}  
  =\int_{C_1}  f(z) dz +
  \int_{C_2}  f(z) dz +
  \int_{C_3}  f(z) dz +
  \int_{C_4}  f(z) dz .
\end{eqnarray*}
We want to find $I_1=\int_{C_1} f(z) dz$, as $R \to \infty$.  Let us first find the integral
along the vertical path $C_3$.
\begin{eqnarray*}
  I_3 &=&  
  \int_R^{-R} \frac{\mathrm{e}^{ (t + 2 \pi \mathrm{i} ) x}}{\mathrm{e}^{t+2 \pi
    \mathrm{i}} + 1 } d t \\
    &=& \mathrm{e}^{2 \pi \mathrm{i} x} 
  \int_R^{-R} \frac{\mathrm{e}^{ t  x}}{\mathrm{e}^{t+2 \pi
    \mathrm{i}} + 1 } d t \\
    &=& \mathrm{e}^{2 \pi \mathrm{i} x} 
    \int_R^{-R} \frac{\mathrm{e}^{ t  x}}{\mathrm{e}^{t}  + 1 } d t \\
    &=& -\mathrm{e}^{2 \pi \mathrm{i} x} I_1,
\end{eqnarray*}
where we reversed the sign since $I_1$ is computed from $-R$ to $R$ instead of
going in the opposite direction.
The integral $I_2$ along the path $C_2$ is evaluated as follows
\begin{eqnarray*}
  I_2 =  
  \int_0^{2 \pi} \frac{\mathrm{e}^{ (R + \mathrm{i} t ) x}}
  {\mathrm{e}^{R+\mathrm{i} t} + 1 } d t
  = \frac{\mathrm{e}^{R x} }{\mathrm{e}^R}
  \int_0^{2 \pi} \frac{\mathrm{e}^{ (\mathrm{i} t ) x}}
  {\mathrm{e}^{\mathrm{i} t} + 1/\mathrm{e}^{R} } d t
  = \mathrm{e}^{R(x-1)} 
  \int_0^{2 \pi} \frac{\mathrm{e}^{ (\mathrm{i} t ) x}}
  {\mathrm{e}^{\mathrm{i} t} + 1/\mathrm{e}^{R} } d t.
\end{eqnarray*}
Now, since $0 < x < 1$ (so $x-1 < 0)$, and the last integral is bounded we have that
$\lim_{R \to \infty} I_2 = 0$. The same argument applies for the integral $I_4$
along the path $C_4$. We then have that, from $I=I_1+I_2+I_3+I_4$, 
\begin{eqnarray*}
  2 \pi \mathrm{i} \mathrm{e}^{\mathrm{i} \pi (x-1)} =
 (1 - \mathrm{e}^{2 \pi \mathrm{i} x}) I_1
\end{eqnarray*}
and
\begin{eqnarray*}
  I_1 = \int_{0}^{\infty} \frac{s^{x-1} ds}{s+1} =  \frac{ 2 \pi \mathrm{i} 
  \mathrm{e}^{ \mathrm{i} \pi (x-1)}}{1 - \mathrm{e}^{2 \pi \mathrm{i} x}}
  = \frac{ \pi}{ \frac{\mathrm{e}^{\mathrm{i} \pi x} - \mathrm{e}^{-\mathrm{i} \pi x}}{2
    \mathrm{i}}} = \frac{\pi}{\sin \pi x}.
\end{eqnarray*}
