\documentclass[journal]{IEEEtran}

% *** CITATION PACKAGES ***
\usepackage[style=ieee]{biblatex}
\bibliography{random_walk.bib}

% *** MATH PACKAGES ***
\usepackage{amsmath}

% *** PDF, URL AND HYPERLINK PACKAGES ***
\usepackage{url}
\hyphenation{op-tical net-works semi-conduc-tor}
\usepackage{graphicx}  % needed to include png, eps figures
\usepackage{float}  % used to fix location of images i.e.\begin{figure}[H]

% *** MY PACKAGES ***
\usepackage{todonotes}
\usepackage[caption=false]{subfig}

\begin{document}

% paper title
\title{Using Random Walk Simulations to Calculate Ground State Energies in
  Quantum Physics}

% author names
\author{Sai Pandian, ID: 29899923}%

% The report headers
\markboth{PHYS6017 Computer Techniques in Physics Report 1, April 2020}
{Shell \MakeLowercase{\textit{et al.}}: Bare Demo of IEEEtran.cls for IEEE Journals}

% make the title area
\maketitle

% As a general rule, do not put math, special symbols or citations
% in the abstract or keywords.
\begin{abstract}
  In this paper, we present a novel way of calculating ground state energies for
  a quantum simulation using a Random Walk Monte Carlo simulation. The random
  walk consists of a walker making steps in random directions, with each step
  having a probability of causing the walker to die and the random walk to end,
  with the probability determined by a function of position. The function can be
  chosen to model specific quantum systems. The rate of death of the walkers is
  used to calculate the ground state energy. This paper explores the efficacy of
  such a method in reproducing the known ground state energy of an infinite
  square well, and the extensibility of the method to more complex
  systems. Using the infinite square well example, the simulation found the
  energy proportionality to be $1.2339 \pm 0.0008$, which is consistent to high
  precision with the known $\frac{\pi^2}{8}$ theoretical constant. Thus, we found
  that this method is very good at reproducing the known results to a high
  precision, and with good reliability, having very small variance in
  repeats. The method is extensible to higher dimensions, with a linear increase
  in time-complexity for each added dimension.
\end{abstract}

\section{Introduction}
\IEEEPARstart{T}{he} developments in computer power in recent years have opened
up the possibility for novel computational solutions to many problems that were
otherwise limited. We now have access to computers that can numerically solve
problems and run simulations that were previously too computationally intensive
to do.  One such problem is the calculation of the ground state energies of
different quantum systems. Many methods exist for solving these problems, using
both classical and quantum computational approaches. Whilst generally it may be
true that Quantum computing approaches are more suited to solving such problems
\cite{Mazzola}, these approaches are still in infancy and are not readily
accessible. Thus, there exist an abundance of classical computing approaches,
such as the Variational-Relaxation algorithm \cite{Schroeder2017}. This is a
particularly useful algorithm for two-dimensional systems with non-separable
potentials but quickly becomes difficult to implement for more complex systems.

In this investigation, we explore an alternative Monte Carlo method using Random
Walk simulations, and demonstrate its efficacy with simple systems. This
approach has applications in many areas of Quantum Physics and is values due to
its effectiveness for more complicated systems.

\section{Theoretical Background}
\label{sec:TheoreticalBackground}

\subsection{Random Walk Simulations}

Random walks describe motion as a series of steps in some vector space, with the
direction of each step being random, i.e. with there being an assigned likelihood
of a step in each possible direction. Consider a simple 1-dimensional line and a
walker standing at a point labelled the origin. The walker takes 20 steps, the
direction of each step (forwards or backwards on the line) is random. The
position of the walker at each step is shown in Figure \ref{fig:cartoon}.

\begin{figure}[H]%[!ht]
  \begin{center}
    \includegraphics[width=0.45\textwidth]{images/cartoon.pdf}
    \caption{The position of a walker at each step in a 20-step random walk
      simulation. The average position of the walker does not necessarily remain
      at the origin as one might expect. Instead it is normal for the
      walker to finish the walk at some distance from the origin, as shown here.}
    \label{fig:cartoon}
  \end{center}
\end{figure}

As we can see from the figure, it is not uncommon for the average position of
the walker to be away from the origin once the walk has concluded. This is
because the position of the walker at any step is dependent only on the position
at the previous step. If the walker happens to take a number of steps in the
same direction, it is highly unlikely for the walker to take an equal number of
steps in the opposite direction, in order to return to the origin. Thus, in such
a case, it is likely that the walker will conclude the walk in a position away
from the origin.

In this example, the walker had an equal likelihood of stepping forward or
backwards, but we can add a bias in a direction if we want to model a particular
phenomenon. The walk is also easily extensible to multiple dimensions, as for
each extra dimension, one extra random number must be drawn. This gives a linear
increase in time-complexity, which is convenient for more complex systems.

\subsection{Application to Quantum Systems}

This investigation applied Random walk simulations to calculate the ground state
energies of Quantum Systems by solving the Schr\"{o}dinger equation, as shown in
\cite{Ceperley1983}.

We can extend the simple one-dimensional line model from Figure
\ref{fig:cartoon} to a quantum system by imagining it as a one-dimensional
simple lattice system. A walker can start at a position labelled the origin, and
then proceed in a random walk. The random walk concludes if the walker ``dies''
on a particular step. The probability that the walker will die is dependent on a
defined potential at that point. For example, in an infinite square well system,
the potential is 0 within a well, and infinite outside the well. So the walker
will have no chance of dying whilst inside the well, but will die if they step
outside.

Let us define $p(j,n+1)$ as the probability that the walker will be at position
$j$ after $n+1$ steps and $a(j)$ as the probability that the walker will die at
position $j$. Thus, for this to be the case, the walker would have had position
$j\pm1$ after $n$ steps. Thus, we can say:

\begin{equation}
  p(j, n+1) =  \frac{1}{2}(1-a(j))(p(j-1,n) + p(j+1,n))
  \nonumber
\end{equation}

If $a(j)$ is small and $n$ is large, we can use Taylor's expansion to expand
each term in this expression and obtain a differential equation. If we then
make an ansatz substitution:

\begin{equation}
  p(j,n) = q(j) \exp(-\lambda n)
  \label{eq:firsteq}
\end{equation}
where $q(j)$ is an arbitrary function and $\lambda$ is the rate of death, the
differential equation in $p(j,n)$ simplifies to:

\begin{equation}
  -\frac{1}{2} \frac{d^2q(j)}{dj^2} + a(j)q(j) = \lambda q(j)
  \label{eq:randomwave}
\end{equation}
The full derivation is taken from \cite{MarcusNewton2020} and is shown in
Appendix \ref{appendix:derivation}. Notice that Equation \ref{eq:randomwave} is
in the form of the Schr\"{o}dinger equation:

\begin{equation}
  \label{eq:schrodinger}
  \frac{-\hbar^2}{2m}\frac{d^2 \psi}{dr^2} + V(r)\psi(r) = E\psi(r)
\end{equation}
Comparing Equation \ref{eq:randomwave} and Equation \ref{eq:schrodinger}, we can
see that the probability of death $a(j)$ is related to the potential $V(r)$,
and the rate of death $\lambda$ is related to the Energy $E$.

We can extend this to an infinite square well by choosing our probability of
death such that:

\begin{equation}
  \label{eq:squarewell}
    a(j) =
    \begin{cases}
      0,& \text{if } j < J\\
      \infty,& \text{if } j \geq J
    \end{cases}
    \nonumber
\end{equation}
where J is a well-defined boundary. So the walker cannot die inside the well but
will immediately die when they step outside, which we expect will mostly
happen given sufficient time. Inside the well, the potential is simply that of a
free particle \cite{Bransden2003}:

\begin{equation}
  \frac{-\hbar^2}{2m}\frac{d^2 \psi}{dj^2} = E\psi(j)
  \nonumber
\end{equation}
where $x$ is the position of the walker. By making the substitution
$x=J\frac{j}{R}$, such that $j=R$ corresponds to the walker being at the
boundary, we find:

\begin{equation}
  \begin{split}
    -\frac{\hbar^2}{2m}\frac{R^2}{J^2}\frac{d^2\psi}{dj^2} &= E\psi(x)\\
    -\frac{1}{2}\frac{d^2\psi}{dj^2} &= \frac{mJ^2E}{\hbar^2R^2}\psi(x)
  \end{split}
  \nonumber
\end{equation}
If we compare this to Equation \ref{eq:randomwave}, allowing $a(j) = 0$ inside
the well, we see that:

\begin{equation}
  E = \lambda R^2 \frac{\hbar^2}{mJ^2}
  \label{eq:kasia}
\end{equation}
where only $\lambda$ is an unknown quantity. Thus, by calculating rate of death
$\lambda$, we can calculate the ground state energy of the infinite square
well. The known ground state energy of an infinite square well is
$\frac{\pi^2}{8}\frac{\hbar^2}{mJ^2}$ \cite{Davies1998}, so we expect to find $\lambda
R^2$ close to $\frac{\pi^2}{8}$.

To find the rate of death $\lambda$, we consider Equation \ref{eq:firsteq}. With
some simple manipulation:
\begin{equation}
  \begin{split}
    p(j, n) & = q(j) \exp(-\lambda n)\\
    \log(p) & = \log(q \exp(-\lambda n)) \\
  \end{split}
  \nonumber
\end{equation}

\begin{equation}
  \log(p) = -\lambda n + log(q)
  \label{eq:straightline}
\end{equation}

Thus, by plotting the logarithm of the probability of surviving $n$ steps
against the number of steps $n$, we can obtain the death rate $\lambda$ from the
gradient of the line.

\section{Method}
We implemented the Random Walk simulation computationally in
C++ in order to optimise the performance of the simulation, and thereby allow
for a larger number of iterations and larger potential wells. The source code is
available \cite{Pandian}. The simulation is easily extensible to multiple
dimensions with a linear increase in time-complexity as the number of dimensions
increases, but this investigation focused on a one-dimensional system.

The random direction is selected using a pseudorandom number generator (pRNG)
known as the Mersenne Twister. This algorithm was chosen as it is a very fast
implementation of a pRNG \cite{Route2017}, passes many statistical randomness
tests \cite{Bellamy2013}, and has a very large period of $2^{19937}-1$.

We initially ran the simulation for a boundary of $J = 20$, with $1000000$
walkers. The step on which each walker died was recorded so that a probability
distribution showing the likelihood of dying on a particular step could be
constructed.

We then considered the probability that a walker will survive $n$ steps, and use
the relationship between the number of walkers surviving $n$ steps and $n$ to
determine the rate of death $\lambda$, as shown in Equation \ref{eq:straightline}.

One method of reducing the computing time of the simulation is to introduce a
maximum number of steps. The walker will die if they reach the boundary of the
well, or if they reach this maximum number of steps, whichever happens
first. The effect of this method on the result is investigated in this paper.

% However, this will introduce some systematic error into the simulation,
% as there will be a disproportionately high number of walkers dying on the
% maximum number of steps. We also investigated these effects here.

% We expect to see an effect on the accuracy of our final ground state depending
% on the size of the infinite well. We investigate these effects by comparing the
% calculated ground state energy to the theoretical energy for different sized wells.

\section{Results and Discussion}

