\documentclass{article}
\usepackage{amsmath, amsthm, amssymb}
\usepackage{graphicx}
\usepackage{listings}

\lstset{% Default options for all algorithm listings read
  language=matlab,
  %labelstep=5,
  %frame=trbl,
  %indent=15pt,
  %indent=12pt,
  showlines=false,
  stringstyle=\itshape%,
  %basicstyle=\ttfamily\footnotesize
}

\author{Nada Amin\\
\texttt{namin@mit.edu}
}

\title{6.003 Lab 3}

\begin{document}

\date{May 5, 2005}

\maketitle

\pagestyle{myheadings}
\markright{Nada Amin (6.003 Lab 3) (05/05/05)}

\section*{Basic Problems}
\subsection*{(a)}
Given an unstable system $H(s)$ which satisfies
\begin{align*}
\frac{dy(t)}{dt} = 2 y(t) + x(t)
\end{align*}
I determine the closed-loop system function $Q(s)$ as a function of $K$
\begin{align*} 
Q(s) = \frac{H(s)}{1 + G(s)H(s)}
\end{align*}
when $G(s)$ is a simple proportional feedback: $G(s)=K$.

From the differential equation of $H(s)$, I find that
\begin{align*}
H(s) = \frac{1}{s-2}
\end{align*}

$H(s)$ has one pole, at $s=2$. Since the system is unstable, the ROC
must be $\Re e \{s\}>2$ so as not to include $\Re e \{s\} = 0$.

Now, 
\begin{align*} 
Q(s) &= \frac{1}{s-2} \frac{1}{1 + \frac{K}{s-2}}\\
Q(s) &= \frac{1}{s-2 + K}
\end{align*}

\subsection*{(b)}
$Q(s) \rightarrow \infty$ when $s - 2 + k = 0$, thus the pole of the
closed-loop occurs at $s = 2 - k$.

For the system to be stable, $\Re e \{s\} = 0$ needs to be part of the
ROC. Assuming the system is causal, implying a right-sided ROC, the system will be stable if the pole occurs before $0$. Thus,

\begin{align*}
s &< 0 \\
k-2 &< 0 \\
-k &< -2\\
k &> 2\\
\end{align*}

For the system to be stable, $k > 2$ is required.

\subsection*{(c)}
See Figure \ref{fig:plotc}.
\begin{figure}[htp]
   \centering
   \includegraphics[width=1\textwidth]{plotc}
   \caption{Plots of the root locus for $K\leq0$ and $K\geq0$.}
   \label{fig:plotc}
\end{figure}

\subsection*{(d)}
See Figure \ref{fig:plotd}.
\begin{figure}[htp]
   \centering
   \includegraphics[width=1\textwidth]{plotd}
   \caption{Plots of the root locus for $K\leq0$ and $K\geq0$.}
   \label{fig:plotd}
\end{figure}

\subsection*{(e)}
The ranges for $K$ that I found such that all poles $p_k$ satisfy $\Re
e \{p_k\} < 0$ and $-5 < \Im \{p_k\} < 5$ are $[-\infty, -6.943]$ and
$[17.05, \infty]$.

\subsection*{(f)}
See Figure \ref{fig:plotf}.
\begin{figure}[htp]
   \centering
   \includegraphics[width=1\textwidth]{plotf}
   \caption{Plots of the root loci for $K\leq0$ and $K\geq0$.}
   \label{fig:plotf}
\end{figure}

\subsection*{(f)}
$Q(s)$ will be stable if all poles have negative real parts, assuming the system is causal.
The poles occur when the denominator is null. Thus,
\begin{align*}
1 + G(s)H(s) &= 0\\
1 + KH(s) &= 0\\
s^2 - 4 + K(s^2 + 3 s + 27.25) &= 0\\
(K+1) s^2 + 3K s + (27.25K - 4) &= 0
\end{align*}
Solving for $s$, I find that,
\begin{align*}
s = \frac{-3K \pm \sqrt{-100K^2 - 93K + 16}}{2K+2}
\end{align*}
Setting $s=0$ and solving for $K$,
\begin{align*}
-3K \pm \sqrt{-100K^2 - 93K + 16} &= 0\\
-109 K^2 - 93K + 16 &= 0
\end{align*}
Thus, 
\begin{align*}
K = -1 && K=0.1468
\end{align*}

From this, I conclude that the ranges for $K$, for which the
closed-loop system is stable, are $[-\infty, -1[$ and 
$[0.1468, \infty]$. This is indeed confirmed by the plot of the root loci.

\subsection*{(g)}
I found that $K=1$ gives me values close to $-0.75$ for the real parts
of the close-loop poles. Let $b$ be the numerator of $H(s)$ and $a$ be
the denominator. I have
\begin{align*}
Q(s) &= \frac{H(s)}{1 + G(s)H(s)}\\
Q(s) &= \frac{H(s)}{1 + KH(s)}\\
Q(s) &= \frac{H(s)}{1 + H(s)}\\
Q(s) &= \frac{b}{a} \frac{1}{1 + \frac{b}{a}}\\
Q(s) &= \frac{b}{a+b}
\end{align*}

Let $b_K$ be the numerator of $Q(s)$ and $a_K$ be the denominator of
$Q(s)$ for some value of $K$. I just showed that for $K=1$, $b_1 = b$
and $a_1 = a + b$.

\subsection*{(f)}
\begin{align*}
H_c(s) &= M(s) H(s)\\
H_c(s) &= \frac{s^2 + 3s + 27.25}{2s^2 + 2\sqrt2 + 23}
\end{align*}

See Figure \ref{fig:plotik}.
\begin{figure}[htp]
   \centering
   \includegraphics[width=1\textwidth]{plotik}
   \caption{Plots for the step response of $Q(s)$ when $K=1$ and $H_c(s)$ for $0 \leq t \leq 5$.}
   \label{fig:plotik}
\end{figure}

\subsection*{(l)}
The poles occur when the denominator goes to $0$. So I set the
denominator to $0$ and solve for $s$ in terms of $\epsilon$.
\begin{align*}
s^2 - \epsilon s - (4 + 2\epsilon) = 0\\
\end{align*}
I find,
\begin{align*}
s=-2 && s=\epsilon + 2
\end{align*}

\subsection*{(m)}
When $\epsilon=0.01$, $H_\epsilon(s) = \frac{s^2+3s+27.25}{s^2 - 0.01s - 4.02}$.

\subsection*{(n)}
See Figure \ref{fig:plotn}.
\begin{figure}[htp]
   \centering
   \includegraphics[width=1\textwidth]{plotn}
   \caption{Plots of $Q(s)$ and $Q_\epsilon(s)$}
   \label{fig:plotn}
\end{figure}

\subsection*{(o)}
See Figure \ref{fig:ploto}.
\begin{figure}[htp]
   \centering
   \includegraphics[width=1\textwidth]{ploto}
   \caption{Plots of $H_c(s)$ and $H_{c\epsilon}(s)$}
   \label{fig:ploto}
\end{figure}

\subsection*{(p)}

The feedback system is unarguably more robust, because it doesn't
require a complete knowledge of the transfer function. Since the
compensated system depends on zero-pole cancellation, the compensating
zero must exactly match the pole to cancel, or else the system won't
stablize. This is why the compensated system will usually diverge in
the face of even small uncertainities.

\section*{MATLAB Code}
This script demonstrates how I completed the lab.
\lstinputlisting{script.m}

\end{document}
