Why does knowing whether the function is odd or even make calculating the fourier series easier? [duplicate]

This question already has an answer here:

The fourier series is given by $$f(x)=\frac12a_0+\sum_{n=1}^\infty(a_n\cos(nx)+b_n\sin(nx))$$ after doing a few examples I noticed that whenever I was evaluating an even function the $a_n$ would disappear because it always turned out to be $0$ after calculating the integral, and when I was evaluating odd functions the $b_n$ would disappear because it would always turn out to be $0$ after calculating the integral.
So how come finding the fourier series of an even function causes the $a_n$ to be $0$ and vice versa for an odd function?

marked as duplicate by idknuttin, user91500, BLAZE, draks ..., Claude LeiboviciDec 10 '15 at 8:25

• Since $\sin$ is odd, if the function is even, there be no $\sin$ components or else the series wouldn't be even, and hence wouldn't equal the function. (And vice-versa) – David Dec 10 '15 at 0:33
Note that any function whose domain is symmetric about $0$ can be written uniquely as the sum of an even function and an odd function. For if $f(x) = e(x) + o(x)$ where $e$ is even and $o$ is odd, then $f(-x) = e(x) - o(x)$, so we can solve for $$e(x) =\frac{f(x) + f(-x)}{2}\\o(x) =\frac{f(x) - f(-x)}{2}$$ Conversely, for an arbitrary function $f$, we can define functions $e$ and $o$ by these formulas. It is easy to see that $e$ is even, $o$ is odd, and $f = e + o$.
If $f$ itself is even, then $e = f$, and $o(x) = 0$ for all $x$. If $f$ is odd, then $o = f$, and $e = 0$.
Now, since $\cos x$ is even, so is $$\frac {a_0} 2 + \sum_{n=1}^\infty a_n\cos nx$$ and similarly, $$\sum_{n=1}^\infty b_n\sin nx$$ is odd. Therefore if $$f(x) = \frac {a_0} 2 + \sum_{n=1}^\infty (a_n\cos nx + b_n\sin nx)$$ then $$e(x) = \frac {a_0} 2 + \sum_{n=1}^\infty a_n\cos nx\\ o(x) = \sum_{n=1}^\infty b_n\sin nx$$ And if $f$ itself is even or odd, then the opposite formula will be $0$.