I have read online that Fourier series are only applicable to periodic functions. Ive included the following example in my work however it is not a periodic function, does this mean that the following calculation is incorrect?
Consider the function $f(x)=x-\pi$, then the following Fourier coefficients over the region$[0,2\pi]$ are:
$a_0={}\frac{1}{\pi}\int^{2\pi}_{0}f(x)\,dx \hspace{1em}\,
={} \frac{1}{\pi}\int^{2\pi}_{0}(x-\pi)\,dx
={} \frac{1}{\pi}\left[\frac{1}{2}x^2-\pi x\right]^{2\pi_{0}}
={}\frac{1}{\pi}(2\pi^2-2\pi^2)
={}0\\
a_n={}\frac{1}{\pi}\int^{2\pi}_{0}\cos(nx)(x-\pi)\,dx
={}\frac{1}{\pi}\left[\frac{\sin(nx)(x-\pi)}{n}\right]^{2\pi}_{0}-\frac{1}{\pi}\int_{0}^{2\pi}\frac{\sin(nx)}{n}\,dx ={}\frac{1}{\pi}\left[\frac{-cos(nx)}{n2}\right]^{2\pi}_{0}
={}0\\
b_n={}\frac{1}{\pi}\int_{0}^{2\pi}\sin(x)(x-\pi)\,dx
={}\frac{1}{\pi}\left[\frac{-cos(x)(x-\pi)}{n}\right]^{2\pi}_{0}+\frac{1}{\pi}\int_{0}^{2\pi}\frac{\cos(nx)}{n}
={}\frac{1}{\pi}\left(\frac{-\pi}{n}\right)-\frac{1}{\pi}\left(\frac{\pi}{n}\right)
={}-\frac{2}{n}$
Giving Fourier series $x-\pi =-\sum_{n=1}^{\infty}\frac{2}{n}\sin(nx)$
Thanks in advance for any help!!
Since you have limited the function to the region $[0,2\pi)$, you've basically stated that the period is $2\pi$. The resulting Fourier series will simply repeat itself on the intervals $[0,2\pi)$, $[2\pi,4\pi)$, $[4\pi,6\pi)$, and so on.
Try plotting the resulting Fourier series for a large number of terms. You will see a periodic "saw" pattern emerge. What you calculated is the Fourier series of that periodic saw function.
But of course, you can restrict yourself to the interval $[0,2\pi]$ afterwards if you want. There is nothing wrong with that.
Edit: To answer the question more directly, no, taking the Fourier series of a non-periodic function is not strictly speaking possible. To treat non-periodic functions, you need to use an integral Fourier transform, which you can think of as a Fourier series with an infinite period.