Integral $\int_{-\pi}^{\pi} \frac{a^2 \cos(nx)}{(a^2 + x^2)^2} dx$ Question
For $a > 0$ and any $n\in\mathbb{Z}$, what is the value of
$$
c_n := \int_{-\pi}^{\pi} \frac{a^2}{(a^2 + x^2)^2} \cos(nx) dx?
$$
My Attempt
CORRECTION
Letting $f_a(x) := \frac{a^2}{(a^2 + x^2)^2}$ for any $a>0$, we can compute that the Fourier transform of $f_a$ is given by
$$
\hat{f}_a(\xi) = \int_{-\infty}^{\infty} f_a(x) e^{i \xi x} dx =\frac{\pi}{2a}(1+a|\xi|)e^{-|\xi|a} \qquad \forall \xi \in \mathbb{R}.
$$
Well, if we let $\chi_{b}(x):=\cases{1 & $x\in[-b,b]$\\ 0 & otherwise}$ for any $b > 0$, we also know that
$$
\begin{align}
\hat{\chi}_{b}(\xi) &= \int_{-\infty}^{\infty} \chi_{b}(x) e^{i\xi x} dx\\
&= \int_{-b}^{b} e^{i\xi x} dx\\
&= \frac{1}{i\xi}\left(e^{ib\xi} - e^{-ib\xi}\right)\\
&= \frac{2\sin(b\xi)}{\xi} = 2b\, \text{sinc}(b\xi).
\end{align}
$$
Furthermore, letting $g_b(\xi) := 2b\, \text{sinc}(bx)$, we can see that for $x\in\mathbb{R}$, by the Fourier inversion theorem, the inverse Fourier transform of $g_b$ is
$$
\begin{align}
\check{g}_b(x) &:= \frac{1}{2\pi}\int_{-\infty}^{\infty}g_b(\xi) e^{-i\xi x} d\xi = \chi_{b}(x).
\end{align}
$$
Returning back to our original question, we see that for $n \in \mathbb{Z}$
$$
\begin{align}
c_n &= \text{Re}\left[\int_{-\infty}^{\infty}f_a(x) \chi_{\pi}(x)e^{inx} dx\right] \\
&= \text{Re}\left[\widehat{f_a \chi_{\pi}}(n)\right]\\
&= \frac{1}{2\pi}\text{Re}\left[(\hat{f}_a \ast \hat{\xi}_{\pi})(n)\right]
\end{align}
$$
where $\ast$ denotes the convolution between two functions

i.e. (brief description) for two functions $f,g$
$$
(f\ast g)(x) = \int_{-\infty}^{\infty} f(y) g(x-y) dy = \int_{-\infty}^{\infty} f(x-y) g(y) dy
$$

NOTE: There was an error in an initial calculation which rendered the other work incorrect. See history of post to see other work.
 A: Note: This is not a correct answer. The residue theorem gives the exact result when the integration is performed over the whole real line (see the comments). I made a sign error in the expression of the integration over the two "vertical lines" (see below): I incorrectly concluded that they cancel out.
The numerical test is quite good for $a<1$ and high $n$, and shows that for some values of the parameters the integral over the whole real line (not surprisingly) approximates the one over $(\pi, \pi)$. I believe that this is a potentially useful application of the residue theorem so I keep it here as it still gives the exact result of the integral
$$
\int_{-\infty}^{\infty} \frac{a^2 \,  \cos(nx) }{(a^2 + x^2)^2} \, dx 
=
\pi  \frac{a\,  |n| +1}{2a} e^{-|n| a }
\qquad n\in\mathbb{Z} \, , \, a>0
$$
When you integrate over the whole real line there is no need to consider the "vertical lines" (take, instead, a semicircle of infinite radius that does not contribute to the closed path).
Below, you can find the original answer (wrong, see comments).
This integral can be solved thanks to the residue theorem. Assume $a>0$ and integer $n$:
$$
c_n := \int_{-\pi}^{\pi} \frac{a^2}{(a^2 + x^2)^2} \cos(nx) dx 
 =   Re(C_n) 
$$
where we define
$$
C_n=\int_{-\pi}^{\pi} f(z) dz =\int_{-\pi}^{\pi} \frac{a^2}{(a^2 + z^2)^2} (e^{i z})^n dz 
$$
The poles of the integrand $f(z)$ are at $z=\pm i a$. The residue for $z=i a$ is,
$$
Res(f,ia) = -i \frac{ e^{-n a}(1+n a) }{4 a}
$$
Now, consider a closed rectangular path in the upper plane. The basis of the rectangle is the interval on the real axis $(-\pi, \pi)$, the vertical sides are the lines $\pm \pi +i y$ for $y>0$ (the path closes at infinity). This path encloses the pole at $+ia$. Application of the residue theorem with this path gives you the desired result (see below).
Note that the two integrals on the parallel vertical lines $\pm \pi +i y$  cancel out, so there is no real need to perform them!
Using Mathematica or WA: I feed Mathematica with the expression in terms of the complex exponential $C_n$ and then I take its real part. When doing the integration, remember to use "Assumptions" to specify $a>0$ and  $n$ integer.
After using the "Re" and "ComplexExpand" commands, as well as some other simplification, I obtain
$$
c_n =  \pi  \frac{a\,  |n| +1}{2a} e^{-|n| a }
\qquad n\in\mathbb{Z} \, , \, a>0
$$
I checked the above result with "NIntegrate" for different choices of $a$ and $n$ and it looks very accurate. As expected, the result goes to zero for large $n$.
