\documentclass{IEEEtran}[journal]

\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{listings}

\title{Exploring the Sampling Theorem with Fourier Analysis}
\author{Aidan Sharpe \& Elise Heim}

\DeclareMathOperator{\sinc}{sinc}

\begin{document}
\maketitle

\section{Results and Discussion}
\subsection{Aliasing}
The sampling theorem states that the sampling frequency must be at least twice the maximum frequency in a signal to be able to uniquely identify each frequency in the signal. When this condition, called the \emph{Nyquist sampling rate condition} is not satisfied, frequencies are no longer distinct. For example, given a sampling frequency of 100[Hz], the maximum distinct frequency is 50[Hz]. Seen in figure \ref{fig:aliasing}, despite being two frequencies: 20[Hz] (top) and 80[Hz] (bottom), they appear the same when plotted.

\begin{figure}[h]
    \includegraphics[width=0.48\textwidth]{Aliasing.png}
    \caption{Ambiguous frequency between 20[Hz] and 80[Hz]}
    \label{fig:aliasing}
\end{figure}

Applying the discrete Fourier transform on the samples of the 20[Hz] signal reveals large frequency contributions at 20[Hz] and 80[Hz] as seen in figure \ref{fig:20HzDTFT}.
\begin{figure}[h]
    \includegraphics[width=0.48\textwidth]{DTFT1.png}
    \caption{Discrete Time Fourier Transform of 20[Hz] signal sampled at 100[Hz]}
    \label{fig:20HzDTFT}
\end{figure}
Even though the signal is strictly a 20[Hz] sinusoidal signal, there seems to be a very strong contribution of 80[Hz]. The correct interpretation of this information is that the samples are identical for an 80[Hz] signal and a 20[Hz] signal sampled at 100[Hz].

\subsection{Fourier Analysis of the Difference of Two Unit Steps}

The Fourier transform is a powerful tool that can convert any signal in the time domain to a corresponding representation in the frequency domain. Given a signal, $x(t)$, its Fourier transform is given by:
\begin{equation}
    X(\omega) = F[x(t)] = \int\limits_{-\infty}^{\infty} x(t)e^{-j\omega t} dt
    \label{eqn:fourier}
\end{equation}
where $\omega$ is the angular frequency. Consider the difference of two unit steps:
$$x(t) = u(t+1/2) - u(t-1/2)$$
In this case, $x(t)$ only impacts the region in which the integral is not zero, so rather than taking the difference of two unit step integrals, the bounds of integration can simply be reduced to $[-1/2, 1/2]$. Evaluating this simpler integral gives:
\begin{equation}
    F[u(t+1/2) - u(t-1/2)] = {2 \sin(\omega/2) \over \omega}
\end{equation}
This result can be verified by using the \verb|fourier(x)| function in MATLAB\textsuperscript{\tiny\textregistered}. In this case, there is no maximum frequency since the Fourier transform is periodic. Therefore, the signal is not band-limited, and lossless sampling is not possible. By sampling with higher frequency, higher fidelity can be achieved. However, since the contribution of frequencies is inversely proportional to the frequency, there will quickly be diminishing returns with high frequency sampling.

Using a MATLAB\textsuperscript{\tiny\textregistered} script to calculate the percent of the power provided by the first $k$ periods of the Fourier transform of $x(t)$, the diminishing returns are quantified and plotted in figure \ref{fig:diminish}.
\begin{figure}[h]
    \includegraphics[width=0.48\textwidth]{DiminishingReturns.png}
    \caption{Diminishing returns on higher fidelity sampling}
    \label{fig:diminish}
\end{figure}

\subsection{Fourier Analysis of the $\sinc(t)$ Function}
Using the definition of the Fourier transform in equation \ref{eqn:fourier}, the $\sinc(t)$ function can be derived to be:
\begin{equation}
F[\sinc(t)] = \pi u(\pi-\omega) - \pi u(-\pi-\omega) 
\end{equation}
where $\sinc(t)$ is the normalized sinc function, and $u(\omega)$ is the unit step. The normalized sinc function was chosen over the unnormalized variant because it is more widely used in telecommunications and signal processing.

\subsection{Sampling Low Frequency Signals}
Considering the signal, $x_\text{compound}(t) = \cos(2\pi t / 5) + \sin(4\pi t / 7) + \cos(16\pi t / 9)$, the maximum frequency is less than 2[Hz]. Therefore, a sampling frequency of only 4[Hz] would still satisfy he Nyquist sampling rate condition. Seen in figure \ref{fig:lofreq} are the first 100 samples of a 4[Hz] sampling of $x_\text{compound}(t)$.
\begin{figure}[h]
    \includegraphics[width=0.48\textwidth]{LoFreqSampling.png}
    \caption{First 100 samples of $x_\text{compound}(t)$ at a sampling rate of 4[Hz]}
    \label{fig:lofreq}
\end{figure}

While the samples may appear quite random, by taking the discrete Fourier transform, and plotting the sums of the corresponding sinusoidal signals, the original continuous time signal can be recovered.

\subsection{Symbolic Fourier Analysis in MATLAB\textsuperscript{\tiny\textregistered}}
Finding the Fourier transform of $x(t) = e^{-4t} u(t)$ can be accomplished by evaluating the integral in equation \ref{eqn:fourier}. This results in the answer of $\frac{1}{4+j\omega}$. MATLAB\textsuperscript{\tiny\textregistered} can be utilized to confirm these calculations with the assistance of a very short program.

In order to find the Fourier transform of the function $x(t) = {\mathrm{e}}^{-a\,\left|t\right|}$, one must begin by taking the integral
\begin{equation}
    X(\omega) = \int e^{-a|t|}e^{-j\omega t}dt
\end{equation}
where $a$ is a constant. Evaluating yields two terms:
$${1 \over a + j\omega} + {1 \over a - j\omega}$$
These terms can further be combined and simplified to $\frac{2\,a}{a^2 +w^2 }$. These calculations were confirmed through a short MATLAB program that resulted in the same answer. Another MATLAB program can be utilized to find the Fourier transform of $x(t) = \cos \left(b\,t\right)$. This result is $\pi \,{\left({\delta }\left(b+w\right)+{\delta }\left(b-w\right)\right)}$. 

\subsection{Two-Dimensional Sampling}
In one dimension, we can consider sampling a time signal. In higher dimensions, we have a continuous-valued function. We evaluate this signal at intervals measured in meters. There are two types of frequencies: continuous space frequency associated with the original image, and discrete space frequency. The Fourier representations for continuous space signals and sampled discrete space signals are important for understanding sampling. The discrete space frequency is equal to the continuous space frequency multiplied by the sampling interval, and the discrete space is equal to continuous space times the sampling interval. The sampling frequencies are similar to the one-dimensional case, where a sample continuous space signal is the sum of samples multiplied by impulses. The spectrum is proportional to the convolution of the original signal and the Fourier transform. The spacing is inversely proportional because they were originally spaced in the frequency domain. Convolution with impulses shifts the function closer to zero, resulting in a sample signal spectrum proportional to the original signal spectrum shifted. The original signal spectrum is represented by a two-dimensional frequency domain quantity, replicated at the sampling frequencies. To prevent aliasing, the bandwidth must be smaller than half of the spacing between these replicas. The two-dimensional version of the Nyquist Sampling Theorem states that if the original image is band-limited, then it can be uniquely constructed from the samples taken. This requires achieving the same sample in a set time. A reconstruction can be created by taking a low-pass filter in two dimensions and choosing the portion of the spectrum that corresponds to the first term of the replicated sample signal spectrum.

\end{document}