\begin{figure*}[ht!]
  \centering
  \subfloat[Linear Scale]
  {\includegraphics[width=0.5\textwidth]{images/cum_exp_plot.pdf}
  \label{fig:cumhist}}
  \centering
  \subfloat[Log Scale]
  {\includegraphics[width=0.5\textwidth]{images/cum_line_plot.pdf}
  \label{fig:cumloghist}}
  \caption{Histograms showing the Probability of surviving to at least a
    particular step in an infinite square well with $J = 20$. The peak of 1 does
    not start at the origin but at step 100. This is because these steps were
    neglected in the plot as prior to this step the exponential shape is less
    clear. An exponential decay curve provides a good fit, with an $R^2$ value
    of 0.9999998. Plotting on a logarithmic scale shows the straight line fit,
    the gradient of which is $\lambda$, giving $\lambda J^2 = 1.2334$, with a
    negligible error. The fluctuation in the higher step number regions is due
    to the large variance in the small number of walkers that die at these
    steps.}
  \label{fig:cumplots}
\end{figure*}

% The simulation was first run for an infinite square well with boundary $J=20$
% with 1000000 walkers. The number of walkers surviving at each step was recorded
% and the histograms in Figure \ref{fig:cumplots} were created. The probability
% that a walker will survive at a particular step is simply the 1 minus the
% normalised cumulative sum of walkers dying at each step. The curve has been
% fitted with an exponential function of the form in Equation
% \ref{eq:firsteq}.

We first investigated an infinite square well with boundary $J=20$ and 1000000
walkers. We found the energy constant to be $1.2339 \pm 0.0008$, calculated from
the probability distribution of survival at a particular step. The probability
that a walker will survive at a particular step is simply the 1 minus the
normalised cumulative sum of walkers dying at each step. Figure
\ref{fig:cumplots} presents this probability and confirms the ansatz of the
exponential function. The curve has been fitted with an exponential function of
the form in Equation \ref{eq:firsteq}. The gradient of Figure
\ref{fig:cumloghist} allowed for calculation of death rate which from Equation
\ref{eq:kasia} gives the calculated energy.

Figure \ref{fig:cumplots} results in a very good fit, with an $R^2$ value of
0.9999998, indicating the data does not vary much from the curve of best
fit. This is likely due to the very large number of walkers used in this
experiment, as allowed by the performant C++ implementation.  We can see this
better in Figure \ref{fig:cumloghist}, which is the same exponential plot fitted
on a logarithmic scale. The closeness of the data to the line of best fit is
evident here. The error in the fitted parameters is negligible, as shown by the
$R^2$ value. The gradient of the fitted line is taken to be $\lambda$ and thus
allows us to calculate $\lambda J^2 = 1.2334$, compared to the theoretical value
of $\frac{\pi^2}{8} = 1.2337$, quoting both values to the precision at which
they vary. Since the numerical error in the fits is negligible, it cannot be
propagated into an error in the final answer. Thus, we get the error in the
final answer from repeated runs of the simulation and taking the standard
deviation of the many values.

As we can observe in Figure \ref{fig:cumhist}, the peak of the curve does not
lie at the origin as we might expect from the fact that all walkers should
survive at least the first step. The reason for this is twofold:
\begin{itemize}
\item For a well with boundary $J$, it is not possible for the walker to die in
  a number of steps less than $J$
\item It is highly unlikely that the walker will die at a number of steps
  greater than but still close to $J$ since it would require walking in the same
  direction a disproportionate number of times.
\end{itemize}

\begin{figure}[H]%[!ht]
  \begin{center}
    \includegraphics[width=0.45\textwidth]{images/exp_plot.pdf}
    \caption{The probability of dying on a particular step in an infinite square
      well with $J=20$. As can be seen, the peak is away from the origin. This
      is because, for a well with boundary $J$, the minimum number of steps a
      walker must take is $J$. However, it is still unlikely that the walker
      will die on this minimum number of steps, as then the walker must walk in
      the same direction every time. Thus, the most probable step for the walker
      to die on is greater than $J$. It is for this reason that the exponential
      decay does not begin at the origin in Figure \ref{fig:cumhist}, meaning
      some earlier steps must be neglected in order to achieve a better fit.}
    \label{fig:hist}
  \end{center}
\end{figure}

These effects are evident in Figure \ref{fig:hist}, which presents the
probability that a walker will die at a particular number of steps. We can see
that the peak of the curve is very clearly at a step that is greater than 20,
which was the $J$ value used in this simulation. Thus, for low step numbers, the
shape of the curve is not exponential. For this reason we used a simple
algorithm to identify a suitable number of steps to skip before fitting the
exponential curve. It is for this reason that the histogram in Figure
\ref{fig:cumhist} does not start at the origin.

\begin{figure}%[!ht]
  \begin{center}
    \includegraphics[width=0.45\textwidth]{images/line_plot.pdf}
    \caption{The probability of dying on a particular step in an infinite square
      well with $J=20$ as in Figure \ref{fig:hist}, plotted on a logarithmic
      scale. As explained for Figure \ref{fig:hist}, the peak probability is on
      a step greater than $J$. This is clear in this plot. It is also evident
      that there is significantly more spread in the points at higher
      steps. This is due to there being significantly fewer walkers dying on
      these steps, so the relative differences are higher. This explains the
      fluctuations seen at higher steps in Figure \ref{fig:cumloghist}.}
    \label{fig:loghist}
  \end{center}
\end{figure}

We observe some fluctuation in the data in the higher steps in Figure
\ref{fig:cumloghist}. This is because there are so few walkers surviving to this
many steps that there is more significant variance in their relative numbers. We
can observe this in Figure \ref{fig:loghist}. At higher step numbers, the spread
is significantly larger due to the greater relative variance in the small number
of walkers surviving to this many steps. When this data is cumulatively summed
to calculate the probability of survival shown in Figure \ref{fig:cumloghist},
the spread is present as the fluctuations.

\begin{figure*}[ht!]
  \centering
  \subfloat[Probability of dying on a particlar step in Linear scale]
  {\includegraphics[width=0.5\textwidth]{images/exp_plot_cutoff.pdf}
  \label{fig:expcutoff}}
  \centering
  \subfloat[Probability of surviving to at least a particular step in a
  logarithmic scale]
  {\includegraphics[width=0.5\textwidth]{images/cum_line_plot_cutoff.pdf}
  \label{fig:cum_line_cutoff_plot}}
  \caption{Histograms showing the results of the simulation when a maximum number
  of steps is introduced. If a walker reaches this number of steps, they
  automatically die, regardless of position. This results in a
  disproportionately high number of walkers dying at this maximum number, 2000
  in this case, as shown by Figure \ref{fig:expcutoff}. Although this presents
  no fluctuation at higher number of steps, as shown in Figure
  \ref{fig:cum_line_cutoff_plot}, some systematic error is introduced
  through this method.}
  \label{fig:cutoffplots}
\end{figure*}

It is possible to remove this variance by introducing a cutoff number of steps,
i.e. a maximum number of steps at which the walker will automatically die,
regardless of whether they reached a boundary or not. Thus, there will not be
such high variance in the number of walkers surviving to high number of
steps. This is presented in Figure \ref{fig:cum_line_cutoff_plot}. While the
Figure \ref{fig:cum_line_cutoff_plot} fit is observed to be better, with a
higher $R^2$ value, some systematic error has been introduced since there will
now be a disproportionately high number of walkers dying at the cutoff step as
can be seen in Figure \ref{fig:expcutoff}. Thus, the final $\lambda J^2$ value
will be less accurate. On a faster computer, with more efficient code, it is
possible to forgo the step cutoff and allow the simulation to run until all the
walkers die. This may take much longer but will ensure there will not be such a
systematic error introduced. This is the method used in this investigation.

\begin{figure}[!ht]
  \begin{center}
    \includegraphics[width=0.45\textwidth]{images/multiplot.pdf}
    \caption{Histogram plotted on a logarithmic scale showing the Probability of
      surviving to at least a particular step in different infinite square wells
      with different boundaries $J$. The simulations were run with $10000$
      walkers The $\lambda J^2$ values for each are shown. The values get closer
      to the theoretical value of $\frac{\pi^2}{8} = 1.2337$ as we increase the
      size of the well. This is likely due to more walkers surviving to a higher
      number of steps, as the well size is increased.}
    \label{fig:multi_line_plot}
  \end{center}
\end{figure}

It is also necessary to investigate how varying the boundary $J$ affects the
accuracy of the final answer. Figure \ref{fig:multi_line_plot} presents the
probability plot from Figure \ref{fig:cumloghist} for many different boundary
$J$ values. No step cutoff was introduced. The calculated $\lambda J^2$ value is
shown in the legend. The gradient evidently changes, since the expected highest
number of steps would increase as the boundary is larger, as there is more
space for the walker to move before reaching a boundary. As shown in the legend,
the calculated $\lambda J^2$ values get closer and closer to the
theoretical value as $J$ increases. This is due to the fact that as $J$
increases, there are more walkers surviving to larger number of steps. Thus, we
can say that using a larger value of $J$ will result in a more accurate answer
but will also be more computationally intensive and take longer. Thus, we make a
trade-off between speed and accuracy and choose $J=20$ for the final
investigation.

Running the simulation 10 times with 1000000 walkers in an infinite square well
with $J=20$ and taking the average $\lambda J^2$ with error being standard
deviation, we find:
\begin{equation}
  \lambda J^2 = 1.2339 \pm 0.0008
  \nonumber
\end{equation}
We quote the precision to the decimal place at which there is variation from the
theoretical result of $1.2337$. We notice that the error in the calculated
answer is small (since there is not much variation between repeated simulations)
and the theoretical result is within the range of the calculated answer.

\section{Conclusions}

In this investigation we demonstrated a method of calculating ground state
energies of a quantum system using Random walk computational simulations. The
investigation focussed on a one dimensional infinite square well, but can easily
be extended to more complex systems such as a circular well in two dimensions.

The investigation explored the effects of varying the size of the well in
determining the ground state energy of a quantum system, and showed that this
Monte Carlo method produces more accurate results for ground state energies of
larger wells.  This is because for wells with larger boundaries, the walker can
take a larger number of steps on average before dying, and thus can populate
larger step bins. Thus, this method produces data that is close to the
theoretical result for larger infinite square wells.

The numerical result found the ground state energy proportionality constant to
be $\lambda J^2 = 1.2339 \pm 0.0008$, which is consistent with the known
theoretical value of $\frac{\pi^2}{8}$.

This method can be easily extended to multiple dimensions with only a linear
increase in time complexity for each added dimension. Thus, while this method
may not be very efficient for low number of dimensions, it quickly becomes
effective at a higher number of dimensions.

