calculate: $\int_{-\infty}^{\infty}\frac{\cos\frac{\pi}{2}x}{1-x^{2}}dx$ using complex analysis ; detect my mistake calculate: $\int_{-\infty}^{\infty}\frac{\cos\frac{\pi}{2}x}{1-x^{2}}dx$ using complex analysis.
My try:
$\int_{-\infty}^{\infty}\frac{\cos\frac{\pi}{2}x}{1-x^{2}}dx$
symetric therefore : $ \int_{-\infty}^{\infty}\frac{\cos\frac{\pi}{2}x}{1-x^{2}}dx=2\int_{0}^{\infty}\frac{\cos\frac{\pi}{2}x}{1-x^{2}}dx$
calculate instead: $2Re\int_{0}^{\infty}\frac{e^{\frac{\pi}{2}zi}}{1-e^{\pi zi}}dz$
use pizza slice:$2Re\int_{0}^{\infty}\frac{e^{\frac{\pi}{2}zi}}{1-e^{\pi zi}}dz=\int_{0}^{2\pi}\frac{e^{\frac{\pi}{2}\theta i}}{1-e^{\pi\theta i}R^{2}}d\theta+\int_{0}^{R}\frac{e^{\frac{\pi}{2}\theta i}}{1-e^{\pi\theta i}R^{2}}dR+\int_{0}^{R}\frac{e^{\frac{\pi}{2}\theta i}}{1-e^{\pi\theta i}R^{2}}dR$
take limits:
$2Re\int_{0}^{\infty}\frac{e^{\frac{\pi}{2}zi}}{1-e^{\pi zi}}dz=Lim_{R\rightarrow\infty}\int_{0}^{2\pi}\frac{e^{\frac{\pi}{2}\theta i}}{1-e^{\pi\theta i}R^{2}}d\theta+Lim_{\theta\searrow0}\int_{0}^{R}\frac{e^{\frac{\pi}{2}\theta i}}{1-e^{\pi\theta i}R^{2}}dR+Lim_{\theta\nearrow0}\int_{0}^{R}\frac{e^{\frac{\pi}{2}\theta i}}{1-e^{\pi\theta i}R^{2}}dR$
$2Re\int_{0}^{\infty}\frac{e^{\frac{\pi}{2}zi}}{1-e^{\pi zi}}dz=0+\int_{0}^{R}\frac{1}{1-e^{\pi\theta i}R^{2}}dR+\int_{0}^{R}\frac{1}{1-e^{\pi\theta i}R^{2}}dR$
According the residue theorem at$ \int_{0}^{\infty}\frac{e^{\frac{\pi}{2}zi}}{1-e^{\pi zi}}dz=2\pi iRes_{z=-1}\frac{e^{\frac{\pi}{2}zi}}{1-e^{\pi zi}}=0
$
therefore:$2Re\int_{0}^{\infty}\frac{e^{\frac{\pi}{2}zi}}{1-e^{\pi zi}}dz=0$
 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}$
$\ds{\underline{\underline{Complex\ Integration}}:}$
\begin{align}
&\bbox[10px,#ffd]{\int_{-\infty}^{\infty}{\cos\pars{\pi x/2} \over
1 - x^{2}}\,\dd x} =
2\int_{0}^{\infty}{\cos\pars{\pi x/2} \over 1 - x^{2}}\,\dd x =
2\,\Re\int_{0}^{\infty}{\expo{\pi x\ic/2}  - \color{red}{\large\ic}
\over 1 - x^{2}}\,\dd x
\\[5mm] = &\
-\overbrace{\lim_{R \to \infty}\Re\int_{\large x\ \in\ R\expo{\pars{0,\pi/2}\,\ic}}{\expo{\pi x\ic/2}  - \ic
\over 1 - x^{2}}\,\dd x}^{\ds{=\ 0}}\ -\
2\,\Re\int_{\infty}^{0}{\expo{\ic\pi\pars{\ic y}/2}  - \ic
\over 1 - \pars{\ic y}^{2}}\,\ic\,\dd y
\\[5mm] = &\
2\int_{0}^{\infty}{\dd y \over 1 + y^{2}} = 2\,{\pi \over 2} =
\bbx{\large\pi} \\ &
\end{align}

