Page MenuHomec4science

midterm.tex
No OneTemporary

File Metadata

Created
Thu, Mar 13, 10:18

midterm.tex

\documentclass[a4paper,13pt,fleqn]{article}
\usepackage{defsDSPcourse}
\usepackage{dspTricks}
\usepackage{dspFunctions}
\usepackage{dspBlocks}
\usepackage{enumitem}
\newif\ifanswers
%\answerstrue
\def\onebyone{} %\newpage}
\begin{document}
\vspace{5em}
\begin{center}%
\sffamily
{\LARGE \bfseries COM-303 - ``Mock'' Midterm Exam - Spring 2020} \\
\vspace{1em}
{\large }
\vspace{1em}
\end{center}
\centerline{\rule{\textwidth}{.5pt}}
\begin{itemize}
\item This mock midterm exam is not graded and it is designed to test your understanding of the material so far
\item Tlthough the test is take-home, try to work on the problems as if taking a real exam; this means \textbf{no internet, no group work and a maximum time of three hours.}
\item The scores indicate the difficulty of the problem; the total is 100 points.
\item The solution will be discussed in the first class after the break.
\end{itemize}
\centerline{\rule{\textwidth}{.5pt}}
\vspace{1em}
\onebyone
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{exercise}{(30 points)}
Consider the causal system described by the following block diagram:
\begin{center}
\begin{dspBlocks}{0.5}{0.6}
$x[n]~~~$ & \BDsplit & \BDdelay & \BDsplit & \BDdelay & \BDsplit & \BDdelay & & \\
& \BDadd & & \BDadd & & \BDadd & & \BDadd & & \BDsplit & $~~~y[n]$ \\
& & & & & & & \BDadd & \BDsplit & \BDdelay \\
& & & & & & & & \BDdelay &
\ncline{->}{1,1}{1,3}\ncline{->}{1,3}{1,5}
\ncline{->}{1,5}{1,7}\ncline{1,7}{1,8}
\ncline{->}{1,2}{2,2}
\ncline{->}{1,4}{2,4}\tlput{$-\frac{1}{2}$}
\ncline{->}{1,6}{2,6}\tlput{$-1$}
\ncline{->}{1,8}{2,8}\tlput{$\frac{1}{2}$}
\ncline{->}{2,2}{2,4}\ncline{->}{2,4}{2,6}\ncline{->}{2,6}{2,8}
\ncline{->}{2,8}{2,11}
\ncline{->}{2,10}{3,10}
\ncline{->}{3,9}{4,9}
\ncline{->}{3,9}{3,8}
\ncline{-}{3,10}{3,9}
\ncline{4,9}{4,8}\tbput{$-\frac{1}{4}~~~~~$}
\ncline{->}{4,8}{3,8}\ncline{->}{3,8}{2,8}
\end{dspBlocks}
\end{center}
\begin{enumerate}
\item Compute its transfer function $H(z) = Y(z)/X(z)$.
\item Is the system stable?
\item Draw a block diagram that implements the same transfer function using just two delay blocks.
\end{enumerate}
\ifanswers{\em\vspace{3em}\par{\bfseries Solution: }
The system can be seen as the cascade of an FIR and an IIR filters
\begin{center}
\begin{dspBlocks}{0.7}{0.4}
$x[n]$~~ & \BDfilter{$B(z)$} & \BDfilter{$1/A(z)$} & ~~$y[n]$
\ncline{->}{1,1}{1,2}\ncline{->}{1,2}{1,3}\ncline{->}{1,3}{1,4}
\end{dspBlocks}
\end{center}
where
\[
B(z) = 1 - \frac{1}{2}z^{-1} - z^{-2} + \frac{1}{2}z^{-3}
\]
and
\[
A(z) = 1 - z^{-1} + \frac{1}{4}z^{-2}.
\]
Since we will need to determine the stability of the system later, we can already factorize $A(z)$ by simple inspection as
\[
A(z) = (1 - \frac{1}{2}z^{-1})^2.
\]
We can also try to see if the root of $A(z)$ is also a root of $B(z)$: indeed $B(1/2) = 0$. We can now factor $B(z)$ either by performing polynomial division or by noticing that both $+1$ and $-1$ are also roots; we have
\[
B(z) = (1 - \frac{1}{2}z^{-1})(1 - z^{-2}).
\]
With this:
\begin{enumerate}
\item The global transfer function is
\[
H(z) = \frac{B(z)}{A(z)} = \frac{1 - z^{-2}}{1 - \frac{1}{2}z^{-1}}.
\]
\item The pole of the system is in $z=1/2$ so the system is stable
\item The system is an incomplete second order section, so we can use the standard Direct Form II like so:
\begin{center}
\begin{dspBlocks}{1.2}{0.4}
$x[n]$~~~~ & \BDadd & \BDsplit & \BDadd & ~~~~~$y[n]$ \\%
& & \BDdelay & & \\%
& & \BDsplit & & \\%
& & \BDdelay & & \\%
& & & &
\psset{arrows=->,linewidth=1.5pt}
\ncline{1,1}{1,2} \ncline{-}{1,2}{1,3}
\ncline{1,3}{1,4} \ncline{1,4}{1,5}
\ncline{-}{3,3}{3,2} \taput{$1/2$}
\ncline{-}{5,3}{5,4}\taput{$-1$}
\ncline{1,3}{2,3} \ncline{2,3}{4,3} \ncline{-}{4,3}{5,3}
\ncline{5,4}{1,4}
\ncline{3,2}{1,2}
\end{dspBlocks}
\end{center}
\end{enumerate}
\vspace{2em}
}\else{}\fi
\end{exercise}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\begin{exercise}{(20 points)}
% Consider the finite-support sequence
% \[
% x[n] = \begin{cases}
% 1/6 & \mbox{for $0 \le n < 6$} \\
% 0 & \mbox{otherwise}
% \end{cases}
% \]
% Next, consider the family of complex-valued finite-support sequences
% \[
% x_k[n] = x[n]\, e^{-j\omega_k n}
% \]
% where $\omega_k = (2\pi/6)k$.
%
% \begin{enumerate}
% \item sketch $|X(e^{j\omega})|$, the magnitude of the DTFT of $x[n]$; be as precise as possible
% \item sketch $|X_k(e^{j\omega})|$, the magnitude of the DTFT of $x_k[n]$, for $k=1$ and $k=4$
% \item prove that $\quad\displaystyle \sum_{k=0}^{5} X_k(e^{j\omega}) = 1$
% \end{enumerate}
%
%
%\ifanswers{\em\vspace{3em}\par{\bfseries Solution: }
%
%\def\sinInt#1{ 90 mul dup dup 0 eq {pop pop 1} {#1 mul sin exch sin div} ifelse #1 div}
%
% \begin{enumerate}
% \item the sequence corresponds to the impulse response of a moving average filter of length six; the magnitude response is
% \[
% |X(e^{j\omega})| = \left| \frac{1}{6} \, \frac{\sin(3\omega)}{\sin(\omega/2)} \right|
% \]
% so it will be equal to zero for $\omega = \pm \pi/3, \pm 2\pi/3, \pm \pi$ and equal to 1 (by continuity) for $\omega=0$:
% \begin{dspPlot}[xtype=freq,xticks=3,height=3cm]{-1,1}{0, 1.2}
% \dspFunc{x \sinInt{6} abs}
% \end{dspPlot}
%
% \item multiplication by $e^{-j\omega_k n}$ in time corresponds to a left shift by $\omega_k = k(\pi/3)$ in frequency. Because of the $2\pi$-periodicity of the spectrum, the shift appears as a circular shift over the $[-\pi, \pi]$ range: \\ \vspace{0.6em} \\
% \begin{tabular}{cc}
% $|X_1(e^{j\omega})|$ & $|X_4(e^{j\omega})|$
% \\
% \begin{dspPlot}[xtype=freq,xticks=3,height=2cm,width=5cm]{-1,1}{0, 1.2}
% \dspFunc{x -.3333 sub \sinInt{6} abs}
% \end{dspPlot}
% &
% \begin{dspPlot}[xtype=freq,xticks=3,height=2cm,width=5cm]{-1,1}{0, 1.2}
% \dspFunc{x -.33333 4 mul sub \sinInt{6} abs}
% \end{dspPlot}
% \end{tabular}
% \item \begin{align*}
% \sum_{k=0}^{5} X_k(e^{j\omega}) &= \sum_{k=0}^{5} \DTFT{x_k[n]} \\
% &= \DTFT{\sum_{k=0}^{5} x_k[n]} \qquad \mbox{\small (by linearity)}\\
% &= \DTFT{\frac{1}{6}\sum_{k=0}^{5} e^{-j\frac{2\pi}{6}nk}} \\
% &= \DTFT{\frac{1}{6}\DFT{1}} \qquad \mbox{\small (DFT in $\mathbb{C}^6$)}\\
% &= \DTFT{\delta[n]} = 1
% \end{align*}
% \end{enumerate}
%}\else{\vspace{1em}}\fi
%\end{exercise}
%
%\vspace{1em}
%
%
%\onebyone
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{exercise}{(10 points)}
Show that absolute summability implies finite energy, that is:
\[
\sum_{n=-\infty}^{\infty} |x[n]| < \infty \Rightarrow \sum_{n=-\infty}^{\infty} |x[n]|^2 < \infty
\]
\ifanswers{\em\vspace{3em}\par{\bfseries Solution: }
If\/ $\sum_n |x[n]| < \infty$, then necessarily the sequence $x[n]$ tends to zero:
\[
\sum_{n=-\infty}^{\infty} |x[n]| < \infty \Rightarrow \lim_{n\rightarrow\pm\infty}x[n] = 0;
\]
therefore there must exist an integer $n_0 > 0$ so that, for all $|n|>n_0$, $|x[n]| < 1$. Then we can write
\[
\sum_{n=-\infty}^{\infty} |x[n]|^2 = \sum_{|n| \le n_0} |x[n]|^2 + \sum_{|n| > n_0} |x[n]|^2;
\]
the first term in the sum is necessarily finite, while for the second term, since $x^2 < x$ for $|x| < 1$, we have
\[
\sum_{|n| > n_0} |x[n]|^2 \leq \sum_{|n| > n_0} |x[n]| \leq \sum_{n=-\infty}^{\infty} |x[n]| < \infty.
\]
}\else{\vspace{1em}}\fi
\end{exercise}
\vspace{1em}
\onebyone
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{exercise}{(10 points)}
Show that
\[
\delta[n] - \frac{1}{2}\sinc\left(\frac{n}{2}\right) = (-1)^n \frac{1}{2}\sinc\left(\frac{n}{2}\right).
\]
\ifanswers{\em\vspace{3em}\par{\bfseries Solution: }
You can solve this in the time domain or in the frequency domain.
{\bfseries Time-domain solution:} For $n = 0$, $\sinc(n/2) = 1$ so that the equality is obviously satisfied:
\[
1 - \frac{1}{2} = \frac{1}{2};
\]
for $n$ nonzero and even the argument of both sincs is an integer, so the equation becomes simply
\[
\delta[n] = 0
\]
which is true for all nonzero even values of $n$; finally, for $n$ odd, we have the tautology
\[
- \frac{1}{2}\sinc\left(\frac{n}{2}\right) = - \frac{1}{2}\sinc\left(\frac{n}{2}\right).
\]
{\bfseries Frequency-domain solution:} $(1/2)\sinc(n/2)$ is the impulse response of an ideal lowpass with cutoff frequency $\omega_c = \pi/2$. Therefore, the left-hand side is the impulse response of an ideal highpass with cutoff frequency $\omega_c = \pi/2$. The right-hand side is the lowpass impulse response modulated by $\cos(\pi n)$, which shifts the frequency response by $\pi$; therefore that too is the impulse response of an ideal highpass with cutoff frequency $\omega_c = \pi/2$.
}\else{\vspace{1em}}\fi
\end{exercise}
\onebyone
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{exercise}{(15 points)}
Consider a generic LTI filter described by the following CCDE, where $M \geq 1$:
\[
y[n] = \frac{1}{18} x[n + M] + \frac{1}{2M-1}\sum_{k=-M+1}^{M-1} x[n - k] + \frac{1}{18} x[n - M]
\]
Determine the values of M (if any) for which the frequency response of the filter has a zero in $\omega = \pi$.
\ifanswers{\em\vspace{3em}\par{\bfseries Solution: }
Set $a = 1/(2M-1)$ and $b = 1/18$. The transfer function of the filter is
\begin{align*}
H(z) &= b(z^{-M} + z^{M}) + \sum_{k=-M+1}^{M-1} az^{-k} \\
&= a + a(z^{-1} + z) + a(z^{-2} + z^{2}) + \ldots + a(z^{-M+1} + z^{M-1}) + b(z^{-M} + z^{M})
\end{align*}
For the filter to have a zero in $\omega = \pi$ it must be $H(-1) = 0$; since it is
\[
(z^{-k} + z^{k})\big|_{z=-1} = \begin{cases}
2 & k \mbox{ even} \\
-2 & k \mbox{ odd}
\end{cases} = 2\cdot (-1)^k
\]
then
\[
H(-1) = a + 2a\sum_{k=1}^{M-1} (-1)^{k} + 2b\cdot (-1)^M.
\]
Since successive terms cancel each other out, the summation can be simplified as
\[
\sum_{k=1}^{M-1} (-1)^{k} = \begin{cases}
-1 & M \mbox{ even} \\
0 & M \mbox{ odd}
\end{cases}
\]
and therefore
\[
H(-1) = \begin{cases}
-a + 2b & M \mbox{ even} \\
a - 2b & M \mbox{ odd}
\end{cases} = \pm\left(\frac{1}{2M-1} - \frac{1}{9} \right)
\]
so that the filter has a zero in $\omega=\pi$ for $M=5$.
}\else{\vspace{1em}}\fi
\end{exercise}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{exercise}{(15 points)}
Consider a signal $x[n]$ with the following (real-valued) spectrum:
\begin{center}
\begin{dspPlot}[height=3cm,xtype=freq,xticks=4,yticks=1,ylabel={$X(e^{j\omega})$},xout=true]{-1,1}{0,1.1}
\dspFunc{x \dspTri{0}{.25}}
\end{dspPlot}
\end{center}
Sketch \emph{as accurately as possible} the spectrum of the following signals:
\begin{enumerate}
\item $a[n] = x[n]\,(1+\cos((\pi/4)n))$
\item $b[n] = x[n]\,\cos((7\pi/8)n)$
\end{enumerate}
\ifanswers{\em\vspace{3em}\par{\bfseries Solution: }
Using the modulation theorem we can write
\begin{align*}
A(e^{j\omega}) &= X(e^{j\omega}) + (1/2)X(e^{j(\omega - \pi/4)}) + (1/2)X(e^{j(\omega + \pi/4)}) \\
B(e^{j\omega}) &= (1/2)X(e^{j(\omega - 7\pi/8)}) + (1/2)X(e^{j(\omega + 7\pi/8)})
\end{align*}
To plot these spectra, we just need to pay attention to the potential aliasing introduced by the modulation; in the following plots, first we show the distinct spectral terms and then their sum:
\begin{dspPlot}[height=3cm,xtype=freq,xticks=4,yticks=1,ylabel={$A(e^{j\omega})$, split},xout=true]{-1,1}{0,1.1}
\dspFunc[linecolor=lightgray]{x \dspTri{0}{.25}}
\dspFunc[linecolor=lightgray]{x \dspTri{0.25}{.25} 0.5 mul}
\dspFunc[linecolor=lightgray]{x \dspTri{-0.25}{.25} 0.5 mul}
\end{dspPlot}
\begin{dspPlot}[height=3cm,xtype=freq,xticks=4,yticks=1,ylabel={$A(e^{j\omega})$},xout=true]{-1,1}{0,1.1}
\dspFunc{x \dspTri{0}{.25}
x \dspTri{0.25}{.25} 0.5 mul
x \dspTri{-0.25}{.25} 0.5 mul
add add}
\end{dspPlot}
\begin{dspPlot}[height=3cm,xtype=freq,xticks=4,yticks=1,ylabel={$B(e^{j\omega})$, split},xout=true]{-1,1}{0,1.1}
\dspFunc[linecolor=lightgray]{x \dspTri{0.875}{.25} 0.5 mul}
\dspFunc[linecolor=darkgray]{x \dspTri{1.125}{.25} 0.5 mul}
\dspFunc[linecolor=darkgray]{x \dspTri{-0.875}{.25} 0.5 mul}
\dspFunc[linecolor=lightgray]{x \dspTri{-1.125}{.25} 0.5 mul}
\end{dspPlot}
\begin{dspPlot}[height=3cm,xtype=freq,xticks=4,yticks=1,ylabel={$B(e^{j\omega})$},xout=true]{-1,1}{0,1.1}
\dspFunc{x \dspTri{0.875}{.25} 0.5 mul
x \dspTri{1.125}{.25} 0.5 mul
x \dspTri{-0.875}{.25} 0.5 mul
x \dspTri{-1.125}{.25} 0.5 mul
add add add}
\end{dspPlot}
}\else{\vspace{1em}}\fi
\end{exercise}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{exercise}{(10 points)}
Consider the following finite-support sequences (the value for $n=0$ is underlined):
\begin{align*}
x[n] &= \ldots, 0, 0, 3, \underline{1}, -1, 2, 0, 0, 0, \ldots \\
h[n] &= \ldots, 0, 0, -1, \underline{0}, 2, 0, 4, 0, 0, \ldots
\end{align*}
Compute $y[n]=h[n]\ast x[n]$.
\ifanswers{\em\vspace{3em}\par{\bfseries Solution: } The convolution is defined as
\[
y[n] = \sum_{k=-\infty}^{\infty}x[k]h[n-k].
\]
If we plot $x[k]$ and, correspondigly, the nonzero portion of $h[n-k]$ for varying values of $n$ we can easily see that the nonzero portions of $x[k]$ and $h[n-k]$ overlap only for eight values of $n$, namely for $-2 \leq n \leq 5$:
\begin{dspPlot}[height=1cm,yticks=3,xout=true,ylabel={$x[k]$}]{-6, 6}{-5, 5}
\dspTapsAt{-6}{0 0 0 0 0 3 1 -1 2 0 0 0 0}
\end{dspPlot}
\begin{dspPlot}[height=1cm,xticks=custom,yticks=2,ylabel={$h[-2-k]$}]{-6, 6}{-5, 5}
\dspTapsAt{-5}{4 0 2 0 -1}
\end{dspPlot}
\begin{dspPlot}[height=1cm,xticks=custom,yticks=2,ylabel={$h[-1-k]$}]{-6, 6}{-5, 5}
\dspTapsAt{-4}{4 0 2 0 -1}
\end{dspPlot}
\begin{dspPlot}[height=1cm,xticks=custom,yticks=2,ylabel={$h[0-k]$}]{-6, 6}{-5, 5}
\dspTapsAt{-3}{4 0 2 0 -1 }
\end{dspPlot}
$\ldots$
\begin{dspPlot}[height=1cm,xticks=custom,yticks=2,ylabel={$h[5-k]$}]{-6, 6}{-5, 5}
\dspTapsAt{2}{4 0 2 0 -1 }
\end{dspPlot}
\[
y[n] = \begin{cases}
-3 & n = -2 \\
-1 & n = -1 \\
7 & n = 0 \\
0 & n = 1 \\
10 & n = 2 \\
8 & n = 3 \\
-4 & n = 4 \\
8 & n = 5 \\
0 & \mbox{otherwise}
\end{cases}
\]
}\else{\vspace{1em}}\fi
\end{exercise}
%\begin{exercise}{(30 points)}
%Consider an LTI system described by the following cascade of two subsystems:
%\begin{align*}
% w[n] &= x[n] - x[n-1] \\
% y[n] &= w[n] - 2w[n-1] + 2w[n-2]
%\end{align*}
%\begin{enumerate}
% \item compute the transfer function of the system (i.e. $H(z) = Y(z)/X(z)$)
% \item sketch the pole-zero plot for the transfer function
% \item is the system stable?
% \item is the {\em inverse} system $1/H(z)$ stable?
% \item compute the output $y[n]$ when the input is
% \[
% x[n] = u[n] - \frac{1}{4}u[n-2]
% \]
% ($u[n]$ is the step sequence).
%\end{enumerate}
%\end{exercise}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{exercise}{(10 points)}
Consider a Type-IV linear phase filter of length 6. If you know that one of the zeros is at $z = 0.5\,e^{j\pi/5}$, write out the remaining zeros of the transfer function.
\ifanswers{\em\vspace{3em}\par{\bfseries Solution: }
Any 6-tap FIR has 5 zeros, since its transfer function is a polynomial of degree 5. A type-IV filter has always a zero in $z=0$ and any other zero is subject to the symmetry constraints for linear-phase FIRs; in particular, for a complex-valued zero $z_0$, also $z^*_0$, $1/z_0$ and $1/z^*_0$ are zeros. So the five zeros are:
\begin{enumerate}
\item $z = 0$
\item $z = 0.5\,e^{j\pi/5}$
\item $z = 0.5\,e^{-j\pi/5}$
\item $z = 2\,e^{-j\pi/5}$
\item $z = 2\,e^{j\pi/5}$
\end{enumerate}
}\else{\vspace{1em}}\fi
\end{exercise}
\end{document}

Event Timeline