More Fourier Series I'm trying to compute the Fourier series of $$f(x)=\frac{1}{2-\cos(x)}$$ on the interval $[0, 2\pi]$. It is an even function, so I need to determine the $a_n$ coefficients. They are given by the following integral:
$$a_n=\frac{1}{\pi}\int_{0}^{2\pi}\frac{\cos(nx/2)}{2-\cos(x)}dx.$$
However, for some reason I can't compute this integral and am thinking I might be doing something wrong. Can anyone help?
 A: Let $\alpha = 2-\sqrt{3}$.  For $|z|=1$ we have the following Laurent expansion:
$$
\frac{1}{2-\frac{z+z^{-1}}{2}} =\frac{-2z}{z^2-4z+1} = \frac{\alpha}{\sqrt{3}z(1-\frac{\alpha}{z})} + \frac{1}{\sqrt{3}(1-\alpha z)}=\\
\frac{1}{\sqrt{3}}\left(\dotsc +\frac{\alpha^2}{z^2} +\frac{\alpha}{z}+1 + \alpha z + \alpha^2 z^2 + \dotsc \right)
$$
Set $z = e^{ i x}$ to get the required Fourier transform:
$$
\frac{1}{2-\cos(x)} = \frac{1}{\sqrt{3}} + \frac{2}{\sqrt{3}} \sum_{n=1}^\infty (2-\sqrt{3})^n \cos(n x).
$$
A: With a general $n$ in the integral formulas, Mathematica didn't finish the integration after more than a minute, which indicates something nontrivial is going on.
However, for particular $n$ values, it finishes very quickly.
f[x_] = 1/(2 - Cos[x]);
L = 2 Pi;
a[n_] := If[n == 0, 2/L*Integrate[f[x], {x, 0, L}], 
   2/L*Integrate[f[x] Cos[n Pi x/L], {x, 0, L}]]
Table[a[n], {n, 0, 10}]


FC[x_, n_] := 1/2*a[0] + Sum[a[i] Cos[i Pi x/L], {i, 1, n}]; 
Plot[Evaluate[{f[x], FC[x, 5]}], {x, 0, L}, 
 PlotStyle -> {{Thick, Black}, {Thick, Blue}}, ImageSize -> 400]


Hope that helps.
