Fourier series: The Fourier series of an arbitrary function
The overall concept
With the Fourier sine series and the Fourier cosine series one can approximate any periodic continuation of a 'neat' function on the interval \((-\pi,\pi)\). The combined Fourier series is then \[\begin{aligned}f(x) &= a_0+a_1\cos(x)+b_1\sin(x)+ a_2\cos(2x)+b_2\sin(2x)\\ &\phantom{=a_0}\;{}+ a_3\cos(3x)+b_3\sin(3x)+\ldots\\ \\ &= a_0+\sum_{n=1}^{\infty}\bigl(a_n\cos(nx) +b_n\sin(n x)\bigr)\end{aligned}\] where the Fourier coefficients can be calculated using the following formulas \[\begin{aligned} a_0 &= \frac{1}{2\pi}\int_{-\pi}^{\pi}f(x)\,\dd x \\ \\ a_n &= \frac{1}{\pi}\int_{-\pi}^{\pi}f(x)\cos(nx)\,\dd x\qquad\text{if }n\ge 1\\ \\ b_n &= \frac{1}{\pi}\int_{-\pi}^{\pi}f(x)\sin(nx)\,\dd x \qquad\text{if }n\ge 1\end{aligned}\] The "cleanliness" of the periodic function is set by the so-called Dirichlet conditions, which must be met. These conditions are that the function \(f\) is continuously differentiable (i.e., the derivative \(f'\) exists and is continuous) with the exception of a finite number of points, and that both the function \(f\) and \(f'\) are piecewise defined on the interval and in jump points have function values that are equal to the average value of lower and upper limit of the function. Henceforth we will always assume in examples that these Dirichlet conditions are met.