$\ds{\underline{\underline{Real\ Integration}}:}$
\begin{align}
&\bbox[10px,#ffd]{\int_{-\infty}^{\infty}{\cos\pars{\pi x/2} \over
1 - x^{2}}\,\dd x} =
{1 \over 2}\int_{-\infty}^{\infty}\bracks{%
{\cos\pars{\pi x/2} \over 1 - x} +
{\cos\pars{\pi x/2} \over 1 + x}}\,\dd x
\\[5mm] = &\
-\int_{-\infty}^{\infty}{\cos\pars{\pi x/2} \over x - 1}\,\dd x =
\int_{-\infty}^{\infty}{\sin\pars{\pi x/2} \over x}\,\dd x =
\int_{-\infty}^{\infty}{\sin\pars{x} \over x}\,\dd x
\\[5mm] = &\ \bbx{\large\pi} \\ &
\end{align}
A: Let $f(z)=\dfrac{e^{i(\pi/2)z}}{1-z^2}.$
We want to find "$\int_{-\infty}^\infty f(x)\,dx$" and then take the real part. I have that in quotes as the integral is problematic unless we're careful about the singularities at $-1,1.$
A contour that will work contains the intervals $[-R,-1-r],$ $[-1+r,1-r],$ and $[1+r,R]$ (here $r,R>0$ and $r$ is much smaller than $R$). We also want the large semicircle described above. Around $-1$ we put the small semicircle of radius $r$ given by $-1-re^{it},0\le t \le \pi.$ Around $1$ we put the semicircle $1-re^{it},0\le t \le \pi.$ Hook these pieces up and orient the resulting closed contour positively. (It's good to draw a picture!)
Call this contour $\gamma=\gamma_{r,R}.$ Note that $\gamma$ does not contain either of $-1,1$ in its interior. Thus by  Cauchy's theorem, $\int_\gamma f(z)\,dz =0.$
There are three intervals in this contour; let's denote the integral of $f$ over the union of all of them by $I(r,R).$ Note that $I(r,R)$ is real.
The first small semicircle:
$$\int_{0}^{\pi} f(-1-re^{it})(-ire^{it})\,dt=-\int_{0}^{\pi}\frac{\exp[i(\pi/2)(-1-re^{it})]ire^{it}}{1-(-1-re^{it})^2}\,dt$$ $$ = -\int_{0}^{\pi}\frac{i\exp[i(\pi/2)(-1-re^{it})]}{-2+re^{it}}\,dt.$$
As $r\to 0^+,$ the last integrand converges nicely to $\dfrac{i\exp[-i(\pi/2]}{-2} = 1/2.$ Thus the integral converges to $-\pi\cdot(1/2)=-\pi/2.$
The big semicircle:
$$\int_{0}^{\pi} f(Re^{it})iRe^{it}\,dt= \int_{0}^{\pi} \frac{\exp[i(\pi/2)Re^{it}]iRe^{it}}{1-R^2e^{2it}}\,dt.$$
This one's easy to estimate: Slap absolute values on everything to see the integrand is bounded above by $R/(R^2-1).$ (The fact that $\sin t\ge 0$ in $[0,\pi]$ comes in here.) As $R\to \infty,$ the integral $\to 0.$
The second small semicircle: Just like the first, giving a limit of $-\pi/2.$
So we have
$$I(r,R) + \text{ integrals over semicirles } = 0.$$
Our works shows that if $R\to \infty$ and $r\to 0$ (let $r=1/R$ if you like) we get
$$\int_{-\infty}^\infty \frac{\cos(\pi/2)x}{1-x^2 } = -(-\pi/2-\pi/2) =\pi.$$

Added later: Comment on errors you may have made. The problems start with "calculate instead"
$$2Re\int_{0}^{\infty}\frac{e^{\frac{\pi}{2}zi}}{1-e^{\pi zi}}dz.$$
I'm not sure why you changed $x$ to $z;$ we're still on the real axis at this point. But that's a minor thing. The big problem is the denominator. As others pointed out, it should be $1-z^2.$ It's important to get this right.
Onward to the pizza slice:
$$2Re\int_{0}^{\infty}\frac{e^{\frac{\pi}{2}zi}}{1-e^{\pi zi}}dz=\int_{0}^{2\pi}\frac{e^{\frac{\pi}{2}\theta i}}{1-e^{\pi\theta i}R^{2}}d\theta+\int_{0}^{R}\frac{e^{\frac{\pi}{2}\theta i}}{1-e^{\pi\theta i}R^{2}}dR+\int_{0}^{R}\frac{e^{\frac{\pi}{2}\theta i}}{1-e^{\pi\theta i}R^{2}}dR.$$
The minor things: You have the same integral added to itself at the end? Also, $dR$ is strange, as $R$ is a limit of integration. And we have an integral over $[0,\infty)$ equal to a sum of integrals over finite intervals?
I'll stop here for now. Can you explain the strategy? What is the pizza slice contour? We can converse on this if you like.
A: You were really close. only one issue:
let's say that the function within the pizza is $f_n$ and the limit is $f$.
You assume that there $f_{n}\begin{array}{c}
loc\\
\nRightarrow
\end{array}f$ (locally uniformly convergence). which isn't correct.
so is the solution completely wrong? no.
if we split a circle from this area, with radius as small as we want:
$\lim_{\delta\rightarrow0}\mathfrak{R\textrm{ }\int_{|\textrm{z-1|=\ensuremath{\delta}}}}\frac{e^{\frac{\pi}{2}z}dz}{z^{2}-1}=\lim_{\delta\rightarrow0}\mathfrak{R\textrm{ }\int_{0}^{2\pi}}\frac{e^{\frac{\pi}{2}e^{\theta i}\delta i+1}dz}{e^{\theta i}+2}d\theta=\mathfrak{R\textrm{ }}\int_{0}^{2\pi}\frac{1}{2}=\pi$
which leads to:
$\int_{-\infty}^{\infty}\frac{\cos\frac{\pi}{2}x}{x^{2}-1}=\pi$
