An integral evaluation I tried my luck with Wolfram Alpha, with $p \in \mathbb{R}$
$$\int_{-\infty}^{\infty} \frac{x^p}{1+x^2} dx = \frac{1}{2} \pi ((-1)^p+1) \sec(\frac{\pi p}{2})$$ for $-1<p<1$, and doesn't exist for other $p$.
I wonder how to integrate it myself? Especially given that $(-1)^p$ may be a non-real complex number. Thanks in advance!
PS: Does Mathematica or some other (free) CAS give the process of deriving the result?
 A: Split integration over $\mathbb{R}$ into integration over $\mathbb{R}_{\geqslant 0}$ and $\mathbb{R}_{<0}$ and perform a change of variables $x \mapsto -x$ in the latter one:
$$
  \int_{-\infty}^\infty \frac{x^p}{1+x^2} \mathrm{d} x = \left(1 + (-1)^p \right) \int_0^\infty \frac{x^p}{1+x^2} \mathrm{d} x
$$
Now the idea is to reduce the integral to the Euler's beta integral. To this end perform substitution $x^2 = \frac{t}{1-t}$ so that $t$ ranges from 0 to 1.
$$
   x \mathrm{d} x = \frac{1}{2} \cdot \frac{\mathrm{d} t}{(1-t)^2}
$$
Thus
$$
 \begin{eqnarray}
  2 \int_0^\infty \frac{x^p}{1+x^2} \mathrm{d} x &=& \int_0^1 \left( \frac{t}{1-t} \right)^{(p-1)/2} \frac{1}{1+ \frac{t}{1-t}} \frac{\mathrm{d} t}{(1-t)^2} \\
  &=& \int_0^1 t^{(p+1)/2 - 1} \left( 1-t \right)^{-1-(p-1)/2} \mathrm{d} t \\
  &=& \operatorname{Beta}\left( \frac{p+1}{2}, \frac{1-p}{2} \right) = \frac{ \Gamma\left( \frac{1-p}{2}  \right) \Gamma\left( \frac{p+1}{2}\right)}{\Gamma\left(  \frac{p+1}{2} + \frac{1-p}{2}  \right)} \\
  &=& \frac{\pi}{ \sin\left( \pi \frac{p+1}{2} \right)} = \pi \sec\left( \frac{\pi p}{2} \right)
\end{eqnarray}
$$
