% -*- latex -*-
\documentclass[letter,12pt]{article}
%---------------------------------------------------------------
%\usepackage{listings}
\usepackage[framed]{matlab-prettifier}
\usepackage{color}
\usepackage{fullpage}
\usepackage{enumitem} % control over itemize, list environment
%---------------------------------------------------------------


\begin{document}
\newcommand{\hwtitle}[1]{%
	\begin{center}
		\Large  \bf Homework #1%
	\end{center}%
}

\newcommand{\mat}[1]{% matlab code
%{\color{blue}\texttt{#1}}%
	% this one does not work inside of captions
	{\lstinline[style = Matlab-editor, basicstyle = \mlttfamily, columns=fixed]!#1!}%
	% this one work but style is different
	%{\lstinline[columns=fixed]!#1!}%
}
%---------------------------------------------------------------
\newcommand{\problem}[1]{% homework problem
	%{\item  \bf #1%}
\item {\bf #1{}:}% the next blank line is important

}

\newcommand{\Matlab}[0]{%
	MATLAB%
}

\newenvironment{homework}[2]%
{%
	\hwtitle{#1}
	#2% Prerequisites

	\begin{enumerate}[
		label={\bf Problem\ \arabic*}, 
		leftmargin=0pt,
		start,
		labelindent=0pt,
		widest=20, align=left, itemindent=!
		]
}%
{%
	\end{enumerate}
}%

%---------------------------------------------------------------
\begin{homework}{10}{
%Prerequisites:
%
%General comments: 
%\begin{itemize}
	%\item Do not forget to run some test cases. 
%\end{itemize}
}

\problem{Problem 1 (5 points)}
%---------------------------------------------------------------
Have a look at the particular realization of the  $N$ point forward DFT
with the omitted  normalization coefficient:
\begin{eqnarray*}
	C_n=\sum_{k=1}^N y_k \exp( -i 2 \pi  (k-1) n /N)
\end{eqnarray*}

Analytically prove that the forward discrete Fourier transform is
periodic, i.e.,
$c_{n+N}=c_{n}$.
Note: recall that $\exp(\pm i 2 \pi)=1$.

Does this also prove  that $c_{-n} = c_{N-n}$?



\problem{Problem 2 (5 points)}
%---------------------------------------------------------------
Use proof for the previous problem relationships and show that
the following relationship holds
for any sample set which has only real values (i.e., no complex part)
\begin{eqnarray*}
	c_n = c_{N-n}^*
\end{eqnarray*}
Where $^*$ depicts the complex conjugation.

\problem{Problem 3 (10 points)}
%---------------------------------------------------------------
Load the data from the file 'hw\_data\_for\_filter.dat' provided at the class web page. 
It contains a table with $y$ vs
$t$ data points (the first column holds the time, the second holds $y$). These data points are
taken with the same sampling rate.


\begin{enumerate}
	\item {(2 points)}
What is the sampling rate?

\item {(3 points)}
Calculate forward DFT of the data (use Matlab built-ins)
and find which 2 frequency components of
the spectrum (measured in Hz not rad${}^{-1}$) are the largest. Note, I refer to
the real frequency of the $\sin$ or $\cos$ component, i.e.,  only positive
frequencies. 

\item {(2.5 points)}
What is the largest frequency (in Hz) in this data set which we
can scientifically discuss?

\item {(2.5 points)}
What is the lowest frequency (in Hz) in this data set which we
can scientifically discuss?

	
\end{enumerate}
%\subproblem{3d (5 points)}
%Consider everything else but above 2 components of the DFT as noise.
%Construct a low-pass filter  which will pass these two components. Plot the
%filter frequency representation (positive and negative frequency). Explain your
%choice of the filter and its parameters.

%\subproblem{3e (3 points)}
%Apply the filter to the data Fourier representation and calculate the inverse
%DFT. Plot the resulting filtered data representation and  raw data points
%in the same plot. Does your filter completely get rid of noise? If not why
%is it so?


\end{homework}
%---------------------------------------------------------------
\end{document}
%---------------------------------------------------------------
