# Fourier series of $\cos (x)$ in $[-\pi , \pi ]$ , coefficients are giving $0$

I don't know if I'm doing something wrong, I need to find the Fourier series of $$f(x) = \cos (x)$$ in $$[- \pi , \pi ]$$ but all the coefficients are giving me $$0$$.

First, clearly $$b_n = 0$$ since $$b_n = \frac{1}{\pi} \int^{\pi}_{-\pi} \cos(x) \sin (n x )dx = 0$$ because it's an odd function.

Then, $$a_0 = \frac{1}{\pi} \int^{\pi}_{-\pi} \cos(x) dx = 0$$ , I don't think there's a detail in this integral.

But, $$a_n = \frac{1}{\pi} \int^\pi_{-\pi} \cos(x) \cos (nx )dx$$ seems to have a detail I'm missing. I did the following:

$$a_n = \frac{1}{\pi} \int^\pi_{-\pi} \cos(x) \cos (nx )dx = \frac{2}{\pi} \int^\pi_{0} \bigg[ \frac{1}{2} \cos ((n+1)x) + \frac{1}{2} \cos ((n-1)x) \bigg] dx = \frac{1}{\pi} \bigg[ \frac{1}{n+1} \sin ((n+1)x) + \frac{1}{n-1} \sin ((n-1)x) \bigg]_{0}^{\pi} = 0$$

I think I'm missing some detail in $$a_n$$ because I don't think my procedures were wrong in $$a_0$$ and $$b_n$$. Any help is greatly appreciated. Thanks.

• Is it the Fourier sine series? Commented Feb 19, 2023 at 16:54
• Don't forget that $\cos(0) = 1$, and that doesn't become a $\sin$ when integrated. Commented Feb 19, 2023 at 16:57

You did everything correctly except for $$n=1$$: Note that you're dividing by $$n-1$$ in the last equality.
Instead you'll get $$a_1=\frac{1}{\pi}\int_{-\pi}^{\pi}\cos^2(x)dx=\frac{1}{\pi}\int_{-\pi}^{\pi}\sin^2(x)dx=2-\frac{1}{\pi}\int_{-\pi}^{\pi}\cos^2(x)dx=2-a_1$$ by integration by parts. Thus, $$a_1=1$$.
• Slight clarification, it's only what you should expect since the period of $cos(x)$ is $T=2 \pi$ and the integration interval [−π,π] is a positive integer multiple of $T=2 \pi$, so only in this case is $cos(x)$ is it's own Fourier series. Commented Feb 19, 2023 at 19:41