\documentclass[report]{IEEEtran}

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

\lstdefinestyle{codestyle}{
    commentstyle=\color{green},
    keywordstyle=\color{blue},
    numberstyle=\tiny\color{gray},
    stringstyle=\color{purple},
    basicstyle=\ttfamily\footnotesize,
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=2
}

\lstset{style=codestyle}

\title{Discrete \& Symbolic Fourier Series}

\author{Elise Heim \& Aidan Sharpe}

\begin{document}
\maketitle

\begin{abstract}
    This lab uses MATLAB for calculating Fourier series of exponential and trigonometric functions. It also includes using a program called fourierseries.m to understand how to compute such a series.
\end{abstract}

\section{Objectives}
This lab is enlightening because it strengthens knowledge of Fourier series. Calculating Fourier series of exponential and trigonometric functions using MATLAB saves time and effort that would otherwise be spent working it out by hand. This makes it significantly easier for people to understand more complex signals, and perform computations with them.

\section{Background \& Introduction}
A Fourier series is an infinite series of trigonometric functions which represents an expansion or approximation of a periodic function, used in Fourier analysis. This is helpful because it allows one to decompose a complex, periodic waveform into its sinusoidal component. These sinusoidal components can be very beneficial in understanding a signal and its attributes. Qualities such as non-causality and the period of a periodic function can be determined more easily in this manner.

\section{Results \& Discussion}
A function $f(t)$ with period $T_0 = 1$. The first period of the function is described by equation \ref{eqn:square_wave}. The function cannot be odd because at no point in time does the function have a negative value. Additionally, the function is not even because it does not have a reflection over the y-axis.

\begin{equation}
f(t) = 
\begin{cases}
    1 & 0 \le t \le {1\over2} \\
    0 & {1\over2} < t \le 1
\end{cases}

    \label{eqn:square_wave}
\end{equation}

\begin{figure}[h]
    \includegraphics[width=0.48\textwidth]{square_wave.png}
    \caption{The square wave between $t = -2$ and $t = 2$.}
    \label{fig:square_wave}
\end{figure}

 The Fourier series comprised of 10, 100, and 2000 terms are all displayed on the graph below in \ref{fig:square_fourier}. As one can see, the first estimation with only 10 terms is very rough, but as the number of terms increases so too does the accuracy of the approximation. The estimation with 2000 terms is very smooth and closely resembles the original function. 

\begin{figure}[h]
    \includegraphics[width=0.48\textwidth]{square_fourier.png}
    \caption{Fourier series approximation of a square wave.}
    \label{fig:square_fourier}
\end{figure}

The Fourier series was then found using a symbolic calculator. This was done by providing the signal, its period, and the number of desired terms. By computing an integral to evaluate the each coefficient, $c_k$, and its corresponding harmonic frequency, $k \omega_0$, the Fourier series was able to be approximated for any value of $n$. This approximation is given by equation \ref{eqn:fourier_approx}. The corresponding coefficients for the approximation are given by equation \ref{eqn:fourier_coeff}.

\begin{equation}
    x(t) = c_0 + \sum_{k=1}^n c_k \cos(k \omega_0 t)
    \label{eqn:fourier_approx}
\end{equation}

\begin{equation}
    c_k = \int\limits_{-T/2}^{T/2} x(t) e^{-j \omega_0 k t} dt
    \label{eqn:fourier_coeff}
\end{equation}

\section{Conclusion}
This lab considerably increased understanding of Fourier series. By calculating them through MATLAB, one can obtain a stronger grasp not only on a power computational tool, but also better comprehend Fourier series through computing approximations. By varying the amount of terms used in the estimation, one can see visually how increasing the number of terms greatly improves the accuracy of such an approximation. Another beneficial aspect of this lab included using the fourierseries.m program. By stepping through how the program works line by line, one can better understand how to find exponential Fourier series using the period. 

\end{document}
