Fourier series for a non-periodic function on an Interval I have a Non-periodic function for which I have to write a Fourier series. The function is defined in an snterval $[0,L]$.
I can take odd or even extension and write the Fourier series. But I want to know if I can write the Fourier series by taking  the function to be periodic with a period L, i.e  I take the function to periodic with periodicity equal to its interval in which its defined. Will this method work? What condition do I have to enforce to make this work?
Also is it necessary that to write a Fourier series in an Interval, the interval should be of the form $[-X,X]$?
 A: Yes, one can use a periodic extension of a function in order to express it as a Fourier series. A typical exercise on the subject is: consider the function $f(x)=x^2$ on the interval $[0,L]$, extended periodically...  This means you'll have an expansion in terms of $\cos\frac{2\pi}{L}n x$ and $\sin\frac{2\pi}{L} nx$ (as these are periodic with period $L$), and the coefficients are 
$$
A_n = \frac{2}{L}\int_0^L f(x)\cos \frac{2\pi n}{L} x\,dx, \quad 
B_n = \frac{2}{L}\int_0^L f(x)\sin \frac{2\pi n}{L} x\,dx
$$ 
for $n=0,1,2,\dots$ (by convention, the series contains $A_0/2$ as the constant term, which allows the above formula to work also when $n=0$.) The interval need not be symmetric ($[-a,a]$) in order for the Fourier series to exist; however, it's often more convenient to integrate over symmetric intervals. 
The quality of approximation near the endpoints may be poor if the behavior of the function at both ends does not match. To mitigate this issue, and also to avoid the problem of non-symmetric interval, I suggest using even periodic extension: that is, first extend the function to $[-L,L]$ as an even function, $f(-x)=f(x)$, and then extend periodically as a function with period $2L$, meaning $f(x+2L)=f(x)$. An advantage of doing so is that $f(-L)=f(L)$ automatically, so the values at the end of the interval $[-L,L]$ match. 
In practice, the above means using the cosine Fourier series
$$
f(x) = \frac{A_0}{2} + \sum_{n=1}^\infty A_n\cos \frac{\pi n}{L} x
$$
where 
$$
A_n = \frac{2}{L}\int_0^L f(x)\cos \frac{\pi n}{L} x\,dx, \quad n=0,1,2,\dots
$$
My blog post illustrates the advantage of using cosines in such situations on the example of non-periodic function $e^x$.
