[Math] Fourier Series of a Constant Function

analysisfourier series

My question is kinda dumb, but here I go: I'm studying Fourier Series on my own for my next semester. I needed to calculate the Fourier Series of the function $f(x) = 5$ defined in $[-4,4]$.

In this case, using the standard notation, $L = 4$ are the coefficients are
$a_{0} = \dfrac{1}{L} \displaystyle \int_{-L}^{L} f(x) \ dx$; $a_{n} = \dfrac{1}{L} \displaystyle \int_{-L}^{L} f(x) \cdot \cos\bigg(\dfrac{n\pi x}{L}\bigg) \ dx$ and $b_{n} = \dfrac{1}{L} \displaystyle \int_{-L}^{L} f(x) \cdot \sin\bigg(\dfrac{n\pi x}{L}\bigg) \ dx$, correct?

Since the function is constant the sines and cosines must have no contribution to the Fourier series at all, i.e., $a_{n} = b_{n} = 0$, but when I'm doing the calculations I'm getting $a_{n} = \dfrac{10}{\pi n} \sin(\pi n)$. It must be a pretty dumb mistake I'm not seeing, I'm kinda new at this subject.

Thanks for the help :]

Best Answer

$a_n = $$\frac {1}{L}\int_{-L}^L 5\cos(\frac {n\pi x}{L}) dx\\ \frac {1}{L}(5\sin(\frac {n\pi x}{L})(\frac {L}{n\pi})|_{-L}^L\\ (\frac {5}{n\pi})(\sin( {n\pi})-\sin(-{n\pi})) = 0$

since $\sin( {n\pi}) = 0$

$b_n = $$\frac {1}{L}\int_{-L}^L 5\sin(\frac {n\pi x}{L}) dx\\ \frac {1}{L}(-5\cos(\frac {n\pi x}{L})(\frac {L}{n\pi})|_{-L}^L\\ (\frac {-5}{n\pi})(\cos( {n\pi})-\cos(-{n\pi})) = 0$

since $\cos x$ is an even function.