Why does extending a function to an even/odd function work when finding a Fourier series? A function $f(x)$ over an interval $[0,l)$ can be extended to an odd/even function.
E.g. the function $f(x) = x$ can be extended to an even function
$ g(x) =
\begin{cases}
  x & 0 < x \\
  -x & x \leq 0
\end{cases}
$
Then we can use a Fourier cosine series. I understand why there are no sine terms (because the product of an even and odd function is odd, and integrated over symmetric limits it evaluates to $0$).
However, I do not understand why the Fourier series for the extended function $g(x)$ is the same as for $f(x)$. They are two different functions, surely they must have a different Fourier series?
The explanation I saw given was that $f(x) = g(x)$ over $[0, 1)$, which is obviously true. However, we evaluated the series over $[-1, 1)$, not $[0, 1)$.
So my question: why is the Fourier series for a function that has been extended to be odd/even the same as the original function?
 A: A comment that got too long and explains what happens:
the Fourier series of a function depends on the interval of integration - for example if we take a function on $[0,1]$ and use the standard basis $\sin n\pi x, \cos n \pi x$ for the Fourier series, we need to integrate $f$ on $[-1,1]$ as that is where those functions form a basis so we need to give values to $f$ on $(-1,0)$ so we get various Fourier series depending on how we extend (we could do odd, even but other ways like say $0$ there - as long as we still get an integrable function we are good); it is a basic result of Fourier series theory and part of why the theory is powerful that the result still converges to the original $f$ on $(0,1)$ (or to the usual $(f(x^+)+f(x^-))/2$ etc) whenever convergence happens (eg $f$ piecewise smooth) or is summable Caesaro to $f$ when summability happens (eg $f$ continuos) regardless which extension, hence which Fourier series we use - at the ends $0,1$ it depends since there the result generally sums/converges to $(f(0^+)+f(0^-))/2$ and same for $1$ so for example for the odd extension we always get $0$ etc
Note that by taking $\cos 2n\pi x, \sin 2n\pi x$ as basis we can get a Fourier series just for the original $f$ since now those are basis on $[0,1]$ and again the result sums/converges to the usual numbers related to $f$ whenever it sums/converges
So by completion, we can get many Fourier series for a function depending on which interval we consider it so which trigonometric basis we choose, but they all behave the same in the neighborhood of any interior point of the original interval where $f$ was given, behavior depending only on the values of the original $f$ there
And to answer concretely the OP question at the end - the Fourier series for $f_{odd},f_{even}$ where those are the odd/even extensions of $f$ to $(-1,0)$ (where we can always change $f(0)$ to $0$ if needed to have a "true" odd extension) are different (different coefficients) and behave differently on $(-1,0)$ but they have the same behavior on $(0,1)$ despite having different coefficients since the behavior there depends only on the original $f$; at the ends $0,1$ again the behavior is different but easily controllable by the defintion of $f_{odd},f_{even}$, while there is no such a thing as "The Fourier series of $f$ on $(0,1)$ with basis $\cos n\pi x, \sin n\pi x$" since those are not a basis there (they are not periodic unless $n$ even) so we need an extension to $(-1,1)$
