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
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}$$