Updated Feb 2022: Cleared up some of the wording.
A brief overview of Fourier analysis (Fourier series and transform).
Fourier Series
Fourier’s theorem
Statement
A function is periodic with period \(2\pi\) if
\[f(x) = f(x + 2\pi).\]\(f(x)\) need only be given on the half-open interval \(x \in [0, 2\pi)\) for it to be specified everywhere.
Fourier’s theorem states that any such \(f(x)\) which is well behaved can be written in each one of the three following (equivalent) forms:
\[\fcolorbox{white}{indigo}{ $ \begin{aligned} f(x) &= \frac{a_0}{2} + \sum_{n = 1}^{\infty} \left[ a_n \mathrm{cos}(nx) + b_n \mathrm{sin}(nx) \right]\\ f(x) &= \frac{a_0}{2} + \sum_{n = 1}^{\infty} A_n \mathrm{cos}(nx + \phi_n)\\ f(x) &= \sum_{n = -\infty }^{\infty} c_n e^{inx} \end{aligned} $ }\]The different sets of coefficients \((a_n, b_n), \ (A_n, \phi_n), \ c_n\) can be converted between easily via trigonometric relations.
Formulae for the coefficients
We are going to make use of the integrals
\[\begin{aligned} I_{n,m} &= \int_0^{2\pi } \mathrm{cos} (nx) \ \mathrm{cos} (mx) \ dx = \delta_{n,m}\pi \\ J_{n,m} &= \int_0^{2\pi } \mathrm{cos} (nx) \ \mathrm{sin} (mx) \ dx = 0 \\ K_{n,m} &= \int_0^{2\pi } \mathrm{sin} (nx) \ \mathrm{sin} (mx) \ dx = \delta_{n,m}\pi. \end{aligned}\]If we integrate \(f(x)\) over its range, \(\int_0^{2\pi} f(x) \ dx\), we see that since the average value of \(\mathrm{sin}(nx)\) and \(\mathrm{cos}(nx)\) is zero. The integral reduces to \(\int_0^{2\pi} \frac{a_0}{2} \ dx\), so we find
\[a_0 = \frac{1}{\pi} \int_0^{2\pi} f(x) \ dx.\]Note: we can integrate over \(2\pi\) at any point in the function’s range, so this is perfectly equivalent to
\[\frac{a_0}{2} = \frac{1}{2\pi} \int_{-\pi}^{\pi} f(x) \ dx.\]In other words, \(\frac{a_0}{2}\) is the average value of \(f(x)\).
For the \(a_n\) coefficients, multiply \(f(x)\) by \(\cos (mx)\) and integrate over the range:
\[\begin{aligned} \int_0^{2\pi} \cos(mx) f(x) \ dx &= \int_0^{2\pi} \sum_{n=1}^{\infty} a_n \cos(nx) \cos(mx) \ dx \\ &= \sum_{n=1}^{\infty}\int_0^{2\pi} a_n \cos(nx) \cos(mx) \ dx \\ &= a_m \int_0^{2\pi} \cos^2(mx) \ dx = \pi a_m, \end{aligned}\]finally, relabelling \(m\) to \(n\) gives
\[\fcolorbox{white}{indigo}{$ \begin{aligned} a_n = \frac{1}{\pi} \int_0^{2\pi} \cos(nx) f(x) \ dx. \end{aligned} $}\]Exactly the same argument holds for the \(b_n\), so similarly
\[\fcolorbox{white}{indigo}{$ \begin{aligned} b_n = \frac{1}{\pi} \int_0^{2\pi} \sin(nx) f(x) \ dx. \end{aligned} $ }\]Examples
Square wave example
Given the function
\[f(x)=\begin{cases} -1 & -\pi \leq x < 0\\ \phantom{-} 1 & \phantom{-} 0 \leq x < \pi \end{cases}\]We see that since it is odd, \(a_n\) must be zero, and we find the \(b_n\) to be \(b_n = \frac{2}{n\pi} \left( 1 - (-1)^n \right)\)
So the Fourier series representation of \(f(x)\) is
\[f(x) = \sum_{n=1}^{\infty} \frac{2}{n\pi} \left( 1 - (-1)^n \right) \sin(nx).\]Triangle wave example
Given the function
\[f(x)=\begin{cases} -x & -\pi \leq x < 0\\ \phantom{-} x & \phantom{-} 0 \leq x < \pi \end{cases}\]We see that since it is even, \(b_n\) must be zero, and we find the \(a_n\) to be \(a_n = \frac{2}{n^2 \pi} \left( (-1)^n - 1 \right)\)
So the Fourier series representation of \(f(x)\) is
\[f(x) = \sum_{n=1}^{\infty} \frac{2}{n^2 \pi} \left( (-1)^n - 1 \right) \cos(nx) .\]Extension to other periods
Suppose \(f(x) = f(x + T),\) that is \(f(x)\) is periodic with some arbitrary period. Then we would write
\[f(x) = \frac{a_0}{2} + \sum_{n = 1}^{\infty} \left[ a_n \mathrm{cos}\left(\frac{2\pi nx}{T} \right) + b_n \mathrm{sin}\left(\frac{2\pi nx}{T} \right) \right]\]And the formulae for the coefficients would become
\[\begin{aligned} a_0 &= \frac{2}{T} \int_{-\frac{T}{2}}^{\frac{T}{2}} f(x) \ dx \\ a_n &= \frac{2}{T} \int_{-\frac{T}{2}}^{\frac{T}{2}} \cos \left(\frac{2\pi nx}{T} \right) f(x) \ dx \\ b_n &= \frac{2}{T} \int_{-\frac{T}{2}}^{\frac{T}{2}} \sin \left(\frac{2\pi nx}{T} \right) f(x) \ dx. \\ \end{aligned}\]This can be simplified by rewriting in terms of angular frequency \(T = \frac{2\pi}{\omega}\)
giving
\[\fcolorbox{white}{indigo}{ $ \begin{aligned} f(x) &= \frac{a_0}{2} + \sum_{n = 1}^{\infty} \left[ a_n \mathrm{cos}(n \omega x) + b_n \mathrm{sin}(n \omega x) \right]\\ a_n &= \frac{2}{T} \int_{-\frac{T}{2}}^{\frac{T}{2}} \cos \left(n \omega x \right) f(x) \ dx \\ b_n &= \frac{2}{T} \int_{-\frac{T}{2}}^{\frac{T}{2}} \sin \left(n \omega x \right) f(x) \ dx. \\ \end{aligned}$ }\]Fourier Transform
Derivation from Fourier Series
Earlier, we noted that the Fourier series can be written
\[f(x) = \sum_{n=-\infty}^{\infty} c_n e^{inx}.\]Using the fact that \(\int_{-\pi}^{\pi} e^{-imx} e^{inx} \ dx = 2\pi \delta_{n,m}\) and integrating over the series representation, we extract the coefficients
\[c_n = \frac{1}{2\pi} \int_{-\pi}^{\pi} e^{-inx} f(x) \ dx.\]For a period of \(2\pi L\), the series becomes
\[\begin{aligned} f(x) &= \sum_{n=-\infty}^{\infty} c_n e^{\frac{inx}{L}}\\ c_n &= \frac{1}{2\pi L} \int_{-\pi L}^{\pi L} e^{\frac{-inx}{L}} f(x) \ dx.\\ \end{aligned}\]Now we define \(\hat{f}\left( \frac{n}{L}\right) = c_n,\) that is, a function that is only defined at the points \(\frac{n}{L}\). The series now looks like
\[\begin{aligned} f(x) &= \sum_{n=-\infty}^{\infty}\hat{f}\left( \frac{n}{L}\right) e^{\frac{inx}{L}}\\ \hat{f}\left( \frac{n}{L}\right) &= \frac{1}{2\pi L} \int_{-\pi L}^{\pi L} e^{\frac{-inx}{L}} f(x) \ dx.\\ \end{aligned}\]Further, if we define \(\widetilde{f}\left( \frac{n}{L} \right) = \sqrt{2\pi} L \hat{f}\left( \frac{n}{L}\right)\) we get
\[\begin{aligned} f(x) &= \frac{1}{\sqrt{2\pi}} \sum_{n=-\infty}^{\infty}\widetilde{f}\left( \frac{n}{L}\right) e^{\frac{inx}{L}} \frac{1}{L}\\ \widetilde{f}\left( \frac{n}{L} \right) &= \frac{1}{\sqrt{2\pi}} \int_{-\pi L}^{\pi L} e^{\frac{-inx}{L}} f(x) \ dx.\\ \end{aligned}\]Rewriting \(\frac{n}{L}\) as \(k\) and taking \(L \rightarrow \infty\) finally gives us
\[\fcolorbox{white}{indigo}{ $ \begin{aligned} f(x) &= \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} e^{ikx}\widetilde{f}(k) \ dx\\ \widetilde{f}(k) &= \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} e^{-ikx} f(x) \ dx.\\ \end{aligned}$ }\]Examples
Gaussian function
Suppose we have \(f(x) = e^{-\alpha x^2}.\) The Fourier transform of this is
\[\begin{aligned} \widetilde{f}(k) &= \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} e^{-ikx} e^{-\alpha x^2} \ dx\\ &= \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} e^{-\alpha \left( x + \frac{ik}{2\alpha} \right)^2 - \frac{k^2}{4\alpha}} \ dx.\\ \end{aligned}\]Shifting this by the substitution \(y = x + \frac{ik}{2\alpha}\) gives
\[\begin{aligned} \widetilde{f}(k) &= \frac{1}{\sqrt{2\pi}} e^{-\frac{k^2}{4\alpha}} \int_{-\infty}^{\infty} e^{-\alpha y^2} \ dy\\ &= \frac{1}{\sqrt{2\pi}} e^{-\frac{k^2}{4\alpha}} \sqrt{\frac{\pi}{\alpha}}\\ &= \frac{1}{\sqrt{2\alpha}} e^{-\frac{k^2}{4\alpha}}. \end{aligned}\]Another Gaussian, but stretched.
Square pulse
Given the function
\[f(x)= \begin{cases} \frac{1}{A} & -A \leq x \leq A\\ 0 & \phantom{--..} |x| > A\\ \end{cases}\]its Fourier transform is
\[\begin{aligned} \widetilde{f}(k) &= \frac{1}{\sqrt{2\pi}} \int_{-A}^{A} \frac{1}{A} e^{-ikx} \ dx \\ &= \frac{1}{A\sqrt{2\pi}} \left[ \frac{e^{ikA} - e^{-ikA}}{ik} \right]\\ &= \sqrt{\frac{2}{\pi}} \frac{\sin(kA)}{kA}\\ &= \sqrt{\frac{2}{\pi}} \mathrm{sinc}(kA)\\ \end{aligned}\]Convolutions
Definition
A convolution is an integral transform that takes two functions and composes them, forming a new function. The definition is
\[(f \star g)(x) = \int_{-\infty}^{\infty} f(x')g(x-x') \ dx'.\]Fourier Transform of a Convolution
The Fourier transform of the convolution of two functions is \(\sqrt{2\pi}\) times the product of the Fourier transforms.
\[\begin{aligned} \mathcal{F}\{f \star g\} &= \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} e^{-ikx} \left[ \int_{-\infty}^{\infty} f(x') g(x-x') \ dx' \right] dx\\ &= \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} f(x') \int_{-\infty}^{\infty} g(x-x') e^{-ikx} \ dx' dx\\ \end{aligned}\]Setting \(y = x - x'\) gives
\[\begin{aligned} \mathcal{F}\{f \star g\} &= \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} f(x') \ dx' \int_{-\infty}^{\infty} e^{-ik(x'+y)} g(y) \ dy\\ &= \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} e^{-ikx'} f(x') \ dx' \int_{-\infty}^{\infty} e^{-iky} g(y) \ dy\\ &= \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} e^{-ikx'} f(x') \ dx' \int_{-\infty}^{\infty} e^{-iky} g(y) \ dy\\ &= \sqrt{2\pi} \widetilde{f}(k) \widetilde{g}(k). \end{aligned}\]