How to orient the integration contour when applying the residue theorem? For fixed $s$ and $k$ real positive numbers, I consider the $2\pi$-periodic function $f:\mathbf R\to\mathbf C$ defined by
$$f(x)=\frac1{s+\mathrm i k\cos x}$$ and want to compute its Fourier series such that 
$$\forall x\in\mathbf R,\;f(x)=\sum_{k\in\mathbf Z}a_k\mathrm e^{-\mathrm ikx}.$$
In order to do so, I express the coefficients $(a_n)$ in the following way for $n\geq0$, 
$$a_n=\frac1{2\pi}\int_0^{2\pi}f(x)\,\mathrm e^{\mathrm i n x}\mathrm dx$$
and rewrite this integral as an contour integral in the complex domain (using $z=\mathrm e^{\mathrm ix}$ and $\mathrm dz=\mathrm i\mathrm e^{\mathrm ix}\mathrm dx$)
$$a_n=\frac1{2\pi\mathrm i}\oint_{\mathcal C}\frac{z^{n-1}\mathrm dz}{s+\frac{\mathrm ik}2(z+z^{-1})}
=\frac1{2\pi\mathrm i}\oint_{\mathcal C}\frac{z^n\mathrm dz}{\frac{\mathrm ik}2z^2+sz+\frac{\mathrm ik}2}.$$
$\mathcal C$ is the unit complex circle centered on $0$.
The denominator haz two roots $z_\pm=\frac{-s\pm\sqrt{k^2+s^2}}{\mathrm ik}$
and only $z_+$ is in the unit disk. So we get 
$$a_n=\frac{(z_+)^{n}}{\frac{\mathrm ik}2(z_+-z_-)}.$$
Here comes the question: I want do compute the same way when $n<0$. I know I should find $a_n=a_{-n}$ because $f$ is even.  If I orient the contour clockwise and take the residue at $z_-$, I indeed get $a_n=-(z_-)^n/(\mathrm ik(z_--z_+)/2)=(z_+)^{-n}/(\mathrm ik(z_+-z_-)/2)=a_{-n}$. However, it not clear to me why, to reach this result, the integration contour must be oriented clockwise and why I should use the residue at $z_-$. Could someone provide an explanation ? Thanks
 A: The complex Fourier series of a $2\pi$-periodic function $f$ can be written in the form
$$f(t)=\sum_{n\in Z} c_n\>e^{-int}\ ,$$
where the $c_n$ are given by
$$c_n={1\over2\pi}\int_0^{2\pi}f(t)\>e^{int}\ dt\ .$$
For $$f(t):={1\over s+i\kappa\cos t}$$ you get in this way
$$c_n={1\over 2\pi i}\int_{\partial D}{z^n\over{i\kappa\over2}z^2+sz+{i\kappa\over2}}\ dz\ .\tag{1}$$
When $n\geq0$ the only singularities of the integrand are your $z_+$ and $z_-$, so that in this case the residue theorem gives
$$c_n={z_+^n\over{i\kappa\over2}(z_+-z_-)}\qquad(n\geq0)\ .$$
When $n<0$ the integrand in $(1)$ is singular as well at the origin, and computing the residue there would be very cumbersome. (One could also compute the residue at $\infty$.) Fortunately the integrand $f$ is an even function, so that we get $c_{-n}=c_n$ for free.
A: If $n<0$, let us write $m=-n$ and
$$g(z)=\frac1{\frac{\mathrm ik}2(z-z_+)(z-z_-)}=\frac{1}{\frac{\mathrm ik}2(z_+-z_-)}
\left(\frac1{z-z_+}-\frac1{z-z_-}\right).$$ The $m^{\text{th}}$ derivative of $g$ is $$g^{(m)}(z)=\frac2{\mathrm ik(z_+-z_-)}(-1)^mm!\left(\frac1{(z-z_-)^{m+1}}-\frac1{(z-z_+)^{m+1}}\right).$$
Therefore 
$$\begin{split}a_{-m}&=\frac1{2\pi\mathrm i}\oint_{\mathcal C}g(z)z^{-m}\mathrm dz\\
&=\frac{1}{(m-1)!}g^{(m-1)}(0)+\lim_{z\to z_+}(z-z_+)\frac{g(z)}{z^m}\\
&=\frac2{\mathrm ik(z_+-z_-)}\left((z_-)^{-m}-(z_+)^{-m}+(z_+)^{-m}\right)\\
&=\frac{(z_-)^{-m}}{\frac{\mathrm ik}2(z_+-z_-)}=\frac{(z_+)^{m}}{\frac{\mathrm ik}2(z_+-z_-)}=a_m\end{split}$$