\pagebreak
\appendices
\section{Random walk Schr\"{o}dinger Equation Derivation}
\label{appendix:derivation}
Consider a one-dimensional lattice upon which a walker is undergoing a random
walker. Let us denote the probability that the walker is at position $j$ after
$n$ steps as $p(j,n)$ and the probability that the walker will die at position
$j$ as $a(j)$. We will denote the position-step number coordinates as $[j,
n]$. Thus, for a walker to have coordinates $[j, n+1]$, in the previous step,
they must have had coordinates $[j \pm 1, n]$. So we can say:

\begin{equation}
  \label{eq:probability}
  p(j, n+1) =  \frac{1}{2}(1-a(j))(p(j-1,n) + p(j+1,n))
\end{equation}

If $a(j)$ is small and $n$ is large, then we can say $p(j, n)$ is a continuous
function and we can use Taylor expansion to expand each of $p(j+1, n)$,
$p(j-1,n)$, and $p(j, n+1)$:

\begin{equation}
  p(j+1, n) = p(j,n) + \frac{\partial p}{\partial j} + \frac{1}{2}
  \frac{\partial^2 p}{\partial j^2} + ...
  \nonumber
\end{equation}
\begin{equation}
  p(j-1, n) = p(j,n) - \frac{\partial p}{\partial j} + \frac{1}{2}
  \frac{\partial^2 p}{+\partial j^2} + ...
  \nonumber
\end{equation}
\begin{equation}
  p(j, n+1) = p(j, n) + \frac{\partial p}{\partial n} + ...
  \nonumber
\end{equation}

We can now substitute these expansions into Equation \ref{eq:probability}, we
find:

\begin{equation}
  p(j, n) + \frac{\partial p}{\partial n} = (1-a(j))\Big(p +
  \frac{1}{2}\frac{\partial^2 p}{\partial j^2}\Big)
  \nonumber
\end{equation}

But the probability of death $a(j)$ and the second derivative are so small, that
their product is neglected. We also let $p(j,n) = q(j) \exp(-\lambda n)$ so that:

\begin{equation}
  -\frac{1}{2} \frac{d^2q(j)}{dj^2} + a(j)q(j) = \lambda q(j)
  \nonumber
\end{equation}

\printbibliography

\end{document}


\chapter{Topics to study other references}

% ------------------------------------
\section{Questions}
% ------------------------------------

%TODO
\begin{itemize}
	\item TODO
\end{itemize}

% ------------------------------------
\section{Other references}
% ------------------------------------

\begin{itemize}
	\item List of open problems concerning quantum invariants
		is at
		\citep{ohtsuki2002problems}

	\item Vassiliev knot invariants, for this
		\citep{bar1995vassiliev}

	\item Khovanov homology
		\citep{bar2005khovanov}

	\item Kaufman's books, for example
		\citep{kauffman2001knots}

	\item Baez's book on gauge theory
		\citep{baez1994gauge}
\end{itemize}

\newpage
% ------------------------------------
\section{Possible Projects}
% ------------------------------------

\subsection{Using Machine Learning to calculate Knot Invariants}

\textbf{Literature:}
\begin{itemize}
	\item \citep{1902.05547}: The authors used a neural network
	to investigate a relationship between the Jones polynomial of a knot
	and the hyperbolic volume of the knot complement in case that the knot is
	hyperbolic

	\item \citep{hughes2016neural}

	\item \citep{bull2018machine}
\end{itemize}

\noindent \textbf{Ideas:}
\begin{itemize}
	\item Use similar machine learning techniques to approximate
	concordance invariants of knots and links

	\item Use Khovanov homology groups as inputs for the
	network in the hope that this captures more combinatorial content
	about the knot than merely the coefficients of knot polynomials.
	One could also try to apply this to other knot homology theories

	\item Use a convolutional neural network to encode and process $2$-dimensional input:
	For example the Khovanov and Heegaard-Floer complexes of a knot can be equipped
	with various gradings which could give extra information

	\item In the case that there seems to be a previously unknown relationship
	between invariants one could then try to prove this exactly
\end{itemize}

\subsection{Visualizing Slice Disks in Trisection diagrams}

There is a relative setting where trisections can be used to
describe embedded $2$-dimensional submanifolds of
$4$-manifolds.
Maybe from this one could try to get new statements about
concordance?

\noindent \textbf{TODO:}
\begin{itemize}
	\item Learn more about trisections and in particular about
	representing surfaces in $4$-manifolds

	\item Find out what people have already tried with questions
	about concordance using trisections

	\item There should be a calculus for modifying trisections?
	Find out more about this.
	Would it be feasible to implement this in a computer program,
	in the spirit of something like Frank Swenton's KirbyCalculator?
	\citep{kirbycalculator}

\end{itemize}


\section{Literatura}
\begin{frame}{Literatura}
	\begin{thebibliography}{9}
	\setbeamertemplate{bibliography item}[online]

	\bibitem{RootFinding}{
		B. N. ~Datta
		\newblock Numerical Methods for the Root Finding Problem
		\newblock \url{http://www.math.niu.edu/~dattab/MATH435.2013/ROOT_FINDING.pdf}
	}

	\bibitem{IterativeMethods}{
		C. T. ~Kelley
		\newblock Iterative Methods for Linear and Nonlinear Equations
		\newblock \url{https://archive.siam.org/books/textbooks/fr16_book.pdf}
	}

\end{thebibliography}
\end{frame}


\setchapterpreamble[ur]{
  \dictum
  [Michèle Audin, \textit{Conseils aux auteurs de textes mathématiques}]
  {Un texte mathématique est, d’abord, un texte.}
  \vspace{1em}
}

\chapter{Writing text}

% According to \cite{mathoverflow_text} and Google~Translate the above quote may be translated as follows:
% \begin{center}
%   \enquote{A mathematical text is, before everything else, a text.}
% \end{center}
In this chapter we will talk about the more text focused aspects of writing mathematics with {\LaTeX}.
We will in particular talk about the interplay between the mathematical content and the text that surrounds it.

\section{Obey orthography}
\index{orthography}
\label{a mathematical text is a text}

A mathematical text has to obey the rules of the language that is it written in (e.g.~English, French, German or Russian).
A mathematical formula is part of the surrounding text, and has to be treated as such.

\section{Proper punctuation}

\subsection{A sentence ends with punctuation}
\index{punctuation!in formulas|(}

\Cref{a mathematical text is a text} has an important consequence:
If a sentence ends with a formula, then this formula need to be followed by some kind of punctuation (in most cases by a period).
The following example is very wrong:
\begin{showlatex}*{Very wrong punctuation in an equation}
It follows that
\[
  a^2 + b^2 = c^2
\]
.
This formula is important.
\end{showlatex}
The next example is also wrong:
\begin{showlatex}*{Wrong punctuation in an equation~I}
It follows that
\[
  a^2 + b^2 = c^2
\]
This formula is important.
\end{showlatex}
The following is still wrong:
\begin{showlatex}*{Wrong punctuation in an equation~II}
It follows that:
\[
  a^2 + b^2 = c^2
\]
This formula is important.
\end{showlatex}
The following example finally does it right:
\begin{showlatex}*{Right punctuation in an equation}
It follows that
\[
  a^2 + b^2 = c^2.
\]
This formula is important.
\end{showlatex}
But it is even better if we add some slight spacing between the formula and the period.
\begin{showlatex}*{Best punctuation in an equation}
It follows that
\[
  a^2 + b^2 = c^2 \,.
\]
This formula is important.
\end{showlatex}
This last approach is taken from \cite{tex_period}, which we strongly encourage the reader to check out.

\index{punctuation!in formulas|)}

\subsection{Punctuation in commutative diagrams?}
\index{punctuation!in commutative diagrams|(}
\index{commutative diagrams|(}

There is some disagreement in the mathematical community about whether a commutative diagram is allowed to include punctuation coming from the surrounding text.
The author is of the opinion that a commutative diagram should not contain any such punctuation.

There are two standard ways to achieve this:
One can finish up the sentence that precedes a commutative diagram beforehand:
\begin{showlatex}{Finishing the sentence before the commutative diagram}
  We consider the following commutative diagram:
  \[
    \begin{tikzcd}
        A
        \arrow{r}
        \arrow{d}
      &
        A'
        \arrow{d}
      \\
        C
        \arrow{r}
      &
        C'
    \end{tikzcd}
  \]
  The horizontal arrows in this diagram are isomorphisms.
\end{showlatex}
But it often better to incorporate the diagram in the surrounding sentence in such a way that it contains no punctuation:
\begin{showlatex}{Incorporating the commutative diagram in the sentence}
  In the commutative diagram
    \[
    \begin{tikzcd}
        A
        \arrow{r}
        \arrow{d}
      &
        A'
        \arrow{d}
      \\
        C
        \arrow{r}
      &
        C'
    \end{tikzcd}
  \]
  both horizontal arrows are isomorphisms.
\end{showlatex}

\index{punctuation!in commutative diagrams|)}
\index{commutative diagrams|)}

\subsection{Lists contain punctuation}
\index{punctuation!in lists|(}
\index{lists}

Text that is organized using list environments still obeys the rules of punctuation.
Consider the following counterexample:
\begin{showlatex}{Wrong punctuation in lists}
  A set $B$ is a basis of $V$ if
  \begin{enumerate}
    \item
      $B$ is linearly independent
    \item
      $B$ is a generating set
  \end{enumerate}
\end{showlatex}
To figure out the correct punctuation simply remove the surrounding list and consider the resulting text.
In the above example this gives the following:
\begin{center}
  A set $B$ is a basis of $V$ if $B$ is linearly independent $B$ is a generating set
\end{center}
This is not a proper sentence, and should instead be as follows:
\begin{center}
  A set $B$ is a basis of $V$ if $B$ is linearly independent and $B$ is a generating set.
\end{center}
The above counterexample should hence read as follows:
\begin{showlatex}{Right punctuation in lists~I}
  A set $B$ is a basis of $V$ if
  \begin{enumerate}
    \item
      $B$ is linearly independent and
    \item
      $B$ is a generating set.
  \end{enumerate}
\end{showlatex}
There are also some other acceptable versions:
\begin{showlatex}{Right punctuation in lists~II}
  A set $B$ is a basis of $V$ if it satisfies the following two conditions:
  \begin{enumerate}
    \item
      $B$ is linearly independent.
    \item
      $B$ is a generating set.
  \end{enumerate}
\end{showlatex}

\index{punctuation!in lists|)}

\subsection{Hyphen and dashes}

\subsubsection{Know your lines}

In {\LaTeX} there are (at least) four line-like symbols which need to be distinguished, the hyphen\massindex[punctuation]{hyphen}, the en~dash\massindex[punctuation]{en~dash}, the em~dash\massindex[punctuation]{em~dash} and the minus~sign\index{minus sign}.
See \cref{dash list} for their {\LaTeX}~code and look.
\begin{table}[tb]
  \begin{center}
  \begin{tabular}{@{}lll@{}}
    \toprule
    \theading{name}
    &
    \theading{code}
    &
    \theading{output}
    \\
    \midrule
    hyphen
    &
    \inlinecode{-}
    &
    -
    \\
    en~dash
    &
    \inlinecode{--}
    &
    --
    \\
    em~dash
    &
    \inlinecode{---}
    &
    ---
    \\
    minus~sign
    &
    \inlinecode{\$-\$}
    &
    $-$
    \\
    \bottomrule
  \end{tabular}
  \end{center}
  \caption{Kinds of hyphen and dashes.}
  \label{dash list}
\end{table}
Each of these symbols plays its own role, and these roles depend both on language and on convention.
For mathematical writing in English the following usages are important:
\begin{myitemize}
  \item
    For \enquote{$n$-dimensional} and \enquote{$3$-manifold}, use the hyphen.
  \item
    For combining names as in \enquote{Cauchy--Schwarz inequality} use the en~dash.
  \item
    To interrupt a sentence{---}as done here{---}use the em~dash without surrounding space, or -- if you’re feeling British -- use the en~dash surrounded by space.
\end{myitemize}
For more information about the use of hyphen and dashes in the English language we refer to \cite[6.75--6.94]{chicago}.

To underline how language dependent the usage of hyphen and dashes is we’re considering in \cref{cgc names} how the the Clebsch--Gordan are called in different languages, as taken from Wikipedia.
(We use the same font%
\footnote{Namely~\enquote{Noto~Serif~CJK~JP}.}
for all examples to allow a better comparison.)
\begin{table}[tb]
  \begin{center}
  \begin{tabular}{@{}lll@{}}
    \toprule
    \theading{language}
    &
    \theading{name}
    &
    \theading{dash used}
    \\
    \midrule
    English
    &
    \multilang{Clebsch–Gordan coefficients}
    &
    en~dash
    \\
    German
    &
    \multilang{Clebsch-Gordan-Koeffizienten}
    &
    hyphen
    \\
    French
    &
    \multilang{coefficients de Clebsch-Gordan}
    &
    hyphen
    \\
    Dutch
    &
    \multilang{Clebsch-Gordan-coëfficienten}
    &
    hyphen
    \\
    Russian
    &
    \multilang{Коэффициенты Клебша — Гордана}
    &
    em~dash
    \\
    Japanese
    &
    \multilang{クレブシュ–ゴルダン係数}
    &
    en~dash
    \\
    \bottomrule
  \end{tabular}
  \end{center}
  \caption{The Clebsch--Gordan coefficients in different languages.}
  \label{cgc names}
\end{table}

\subsubsection{Don’t put a hyphen in math~mode}

A non-trivial amount of people makes the mistake of putting a hyphen\massindex[punctuation]{hyphen} into math~mode.
\begin{showlatex}{An accidental hyphen in math~mode}
Let~$A$ be an $R-$module.
\end{showlatex}
We can see that we don’t get a hyphen but a minus sign.
We hence need to place the symbol~\inlinecode{-} outside of the math environment.
\begin{showlatex}{Proper placement of the hyphen}
Let~$A$ be an $R$-module.
\end{showlatex}

\subsection{Correct spacing after a period}
\label{spacing after dots}
\index{spacing!after a period|(}

\subsubsection{The problem}

Not all periods are treated equally by {\LaTeX}:
If a period is both followed by whitespace and not preceded by an uppercase letter then {\LaTeX} will assume that this period is supposed to end a sentence.
It will some introduce some additional space following this period.
The effect of this can be seen in \cref{period spacing}.
\begin{table}
  \begin{center}
  \begin{tabular}{@{}r@{\hskip 2.7em}r@{\hskip 2.7em}l@{\hskip 2.7em}l@{}}
    \toprule
    \multicolumn{2}{c}{\theading{right aligned}}
    &
    \multicolumn{2}{c}{\theading{left aligned}}
    \\
    \cmidrule(r{2.7em}){1-2}\cmidrule{3-4}
    \scalebox{3.5}[3.5]{x. x}
    &
    \scalebox{3.5}[3.5]{x. X}
    &
    \scalebox{3.5}[3.5]{x. x}
    &
    \scalebox{3.5}[3.5]{X. x}
    \\
    \scalebox{3.5}[3.5]{X. x}
    &
    \scalebox{3.5}[3.5]{X. X}
    &
    \scalebox{3.5}[3.5]{x. X}
    &
    \scalebox{3.5}[3.5]{X. X}
    \\
    \bottomrule
  \end{tabular}
  \end{center}
  \caption{Spacings after a period (with a zoom of factor~$3.5$).}
  \label{period spacing}
\end{table}

We can see from the first two columns of~\cref{period spacing} (by considering the positions of the periods) that the spacing in~\enquote{\inlinecode{x.~*}} is larger then the corresponding spacing in~\enquote{\inlinecode{X.~*}}.
This happens because {\LaTeX} thinks that the period in~\enquote{\inlinecode{x. *}} is supposed to end a sentence.
We can also see from the first two tables that this difference of spacing occurs both if the following letter is lower case and if it is upper case.
We can see from the third and fourth column that the amount of additional spacing does not depenend on whether the following letter is in lower case or upper case.

\subsubsection{First Solution}

The default behaviour of {\LaTeX}, to put additional space after a period that ends a sentence, is outdated.
So it is best to just deactivate it.
This can via the command \comname{frenchspacing}\massindex[spacing!after a period]{frenchspacing}[\comname].
By putting this command in the preamble, the whole document will be affected.

\begin{showcode}{Using \comname{frenchspacing}}
  \documentclass[a4paper, 10pt]{scrartcl}

  \frenchspacing

  \begin{document}

  No additional space after a sentence in this document.

  \end{document}
\end{showcode}

The additional spacing can also be reenabled by \comname{nofrenchspacing}\massindex[spacing!after a period]{nofrenchspacing}[\comname].

\begin{showlatex}{Using \comname{nofrenchspacing}}
  \frenchspacing
  Observe the spacing. Between the preceeding period.
  \nonfrenchspacing\\
  Observe the spacing. Between the preceeding period.
\end{showlatex}

\subsubsection{Second Solution}

If the default behavior should be kept, then one needs to do more manual work.

We can use the command~\enquote{\comname{ }} -- which we will write for readability as~\comname{(space)}\massindex[spacing!after a period]{(space)}[\comname] -- to tell~{\LaTeX} that a preceding period is not meant to end a sentence.
We can similarly use the command~\comname{@}\massindex[spacing!after a period]{"@}[\comname] to tell {\LaTeX} that the following period is ending a sentence.
Consider the following example:
\begin{showlatex}{Proper spacing after periods}
Imagine now some old and long-dead English kings, e.g.\ Henry III and Henry IV\@.
(Kings not named Henry are also okay.)
\end{showlatex}
Note that in the above example one should also use ties~\inlinecode{\customtexttilde} (as explained in \cref{non-breakable space}) to ensure that the Henries don’t lose their number.
\begin{showlatex}{Proper spacing after periods, and using~\inlinecode{\customtexttilde}}
Imagine now some old and long-dead English kings, e.g.\ Henry~III and Henry~IV\@.
(Kings not named Henry are also okay.)
\end{showlatex}

It should be pointed out that if a problematic period is followed by a closing parenthesis, a closing bracket, or quotations marks then then the problematic spacing will still occur after these symbols.
Lets consider the following example (where we use the otherwise forbidden~\comname{\tbs} to compare the versions).
\begin{showlatex}{Spacings after periods followed by parentheses or quotation marks}
Many colours (e.g. red, blue, etc.) are supported by \enquote{ColorX}. Even purple! \\
Many colours (e.g.\ red, blue, etc.) are supported by \enquote{ColorX}. Even purple! \\
Many colours (e.g.\ red, blue, etc.)\ are supported by \enquote{ColorX}. Even purple! \\
Many colours (e.g.\ red, blue, etc.)\ are supported by \enquote{ColorX}\@. Even purple!
\end{showlatex}

The problem of a sentence ending with an upper case letter does not occur if this letter is in math~mode.
\begin{showlatex}{Upper case mathematics followed by a period}
Let $f$ be an endomorphism of $X$.
Then $f$ is an isomorphism or $f = 0$.\\
Let $f$ be an endomorphism of $X$\@.
Then $f$ is an isomorphism or $f = 0$.\\
Let $f$ be an endomorphism of $X$.\
Then $f$ is an isomorphism or $f = 0$.
\\
Let $f$ be an endomorphism of $\operatorname{X}$.
Then $f$ is an isomorphism or $f = 0$.\\
Let $f$ be an endomorphism of $\operatorname{X}$\@.
Then $f$ is an isomorphism or $f = 0$.\\
Let $f$ be an endomorphism of $\operatorname{X}$.\
Then $f$ is an isomorphism or $f = 0$.
\end{showlatex}

In view of the upcoming \cref{non-breakable space} we get a problem:
What if we want the space after an abbreviation, as in~\enquote{i.e.~word}, not to be broken?
Should we then write~\inlinecode{i.e.{\tbs} word} or~\inlinecode{i.e.{\customtexttilde}word}?

In this case we write~\inlinecode{i.e.{\customtexttilde}word}, since the tie~\inlinecode{\customtexttilde} already contains the effect of~\comname{(space)}.
Consider for this the following example:
\begin{showlatex}{Spacing of~\inlinecode{\customtexttilde} and~\enquote{\inlinecode{{\tbs} }}}
Let $M$ be a $2$-manifold, e.g. $M = S^2$. \\
Let $M$ be a $2$-manifold, e.g.\ $M = S^2$. \\
Let $M$ be a $2$-manifold, e.g.~$M = S^2$.
\end{showlatex}

To summarize this \lcnamecref{spacing after dots}:
If an abbreviation or some non-word things appear one should pay heed to periods which may occur at their ends.
Most of these special cases are covered by paying attention to~\enquote{i.e.~*} and~\enquote{e.g.~*}.

We refer to \cite[19.5.1, 19.6]{latex2e_manual} for more information on this topic.

\index{spacing!after a period|)}

\section{Text layout}

\subsection{Use non-breakable space}
\label{non-breakable space}

If two expressions in text mode are separated by a space or a hyphen then {\LaTeX} may separate these expressions in the output \filename{pdf}-file by a line break\index{line breaks!in text mode}.
But such line breaks are often undesirable and can sometimes be downright wrong.
Comsider for this the following examples:
\begin{myitemize}
  \item
    Abbreviations like~\enquote{Prof.~Dr.~John Doe}.
  \item
    Cmbinations of words and numbers like~\enquote{Lemma~5}.
  \item
    Combinations of mathematics and words like~\enquote{$3${\nbd}dimensional}.
\end{myitemize}
In such cases one needs to prevent the line break.

\subsubsection{Line breaks at a space}

No line break will occur if the tie\index{\customtexttilde}\index{tie}\index{unbreakable!space} symbol~\inlinecode{\customtexttilde} is used instead of a space.
Consider for this the following example:
% fragile example
\begin{showlatex}*{An unwanted line break at a space}
Text text text text text text text text text text text text text, so by Lemma 35 text text text text text text text text
\end{showlatex}
We don’t want a line break to occur in the term~\enquote{Lemma~35} and thus introduce a tie.
\begin{showlatex}*{Using~\inlinecode{\customtexttilde} to prevent unwanted line breaks at spaces}
Text text text text text text text text text text text text text, so by Lemma~35 text text text text text text text text
\end{showlatex}

\subsubsection{Line breaks at a hyphen}

Consider the following example:
% % fragile example
\begin{showlatex}{An unwanted line break at a hyphen}
  textextext textextext textextext textextext textextext textextext textext 123456-dimensional textextext
\end{showlatex}
To prevent a line break at the hyphen\massindex[punctuation]{hyphen} we put~\comname{nobreakdash} before it:
\begin{showlatex}{Using~\comname{nobreakdash} to prevent unwanted line breaks at hyphens}
  textextext textextext textextext textextext textextext textextext textext 123456\nobreakdash-dimensional textextext
\end{showlatex}
The command~\comname{nobreakdash} works not only with hyphens but also with en~dashes\index{unbreakable!dash}\massindex[punctuation]{en~dash} and em~dashes\index{unbreakable!dash}\massindex[punctuation]{em~dash}.

\subsection{Don’t use \comtitle{\tbs} or \comtitle{newline}}

The proper way to separate two succeeding paragraphs\index{paragraphs}\index{indentation!of paragraphs} in {\LaTeX} is to leave an empty line between them.
\begin{showlatex}*{New paragraphs done right}
This is the first paragraph.
It consists of multiples lines to make this example better.

This is a second paragraph.
It also consists of multiple lines to make this example even more better.

This one is the third and last paragraph in this example.
It also consists of multiple lines.
\end{showlatex}
Note that new paragraphs start indented.

The use of~\comname{\tbs}\massindex{\tbs}[\comname] or~\comname{newline}\massindex{newline}[\comname] doesn’t actually end a paragraph but only forces a line break.\index{line breaks!in text mode}
\begin{showlatex}*{New \enquote{paragraphs} done wrong}
This is the first paragraph in a counterexample.\\
This is not a new paragraph.
The text is just forced to start a new line.\newline
This one is also not a new paragraph.
But this whole thing looks ugly.
\end{showlatex}
The use of \comname{\tbs} and \comname{newline} is only for starting new rows in matrices, tables and arrays.%
\footnote{
  In this text we sometimes use~\comname{\tbs} to tweak examples, to make certain lines more comparable.
  This is done purely for technical purposes and should not be done for actual mathematical writings.
}
Don’t use is to separate paragraphs.

\subsection{Text consisting of lists}

The two list~environments~\envname{enumerate} and~\envname{itemize} contain by default certain indentations, that can be problematic in mathematical writing.

\subsubsection{Identation compared to the left~margin}

There is by default some indentation between the left~margin of the text area and the item labels.
This is meant to visually separate the list from the surrounding text.
But in mathematical writing there often occur lists that don’t have a surrounding text.
The most prominent example for this are propositions (and their proofs) that consist of multiple statements:
\begin{showlatex}{A list without surrounding text}
\begin{theorem}
  Let $G$ be a finite group.
  \begin{enumerate}
    \item
      If $H$ is subgroup of $G$ then $\operatorname{ord}(H)$ divides $\operatorname{ord}(G)$.
    \item
      If $g$ is any element of $G$ then $\operatorname{ord}(g)$ divides $\operatorname{ord}(G)$.
    \item
      Every group of prime order is cyclic.
    \item
      If $p$ is a prime divisor of $\operatorname{ord}(G)$ then $G$ contains an element of order $p$.
  \end{enumerate}
\end{theorem}
\end{showlatex}

In such cases one should remove the identation between the left~margin of the text area and the item~labels, as explained in \cref{list indentation with enumitem}.
\begin{showlatex}{A list without surrounding text}
\begin{theorem}
  Let $G$ be a finite group.
  \begin{enumerate}[wide = 0pt, leftmargin=*]
    \item
      If $H$ is subgroup of $G$ then $\operatorname{ord}(H)$ divides $\operatorname{ord}(G)$.
    \item
      If $g$ is any element of $G$ then $\operatorname{ord}(g)$ divides $\operatorname{ord}(G)$.
    \item
      Every group of prime order is cyclic.
    \item
      If $p$ is a prime divisor of $\operatorname{ord}(G)$ then $G$ contains an element of order $p$.
  \end{enumerate}
\end{theorem}
\end{showlatex}

\subsubsection{Theorems and proofs beginning with a list}

If a theorem-like~environment\index{theorem-like environments} or a the environment~\envname{proof}\massindex[\piname{amsthm}]{proof}[\envname] begins with a list~environment then the first item of this list will not be aligned with the other list items:
\begin{showlatex}{Improper aligned of list items}
\begin{lemma}
\begin{enumerate}
  \item
    Every group $G$ is isomorphic to its opposite group $G^{\mathrm{op}}$.
  \item
    A group $G$ equals its opposite group $G^{\mathrm{op}}$ if and only if it is abelian.
\end{enumerate}
\end{lemma}
\end{showlatex}

One way to circumvent this problem is by inserting the command~\comname{leavevmode}\massindex{leavevmode}[\comname] before the beginning of the list.
\begin{showlatex}{Proper aligned of list items with~\comname{leavevmode}}
\begin{lemma}
\leavevmode
\begin{enumerate}
  \item
    Every group $G$ is isomorphic to its opposite group $G^{\mathrm{op}}$.
  \item
    A group $G$ equals its opposite group $G^{\mathrm{op}}$ if and only if it is abelian.
\end{enumerate}
\end{lemma}
\end{showlatex}
The problem with this approach is that it allows a line break to occur at the position of~\comname{leavevmode}.
So it may happen that the header of the theorem-like environment of proof environment occurs at the very bottom of the page while the list appears only on the next page.
(This looks quite horrible.)

As far as the author is aware there exists no good solution for this problem.%
\footnote{The package~\packname{ntheorem}\massindex[packages]{ntheorem}[\packname] is allegedly able to address this problem, at the price of introducing new problems.}
A good way of coping with this problem is to circumvent it by introducing some text before the list~environment:
\begin{showlatex}{Proper aligned of list items by introducing text}
\begin{lemma}
Let $G$ be a group with opposite group $G^{\mathrm{op}}$.
\begin{enumerate}
  \item
    The groups $G$ and $G^{\mathrm{op}}$ are isomorphic.
  \item
    The groups $G$ and $G^{\mathrm{op}}$ are equal if and only if $G$ is abelian.
\end{enumerate}
\end{lemma}
\end{showlatex}
An seen above we should also eliminate the indentation between the left~margin of the text~area and the item~labels:
\begin{showlatex}{Proper aligned of list items by introducing text}
\begin{lemma}
Let $G$ be a group with opposite group $G^{\mathrm{op}}$.
\begin{enumerate}[wide = 0pt, leftmargin=*]
  \item
    The groups $G$ and $G^{\mathrm{op}}$ are isomorphic.
  \item
    The groups $G$ and $G^{\mathrm{op}}$ are equal if and only if $G$ is abelian.
\end{enumerate}
\end{lemma}
\end{showlatex}

\section{Mathematics in text}

\subsection{Don’t break inline mathematics}
\label{breaking inline math}

When inline formulas or inline equations are too long or badly placed then it can happen that a line break\index{line breaks!in text mode} occurs inside the formula, tearing it apart:
% fragile example
\begin{showlatex}[before lower = {\binoppenalty=100}, after lower = {\binoppenalty = \maxdimen}]{Line break in inline math}
The most important formula of all times is without a doubt is my mind $1 + 2 + 3 + 4 = 10$.
Truly a work of genius!
% fragile example
\end{showlatex}
This horrible affront to nature can thankfully be eliminated by setting the penalties~\comname{binoppenalty}\massindex[penalties]{binoppenality}[\comname] and~\comname{relpenalty}\massindex[penalties]{relpenalty}[\comname] to their maximum value, which can be accessed via the command~\comname{maxdimen}\massindex{maxdimen}[\comname].
\begin{showlatex}{Preventing inline math in inline math}
% in the preamble:
\binoppenalty = \maxdimen
\relpenalty   = \maxdimen
% in the main text:
The most important formula of all times is without a doubt is my mind $1 + 2 + 3 + 4 = 10$.
Truly a work of genius!
\end{showlatex}

\subsection{Don’t begin a sentence with a mathematical symbol}

Don’t begin a sentence with a mathematical symbol.
Consider the following example:
\begin{showlatex}{Mathematics at the beginning of a sentence}
\begin{theorem}
  $\mathbf{Mod}(R)$ is an abelian category.
\end{theorem}
\end{showlatex}
Instead do the following:
\begin{showlatex}{No mathematics at the beginning of a sentence}
\begin{theorem}
  The category $\mathbf{Mod}(R)$ is abelian.
\end{theorem}
\end{showlatex}

An exception to the above rule are lists\index{lists}, in which short entries may start with a math symbol.
Consider for this the following example.
\begin{showlatex}{List items beginning with mathematics}
Let $V$ be a finite dimensional vector space.
Let $U$ and $W$ be two linear subspaces of $V$ of complementary dimensions, i.e.\ such that $\dim V = \dim U + \dim W$.
Then the following conditions are equivalent:
\begin{enumerate}[label = \roman*)]
  \item
    $V = U \oplus W$.
  \item
    $V = U + W$.
  \item
    $U \cap W = 0$.
\end{enumerate}
\end{showlatex}

\subsection{Don’t put two formulas next to each other}

One should not put two mathematical formulas right next to each other.
Consider the following example:
\begin{showlatex}{Not properly separating mathematics}
Then $f^2 = g$,$f$ is differentiable and $f = \exp(h)$.
\end{showlatex}
The human eye (and brain) parses this sentence as follows:
\begin{center}
  Then
  \quad
  $f^2 = g$,$f$
  \quad
  is differentiable and
  \quad
  $f = \exp(h)$.
\end{center}
But this betrays the actual content of the sentence.
This problem can be fixed by introducing some more text.
One solution is the following:
\begin{showlatex}{Properly separating mathematics~I}
Then $f^2 = g$, the function $f$ is differentiable and $f = \exp(h)$.
\end{showlatex}
This sentence is parsed as follows:
\begin{center}
  Then
  \quad
  $f^2 = g$,
  \quad
  the function
  \quad
  $f$
  \quad
  is differentiable and
  \quad
  $f = \exp(h)$.
\end{center}
The following is another solution:
\begin{showlatex}{Properly separating mathematics~II}
The function $f$ satisfies $f^2 = g$, it is differentiable and $f = \exp(h)$.
\end{showlatex}
This sentence is parsed as follows:
\begin{center}
  The function
  \quad
  $f$
  \quad
  satisfies
  \quad
  $f^2 = g$,
  \quad
  it is differentiable and
  \quad
  $f = \exp(h)$.
\end{center}

\subsection{Don’t begin a line with a mathematical symbol (optional)}

One interesting idea for inline mathematics is to never start a line with a mathematical symbol.
This can be achieved by prefixing every inline mathematical formula by a tie~\inlinecode{\customtexttilde}.
The author has taken this approach from~\cite{nomath_at_line}.

\section{Text in mathematics}

\subsection{Use \comtitle{text}}

When text needs to be used in math~mode the command~\comname{text} is to be used.
\begin{showcode}{Syntax of \comname{text}}
\text{normal text in math mode}
\end{showcode}
Let’s start with the following horrible example:
\begin{showlatex}{Missing text in math~mode}
Let $A \coloneqq \{ x \in [0,1] : x \; is \; rational \}$.
\end{showlatex}
This next one looks a bit better, but is still not okay:
\begin{showlatex}[label = {wrong math mode position}]{Wrong way of using text in math~mode}
Let $A \coloneqq \{ x \in [0,1] : x \text{ is rational} \}$.
\end{showlatex}
Instead do this:
\begin{showlatex}[label = {right math mode position}]{Right way of using text in math~mode}
Let $A \coloneqq \{ x \in [0,1] : \text{$x$ is rational} \}$.
\end{showlatex}
Note that the right code reflects the actual structure\index{structure of an expression} of the displayed expression:
Indeed, the diagram in \cref{structure tree of definition} shows the structure of the given expression.
\begin{figure}[tb]
  \begin{center}
    % the following diagram uses the "trees" library
    \begin{tikzpicture}[
      every node/.style = {shape=rectangle, rounded corners, draw, align=center, level distance = 5em},
      level 1/.style = {sibling distance = 8em, level distance = 3em},
      level 2/.style = {sibling distance = 12em, level distance = 4em}
      ]
      \node {definition}
        child { node {name} }
        child { node {set}
                child { node {range of elements} }
                child { node {condition on elements} }
              }
        ;
    \end{tikzpicture}
  \end{center}
  \caption{Structure tree of the definition.}
  \label{structure tree of definition}
\end{figure}
To get the right kind of code we assign to each node of this diagram the desired content, and whether this node is mathematics or text.
If a node contains both mathematics and text then it is primary a text, which just happens to contain some mathematics.
We arrive at the diagram in \cref{structure tree of math}.
\begin{figure}[tb]
  \begin{center}
    % the following diagram uses the "trees" library
    \begin{tikzpicture}[
      every node/.style = {shape=rectangle, rounded corners, draw, align=center, level distance = 5em},
      level 1/.style = {sibling distance = 8em, level distance = 3em},
      level 2/.style = {sibling distance = 12em, level distance = 4em}
      ]
      \node {$\coloneqq$ \\ math}
        child { node {$A$ \\ math} }
        child { node {$\{ \; : \; \}$ \\ math}
                child { node {$x \in [0,1]$ \\ math} }
                child { node {$x$ is rational \\ text} }
              }
        ;
    \end{tikzpicture}
  \end{center}
  \caption{Structure tree of the mathematical expression.}
  \label{structure tree of math}
\end{figure}
By transforming this diagram node-wise into code we arrive at \cref{right math mode position}.
Note that both the nodes~\enquote{$x \in [0,1]$} and~\enquote{$x$ is rational} both contain mathematics, but that the second is actually a text.
It is therefore not proper to combine these two math~modes, as done in \cref{wrong math mode position}.

\subsection{Put space around text in display mathematics}

Sometimes a single line of displayed mathematics end with some text, as in the following example.
\begin{showlatex}{Wrong spacing around text in math~mode~I}
Therefore
\[
  g h g^{-1}
  =
  h
  \text{for all $g, h \in G$}.
\]
\end{showlatex}
In such a case one needs to put space\index{spacing!in math~mode} between the mathematics and the text.
This space should not be part of the text.
Consider the following counterexample:
\begin{showlatex}{Wrong spacing around text in math~mode~II}
Therefore
\[
  g h g^{-1}
  =
  h
  \text{ for all $g, h \in G$.}
\]
\end{showlatex}
Instead the spacing should be put between the formula and the text.

In the above example, where a single block of mathematics is follows by a single block of text which contains quantifiers for the previous formula, one should use the spacing~\comname{qquad}\massindex[spacing]{qquad}[\comname]:
\begin{showlatex}{Right spacing around text in math~mode~I}
Therefore
\[
  g h g^{-1}
  =
  h
  \qquad
  \text{for all $g, h \in G$.}
\]
\end{showlatex}
Sometimes two blocks of mathematics are separated by a short text.
In this case one should use the spacing~\comname{quad}\massindex[spacing]{quad}[\comname] on both sides of the text:
\begin{showlatex}{Right spacing around text in math~mode~II}
That $gh = hg$ can equivalently be expressed as
\[
  g h g^{-1} = h
  \quad\text{and}\quad
  h g h^{-1} = g \,.
\]
\end{showlatex}
It may even be appropriate to use~\comname{qquad} on both sides when more space is needed.

\subsection{Use \comtitle{intertext} and \comtitle{shortintertext}}

Multi-line display mode environments like \envname{gather*}\massindex[display math environment, multi-line mathematics]{gather*}[\envname] and \envname{align*}\massindex[display math environment, multi-line mathematics]{align*}[\envname] (see \cref{display environments}) can be interrupted by inserting some text via the commands~\comname{intersect}\massindex[text in math~mode]{intertext}[\comname] and~\comname{shortintertext}\massindex[text in math~mode]{shortintertext}[\comname] to insert some text between different lines of mathematics.
This is particularly useful to combine multiple \envname{align*}~environments into a single one, which then allows for a common alignment\index{aligning formulas} of all lines.

The following is an example for what we don’t want.
\begin{showlatex}{Two non-aligned blocks}
We consider the equalities
\begin{align*}
  H
  &= a_1 + a_2 + a_3 + a_4 \\
  &= b_1 + b_2 + b_3 + b_4 + b_5 + b_6 \\
  &= c_1 + c_2 + c_3 + c_4 + c_5
\end{align*}
and
\begin{align*}
  I
  &= d_1 + d_2 + d_3 + d_4 + d_5 + d_6 \\
  &= e_1 + e_2 + e_3 \\
  &= f_1 + f_2 + f_3 + f_4 + f_5 \,.
\end{align*}
\end{showlatex}
Note the annoying misalignment of the equality signs of the two \envname{align*}~environments.
We can solve this problem by using only one \envname{align*}~environment and inserting the text~\enquote{and} by using the command~\comname{intertext}:
\begin{showlatex}{Two aligned blocks}
We consider now the equalities
\begin{align*}
  H
  &= a_1 + a_2 + a_3 + a_4 \\
  &= b_1 + b_2 + b_3 + b_4 + b_5 + b_6 \\
  &= c_1 + c_2 + c_3 + c_4 + c_5
\intertext{and}
  I
  &= d_1 + d_2 + d_3 + d_4 + d_5 + d_6 \\
  &= e_1 + e_2 + e_3 \\
  &= f_1 + f_2 + f_3 + f_4 + f_5 \,.
\end{align*}
\end{showlatex}

The command~\comname{shortintertext} works in the same way as~\comname{intertext} but inserts less vertical space\index{spacing} around it.
To see the effects of~\comname{shortintertext} let us start with the following example:
\begin{showlatex}*{Two non-aligned equalities}
It follows from the identity
\[
  a = b
\]
that
\[
  b = a \,,
\]
which proves the theorem.
\end{showlatex}
We naturally want to align the two equality signs, which we by using a single \comname{align*}~environment together with~\comname{intertext}, as explained above:
\begin{showlatex}*{Two aligned equalities with too much space}
It follows from the identity
\begin{align*}
  a &= b
\intertext{that}
  b &= a \,,
\end{align*}
which proves the theorem.
\end{showlatex}
But we can see that the inserted~\comname{intersect} puts a large distance between the two formulas.
This distance is far too large for our taste.
We can solve this problem by using~\comname{shortintertext} instead of~\comname{intertext}, as the following example shows:
\begin{showlatex}*{Two aligned equalities with proper space}
It follows from the identity
\begin{align*}
  a &= b
\shortintertext{that}
  b &= a \,,
\end{align*}
which proves the theorem.
\end{showlatex}

\section{Mathematics as text}

\subsection{Don’t abuse math as text}

Again similar to \cref{no logical symbols} one should not abuse mathematical symbols as words:

A mathematical symbol can often replace parts of a sentence, in particular a verb.
\begin{showlatex}{Right way of using mathematical symbols as words}
Then $a = b$ and thus $b \leq c$.
\end{showlatex}
But this use of mathematics should be treated with care, and not abused:
\begin{showlatex}{Wrong way of using mathematical symbols as words}
The integer $a$ is $< 0$ and thus $\notin \mathbb{N}$.
\end{showlatex}
This kind of tortue is highly illegal, so don’t do it!

\subsection{Logical symbols don’t replace text}
\label{no logical symbols}

Mathematicians often abuse logical symbols\index{logical symbols} like
\[
  \exists \,,
  \quad
  \forall \,,
  \quad
  \implies \,,
  \quad
  \iff
\]
as replacements for written out words.
This is okay in handwriting and on blackboards, but it is not okay in a properly written out mathematical text.
\begin{showlatex}{Abuse of quantifiers}
It follows that $\forall y \in B$ that $\exists x \in A$ with $f(x) = y$.
\end{showlatex}
One needs to instead write out the used quantifiers.
\begin{showlatex}{Writing out quantifiers}
It follows that for every element $y \in B$ there exists an element $x \in A$ with $f(x) = y$.
\end{showlatex}
In this example one should also write out the element relation:
\begin{showlatex}{Best use of quantifiers}
It follows that for every element $y$ of $B$ there exists an element $x$ of $A$ with $f(x) = y$.
\end{showlatex}

The use of the above logical symbols is of course okay if they are used in their actual logical function:
\begin{showlatex}{Okay way to use logical symbols}
  Let $f \colon X \to Y$ be a morphism in a category $\mathcal{C}$.
  Then
  \begin{align*}
    {}&
      \text{$f$ is an epimorphism}
    \\
    \iff{}&
    \bigl[
    \forall Z \in \operatorname{Ob}(\mathcal{C}):
    \forall g, h \in \mathcal{C}(Y,Z):
    g \circ f = h \circ f \implies g = h
    \bigr]
    \\
    \iff{}&
    \bigl[
    \forall Z \in \operatorname{Ob}(\mathcal{C}):
    \text{$f^* \colon \mathcal{C}(Y,Z) \to \mathcal{C}(X,Z)$ is injective}
    \bigr]
    \\
    \implies{}&
    \text{$f^* \colon \mathcal{C}(Y,-) \to \mathcal{C}(X,-)$ is a monomorphism in~$\mathbf{Fun}(\mathcal{C}, \mathbf{Set})$}
  \end{align*}
\end{showlatex}

\subsection{Don’t use \enquote{iff}}
\index{iff}
\label{no iff}

Similarly to \cref{no logical symbols} abbreviations like~\enquote{iff} need to be written out in a proper mathematical text.


%
% This is a borrowed LaTeX template file for lecture notes for CS267,
% Applications of Parallel Computing, UCBerkeley EECS Department.
% Now being used for CMU's 10725 Fall 2012 Optimization course
% taught by Geoff Gordon and Ryan Tibshirani.  When preparing
% LaTeX notes for this class, please use this template.
%
% To familiarize yourself with this template, the body contains
% some examples of its use.  Look them over.  Then you can
% run LaTeX on this file.  After you have LaTeXed this file then
% you can look over the result either by printing it out with
% dvips or using xdvi. "pdflatex template.tex" should also work.
%

\documentclass[twoside]{article}
\setlength{\oddsidemargin}{0.25 in}
\setlength{\evensidemargin}{-0.25 in}
\setlength{\topmargin}{-0.6 in}
\setlength{\textwidth}{6.5 in}
\setlength{\textheight}{8.5 in}
\setlength{\headsep}{0.75 in}
\setlength{\parindent}{0 in}
\setlength{\parskip}{0.1 in}

%
% ADD PACKAGES here:
%

\usepackage{amsmath,amsfonts,graphicx}

%
% The following commands set up the lecnum (lecture number)
% counter and make various numbering schemes work relative
% to the lecture number.
%
\newcounter{lecnum}
\renewcommand{\thepage}{\thelecnum-\arabic{page}}
\renewcommand{\thesection}{\thelecnum.\arabic{section}}
\renewcommand{\theequation}{\thelecnum.\arabic{equation}}
\renewcommand{\thefigure}{\thelecnum.\arabic{figure}}
\renewcommand{\thetable}{\thelecnum.\arabic{table}}

%
% The following macro is used to generate the header.
%
\newcommand{\lecture}[4]{
   \pagestyle{myheadings}
   \thispagestyle{plain}
   \newpage
   \setcounter{lecnum}{#1}
   \setcounter{page}{1}
   \noindent
   \begin{center}
   \framebox{
      \vbox{\vspace{2mm}
    \hbox to 6.28in { {\bf EE302 - Feedback Systems
	\hfill Spring 2019} }
       \vspace{4mm}
       \hbox to 6.28in { {\Large \hfill Lecture #1 \hfill} }
       \vspace{2mm}
       \hbox to 6.28in { {\it Lecturer: #2 \hfill } }
      \vspace{2mm}}
   }
   \end{center}
   \markboth{Lecture #1}{Lecture #1}

   \vspace*{4mm}
}
%
% Convention for citations is authors' initials followed by the year.
% For example, to cite a paper by Leighton and Maggs you would type
% \cite{LM89}, and to cite a paper by Strassen you would type \cite{S69}.
% (To avoid bibliography problems, for now we redefine the \cite command.)
% Also commands that create a suitable format for the reference list.
\renewcommand{\cite}[1]{[#1]}
\def\beginrefs{\begin{list}%
        {[\arabic{equation}]}{\usecounter{equation}
         \setlength{\leftmargin}{2.0truecm}\setlength{\labelsep}{0.4truecm}%
         \setlength{\labelwidth}{1.6truecm}}}
\def\endrefs{\end{list}}
\def\bibentry#1{\item[\hbox{[#1]}]}

%Use this command for a figure; it puts a figure in wherever you want it.
%usage: \fig{NUMBER}{SPACE-IN-INCHES}{CAPTION}
\newcommand{\fig}[3]{
			\vspace{#2}
			\begin{center}
			Figure \thelecnum.#1:~#3
			\end{center}
	}
% Use these for theorems, lemmas, proofs, etc.
\newtheorem{theorem}{Theorem}[lecnum]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{definition}[theorem]{Definition}
\newenvironment{proof}{{\bf Proof:}}{\hfill\rule{2mm}{2mm}}

% **** IF YOU WANT TO DEFINE ADDITIONAL MACROS FOR YOURSELF, PUT THEM HERE:

\begin{document}

% Lecture Details
\lecture{8}{Asst. Prof. M. Mert Ankarali}

\par

\section{Second Order Systems}

Let's derive the transfer functions for the following electrical and
mechanical systems

    \begin{minipage}[h]{1\linewidth}
    \begin{center}
     \includegraphics[width=1\textwidth]{2ndOrderSystems}
    \end{center}
  \end{minipage}

\begin{align*}
  G_A(s) &= \frac{V_C(s)}{V_s(s)} = \frac{\frac{1}{LC}}{s^2 +
  \frac{R}{L} s + \frac{1}{LC} }
\\
  G_B(s) &= \frac{Y(s)}{F(s)} = \frac{\frac{1}{M}}{s^2 +
  \frac{b}{M} s + \frac{k}{M} }
\\
   G_C(s) &= \frac{\Theta(s)}{\mathcal{T}(s)} = \frac{\frac{1}{J}}{s^2 +
  \frac{\beta}{J} s + \frac{\kappa}{J} }
\end{align*}

Most of the (passive) second order systems, can be put into the following the
standard form
%
\begin{align*}
G(s) =  K_{DC} \frac{\omega_n^2}{s^2 + 2 \zeta \omega_n s + \omega_n}
\end{align*}
%
where

 \begin{minipage}[h]{1\linewidth}
\begin{tabular}{|c|l|}
\hline
 $0 < \omega_n$ & Undamped natural frequency
 \\
 $0 < \zeta $ & Damping ratio
 \\
 $K_{DC}$ & DC Gain
\\
\hline
\end{tabular}
  \end{minipage}

\vspace{12pt}

Accordingly for the systems that we analyzed previously we have the
following relations
%
\begin{align*}
A:& \quad  \omega_n = \sqrt{\frac{1}{LC}} \ , \ \zeta = \frac{R}{2}
  \sqrt{ \frac{C}{L} } \ , \ K_{DC} = 1
\\
B:& \quad  \omega_n = \sqrt{\frac{k}{M}} \ , \ \zeta = \frac{b}{2}
  \sqrt{ \frac{1}{M k} } \ , \ K_{DC} = \frac{1}{k}
\\
C:& \quad  \omega_n = \sqrt{\frac{\kappa}{J}} \ , \ \zeta = \frac{b}{2}
  \sqrt{ \frac{1}{J \kappa} } \ , \ K_{DC} = \frac{1}{\kappa}
\end{align*}

\textbf{Definition:} Given a transfer function, $G(s) =
\frac{N(s)}{D(s)}$, where $N(s)$ and $D(s)$ are polynomials in $s$.
Roots of $N(s)$ are called ``zeros'' of $G(s)$, and roots of $D(s)$
are called the ``poles'' of $G(s)$.

Behavior of the output $y(t)$ are majorly determined by the pole
locations.

\subsection{Step Response Types for the Second Order System in Standard
  Form}

Given that $G(s) = \frac{\omega_n^2}{s^2 + 2 \zeta \omega_n s +
  \omega_n^2}$, the poles can be computed as
%
\begin{align*}
  s_{1,2} = - \zeta \omega_n \pm \omega_n \sqrt{\zeta^2 - 1}
\end{align*}

\textbf{Case 1:} When $\zeta = 0$, the system becomes undamped and
$G(s)$ takes the form
%
\begin{align*}
  G(s) = \frac{\omega_n^2}{s^2 + \omega_n^2}
\end{align*}
%
We can compute the step-response as
%
\begin{align*}
 Y(s) &= G(s) U(s) = \frac{1}{s} \frac{\omega_n^2}{s^2 + \omega_n^2} =
        \frac{1}{s} - \frac{s}{s^2 + \omega_n^2}
\\
y(t) &= 1 - \cos(\omega_n t) \quad \mathrm{for} \ t > 0
\end{align*}
%
Pole locations and step response when $\zeta = 0$ (undamped), is illustrated in
the Figure below

    \begin{minipage}[h]{1\linewidth}
    \begin{center}
     \includegraphics[width=0.7\textwidth]{undamped}
    \end{center}
  \end{minipage}

\textbf{Case 2:} When $\zeta = 1$, the system becomes ``critically'' damped and
$G(s)$ takes the form
%
\begin{align*}
	G(s) = \frac{\omega_n^2}{s^2 + 2 \omega_n s + \omega_n} = \frac{\omega_n^2}{(s + \omega_n )^2}
\end{align*}
%
We can compute the step-response as
%
\begin{align*}
 Y(s) &= G(s) U(s) = \frac{1}{s} \frac{\omega_n^2}{(s + \omega_n )^2}
 = \frac{1}{s} -  \frac{1}{s + \omega_n} + \frac{\omega_n}{(s + \omega_n)^2}
\\
y(t) &= 1 - e^{-\omega_n t} - \omega_n t e^{-\omega_n t}
\end{align*}
%
Pole locations and step response when $\zeta = 1$ (critically damped), is illustrated in
the Figure below

    \begin{minipage}[h]{1\linewidth}
    \begin{center}
     \includegraphics[width=0.75\textwidth]{critical}
    \end{center}
  \end{minipage}

  \textbf{Case 3:} When $\zeta > 1$, the system becomes over damped and there exist
  two real roots
 	%
	\begin{align*}
		p_1 &= - \zeta \omega_n + \omega_n \sqrt{\zeta^2 - 1} > - \omega_n
		\\
		p_2 &= - \zeta \omega_n - \omega_n \sqrt{\zeta^2 - 1} < - \omega_n
	\end{align*}
%
$G(s)$ can be written in terms of $s_1$ and $s_2$
%
\begin{align*}
	G(s) = \frac{p_1 p_2}{(s+p_1) (s+p_2)}
\end{align*}
%
where it is easy to see that $p_1 p_2 = \omega_n^2$. Finally, we can compute the step-response as
%
\begin{align*}
 Y(s) &= G(s) U(s) = \frac{p_1 p_2}{s (s-p_1) (s-p_2)}
 \\
 y(t) &= 1 + \frac{p_2}{p_1 - p_2} e^{p_1 t} - \frac{p_1}{p_1 - p_2} e^{p_2 t}
 \end{align*}
 %
 Pole locations and step response when $\zeta > 1$ (over damped), is illustrated in
the Figure below

    \begin{minipage}[h]{1\linewidth}
    \begin{center}
     \includegraphics[width=0.9\textwidth]{over}
    \end{center}
  \end{minipage}

\textbf{Case 3:} When $0 <  \zeta < 1$, the system becomes under damped and there exist
  two complex conjugate roots.
  %
 \begin{align*}
 p_{1,2} &= - \zeta \omega_n \pm j \omega_n \sqrt{1 - \zeta^2}
 \\
 | p_{1,2} | &= \omega_n
 \end{align*}
 %
 Let $\sigma = \zeta \omega_n$ and $\omega_d = \omega_n \sqrt{1 - \zeta^2}$ (which is called damped
 natural frequency), then we know that general solution of the ODE solution takes the form
 %
 \begin{align*}
 	y(t) = y_p(t) + C_1 e^{-\sigma t} \cos(\omega_d t) + C_2 e^{-\sigma t} \sin(\omega_d t)
 \end{align*}
 %
Steady-state conditions leads that $y_p(t) = 1$. Then we can compute remaining coefficients
from zero initial conditions constraints
 %
 \begin{align*}
 y(0) = 0 \quad \rightarrow \quad& C_1 = -1
 \\
 \dot{y}(0) = 0 \quad \rightarrow \quad&
\frac{d}{dt} \left[ e^{-\sigma t} [ -\cos(\omega_d t) + C_2  \sin(\omega_d t) ] \right]|_{t = 0} = 0
\\
& \left[ -\sigma e^{-\sigma t} [ -\cos(\omega_d t) + C_2  \sin(\omega_d t) ]
+ e^{-\sigma t} [ \omega_d  \sin(\omega_d t) + C_2  \omega_d \cos(\omega_d t) ]  \right] |_{t = 0} = 0
\\
&\left[ \sigma  + C_2  \omega_d  \right] = 0
\\
&C_2 = -\frac{\sigma}{\omega_d} = -\frac{\zeta}{\sqrt{1 - \zeta^2}}
 \end{align*}
 %
 Finally output, $y(t)$, takes the form
 %
  \begin{align*}
  y(t) = 1 - e^{-\sigma t} \left[ \cos(\omega_d t) + \frac{\zeta}{\sqrt{1 - \zeta^2}} \sin(\omega_d t) \right]
  \end{align*}
%
If we combine $\cos$ and $\sin$  terms into a single $\sin$ with phase shift we obtain
%
 %
  \begin{align*}
    y(t) &= 1 - \frac{e^{-\sigma t}}{ \sqrt{1 - \zeta^2} } \left[ \sqrt{1 - \zeta^2} \cos(\omega_d t) + \zeta \sin(\omega_d t) \right]
    \\
    \\
&= 1 - \frac{e^{- \zeta \omega_n t}}{ \sqrt{1 - \zeta^2} } \sin(\omega_d t + \phi) \quad t \geq 0
  \end{align*}
  %
  where
  %
 \begin{align*}
   \sin(\omega_d t + \phi) &=   \sin( \phi)  \cos(\omega_d t) +   \cos( \phi)   \sin(\omega_d t)
   \\
   \cos( \phi) &= \zeta
   \\
   \sin( \phi) &= \sqrt{1 - \zeta^2}
   \\
   \tan( \phi) &= \frac{\sqrt{1 - \zeta^2} }{\zeta}
\end{align*}
   %
 Pole locations and step response when $\zeta > 1$ (under damped), is illustrated in
the Figure below

    \begin{minipage}[h]{1\linewidth}
    \begin{center}
     \includegraphics[width=0.9\textwidth]{under}
    \end{center}
  \end{minipage}

%
\subsection{Transient Response Characteristics for Underdamped Second Order Systems in Standard Form}

Important transient characteristics and performance metrics for $2^{nd}$ order underdamped systems are
illustrated in the Figure below.

    \begin{minipage}[h]{1\linewidth}
    \begin{center}
     \includegraphics[width=0.8\textwidth]{transient}
    \end{center}
  \end{minipage}

\textbf{Rise Time ($tr$):}  The first time instant the response intersects the $y =1$ line.
%
 \begin{align*}
 y(t_r) &= 1
 \\
 1 &= 1 - \frac{e^{- \zeta \omega_n t_r}}{ \sqrt{1 - \zeta^2} } \sin(\omega_d t_r + \phi)
 \\
 \pi &= \omega_d t_r + \phi
 \\
 t_r &= \frac{\pi - \phi}{\omega_d}
\end{align*}

  \textbf{Peak Time ($t_p$):}  The first time instant the response makes a peak
  %
 \begin{align*}
& \left[  \frac{d y}{dt} \right]_{t_p} = 0
 \\
& \frac{d }{dt} \left[ - \frac{e^{-\zeta \omega_n t}}{ \sqrt{1 - \zeta^2} } \left[ \sqrt{1 - \zeta^2} \cos(\omega_d t) + \zeta \sin(\omega_d t)
\right] \right]_{t_p} = 0
\\
& \left[
 \zeta \omega_n e^{-\zeta \omega_n t} \left[ \sqrt{1 - \zeta^2} \cos(\omega_d t) + \zeta \sin(\omega_d t) \right] -
e^{-\zeta \omega_n t} \left[ - \omega_d \sqrt{1 - \zeta^2} \sin(\omega_d t) + \zeta \omega_d \cos(\omega_d t) \right]
\right]_{t_p} = 0
\\
& \left[
\left[  \zeta  \sqrt{1 - \zeta^2} \cos(\omega_d t) + \zeta^2 \sin(\omega_d t) \right] -
\left[ - (1 - \zeta^2) \sin(\omega_d t) + \zeta \sqrt{1 - \zeta^2} \cos(\omega_d t) \right]
\right]_{t_p} = 0
\\
& \left[
 \left[  \zeta^2 \sin(\omega_d t) + (1 - \zeta^2) \sin(\omega_d t)  \right]
\right]_{t_p} = 0
\\
&\sin(\omega_d t_{t_p})  = 0
\\
&t_p = \frac{\pi}{\omega_d}
\end{align*}

\textbf{Maximum Overshoot ($M_p$):}  The maximum amount by which the response exceeds the value $1$.
 %
\begin{align*}
	M_p &= y(t_p) - 1
	\\
	&= \left[1 - \frac{e^{-\zeta \omega_n t}}{ \sqrt{1 - \zeta^2} } \left[ \sqrt{1 - \zeta^2} \cos(\omega_d t) + \zeta \sin(\omega_d t)
\right] \right]_{t_p} - 1
\\
&= \left[ \frac{e^{-\zeta \omega_n \frac{\pi}{\omega_d}}}{ \sqrt{1 - \zeta^2} } \sqrt{1 - \zeta^2} (-1) \right]
\\
M_p &= e^{-\pi  \frac{\zeta}{\ \sqrt{1 - \zeta^2}}} = e^{\frac{-\pi}{\tan \phi}}
\end{align*}

Maximum Percentage Overshoot ($MP_p$) is simply calculated as $MP_p =
M_p \, 100$.

\textbf{Settling Time ($t_s$):}  The earliest time instant such that
$|y(t) - 1| \leq 0.02 s$ or ($|y(t) - 1| \leq 0.05 s$) for all $t \geq
t_s$.Actual, settling time is very difficult to compute analytically (not
so hard with numerical simulations). Thus we use following
approximations.
%
\begin{align*}
  t_{s,5} &=\frac{3}{\zeta \omega_n} \quad \%5
\\
  t_{s,2} &=\frac{4}{\zeta \omega_n} \quad \%2
\end{align*}

% Since, $ | \sin(\omega_d t + \phi) | \leq 1$, we have the following
% relations
% %
% \begin{align*}
%  y(t) &\leq 1 + \frac{e^{-\zeta \omega_n t}}{\sqrt{1 - \zeta^2}} =
%   y_{eu}(t)
% \\
%  y(t) &\geq 1 - \frac{e^{-\zeta \omega_n t}}{\sqrt{1 - \zeta^2}} =
%   y_{el}(t)
% \end{align*}
% %
% where $ y_{eu}(t)$ and $y_{el}(t)$ are called the envelopes of the
% response. These envelopes are illustrated in Figure below.
% %
%     \begin{minipage}[h]{1\linewidth}
%     \begin{center}
%      \includegraphics[width=0.9\textwidth]{envelopes}
%     \end{center}
%   \end{minipage}

\textbf{Example 1:}

In this problem, we perform four different pole
re-location cases. During re-locations we keep some parameters
constant. Specifically
%
\begin{enumerate}
\item $p_1$ moved to a new location $p_2$ by keeping $\zeta$ (and
  $\phi$) constant.
\item $p_1$ moved to a new location $p_2$ by keeping $\omega_d$
  constant.
\item $p_1$ moved to a new location $p_2$ by keeping $\omega_n$
  constant.
\item $p_1$ moved to a new location $p_2$ by keeping $\sigma = \zeta \omega_n$
  constant.
\end{enumerate}

For each four cases, explain what happens rise time, peak time,
maximum overshoot, and settling time.

    \begin{minipage}[h]{1\linewidth}
    \begin{center}
     \includegraphics[width=0.83\textwidth]{ex}
    \end{center}
  \end{minipage}

\textbf{Example 2:} Consider the following closed-loop system

     \begin{minipage}[h]{1\linewidth}
    \begin{center}
     \includegraphics[width=0.8\textwidth]{example}
    \end{center}
  \end{minipage}

Design $K_P$ and $K_D$ gains such that, maximum percent overshoot is less than $\%4.32$,
and settling time ($\%2$) is less than $1$ s.

\textbf{Solution:} Lets compute the closed-loop transfer function. In order to do that, first derive the transfer
function from $E(s)$ to $Y(s)$ which is called feed-forward transfer function.
%
\begin{align*}
 \frac{Y(s)}{E(s)} = K_P \left[ \frac{1/s}{1 + K_D/s} \right] \frac{1}{s} = \frac{K_P}{s (s + K_D)}
\end{align*}
%
we can derive the $G(s)$ as
%
\begin{align*}
	G(s) = \frac{ \frac{K_P}{s (s + K_D)}}{1 +  \frac{K_P}{s (s + K_D)}} = \frac{K_P}{s^2 + K_D s + K_P}
\end{align*}
%
We can see that with $K_P$ and $K_D$ gains we have total control on the characteristic equation.
Now let's analyze the performance requirements.

First requirement state that Maximum percent overshoot is less than $\%4.32$, which means that $M_P < 0.0432$.
Let's find a condition on $\zeta$ or $\phi$,
\begin{align*}
  M_P = e^{-\pi  \frac{\zeta}{\ \sqrt{1 - \zeta^2}}} = e^{-\pi / \tan \phi} &< 0.0432 \\
  -\pi / \tan \phi &< -\pi \\
  \tan \phi &< 1
\end{align*}
%
The region on $s$-plane that satisfy the $M_P$ requirement is illustrated below.

     \begin{minipage}[h]{1\linewidth}
    \begin{center}
     \includegraphics[width=0.35\textwidth]{damping}
    \end{center}
  \end{minipage}

Second requirement state that settling time ($\%2$) is less than $1$ s, which implies
%
\begin{align*}
  t_{s,2} = \frac{4}{\zeta \omega_n} = \frac{4}{\sigma} &< 1\\
  \sigma >  4
\end{align*}
%
The region on $s$-plane that satisfy the settling time requirement is illustrated below.

     \begin{minipage}[h]{1\linewidth}
    \begin{center}
     \includegraphics[width=0.35\textwidth]{settling}
    \end{center}
  \end{minipage}

  If we combine the requirements, we obtain the following region of possible pole locations.

     \begin{minipage}[h]{1\linewidth}
    \begin{center}
     \includegraphics[width=0.4\textwidth]{result}
    \end{center}
  \end{minipage}

  Based on these requirements let's choose $p_{1,2} = -5 \pm 4 j$ as desired pole locations.
  We can then compute the desired characteristic equation and then find the associated controller
  gains as
  %
  \begin{align*}
  	d^*(s) &= (s + 5 + 4 j) (s + 5 - 4 j) = s^2 + 10 s + 41
	\\
	K_P &= 41
	\\
	K_D &= 10
  \end{align*}
  %
  If we plot the step-response, we can illustrate the performance and check if we can meet the
  requirements.

       \begin{minipage}[h]{1\linewidth}
    \begin{center}
     \includegraphics[width=0.45\textwidth]{stepex}
    \end{center}
  \end{minipage}

  \subsubsection*{Transient Specifications for Over-damped Case}

\begin{itemize}
  \item Obviously, there is no over-shoot in over-damp case, thus $M_P = 0$.
  \item For settling time we can use the same approximate formula by considering the dominant/slowest
  pole, i.e.
  %
  \begin{align*}
  t_{s,5} &=\frac{3}{\sigma_{min}} \quad \%5
	\\
  t_{s,2} &=\frac{4}{\sigma_{min}} \quad \%2
  \end{align*}
  %
  \item Since $y(t)$ only crosses the $y = 1$ as $t \to \infty$, $t_r$ definition is not applicable for
  over-damped case. Instead, a different rise time definition can be used (which is applicable for both
  over-damped, under-damped, critically-damped systems, as well as first order systems). $\bar{t}_r$
  is the time for $y(t)$ to go from $0.1$ to $0.9$. It is pretty hard to compute this time analytically, thus in
  general numerical and/or graphical methods are used.

  Rise-time concept is illustrated in the figure below, for an example system.
  \vspace{6pt}

         \begin{minipage}[h]{1\linewidth}
    \begin{center}
     \includegraphics[width=0.45\textwidth]{rise2}
    \end{center}
  \end{minipage}

\end{itemize}

\section{Higher Order Systems}

In general, the poles closer to the $j \omega$ axis determine the behavior of the system. If the ``distance''
between the poles that are close to the $j \omega$ axis and other poles is high, then they dominate the
behavior and we call them dominant poles. For example, figure given below illustrates a third order system,
where we have two complex conjugate roots and one real root. In this case, the magnitude of the real pole
is more than three times of the magnitude of the real part of the complex conjugate poles, thus the systems acts like
a second order system.

         \begin{minipage}[h]{1\linewidth}
    \begin{center}
     \includegraphics[width=0.6\textwidth]{third}
    \end{center}
  \end{minipage}

% **** This ENDS THE EXAMPLES. DON'T DELETE THE FOLLOWING LINE:
\end{document}