Courtesy of Matthew Jenkins
<aside> đź’ˇ Fourier Series:
Any periodic function can be written as an infinite sum of cosines and sines with angular frequencies that are integer multiples of the fundemental frequency $\frac{2\pi}{L}$
The Fourier Series of a periodic function $f(x)$ with period/wavelength $L$ is defined as:
$$ f(x) = \frac{a_0}2 + \sum_{n=1}^\infin a_n\cos\frac{2\pi nx}L + \sum_{n=1}^\infin b_n\sin\frac{2\pi nx}L $$
where
$$ \begin{align*} a_n &= \frac2L\int_{x_0}^{x_0+L} f(x)\ \cos\frac{2\pi n x}L \ \ dx \\ \ \\ b_n &= \frac2L\int_{x_0}^{x_0+L} f(x)\ \sin\frac{2\pi n x}L \ \ dx \end{align*} $$
The $a_n$ equation above is defined for every $n$ except $n=0$, so to solve for $a_0$ we can set $n=0$ and solve before integrating, giving us:
$$ a_0 = \frac2L\int_{x_0}^{x_0+L} f(x)\ dx $$
…because $\cos(2\pi n)$ is always $0$. If $a_n=0$, $a_0=0$.
Notes:
</aside>
Let’s say we approximate our periodic function with a fourier series approximation with N terms:
$$ f_N(x) = \frac{a_0}2 + \sum_{n=1}^N a_n\cos\frac{2\pi nx}L + \sum_{n=1}^\infin b_n\sin\frac{2\pi nx}L $$
This and all its derivatives are continuous, meaning it approximates $f(x)$ well except at a discontinuity, where it approximates a jump with a smooth function. As a result, there is always a overshoot at the discontinuity resulting in Gibbs’ Peaks.
The peaks overshoot the jump by about 9% for any function with a discontinuity as $N\rarr\infin$.
Instead of using $\sin\frac{2\pi nx}L$ and $\cos\frac{2\pi nx}L$, we can use $e^{i2\pi nx/L}$:
<aside> đź’ˇ
Complex Fourier Series:
The Complex Fourier Series of a function $f(x)$ is defined as:
$$ f(x)=\sum_{n=-\infin}^\infin d_n e^{i2\pi nx/L} $$
Note: The above sum is over all $n$, not just positive.
$d_n$ is given by the following:
$$ d_n=\frac1L \int_{x_0}^{x_0+L} f(x) e^{-i2\pi nx/L} $$
</aside>
By replacing $e^{i2\pi nx/L}$ with $\cos\frac{2\pi nx}L + i\sin\frac{2\pi nx}L$, we can solve for $d_n$ and find that:
$$ \begin{matrix*} a_n = d_n+d_{-n} &&&& b_n = i(d_n-d_{-n})
\end{matrix*} $$
Consider a function that vanishes at $x=\pm\infin$ (pictured above):