Mathematically, the Fourier series works like this. Suppose the periodic function you start with is $f(t)$, repeating with a period $T$. Then it can be expressed by

$$f(t)=a_0+\sum_{n=1}^\infty \left( a_n \cos \dfrac{2n\pi t}{T} + b_n \sin \dfrac{2n\pi t}{T} \right) \tag{1}$$

where

$$a_0=\dfrac{1}{T}\int_0^T f(t) dt, a_n=\dfrac{2}{T}\int_0^T f(t)\cos \dfrac{2n\pi t}{T} dt \tag{2}$$

and

$$b_n=\dfrac{2}{T}\int_0^T f(t)\sin \dfrac{2n\pi t}{T} dt. \tag{3}$$

Alternatively, there is a neater form in terms of complex numbers:

$$f(t)=\sum_{n=-\infty}^\infty c_n e^{2in\pi t/T} \tag{4}$$

where

$$c_n=\dfrac{2}{T}\int_0^T f(t)e^{-2in\pi t/T} dt. \tag{5}$$

If the function $f$ is not periodic, like the hammer pulse discussed in the main text, then instead of a sum over discrete harmonic frequency components we need an integral:

$$f(t)=\int_{-\infty}^\infty F(\omega) e^{i \omega t} dt \tag{6}$$

where

$$F(\omega)=\dfrac{1}{2\pi}\int_{-\infty}^\infty f(t) e^{-i \omega t} d\omega. \tag{7}$$

$F(\omega)$ is called the Fourier transform of $f(t)$.

You should note that not everyone chooses to put the factor $2 \pi$ in exactly the same place as it appears in equation (7). The factor always appears somewhere, in either or both of equations (6) and (7), but there are several possible ways to do it. These are all self-consistent, but lead to slightly different definitions of the transform. I will always use the convention shown here, but you may find alternative usage in textbooks or other web sites.

The FFT algorithm gives a way to calculate a Fourier series for a sampled function, where we only know the values of the function at times $t_n=nh$ where $h$ is the chosen time step, the inverse of the sampling rate. So for example a typical audio file with a sampling rate of 44.1 kHz has an interval $h = 1/44100$ s = 22.7 $\mu$s. Although it is called the Fast Fourier *Transform*, this is misleading: a computer can only ever handle a finite number of sampled values, and what the FFT gives you is the set of (complex) Fourier *series* coefficients based on harmonics of the frequency which is the inverse of the total length of the sampled segment in seconds. An important result, the Nyquist-Shannon sampling theorem, tells us that the FFT contains frequency components only up to the *Nyquist frequency*, which is half the sampling frequency (e.g. 22.05 kHz for the audio file). If the original signal contained frequency content higher than this frequency it will be represented in a misleading way in the FFT result, a phenomenon known as *aliasing*.