What is the $L$ in the Fourier series term? I am a bit confused about this:
I want to calculate the Fourier series $S^f$ of $f(x)$, where $f$ is periodic with period $k\in \mathbb{R}$.
I know that the equations for my terms are:
$$a_n=\frac{\color{red}{2}}{L} \int_{-L}^L f(x)\cos {\frac{n\pi x}{L}} dx$$
$$b_n=\frac{\color{red}{2}}{L} \int_{-L}^L f(x)\sin {\frac{n\pi x}{L}} dx$$
How do I know what is $L$?
Example:$$
f(x)=\left\{\begin{matrix}
L+x, & -L\leq x <0\\ 
L-x, & 0 \leq x<L
\end{matrix}\right.$$
Assume that the given function is periodically extended outside the original interval.
I am getting confused between $L=2 \pi$ and $L=\pi$ in this example.
Another one:
$$f(x)=\left\{\begin{matrix}
0, & -1\leq x <0\\ 
x^2/4, & 0 \leq x<1
\end{matrix}\right.$$

For the formula for Fourier coefficients, the function is originally defined on $[-L,L]$, and then the function is extended to a periodic function on ${\mathbb R}$. 
So in your first example the $L$ in the formula for Fourier coefficients is the same as the $L$ in the definition of the function, while in the second case the $L$ in the formula for Fourier coefficients is equal to $1$.
