Correct computation of Fourier Coefficient in WolframAlpha

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}

• Thanks a lot! Yes, that's the way I derived the coefficients, so it seems WA is giving a wrong output. At first of course I thougth that the mistake was on my part, because the FourierSeries calculator its surely commonly used, and the function it's not a complicated one... I have written an email to them to report the apparent bug. – Jaime Arboleda Castilla May 10 '18 at 7:04
• You're welcome. My pleasure. – Mark Viola May 10 '18 at 13:41
• Ok, I voted up, but I did not know that I needed to tick also to accept the answer (I'm more or less new here). Thanks again! :) – Jaime Arboleda Castilla May 10 '18 at 20:34
• No, there can only be one answer? I did not know. – Jaime Arboleda Castilla May 13 '18 at 18:47

A more direct computation without Fourier integrals uses partial fraction decomposition after inserting $\cos x = \frac12(e^{ix}+e^{-ix})$ and $e^{ix}=z$ and geometric series for the factors \begin{align} \frac{3}{5-2(z+z^{-1})}&=-\frac{(4z-2)-(z-2)}{(2z-1)(z-2)}=\frac{1}{2z-1}-\frac2{z-2}\\ &=\frac1{2z}\sum_{k=0}^\infty \left(\frac{1}{2z}\right)^k+\sum_{k=0}^\infty \left(\frac{z}{2}\right)^k\\ &=\frac12+\sum_{k=1}^\infty\frac{z^k+z^{-k}}{2^{k}}\\ &=\frac12+\sum_{k=1}^\infty\frac{\cos(kx)}{2^{k-1}}. \end{align}