It's a very straightforward problem. I have to compute the Fourier series of
$$\frac{3}{5-4\cos(x)}$$
I have done it using residues and I have got the following coefficients:
$$c_n = 2 ^{-|n|}$$
I think they are correct, but when I checked with Wolfram using the FourierSeries function, the result seems to be wrong. But if I compute the integral directly in Wolfram, the output then is ok. Could it be that the function FourierSeries and FourierCoefficient have a bug? Anyone has used them?
Thanks a lot, because I have consumed a lot of time trying to figure out my mistake...
For example, using this url.
And this one.
You can see a different result, and I think it should give the same output.
EDIT: The people from Technical Support in Wolfram have confirmed by mail there was a bug and are trying to fix it.
There does seem to be an error with WA's Fourier Series calculator for the function $\frac{3}{5-4\cos(x)}$. See this link.
We can proceed to develop the Fourier coefficients by noting that
$$\begin{align} \frac1{2\pi}\int_0^{2\pi}\frac{3}{5-4\cos(x)}e^{-inx}\,dx&=\frac1{2\pi i}\left(\oint_{|z|=1}\frac{z^{-n}}{z-1/2}\,dz-\oint_{|z|=1}\frac{z^{-n}}{z-2}\,dz \right)\tag1 \end{align}$$
For $n\le 0$, the first and second integrals on the right-hand side of $(1)$ have first order poles at $z=1/2$ and $z=2$, respectively. Hence, we have from the residue theorem
$$\frac1{2\pi}\int_0^{2\pi}\frac{3}{5-4\cos(x)}e^{-inx}\,dx= \left(\frac12\right)^n$$
For $n\ge 1$, we can make use of symmetry (evenness and $2\pi$-periodicity) and write
$$\begin{align} \frac1{2\pi}\int_0^{2\pi}\frac{3}{5-4\cos(x)}e^{-inx}\,dx&=\frac1{2\pi}\int_0^{2\pi}\frac{3}{5-4\cos(x)}e^{-i|n|x}\,dx\\\\ \end{align}$$
from which we immediately find that for $n\ge 1$
$$\frac1{2\pi}\int_0^{2\pi}\frac{3}{5-4\cos(x)}e^{-inx}\,dx= \left(\frac12\right)^{-n}$$
Therefore, we have
$$\begin{align} \frac{3}{5-4\cos(x)}&=\sum_{n=-\infty}^\infty \left(\frac12\right)^{|n|} e^{inx}\\\\ &=1 +2\sum_{n=1}^\infty \left(\frac12\right)^n\cos(nx) \end{align}$$