Evaluate $\int_{0}^{1} \frac{x^a+x^{-a}}{1+x^2} dx$ $$\int_{0}^{1} \frac{x^a+x^{-a}}{1+x^2} dx$$
where $a \in (-1,1)$
This is part from a bunch of residue theorem exercises and I can't find out how this can relate to complex analysis. Some common substitutions might solve this in the real way but how to approach this in the other way?
 A: Use$$\int_0^1\frac{x^{-a}dx}{1+x^2}=\int_1^\infty\frac{y^ady}{1+y^2}$$to rewrite the integral as$$\int_0^\infty\frac{x^adx}{1+x^2}.$$Now use $x=\tan t$ to rewrite it again as$$\int_0^{\pi/2}\tan^atdt=\frac12\operatorname{B}\left(\frac{1+a}{2},\,\frac{1-a}{2}\right)=\frac{\pi}{2}\sec\frac{a\pi}{2}.$$While most of this uses Beta & Gamma functions, you also need the Gamma function's reflection formula, which has proofs using complex analysis. Alternatively, we could replace $x=\tan t$ with $x=\exp u$, then continue thereafter with the residue theorem.
A: Cosecant Series
$$
\begin{align}
\int_0^1\frac{x^a+x^{-a}}{1+x^2}\,\mathrm{d}x
&=\scriptsize\left(\frac1{a+1}-\frac1{a-1}\right)-\left(\frac1{a+3}-\frac1{a-3}\right)+\left(\frac1{a+5}-\frac1{a-5}\right)\cdots\tag1\\
&=\frac12\sum_{k\in\mathbb{Z}}\frac{-1^k}{k+\frac{a+1}2}\tag2\\
&=\frac\pi2\csc\left(\pi\frac{a+1}2\right)\tag3\\[6pt]
&=\frac\pi2\sec\left(\frac{\pi a}2\right)\tag4
\end{align}
$$
Explanation:
$(1)$: use series for $\frac1{1+x^2}$ and integrate term by term
$(2)$: write series as a sum over $\mathbb{Z}$; i.e. $\sum\limits_{k\in\mathbb{Z}}f(k)=\sum\limits_{k=1}^\infty(f(k-1)+f(-k))$
$(3)$: use this answer or this answer
$(4)$: $\csc\left(x+\frac\pi2\right)=\sec(x)$

Contour Integration
$$
\begin{align}
\int_0^1\frac{x^a+x^{-a}}{1+x^2}\,\mathrm{d}x
&=\int_1^\infty\frac{x^a+x^{-a}}{1+x^2}\,\mathrm{d}x\tag5\\
&=\frac12\int_0^\infty\frac{x^a+x^{-a}}{1+x^2}\,\mathrm{d}x\tag6\\
&=\frac\pi4\left(\csc\left(\pi\frac{1+a}2\right)+\csc\left(\pi\frac{1-a}2\right)\right)\tag7\\[6pt]
&=\frac\pi2\sec\left(\frac{\pi a}2\right)\tag8
\end{align}
$$
Explanation:
$(5)$: substitute $x\mapsto\frac1x$
$(6)$: average the left and right hand sides of $(5)$
$(7)$: $(1)$ from this contour integration answer
$(8)$: $\csc\left(\frac\pi2+x\right)=\csc\left(\frac\pi2-x\right)=\sec(x)$
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
It's a "candidate" to the
Ramanujan's Master Theorem:
\begin{align}
&\bbox[5px,#ffd]{%
\int_{0}^{1}{x^{a} + x^{-a} \over 1 + x^{2}}\,\dd x} =
{1 \over 2}\int_{0}^{\infty}{x^{a} + x^{-a} \over 1 + x^{2}}\,\dd x
\\[5mm] = &\
\int_{0}^{\infty}{x^{a} \over 1 + x^{2}}\,\dd x =
{1 \over 2}\int_{0}^{\infty}{x^{\pars{\color{red}{a/2 + 1/2}} - 1} \over 1 + x}\,\dd x
\end{align}
Note that
$\ds{{1 \over 1 + x} = \sum_{k = 0}^{\infty}\pars{-1}x^{k} =
\sum_{k = 0}^{\infty}\color{red}{\Gamma\pars{k + 1}}
\,{\pars{-x}^{k} \over k!}}$.
Then,
\begin{align}
&\bbox[5px,#ffd]{%
\int_{0}^{1}{x^{a} + x^{-a} \over 1 + x^{2}}\,\dd x} =
{1 \over 2}\,\Gamma\pars{{a \over 2} + {1 \over 2}}
\Gamma\pars{-\bracks{{a \over 2} + {1 \over 2}} + 1}
\\[5mm] = &\
{1 \over 2}\,{\pi \over\sin\pars{\pi a/2 + \pi/2}} =
\bbx{{1 \over 2}\,\pi\sec\pars{\pi a \over 2}} \\ &
\end{align}
