% !TeX root = article.tex
\section{Description of plasticity in the framework of physics engines}

In this section, key concepts related to the introduced model are explained. The main differences between
traditional structural analysis and physics engines based approaches are reviewed and discussed.

Velocity-based formulation of constraint based rigid body simulation
is  commonly used by physics based game
developers and film production teams.
%\citet[p.~45]{erleben.thesis}
\cite{erleben.thesis}
provides reasoning and theoretical details for the popularity of
velocity-based formulation in constraint-based rigid body simulation instead of accelaration based.
The main reason is that collision handling can be done without the use of additional procedures.

Work presented by
\cite{erleben.thesis} provides the basis for the velocity-based formulation discussed in this work.
%\citet[p.~45-50]{erleben.thesis}.
% pdf page 64
In the following section, these formulations will be clarified by a simple example using \cbullet\ implementation.

Impulse $\vec{J}$
in the time interval $\Delta t $ can be written as:
\begin{equation} \label{eq:impulseIntegral}
\vec{J} = \int_{0}^{\Delta t} \vec{f}_{true}(t) dt,
\end{equation}
where $\vec{f}_{true}(t)$ is force.

Using Newton's second law of motion $\vec{F}=m\vec{a}$ ,
$\vec{v}^{\Delta t}$ can be solved for the velocity as:
\begin{equation} \label{eq:impulseIntegraWithNewton}
\int_{0}^{\Delta t} m \frac{d\vec{v}}{dt}dt= \int_{0}^{\Delta t} \vec{f}_{true}(t)
\end{equation}
\begin{equation} \label{eq:impulse}
m(\vec{v}^{\, \Delta t} - \vec{v}^{\, 0})=\vec{J},
\end{equation}
where superscripts denote time, i.e. ${\vec{v}}^{\Delta t}=\vec{v}(\Delta t)$.
Next position can be found
by integrating the velocity.
Updates after each step can be summarized  for locations and
for velocities respectively as follows:

\begin{equation} \label{eq:eomL} % pdf page 69
\vec{s}^{\, t+\Delta t} = \vec{s}^{\, t}+\Delta t S \vec{u}^{\, t+\Delta t}
\end{equation}

\begin{equation} \label{eq:eomV}
\vec{u}^{\, t+\Delta t} = \vec{u}^{\, t}+\Delta t M^{-1}(C N \vec{f}^{\ t+\Delta t} + \vec{f}_{ext}) .
\end{equation}

The symbols used in Equations \ref{eq:eomL} and \ref{eq:eomV}
are summarized in Table \ref{tab:eom}.
Figure \ref{fig:eom-contact} describes the collision of two
bodies, rectangular body $B_1$ and triangular body $B_2$
where $\vec{r}_i$ is position of body $i$,
$\vec{p}_k $ is position of contact point $k$,
$\vec{r}_{ik} $ is a vector between the center of gravity of body $i$ and contact point $k$,
and
$\vec{n}_{k}$ is the contact normal for contact point $k$.
It is common convention that the contact normal points
from the body with the smallest index to the body with the largest index, \cite{erleben.thesis}.
In case of point or edge contacts, averaging the normals of neighboring polygons can be used, \cite{Hahn:1998}.

\begin{figure}[tb!]
\centering
\begin{tikzpicture}
\coordinate (O1) at(2,1);
\coordinate (O2) at(2,4);
\coordinate (C) at(2,2);
\draw (0,0) -- (4,0) -- (4,2) -- (0,2) --(0,0);
\draw (2,2) -- (3.5,5) -- (0.5,5) -- (2,2) ;
\node at (3.5,0.4) {$B_1$};
\filldraw (O1) circle (0.5mm) node[anchor=north] {$\vec{r}_1$};
\node at (2.8,4.5) {$B_2$};
\filldraw (O2) circle (0.5mm) node[anchor=south] {$\vec{r}_2$};
\filldraw (C) circle (0.5mm) node[anchor=north west] {$\vec{p}_1$};
\draw[-{Stealth[length=3mm]}] (O1) -- (C) node[anchor=north east] {$\vec{r}_{11}$};
\draw[-{Stealth[length=3mm]}] (O2) -- (C) node[anchor=south east] {$\vec{r}_{21}$};
\draw[-latex,thick] (C) -- ++(0,1.4) node[anchor=west] {$\vec{n}_{1}$};
\node[anchor=west] at (4.5,4.5) {
$\vec{r}_i$  =  position of body $i$
};
\node[anchor=west] at (4.5,4) {$\vec{p}_k $ = position of contact point $k$};
\node[anchor=west] at (4.5,3.5) {$\vec{r}_{ik} $ = $\vec{p}_k - \vec{r}_i $};
\node[anchor=west] at (4.5,3) {$\vec{n}_{k} $ = normal for contact point $k$};
\end{tikzpicture}
\caption{Illustration of nomenclature for equations of motion for collision.}
\label{fig:eom-contact}
\end{figure}

% pdf page 33, notation in typical ODEs
\begin{table}
\tbl{Nomenclature for equations of motion}{
\begin{tabular}{|l| l|}
\hline
{\bf Symbol} & {\bf Description} \\  \hline
$\vec{r}_i$ & position of center of mass for body $i$  \\ \hline
$\vec{q}_i$ & orientation for body $i$ as quaternion $\lbrack s_i, x_i, y_i, z_i \rbrack ^T $ \\
\hline
$\vec{p}_h$ & contact or joint point $k$  \\ \hline
$\vec{r}_{ki}$ & $\vec{p}_k - \vec{r}_i$  \\ \hline
$\vec{s}$ & $\lbrack \vec{r}_1, \vec{q}_1,...,\vec{r}_n, \vec{q}_n \rbrack ^T $\\ \hline
$Q_i$ & \begin{tabular}{@{}c}
rotation of quaternion $\vec{q}_i$
as matrix \\ where
$\frac{1}{2}\vec{\omega}_i \vec{q}_i=Q_i \vec{\omega}_i$
\end{tabular}
   $
\frac{1}{2} \left[ \begin{array}{ccc}
-x_i & -y_i & -z_i \\
s_i & z_i & -y_i \\
-z_i & s_i & x_i \\
y_i & -x_i & s_i
\end{array} \right]
$
\\ \hline
$S$ &
\begin{tabular}{@{}c}
generalized transformation matrix \\
$ S \in \mathbb{R}^{7n \times 6n}$
\end{tabular}
 $ \left[ \begin{array}{ccccc}
1 &  &  & & 0 \\
 & Q_i  \\
 & & \ddots  \\
 & & & 1 \\
0 & & & & Q_n
\end{array} \right]
$
\\ \hline
$\vec{v}_i$ & linear velocity of  center of mass for body $i$   \\ \hline
$\vec{\omega}_i$ & angular velocity of center of mass for body $i$  \\ \hline
$\vec{u}$ & $\lbrack \vec{v}_1, \vec{\omega}_1,...,\vec{v}_n, \vec{\omega}_n \rbrack ^T $\\ \hline
$M$ &
\begin{tabular}{@{}c}
 generalized mass matrix \\
$ M \in \mathbb{R}^{6n \times 6n}$
\end{tabular}
$
\left[ \begin{array}{ccccc}
m_i 1 &  &  & & 0 \\
 & I_1  \\
 & & \ddots  \\
 & & & m_n 1 \\
0 & & & & I_n
\end{array} \right]
$
\\ \hline
$I_i$ & inertia tensor for body $i$  \\ \hline
$C$ & contact condition matrix  $ C \in \mathbb{R}^{6n \times 3K}$ \\ \hline
$N$ & contact normal matrix  $ N \in \mathbb{R}^{3K \times K}$ \\ \hline
\end {tabular}}
\label{tab:eom}
\end{table}

Friction in contacts and joint constraints can be handled in a unified way by refactoring
equation \ref{eq:eomV} as,
\cite{erleben.thesis}
%\citet[p.~66-67]{erleben.thesis}
\begin{equation} \label{eq:eomV2}
\vec{u}^{\, t+\Delta t} = \vec{u}^{\, t}+\Delta t M^{-1}(
 J_{contact}^T \vec{\lambda}_{contact}
+ J_{joint}^T \vec{\lambda}_{joint}
+ \vec{f}_{ext}),
\end{equation}
where Jacobian terms $J_{joint}^T$ for joints are
derived by taking time derivatives of the kinematic constraints.
Symbols used in Equation \ref{eq:eomV2} are summarized in Table
\ref{tab:eom-g} and Figure \ref{fig:eom-joint},
where $\vec{r}_{anc}^{\,i}$ is used to define at which point
joint constraint is applied relative to body $i$.

\begin{figure}
\centering
\begin{tikzpicture}
\coordinate (O1) at(1,1);
\coordinate (O2) at(1,3);
\coordinate (C) at(1,2);
\draw (0,0) -- (2,0) -- (2,2) -- (0,2) --(0,0);
\draw (0,2) -- (2,2) -- (2,4) -- (0,4) --(0,2) ;
\node at (0.5,0.4) {$B_1$};
\filldraw (O1) circle (0.5mm) node[anchor=north] {$\vec{r}_1$};
\node at (0.5,3.5) {$B_2$};
\filldraw (O2) circle (0.5mm) node[anchor=south] {$\vec{r}_2$};
\draw[-{Stealth[length=3mm]}] (O1) -- (C) node[anchor=north east] {$\vec{r}_{anc}^{\,1}$};
\draw[-{Stealth[length=3mm]}] (O2) -- (C) node[anchor=south east] {$\vec{r}_{anc}^{\,2}$};
\node[anchor=west] at (4.5,3.5) {
$\vec{r}_i$  =  position of body $i$
};
\node[anchor=west] at (4.5,3) {$\vec{r}_{anc}^{\,i} $ = body frame vector $i$};
\end{tikzpicture}
\caption{Illustration of nomenclature for equations of motion for joint.}
\label{fig:eom-joint}
\end{figure}

% pdf page 33, notation in typical ODEs
\begin{table}
\tbl{Additional terms  for generalized equations of motion}{
\begin{tabular}{|l| l|}
\hline
{\bf Symbol} & {\bf Description} \\  \hline
$J_{contact}$ & Jacobian matrix for contacts  \\ \hline
$\lambda_{contact}$ & vector of lagrange multipliers for contacts  \\ \hline
$J_{joint}$ & Jacobian matrix for joints  \\ \hline
$\lambda_{joint}$ & vector of lagrange multipliers for joints  \\ \hline
\end {tabular}}
\label{tab:eom-g}
\end {table}

Constraint processing in \cbullet\ is based on ODE, \cite{ode}.
Joints are also discussed in detail in
\cite{erleben.thesis}.
%\citet[p.~60-90]{erleben.thesis}.
Equations \ref{eq:constraintEquation}, \ref{eq:lambdaLow} and
\ref{eq:lambdaHigh}
are created for each constraint.
Derivation for terms in Equation \ref{eq:constraintEquation}
can be done using the position and orientation of connected bodies
e.g. for ball joint formulation is based on both joint points having the same position.
In contact cases, formulation is easier if it is done using velocities, \cite{ode.joints}.

\begin{equation} \label{eq:constraintEquation}
J_1 \vec{v}_1 + \Omega_1 \vec{\omega}_1 +
J_2 \vec{v}_2 + \Omega_2 \vec{\omega}_2 = \vec{c} + C \vec{\lambda}
\end{equation}

\begin{equation} \label{eq:lambdaLow}
\vec{\lambda} \geq \vec{l}
\end{equation}

\begin{equation} \label{eq:lambdaHigh}
\vec{\lambda} \leq \vec{h}
\end{equation}

In the following section, these equations will be explained by a simple example.
The main parameters  and corresponding fields in \cbullet\
are given in Table \ref{tab:constraintParameters}.

\begin {table}
\tbl {Constraint parameters}{
\begin{tabular}{|c| l| l|}
\hline
{\bf Parameter} & {\bf Description} & {\bf btConstraintInfo2 pointer}\\  \hline
$J_1, \Omega_1$ & Jacobian & m\_J1linearAxis, m\_J1angularAxis \\
$J_2, \Omega_2$ & & m\_J2linearAxis, m\_J2angularAxis \\ \hline
$\vec{v}$ & linear velocity & \\ \hline
$\vec{\omega}$ & angular velocity & \\ \hline
$\vec{c}$        &  right side vector   & m\_constraintError \\ \hline
$C$  & constraint force mixing & cfm \\  \hline
$\vec{\lambda}$ & constraint force &  \\ \hline
$\vec{l}$ & low limit for constraint force & m\_lowerLimit \\ \hline
$\vec{h}$ & high limit for constraint force & m\_upperLimit \\ \hline
\end {tabular}}
\label{tab:constraintParameters}
\end {table}

In structural analysis, a formulation and associated numerical solution procedure are selected
based on needed features.
Often,  finite element method is used.
In most cases, a static solution with an assumption of linear strain-displacement relation
using displacement based boundary conditions is used.
\cite{bathe-1975} provides a description for handling of various nonlinearities.
In large displacement analysis, formulation may be based on updated formulation (Eulerian) or
Lagrangian formulation where initial configuration is used.
Further enhancements are material nonlinearity and dynamic analysis.
Physics engine provides dynamic analysis with large reference translations and rotations
while assuming bodies to be undeformable.

Material plasticity can be accounted for in simulations by using a suitable coefficient of restitution.
This provides a reasonable means to simulate loss of energy in collisions.
In this work simulation of breaking of bodies made of ductile material is made more realistic
by splitting the rigid body
to multiple bodies that are connected by energy absorbing joints.
A typical engineering stress-strain curve of ductile steel is shown in Figure \ref{fig:sscurve}.

\begin{figure}
\centering
\begin{tikzpicture}
\coordinate (Y) at (1,4);
\draw[->] (0,0) -- (6,0) node[right] {\large{$\epsilon$}};
\draw[->] (0,0) -- (0,5) node[above] {\large{$\sigma$}};
\draw(0,0) -- (Y) -- (2,4) .. controls (5,5) .. (6,4);
\draw[dashed](0,4) -- (Y);
\node at (-0.2,4) [align=right] {$f_y$};
\draw(0.25,1) -- (0.5,1) -- (0.5,2);
\node at (0.75,1.5) {$E$};
\node at (0.8,2.5) [anchor=west] {$\sigma = E \epsilon$ if $\sigma \le f_y$};
\end{tikzpicture}
\caption{Engineering stress-strain curve of ductile steel (not to scale).}
\label{fig:sscurve}
\end{figure}

In Figure \ref{fig:sscurve}, $\sigma$ is stress, $E$ is Youngs modulus and $f_y$ is yield stress.
Engineering stress and strain mean that original dimensions are used in stress calculation,
\cite{dowling}.
%\citet[p.~108]{dowling}.
The stress-strain curve is not drawn to scale as elastic strain could not be seen as it is typically
0.001 to 0.005 and fracture strain can be 100 times larger.

In this work, an elastic-fully plastic material model is used in most scenarios.
Having elastic part allows elastic displacements for slender structures.
Elastic material behavior is ignored in approach introduced in this work if
the deformation is related to ahigher frequency
than integration stability would allow.
It should be noted that geometry
of bodies is not updated during analysis and thus engineering stress-strain properties are used.

In this work, strain hardening is taken into account by assuming that plastic volume in bending
expands,
\cite{dowling}.
%\citet[p.~672]{dowling}.
Material that starts to yield first is hardened and as a result of which yielding moves.

The difference between the elastic and plastic section modulus is depicted in Figure \ref{fig:wp}.

\begin{figure}[htb!]
\centering
\begin{tikzpicture}
\coordinate (S) at (2.5,5);
\draw (0,5) -- (4,5) ;
\draw (0,0) -- (4,0) ;
\draw (2,0) -- (2,5) ;
\draw (1.5,0) -- (S);
\node[above] at (S) [align=center] {\large{$\sigma<f_y$}};
\node[anchor=west] at (3,3) {
\begin{tabular}{l}
Under elastic load\\
stress increases\\
linearly from zero\\
at neutral axis to\\
maximum value at \\
surface of body
\end{tabular}
};
\end{tikzpicture}
\hspace{1cm}
\begin{tikzpicture}
\coordinate (S) at (3,5);
\draw (0,5) -- (4,5) ;
\draw (0,0) -- (4,0) ;
\draw (2,0) -- (2,5) ;
\draw (1,0) -- (1,2.5) -- (3,2.5) -- (S);
\node[above] at (S) [align=center] {\large{$\sigma=f_y$}};
\node[anchor=west] at (3,3) {
\begin{tabular}{l}
Under fully plastic load\\
stress is at yield\\
level over full\\
cross section
\end{tabular}
};
\end{tikzpicture}
\caption{Axial stress distribution over a cross section for bending under elastic and fully plastic loads.}
\label{fig:wp}
\end{figure}

As shown in Figure 2.4, if stress is below yield limit $f_y$, stress and strain are linear within the material.
If cross section is fully plastic, stress is assumed to be at yield level over the whole cross section such that
the plastic section modulus is higher than the elastic section modulus.

In this work, plasticity is handled by defining maximum forces
in Equations \ref{eq:lambdaLow} and
\ref{eq:lambdaHigh} using plastic capacities, which are defined below.

Maximum force acting in a direction of $\vec{r}_{anc}^{\,i} $
is product of area and yield stress as follows:

\begin{equation} \label{eq:fN}
N_{max}= \int_A f_y.
\end{equation}

Maximum forces acting perpendicular to $\vec{r}_{anc}^{\,i} $
are a product of area and shear yield stress $\tau_y$ as follows:
\begin{equation} \label{eq:fQ}
Q_{max}= \int_A \tau_y.
\end{equation}

Maximum moments acting around the axis perpendicular to $\vec{r}_{anc}^{\,i} $
are integrals of the perpdendicular distance
and yield stress $f_y$ as given for the moment around the $x$-axis
and moment around the $z$-axis, respectively:

\begin{equation} \label{eq:Mx}
M_{max}^x= \int_A z f_y,
\end{equation}

\begin{equation} \label{eq:Mz}
M_{max}^z= \int_A x f_y.
\end{equation}

Maximum moment around $\vec{r}_{anc}^{\,i} $
is an integral of distance $d$ from the joint point
and shear yield stress $\tau_y$ as:

\begin{equation} \label{eq:My}
M_{max}^y= \int_A d \tau_y.
\end{equation}

Maximum forces and moments for a
rectangular section with width $b$ and height $h$ using constant yield stress
are given in Table \ref{tab:maxForces}.
Yield shear stress is assumed to be $ 0.5\, f_y$ using the Tresca yield critetion.
If the von Mises yield criterion is used 0.5 is replaced by 0.58 ($1/\sqrt{3}$), \cite{dowling}.
% p. 262, p. 268
These are not exact values in a multiaxial stress state but they
should be acceptable in most gaming scenarios.

\begin {table}
\tbl {Maximum forces and moments for
rectangular section with width $b$ and height $h$ using constant yield stress $f_y$}{
\begin{tabular}{| c| c|}
\hline
{\bf Direction} & {\bf Maximum value}  \\ \hline
maximum shear force & $0.5\, b\, h f_y$ \\ \hline
maximum normal force & $b\, h\, f_y$  \\ \hline
maximum bending moment in direction of $h$& $0.25\, b\, h^2 \, f_y$  \\ \hline
maximum bending moment in direction of $b$ & $0.25\, b^2\, h\, f_y$  \\ \hline
maximum torque & $ \approx 0.19\, b\, h\, \frac{b\, + h}{2} f_y$  \\ \hline
\end{tabular}}
\label{tab:maxForces}
\end {table}

For torque there is a closed form solution only for
circular cross sections.
Given approximation is
best suited for cases where $b$ and $h$ are similar.
Better approximation for any given $b$ and $h$ can be obtained
by integrating distance from the center of the joint over cross section and
multiplying it with the yield shear stress e.g. using Octave, \cite{octave}.
An example of calculation of the maximum moment  around $\vec{r}_{anc}^{\,i} $
is shown in Figure \ref{fig:octave-mp}.

\begin{figure}
\centering
\lstset{language=octave}
\begin{lstlisting}
b=0.01; h=0.01; fy=200e6;
wpy=fy/2*dblquad(@(x,z)...
 sqrt(x.*x+z.*z),-b/2,b/2,-h/2,h/2)
38.2
\end{lstlisting}

\caption{Calculation of maximum moment  around $\vec{r}_{anc}^{\,i} $ using Octave.}
\label{fig:octave-mp}
\end{figure}

The basic idea introduced in this study can be tested with any framework having motors and hinge constraints.
This can be done by setting the target velocity of the motor to zero and limiting
the maximum motor impulse to plastic moment multiplied by a timestep.

Further enhancements were created and tested by forking \cbullet\ source code
and adding new constraints, \cite{pbullet}.
Instructions for using  windows executable and  source code are available, \cite{bp}.


\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{pst-plot}
\usepackage{graphicx}
\usepackage{endnotes}
\usepackage{graphics}
\usepackage{floatflt}
\usepackage{wrapfig}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{verbatim}
\usepackage{hyperref}
\usepackage{multirow}
\usepackage{pdflscape}

\usepackage{hyperref}
\hypersetup{pdfborder={0 0 0 0}}

\pdfpagewidth 210mm
\pdfpageheight 297mm
\setlength\topmargin{0mm}
\setlength\headheight{0mm}
\setlength\headsep{0mm}
\setlength\textheight{250mm}
\setlength\textwidth{159.2mm}
\setlength\oddsidemargin{0mm}
\setlength\evensidemargin{0mm}
\setlength\parindent{7mm}
\setlength\parskip{0mm}

\newenvironment{exercise}[3]{\paragraph{Exercise #1: #2 \textsc{(#3pt)}}\ \\}{
\medskip}
\newcommand{\question}[2]{\setlength\parindent{0mm}\ \\$\mathbf{Q_#1:}$ #2\ \\}

\author{\large{Ilya Kuzovkin, Raul Vicente}}
\title{\huge{Introduction to Computational Neuroscience}\\\LARGE{Practice II: Data Analysis - Continuous Data}}

\begin{document}
\maketitle
\ \\
This is how usual EEG recording of one channel looks like:
\begin{figure}[H]
   \centering
   \includegraphics[width=0.8\textwidth]{eegrecording.png}
\end{figure}
On the $x$ axis there is time, on the $y$ axis strength of the recorded signal in $\mu$V. The dashed line at the time point $x=1000$ is the moment when the \emph{stimulus} (picture) was shown to the test subject.

%
% ERP
%
\begin{exercise}{1}{Event Related Potential (ERP)}{1}
By looking at the plot above one cannot say that showing the stimulus had any considerable effect on the test subject. It seems that there is an increase starting at the time point 1200 and ending at the time point 1500, but that can be a random event, which is not related to the stimulus.

In such studies the way to go is to conduct the same experiment several times and then average the results. In this way the response, if it is there, will reveal itself much more clearly.

In the \texttt{data} folder you have file \texttt{erptrials.csv}. One row is one trial recorded for 2 seconds with sampling rate of 1000 Hz. The stimulus was shown at the time point 1000 (1 second). There are 79 trials in this file. Your task is to plot an average of all 79 trials and see whether there is a clear ERP response or not.
\end{exercise}

%
% Apply fourier
%
\begin{exercise}{2}{Frequency Analysis}{2}
The most popular operation that you can do with continuous brain data is converting it from the \emph{time domain} to the \emph{frequency domain}. Due to the fact that any function can be represented as a sum of sinusoids we can decompose our signal into such sinusoids and observe from which frequency components it consists. In terms of the brain data such transformation makes particular sense, because of the \emph{brain rhythms} -- different frequencies of the firings of the neurons are related to the different kinds of mental activity\footnote{\url{http://en.wikipedia.org/wiki/Electroencephalography\#Wave_patterns}}.

\ \\
In this exercise we will plot \emph{power spectrum} and see how \emph{alpha wave} emerges when the test subject's eyes are closed. In the \texttt{data} folder you can find two files: \texttt{eyes\_open.csv} and \texttt{eyes\_closed.csv}. The data is recorded from the channel \texttt{Pz}. One row contains 4 seconds of the signal, sampling rate is 512. Each file has 15 recordings.

\ \\
Your task is to perform Fourier analysis on both datasets, plot power spectra and compare the results. Do it as follows:
\begin{enumerate}
	\item Plot some of the signals just to see how they look like.
	\item For each recorded signal (2048 data points):
		\begin{enumerate}
			\item Use \texttt{fft(signal)} to compute power spectrum of this signal. You will get a vector of complex numbers.
			\item Use \texttt{abs(result\_of\_fft)} to obtain the magnitude\footnote{\url{http://www.mathworks.se/help/matlab/ref/abs.html}}. \texttt{abs(result\_of\_fft)}$^2$ will give you power.
		\end{enumerate}
	\item Sum together 15 power spectrum distributions, that you got from the previous step.
	\item And divide the resulting vector by 15 to obtain the average.
	\item Plot it. You will see that the right part of the graph is mirror image of the left part. Discard the right part.
	\item Your $x$ axis goes from 1 to 1024, which does not correspond to actual frequencies. Compute correct $x$ axis as follows:
		\begin{verbatim}
		dt = 1/512;             % time step
df = 1/4;               % frequency step
fNQ = 1/dt/2;           % fNQ is the maximal frequency, in our case it is 256
                        %   if you have discarded part of the data in step 5
                        %   or 512 if you did not
xaxis = (0:df:fNQ-df);  % points for your X axis, should be of the same length
                        %   as the vector of frequencies
		\end{verbatim}
	\item And plot it again
		\begin{verbatim}
		plot(xaxis, powers_average);
		\end{verbatim}
		Now your axis goes from 0 to 256 (or 512) with step of 4, which corresponds to the frequency range \texttt{pow} function produced.
\end{enumerate}

\ \\
After making the plot more beautiful and focusing on the range from 0 to 30 Hz you should obtain the result that looks something like this:
\begin{figure}[H]
   \centering
   \includegraphics[width=1\textwidth]{fouriereyes.png}
\end{figure}
\end{exercise}

%
% Epilepsy
%
\begin{exercise}{3}{Epilepsy}{2}
In the folder \texttt{data/epilepsy} you have two data files: \texttt{sz4\_pre.dat} and \texttt{sz4\_ict.dat}. This data was recorded using ECoG\footnote{http://en.wikipedia.org/wiki/Electrocorticography} array. The file with the suffix \texttt{\_pre} is recorded before the seizure and the \texttt{\_ict} file is recorded during the epilepsy seizure. Read the \texttt{README.txt} file for the description of the data. Your task is to perform Fourier analysis on both files and see how brain activity changes during the epilepsy seizure. Speculate what is the nature of the peak around 60Hz.
\paragraph{Hint.} Reuse the code from the previous exercise.
\paragraph{Hint.} The data has readings from the 76 electrodes. First make Fourier transform on each of them separately, then compute the power spectra (each one separately) and then compute the average and plot that.
\end{exercise}

%
% Discuss
%
\begin{exercise}{4}{Nyquist theorem}{1}
What does Nyquist theorem say? What does it mean? What are the implications?\\
What does this picture illustrate?
\begin{figure}[H]
   \includegraphics[width=0.4\textwidth]{nyquist.png}
\end{figure}
\ \\
Prepare to present and explain the theorem to your fellow students.
\end{exercise}

%
% Play DFT
%
\begin{exercise}{5*}{Discrete Fourier Transform (DFT)}{bonus 2}
Now let us have a look on what happens behind the scenes when you call the \texttt{fft}\footnote{Actually Fast Fourier Transform (FFT) is a specific algorithm. In this exercise we do not analyse that, but rather look at the equations, which FFT solves in his own mysterious way.} function. Fourier transform is possible because, as we mentioned before, any function can be represented as a sum of sinusoidal functions of different frequencies and amplitudes. If you have some variable changing over time you can transform this data from the \emph{time domain} (time on the $x$ axis and the value of the variable on the $y$ axis) to the \emph{frequency domain} (frequency on the $x$ axis and it's \emph{power} on the $y$ axis) to see if there is any periodicity in the changes of that variable.

\ \\
Transformation is defined both for continuous and discrete data. On practice we mostly work with a discrete signal and therefore we use Discrete Fourier Transform (DFT). The equation for the discrete transform is
$$X_f = \displaystyle\sum_{t=0}^{N-1}x_t e^{-i2\pi f\frac{t}{N}}$$
where
\begin{itemize}
\itemsep 0em
	\item $f$ is the frequency of the component, contribution of which you are trying to estimate.
	\item $X_f$ is a complex number, that encodes both amplitude and phase of the sinusoidal component.
	\item $x_t$ is a value of your signal at the time point $t$.
	\item $N$ is the total number of time points.
\end{itemize}
Let us say that you would like to know contribution of sinusoidal components of frequencies from 1 to 100 Hz. Then you should apply this equation 100 times. As a result you will get 100 complex numbers.
To extract amplitude from these numbers use the following equation on each of them:
$$A_f = 2\frac{\sqrt{\text{Re}(X_f)^2 + \text{Im}(X_f)^2}}{N}$$
Now you have all the contributions and you have completed Discrete Fourier Transform of your signal. For example if 7th number is "25" then it means that the amplitude of the sinusoidal component with frequency 7 $\times$ df Hz is 25.

\ \\
Here you see a curve, that is a sum of three sinusoids. Your task is to apply DFT and find out frequencies and amplitudes of those components. You can find data points for this curve in the file \texttt{curve.csv}.
\begin{figure}[htbp]
   \centering
   \includegraphics[width=0.6\textwidth]{dodft.png}
\end{figure}
\end{exercise}

\ \\
\ \\
\ \\
\ \\
Please submit a \texttt{pdf} report with the answers to the questions, plots and comments about your solutions. Also submit the code for the programming exercise(s). Pack those into the \texttt{zip} archive and upload to the course web page.

\end{document}

2015/Practices/03 - Continuous Data/text/cns-continuousdata.tex


\section{Introduction} \label{introduction}
The scenario used for this thesis is an application which constantly receives data in form of a time series stream from
one or more sensors. The application itself does not have a general interest in a long term evaluation of the data. Only
the most recent time series window has to be classified in the evaluation. The result of the evaluation can be stored or
processed by an other application, the time series window moves on and has to be evaluated again. This process is
continuously repeated with every times series window being readable only once. Dynamic Time Warping (DTW) in combination
with a 1-Nearest-Neighbour (1NN) classification for the evaluation is an obvious approach for such a scenario. The
disadvantage is that this approach is computationally too demanding for many real time applications \cite{xi2006fast}.
This disadvantage becomes even more tragic under the assumption that perhaps a large amount of incoming time series
windows is unclassifiable due to a too large distance to the nearest neighbour.

This bachelor thesis explains the approach of a sliding window filter for time series ahead of the 1NN in combination
with DTW (1NN-DTW) to reduce the execution of 1NN-DTW on unclassifiable time series windows. The condition for such a
filter is linear complexity. Furthermore the combination of the filter ahead of the 1NN-DTW should perform with a
similar accuracy as 1NN-DTW on its own.

An experiment that simulates an above described scenario was carried out to expose the additional benefit of a filter
ahead of 1NN-DTW under the given conditions.%TODO double of

The bachelor thesis is organized as follows. Section \ref{background_and_notation} is explaining the sliding window
technique and basics around time series similarity measures that are used in this bachelor thesis. Furthermore
the sliding window filter is described at the end of the same section. The description of the experiment and the
evaluation of the results are contained in section \ref{experiment}. Conclusions are offered and future work
is suggested in section \ref{conclusion_and_future_work}.


\section{Solution}
\label{sec:sol}
% (The actual solution in details. Note that there is no need for code or
% specific software component tools description here. Also, you do not explain things
% already known by the theory, e.g., do not start elaborating on what is clustering and
% how useful it is.)
In this section, we present an algorithm to deal with the problem.
Furthermore, we also describe some optimizations, whose improvement will be
shown in Section~\ref{sec:eval} along with the evaluation results.

\subsection{Proposed solution}
The solution we propose is based on the A-Priori algorithm.

The general idea is that we first group the tweets by the period they belong to,
and then, for each period, we find the popular topics in the period by
exploiting the A-Priori algorithm. In this case, the transactions are represented by
the tweets and the items of a transaction are the relative tokens. Consequently,
the frequent itemsets returned by the algorithm are the popular topics of the period.
So, we extract the popular topics in the period using the A-Priori algorithm,
setting as threshold $s$.

By doing so, we build another dataset which will be the input for another
instance of the A-Priori: in
the new dataset, we have a transaction for each period of time and the items of a transaction
are the popular topics in that period. As threshold for this second instance we use $r$.

This algorithm answer exactly the problem stated in Section~\ref{sec:ps}, as
it finds the topics which are $s$-popular in a fraction of periods of time greater than or equal to $r$,
which is the definition of $s$-popular-$r$-consistent.

Actually, since in the second instance of the algorithm we only need to find
itemsets of size $1$, i.e. single topics,
we only need to count in how many periods of time a topic is found to be frequent.
Thus, we only need to perform the first pass of A-Priori, without the need to build
candidate pairs and so on. The complete process is shown in Algorithm~\ref{alg:pcis}.

\input{algorithms/popular_consistent_itemsets.tex}

The classical A-Priori algorithm is described in Section~\ref{sec:rw}.
However, if the dataset is not too big, we can exploit this
fact to implement it more efficiently, by storing some additional
data structures. We now proceed to describe these optimizations.

% \input{algorithms/apriori_standard.tex}

\subsection{Optimizations}

The idea is illustrated in Algorithm~\ref{alg:apriori_opt}.

\input{algorithms/apriori_std_opt.tex}

First, Procedure~\ref{alg:getItems} is called. The procedure scans all the transactions
and the items in them, building three data structures:
\begin{description}
    \item[itemIndex, indexItem] used to map items to numbers and vice versa. In fact,
        the algorithm finds frequent itemsets of numbers corresponding to items, to
        be more efficient both in terms of time and memory.
        Once the itemsets of numbers are found, they are converted back to sets of items.
    \item[items] that is a set composed of the sets containing single items, i.e. the candidates
        of size $1$.
    \item[indexTransactions] an array where the $i$-th entry is the set of the transactions
        containing the $i$-th item.
\end{description}

The rest of the algorithm is almost the same as the classical
version, except for the computation of the support of an itemset
in Procedure~\ref{alg:getSupport},
which exploits the \emph{indexTransactions} structure to speed up the
computation. In fact, having in main memory the set of transactions
containing each item allows us to get the support of the
itemset fast by computing the size of the intersection of the transactions set of
each item in the itemset.

Finally, once found the frequent itemsets are found, the algorithm maps back
set of numbers to sets of items, as shown in Procedure~\ref{alg:mapItems}.

% \input{algorithms/apriori_opt.tex}

\input{algorithms/apriori_std_get_items.tex}

\input{algorithms/apriori_std_get_support.tex}

\input{algorithms/apriori_std_map_items.tex}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Symmetry analysis}

The symmetry analysis performed by \calcprog\ is relatively extensive
and flexible.  While the program doesn't find all
of the symmetry elements possessed by molecules, it does get a lot of
them.

In order to make the symmetry analysis as flexible as possible, the
molecule can first be moved to the center of mass frame of reference.
The
moments of inertia are then found and the whole molecule is rotated
into the principle axis frame.  This allows molecules which are not
located exactly at the origin or aligned perfectly with the Cartesian
axes to be analyzed.

The transformation to the principle axis frame is controlled by the
keyword {\sf Principle Axes}.  If this keyword is not specified, the
symmetry analysis will be done in the orientation specified in the
{\sf Geometry} section.

The program searches for the following
symmetry elements:

\begin{itemize}

\item {\bf an inversion center}

\item {\bf rotation axes} from C$_2$ through C$_8$ about the three
Cartesian axes.

\item {\bf improper rotation axes} from S$_3$ through S$_8$ about the
three Cartesian axes.

\item {\bf mirror planes} perpendicular to the Cartesian axes.

\end{itemize}

The elements found, their axes, and atoms which are equivalent under
each operation are printed to the output file.

The characters of the wavefunctions with respect to each operation are
determined by constructing the appropriate transformation matrix for
each operation and transforming the vector of atomic orbital
coefficients for each molecular orbital.  The result of this process
is the actual character of the wavefunction with respect to the
symmetry operation, not just a symmetric/anti-symmetric label.
It is important to realize that the results of this method of
displaying the results of symmetry analysis can give results which
are, at first, confusing for degenerate orbitals.  If you are looking
at the characters of a set of degerate orbitals and trying to compare
them to the characters given in a character table, it is very
important that you sum the characters of each of the members of the
degenerate set.

When a reaction coordinate is being followed, \calcprog\ first
generates all the geometries along the coordinate and determines the
symmetry elements which they possess.  The only symmetry elements
reported are those which are conserved along the entire distortion.
This means that you don't have to worry about moving from high to low
symmetry geometries or {\it vice versa}.  {\bf Note:} It is possible
that loss of symmetry elements will lead to problems in constructing a
Walsh diagram.  In these cases {\bf {\sf fit\_walsh}} will warn you.
If the diagram as constructed is incorrect, you can either change your
reaction coordinate to not include geometries with problematic
degeneracies or edit the {\tt .WALSH} file by hand to fix it.  This is
explained in more detail below in the section on fitting programs.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Like most advanced LaTeX files, this one begins with a lot of
% boilerplate. You don't need to understand (or even read) most of it.
% All you need to do is fill in your name, UMN ID, email address,
% and the number of the pset. (Search for "METADATA" to find the place
% for this.) Then, you can go straight to the "EXERCISE 1"
% section and start writing your solutions.
% The "VARIOUS USEFUL COMMANDS" section is probably worth taking a
% look at at some point.

%----------------------------------------------------------------------------------------
%	PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------
\documentclass[paper=a4, fontsize=12pt]{scrartcl} % A4 paper and 12pt font size
\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs
\usepackage[english]{babel} % English language/hyphenation
\usepackage{amsmath,amsfonts,amsthm,amssymb} % Math packages
\usepackage{mathrsfs}    % More math packages
\usepackage{sectsty}  % Allows customizing section commands
\allsectionsfont{\centering \normalfont\scshape} % Make all section titles centered, the default font and small caps %remove this to left align section tites
\usepackage{hyperref} % Turns cross-references into hyperlinks,
                      % and defines \url and \href commands.
\usepackage{graphicx} % For embedding graphics files.
\usepackage{framed}   % For the "leftbar" environment used below.
\usepackage{ifthen}   % Used for the \powset command below.
\usepackage{lastpage} % for counting the number of pages
\usepackage[headsepline,footsepline,manualmark]{scrlayer-scrpage}
\usepackage[height=10in,a4paper,hmargin={1in,0.8in}]{geometry}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tikz}     % This is a powerful tool to draw vector
                      % graphics inside LaTeX. In particular, you can
                      % use it to draw graphs.
\usepackage{verbatim} % For the "verbatim" environment, in which
                      % special symbols can be used freely without
                      % confusing the compiler. (And it's typeset in
                      % a constant-width font.)
                      % Useful, e.g., for quoting code (or ASCII art).

%\numberwithin{table}{section} % Number tables within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)

\setlength\parindent{20pt} % Makes indentation for paragraphs longer.
                           % This makes paragraphs stand out more.

%----------------------------------------------------------------------------------------
%	VARIOUS USEFUL COMMANDS
%----------------------------------------------------------------------------------------
% The commands below might be convenient. For example, you probably
% prefer to write $\powset[2]{V}$ for the set of $2$-element subsets
% of $V$, rather than writing $\mathcal{P}_2(V)$.
% Notice that you can easily define your own commands like this.
% Caveat: Some of these commands need to be properly "guarded" when
% they occur in subscripts or superscripts. So you should not write
% $K_\CC$, but rather $K_{\CC}$.
\newcommand{\CC}{\mathbb{C}} % complex numbers
\newcommand{\RR}{\mathbb{R}} % real numbers
\newcommand{\QQ}{\mathbb{Q}} % rational numbers
\newcommand{\NN}{\mathbb{N}} % nonnegative integers
\newcommand{\DD}{{\mathbb{D}}} % dual numbers
\newcommand{\PP}{\mathbb{P}} % positive integers
\newcommand{\KK}{\mathbb{K}} % notation for a ring
\newcommand{\LL}{\mathbb{L}} % notation for a ring
\newcommand{\MM}{\mathbb{M}} % notation for a ring
\newcommand{\FF}{\mathbb{F}} % notation for a field
\newcommand{\Z}[1]{\mathbb{Z}/#1\mathbb{Z}} % integers modulo k
                                            % (syntax: "\Z{k}")
\newcommand{\ZZ}{\mathbb{Z}} % integers
\newcommand{\id}{\operatorname{id}} % identity map
\newcommand{\op}{\operatorname{op}} % opposite ring
\newcommand{\End}{\operatorname{End}} % endomorphism ring
\newcommand{\lcm}{\operatorname{lcm}}
% Lowest common multiple. For historical reasons, LaTeX has a \gcd
% command built in, but not an \lcm command. The preceding line
% rectifies that.
\newcommand{\Int}{\operatorname{Int}} % integer-valued polynomials
\newcommand{\set}[1]{\left\{ #1 \right\}}
% $\set{...}$ compiles to {...} (set-brackets).
\newcommand{\abs}[1]{\left| #1 \right|}
% $\abs{...}$ compiles to |...| (absolute value, or size of a set).
\newcommand{\tup}[1]{\left( #1 \right)}
% $\tup{...}$ compiles to (...) (parentheses, or tuple-brackets).
\newcommand{\ive}[1]{\left[ #1 \right]}
% $\ive{...}$ compiles to [...] (Iverson bracket, aka truth value; also, set of first n integers; also, polynomial).
\newcommand{\ivee}[1]{\left[ \left[ #1 \right] \right]}
% $\ivee{...}$ compiles to [[...]] (formal power series).
\newcommand{\floor}[1]{\left\lfloor #1 \right\rfloor}
% $\floor{...}$ compiles to |_..._| (floor function).
\newcommand{\underbrack}[2]{\underbrace{#1}_{\substack{#2}}}
% $\underbrack{...1}{...2}$ yields
% $\underbrace{...1}_{\substack{...2}}$. This is useful for doing
% local rewriting transformations on mathematical expressions with
% justifications. For example, try this out:
% $ \underbrack{(a+b)^2}{= a^2 + 2ab + b^2 \\ \text{(by the binomial formula)}} $
\newcommand{\powset}[2][]{\ifthenelse{\equal{#2}{}}{\mathcal{P}\left(#1\right)}{\mathcal{P}_{#1}\left(#2\right)}}
% $\powset[k]{S}$ stands for the set of all $k$-element subsets of
% $S$. The argument $k$ is optional, and if not provided, the result
% is the whole powerset of $S$.
\newcommand{\calF}{\mathcal{F}}
\newcommand{\horrule}[1]{\rule{\linewidth}{#1}} % Create horizontal rule command with 1 argument of height
\newcommand{\nnn}{\nonumber\\} % Don't number this line in an "align" environment, and move on to the next line.

%----------------------------------------------------------------------------------------
%	MAKING SUMMATION SIGNS ALWAYS PUT THEIR BOUNDS ABOVE AND BELOW
%	THE SIGN
%----------------------------------------------------------------------------------------
% The following are hacks to ensure that sums (such as
% $\sum_{k=1}^n k$) always put their bounds (i.e., the $k=1$ and the
% $n$) underneath and above the sign, as opposed to on its right.
% Same for products (\prod), set unions (\bigcup) and set
% intersections (\bigcap). Remove the 8 lines below if you do not want
% this behavior.
\let\sumnonlimits\sum
\let\prodnonlimits\prod
\let\cupnonlimits\bigcup
\let\capnonlimits\bigcap
\renewcommand{\sum}{\sumnonlimits\limits}
\renewcommand{\prod}{\prodnonlimits\limits}
\renewcommand{\bigcup}{\cupnonlimits\limits}
\renewcommand{\bigcap}{\capnonlimits\limits}

%----------------------------------------------------------------------------------------
%	ENVIRONMENTS
%----------------------------------------------------------------------------------------
% The incantations below define how theorem environments
% (\begin{theorem} ... \end{theorem}) and their likes will look like.
\newtheoremstyle{plainsl}% <name>
  {8pt plus 2pt minus 4pt}% <Space above>
  {8pt plus 2pt minus 4pt}% <Space below>
  {\slshape}% <Body font>
  {0pt}% <Indent amount>
  {\bfseries}% <Theorem head font>
  {.}% <Punctuation after theorem head>
  {5pt plus 1pt minus 1pt}% <Space after theorem headi>
  {}% <Theorem head spec (can be left empty, meaning `normal')>

% Environments which make the text inside them slanted:
\theoremstyle{plainsl}
  \newtheorem{theorem}{Theorem}[section]
  \newtheorem{proposition}[theorem]{Proposition}
  \newtheorem{lemma}[theorem]{Lemma}
  \newtheorem{corollary}[theorem]{Corollary}
  \newtheorem{conjecture}[theorem]{Conjecture}
% Environments that don't:
\theoremstyle{definition}
  \newtheorem{definition}[theorem]{Definition}
  \newtheorem{example}[theorem]{Example}
  \newtheorem{exercise}[theorem]{Exercise}
  \newtheorem{examples}[theorem]{Examples}
  \newtheorem{algorithm}[theorem]{Algorithm}
  \newtheorem{question}[theorem]{Question}
 \theoremstyle{remark}
  \newtheorem{remark}[theorem]{Remark}
\newenvironment{statement}{\begin{quote}}{\end{quote}}
\newenvironment{fineprint}{\begin{small}}{\end{small}}

%----------------------------------------------------------------------------------------
%	METADATA
%----------------------------------------------------------------------------------------
\newcommand{\myname}{Darij Grinberg} % ENTER YOUR NAME HERE
\newcommand{\myid}{00000000} % ENTER YOUR UMN ID HERE
\newcommand{\mymail}{dgrinber@umn.edu} % ENTER YOUR EMAIL HERE
\newcommand{\psetnumber}{3} % ENTER THE NUMBER OF THIS PSET HERE

%----------------------------------------------------------------------------------------
%	HEADER AND FOOTER
%----------------------------------------------------------------------------------------
\ihead{Solutions to midterm \#\psetnumber} % Page header left
\ohead{page \thepage\ of \pageref{LastPage}} % Page header right
\ifoot{\myname, \myid} % left footer
\ofoot{\mymail} % right footer

%----------------------------------------------------------------------------------------
%	TITLE SECTION
%----------------------------------------------------------------------------------------
\title{
\normalfont \normalsize
\textsc{University of Minnesota, School of Mathematics} \\ [25pt] % Your university, school and/or department name(s)
\horrule{0.5pt} \\[0.4cm] % Thin top horizontal rule
\huge Math 4281: Introduction to Modern Algebra, \\
Spring 2019:
Midterm \psetnumber\\% The assignment title
\horrule{2pt} \\[0.5cm] % Thick bottom horizontal rule
}
\author{\myname}

\begin{document}

\maketitle % Print the title

\begin{center} % Delete this if you want to save space!
{\large due date: \textbf{Monday, 6 May 2019 at 20:00} on Canvas or by email. \\

\textbf{No collaboration allowed} -- this is a midterm.

Please solve \textbf{at most 3 of the 6 exercises}!}
\end{center}

%----------------------------------------------------------------------------------------
%	EXERCISE 1
%----------------------------------------------------------------------------------------
\horrule{0.3pt} \\[0.4cm]

\section{Exercise 1: Nonunital rings and local unities}

\subsection{Problem}

A \textit{nonunital ring} is defined in the same way as we defined a ring,
except that we don't require it to be endowed with an element $1$ (and,
correspondingly, we omit the ``Neutrality of one'' axiom).
This does not mean that a nonunital ring must not contain an element $1$
that would satisfy the ``Neutrality of one'' axiom; it simply means that
such an element is not required (and not considered part of the ring
structure).
So, formally speaking, a nonunital ring is a
$4$-tuple $\tup{\KK, +, \cdot, 0}$
(while a ring in the usual sense is a $5$-tuple
$\tup{\KK, +, \cdot, 0, 1}$)
that satisfies all the ring axioms except for ``Neutrality of one''.

Thus, every ring becomes a nonunital ring if we forget its unity (i.e., if
$\tup{\KK, +, \cdot, 0, 1}$ is a ring, then $\tup{\KK, +, \cdot, 0}$
is a nonunital ring).
But there are other examples as well:
For instance, if $n \in \ZZ$ is arbitrary, then
$n \ZZ := \set{ nz \mid z \in \ZZ }
= \set{ \text{all multiples of } n }$ is a nonunital ring
(when endowed with the usual $+$, $\cdot$ and $0$).

An element $z$ of a nonunital ring $\KK$ is said to be a \textit{unity}
of $\KK$ if every $a \in \KK$ satisfies $az = za = a$.
In other words, an element $z$ of a nonunital ring $\KK$ is said
to be a \textit{unity} of $\KK$ if equipping $\KK$ with the unity
$z$ results in a ring (in the usual sense of this word).

Prove the following:

\begin{enumerate}

\item[\textbf{(a)}] If $n \in \ZZ$, then the nonunital ring $n \ZZ$
has a unity if and only if $n \in \set{1, 0, -1}$.

\item[\textbf{(b)}] Any nonunital ring has \textbf{at most one} unity.

\end{enumerate}

Now, let $\KK$ be a nonunital ring.
As usual, we write $+$ and $\cdot$ for its two operations,
and $0$ for its zero.

Let $z \in \KK$. Define a subset $U_z$ of $\KK$ by
\[
U_z = \set{ r \in \KK \mid rz = zr = r }.
\]

\begin{enumerate}

\item[\textbf{(c)}] Prove that $0 \in U_z$, and that every
$a, b \in U_z$ satisfy $a + b \in U_z$ and $ab \in U_z$.

\end{enumerate}

Thus, we can turn $U_z$ into a nonunital ring by endowing $U_z$
with the binary operations $+$ and $\cdot$ (inherited from $\KK$) and
the element $0$. Consider this nonunital ring $U_z$.

\begin{enumerate}

\item[\textbf{(d)}]
Assume that $z^2 = z$.
Prove that $z$ is a unity of the nonunital ring $U_z$.

\end{enumerate}

[\textbf{Hint:} In \textbf{(b)}, what would the product of two unities be?]

\subsection{Solution}

[...]

%----------------------------------------------------------------------------------------
%	EXERCISE 2
%----------------------------------------------------------------------------------------
\horrule{0.3pt} \\[0.4cm]

\section{Exercise 2: Rings from nonunital rings}

\subsection{Problem}

Let $\KK$ be a nonunital ring.
(See Exercise 1 for the definition of this notion.)
Let $\LL$ be the Cartesian product $\ZZ \times \KK$ (so far, just a set).
Define a binary operation $+$ on $\LL$ by setting
\[
\tup{n, a} + \tup{m, b} = \tup{n+m, a+b}
\qquad
\text{for all } \tup{n, a}, \tup{m, b} \in \LL .
\]
(This is an entrywise addition.)
Define a binary operation $\cdot$ on $\LL$ by
\[
\tup{n, a} \tup{m, b} = \tup{nm, nb + ma + ab}
\qquad
\text{for all } \tup{n, a}, \tup{m, b} \in \LL .
\]
(Here, $nb$ and $ma$ are defined in the usual way:
If $n \in \ZZ$ and $a \in \KK$, then $na \in \KK$ is defined by
\[
na=
\begin{cases}
\underbrace{a+a+\cdots+a}_{n \text{ times}},           & \text{if } n \geq 0;\\
- \tup{\underbrace{a+a+\cdots+a}_{-n \text{ times}}} , & \text{if } n < 0
\end{cases}
.
\]
This does not require $\KK$ to have a unity.)

Prove that $\LL$, endowed with these two operations $+$ and $\cdot$ and
the zero $\tup{0, 0}$ and the unity $\tup{1, 0}$, is a ring
(in the usual sense of this word).

[\textbf{Hint:} You can use rules like $n \tup{a + b} = na + nb$ and
$\tup{n + m} a = na + ma$ and $\tup{nm} a = n \tup{ma}$
(for $n, m \in \ZZ$ and $a, b \in \KK$) without proof; they can be
proven just as for usual rings.
You can also use the fact that finite sums of elements of $\KK$ are
well-defined and behave as we would expect them to
(we already tacitly used that in writing
``$\underbrace{a+a+\cdots+a}_{n \text{ times}}$'' without parentheses).

You don't need to check the ``additive'' axioms (associativity of
addition, commutativity of addition, neutrality of zero, and
existence of additive inverses); as far as addition and zero are
concerned, $\LL$ is just a Cartesian product.]

\subsection{Remark}

This exercise gives a way to ``embed'' any nonunital ring $\KK$
into a ring $\LL$.
This helps proving properties of nonunital rings, assuming that
you can prove them for rings.

There is also a much simpler notion of a Cartesian product of two nonunital
rings (in which both addition and multiplication are defined entrywise). This
lets us define a nonunital ring $\ZZ \times \KK$. But this is
\textbf{not} the ring $\LL$; it does not generally have a unity.

\subsection{Solution}

[...]

%----------------------------------------------------------------------------------------
%	EXERCISE 3
%----------------------------------------------------------------------------------------
\horrule{0.3pt} \\[0.4cm]

\section{Exercise 3: More sums from number theory}

\subsection{Problem}

\begin{enumerate}

\item[\textbf{(a)}]
Let $n$ be a positive integer.
Prove that
\[
\sum_{j=1}^{n} \gcd \tup{j, n}
= \sum_{d \mid n} d \phi\tup{ \dfrac{n}{d} }.
\]
More generally, if $\tup{a_1, a_2, a_3, \ldots}$ is a sequence
of reals, then prove that
\[
\sum_{j=1}^{n} a_{\gcd \tup{j, n}}
= \sum_{d \mid n} a_d \phi\tup{ \dfrac{n}{d} }.
\]

\item[\textbf{(b)}]
Let $n \in \NN$. Prove that
\begin{align*}
& \tup{ \text{the number of $\tup{x, y} \in \ZZ^2$ satisfying
              $x^2 + y^2 \leq n$} } \\
& = 1 + 4\sum_{k \in \NN} \tup{-1}^k \floor{ \dfrac{n}{2k+1} } \\
& = 1 + 4 \tup{   \floor{\dfrac{n}{1}} - \floor{\dfrac{n}{3}}
                + \floor{\dfrac{n}{5}} - \floor{\dfrac{n}{7}}
                + \floor{\dfrac{n}{9}} - \floor{\dfrac{n}{11}}
                \pm \cdots } .
\end{align*}
(The infinite sums in this equality have only finitely many nonzero addends,
and thus are well-defined.)

\end{enumerate}

[\textbf{Hint:} Parts \textbf{(a)} and \textbf{(b)} have nothing to do with
each other.

This is a good place for a reminder that results proven in the notes, as well
as problems from previous homework sets and midterms, can be freely used. Both
parts have rather short solutions if you remember the right results to use!]

\subsection{Remark}

Part \textbf{(b)} of this exercise is a ``discrete'' version of the
famous Madhava--Gregory--Leibniz series
\[
\dfrac{\pi}{4}
= \dfrac{1}{1} - \dfrac{1}{3} + \dfrac{1}{5} - \dfrac{1}{7}
  + \dfrac{1}{9} - \dfrac{1}{11} \pm \cdots
\]
(where $\pi$, at last, does denote the area of the unit circle).
Indeed, if we divide the number of $\tup{x, y} \in \ZZ^2$ satisfying
$x^2 + y^2 \leq n$ by $n$, then we obtain an approximation to
the area of the unit circle that gets better as $n$
grows\footnote{Just observe that the pairs
$\tup{x, y} \in \ZZ^2$ satisfying $x^2 + y^2 \leq n$, regarded
as points in the Euclidean plane, are precisely the lattice points
inside the circle with center $0$ and radius $\sqrt{n}$.
Thus, by counting these pairs, we are approximating the area of this
circle. See \cite[Theorem 12.1]{Clark18} for a rigorous proof.}.
On the other hand, it appears reasonable that dividing
\[
1 + 4 \tup{   \floor{\dfrac{n}{1}} - \floor{\dfrac{n}{3}}
                + \floor{\dfrac{n}{5}} - \floor{\dfrac{n}{7}}
                + \floor{\dfrac{n}{9}} - \floor{\dfrac{n}{11}}
                \pm \cdots }
\]
by $n$, we obtain an approximation to
$4 \tup{\dfrac{1}{1} - \dfrac{1}{3} + \dfrac{1}{5} - \dfrac{1}{7}
        + \dfrac{1}{9} - \dfrac{1}{11} \pm \cdots}$.
I am not sure whether this can be rigorously proven,
however.\footnote{Of course, for any given $k \in \NN$,
the number
$\dfrac{1}{n}\tup{\floor{\dfrac{n}{2k+1}} - \dfrac{n}{2k+1}}$
does converge to $0$ when $n \to \infty$.
But here we are taking an alternating sum of infinitely many
such numbers; we can ignore all but the first $n$, but even
the first $n$ may no longer converge to $0$ when summed
together.}

\subsection{Solution}

[...]

%----------------------------------------------------------------------------------------
%	EXERCISE 4
%----------------------------------------------------------------------------------------
\horrule{0.3pt} \\[0.4cm]

\section{Exercise 4: Squares in finite fields II}

\subsection{Problem}

Let $\FF$ be a finite field such that
$2 \cdot 1_{\FF} \neq 0_{\FF}$.
In Exercise 5 of
\href{http://www.cip.ifi.lmu.de/~grinberg/t/19s/hw6s.pdf}{homework set \#6},
we have seen that
$\abs{\FF}$ is odd, and that the number of squares in $\FF$ is
$\dfrac{1}{2} \tup{ \abs{\FF} + 1 }$.

In the following, the word ``square'' shall always mean
``square in $\FF$''.

A \textit{nonsquare} shall mean an element of $\FF$ that is not
a square.

Prove the following:

\begin{enumerate}

\item[\textbf{(a)}]
The product of two squares is always a square.

\item[\textbf{(b)}]
The product of a nonzero square with a nonsquare is always
a nonsquare.

\item[\textbf{(c)}]
The product of two nonsquares is always a square.

\end{enumerate}

[\textbf{Hint:} It is easiest to solve the three parts in
this exact order.
For \textbf{(c)}, recall that if a subset
$Y$ of a finite set $X$ satisfies $\abs{Y} \geq \abs{X}$,
then $Y = X$.]

\subsection{Solution}

[...]

%----------------------------------------------------------------------------------------
%	EXERCISE 5
%----------------------------------------------------------------------------------------
\horrule{0.3pt} \\[0.4cm]

\section{Exercise 5: Formal differential calculus}

\subsection{Problem}

Let $\KK$ be a commutative ring.
For each FPS\footnote{Just as in class, the abbreviation ``FPS''
stands for ``formal power series''.
All FPSs and polynomials in this exercise are in $1$ indeterminate
over $\KK$; the indeterminate is called $x$.}
\[
f = \sum_{k \in \NN} a_k x^k = a_0 x^0 + a_1 x^1 + a_2 x^2 + \cdots \in \KK\ivee{x}
\qquad
\text{(where $a_i \in \KK$),}
\]
we define the \textit{derivative} $f'$ of $f$ to be the FPS
\[
\sum_{k > 0} k a_k x^{k-1}
= 1 a_1 x^0 + 2 a_2 x^1 + 3 a_3 x^2 + \cdots \in \KK\ivee{x} .
\]
(This definition imitates the standard procedure for differentiating
power series in analysis, but it does not require any analysis or
topology itself. In particular, $\KK$ may be any commutative ring
-- e.g., a finite field.)

Let $D : \KK\ivee{x} \to \KK\ivee{x}$ be the map sending
each FPS $f$ to its derivative $f'$.
We refer to $D$ as \textit{(formal) differentiation}.
As usual, for any $n \in \NN$, we let $D^n$ denote
$\underbrace{D \circ D \circ \cdots \circ D}_{n \text{ times}}$
(which means $\id$ if $n = 0$).

Prove the following:

\begin{enumerate}

\item[\textbf{(a)}]
If $f \in \KK\ive{x}$, then $f' \in \KK\ive{x}$ and
$\deg \tup{f'} \leq \deg f - 1$.
(In other words, the derivative of a polynomial is again
a polynomial of degree at least $1$ less.)

\item[\textbf{(b)}]
The map $D : \KK\ivee{x} \to \KK\ivee{x}$ is $\KK$-linear
(with respect to the $\KK$-module structure on $\KK\ivee{x}$
defined in class -- i.e., both addition and scaling of FPSs
are defined entrywise).

\item[\textbf{(c)}]
We have $\tup{fg}' = f' g + f g'$ for any two FPSs
$f$ and $g$.
(This is called the \textit{Leibniz rule}.)

\item[\textbf{(d)}]
We have $D^n \tup{x^k} = n! \dbinom{k}{n} x^{k-n}$
for all $n \in \NN$ and $k \in \NN$.
Here, the expression ``$\dbinom{k}{n} x^{k-n}$'' is
to be understood as $0$ when $k < n$.

\item[\textbf{(e)}]
If $\QQ$ is a subring of $\KK$, then
every polynomial $f \in \KK\ive{x}$ satisfies%
\footnote{Just as in class, I am using the notation
``$f \ive{u}$'' for the evaluation of $f$ at $u$.
The more common notation for this is $f \tup{u}$,
but is too easily mistaken for a product. \\
Note also that we need to require $f$ to be a
polynomial here, since $f \ive{x+a}$ would not
be defined if $f$ was merely an FPS.}
\[
f \ive{x+a} = \sum_{n \in \NN} \dfrac{1}{n!} \tup{D^n \tup{f}} \ive{a} \cdot x^n
\qquad \text{for all $a \in \KK$} .
\]
(The infinite sum on the right hand side has only
finitely many nonzero addends.)

\item[\textbf{(f)}]
If $p$ is a prime such that $p \cdot 1_\KK = 0$
(for example, this happens if $\KK = \ZZ / p$),
then $D^p \tup{f} = 0$ for each $f \in \KK\ivee{x}$.

\end{enumerate}

Now, assume that $\QQ$ is a subring of $\KK$.
For each FPS
\[
f = \sum_{k \in \NN} a_k x^k = a_0 x^0 + a_1 x^1 + a_2 x^2 + \cdots \in \KK\ivee{x}
\qquad
\text{(where $a_i \in \KK$),}
\]
we define the \textit{integral} $\int f$ of $f$ to be the FPS
\[
\sum_{k \geq 0} \dfrac{1}{k+1} a_k x^{k+1}
= \dfrac{1}{1} a_0 x^1 + \dfrac{1}{2} a_1 x^2 + \dfrac{1}{3} a_2 x^3 + \cdots \in \KK\ivee{x} .
\]
(This definition imitates the standard procedure for integrating
power series in analysis, but again works for any commutative
ring $\KK$ that contains $\QQ$ as subring.)

Let $J : \KK\ivee{x} \to \KK\ivee{x}$ be the map sending
each FPS $f$ to its integral $\int f$.
Prove the following:

\begin{enumerate}

\item[\textbf{(g)}]
The map $J : \KK\ivee{x} \to \KK\ivee{x}$ is $\KK$-linear.

\item[\textbf{(h)}]
We have $D \circ J = \id$.

\item[\textbf{(i)}]
We have $J \circ D \neq \id$.

\end{enumerate}

[\textbf{Hint:} Don't give too much detail; workable outlines
are sufficient.
Feel free to interchange summation signs without justification.
For part \textbf{(c)}, it is easiest to first prove it
in the particular case when $f = x^a$ and $g = x^b$ for some
$f$ and $g$, and then obtain the general case by interchanging
summations.]

\subsection{Remark}

This exercise is just the beginning of ``algebraic calculus''.
A lot more can be done: Differentiation can be extended to
rational functions; partial derivatives can be defined for
multivariate polynomials and FPSs; differential equations can
be solved formally in FPSs (rather than functions); even a
purely algebraic analogue of the classical
$f'\tup{x} = \lim\limits_{\varepsilon\to 0} \dfrac{f\tup{x+\varepsilon} - f\tup{x}}{\varepsilon}$
definition exists\footnote{See Theorem 5 in
\url{https://math.stackexchange.com/a/2974977/} .}.
These algebraic derivatives play crucial roles in the
study of fields (including finite fields!), in algebraic
geometry (where they help define what a
``singularity'' of an algebraic variety is) and in
enumerative combinatorics (where they aid in computing
generating functions).

Part \textbf{(e)} is perhaps the easiest instance of
the well-known Taylor formula (no error terms, no
smoothness requirements, no convergence issues).

The ``integral'' $\int f$ we defined above is, of course,
only one possible choice of an FPS $g$ satisfying $g' = f$.
Just as in calculus, you can add any constant to it, and
you get another.
Part \textbf{(h)} is an algebraic version of one half of
the Fundamental Theorem of Calculus.
You can easily prove the other half: For each FPS $f$,
the FPS $\tup{J \circ D} \tup{f}$ differs from $f$ only
in its constant term.

If $\KK$ contains $\QQ$ as a subring, then both $J$ and $D$ are
elements of the $\KK$-algebra $\End \tup{\KK\ivee{x}}$
(by parts \textbf{(b)} and \textbf{(g)} of this exercise).
Part \textbf{(h)} of this exercise shows that $J$ is a right
inverse of $D$; but part \textbf{(i)} shows that $J$ is not a
left inverse (and thus not an inverse) of $D$.
This yields an example of a left inverse that is not a right
inverse.

\subsection{Solution}

[...]

%----------------------------------------------------------------------------------------
%	EXERCISE 6
%----------------------------------------------------------------------------------------
\horrule{0.3pt} \\[0.4cm]

\section{Exercise 6: Formal difference calculus and integer-valued polynomials}

\subsection{Problem}

Let $\KK$ be a commutative ring.

For any polynomial $f \in \KK\ive{x}$,
we define the \textit{first finite difference} $f^\Delta$ of $f$
to be the polynomial
\[
f \ive{x+1} - f \ive{x} \in \KK\ive{x} .
\]
(This is a ``discrete analogue'' of the derivative,
in case the analysis-free derivative from Exercise 5
was not discrete enough for you.
It cannot be extended to FPSs, however, since you cannot
substitute $x+1$ for $x$ in an FPS.)

Let $\Delta : \KK\ive{x} \to \KK\ive{x}$ be the map sending
each polynomial $f$ to $f^\Delta$.
As usual, for any $n \in \NN$, we let $\Delta^n$ denote
$\underbrace{\Delta \circ \Delta \circ \cdots \circ \Delta}_{n \text{ times}}$
(which means $\id$ if $n = 0$).

Prove the following:

\begin{enumerate}

\item[\textbf{(a)}]
The map $\Delta : \KK\ive{x} \to \KK\ive{x}$ is $\KK$-linear
(with respect to the $\KK$-module structure on $\KK\ive{x}$
defined in class -- i.e., both addition and scaling of
polynomials are defined entrywise).

\item[\textbf{(b)}]
We have $\tup{fg}^\Delta = f^\Delta g + f\ive{x+1} g^\Delta$
for any two polynomials $f$ and $g$.

\end{enumerate}

Now, assume that $\QQ$ is a subring of $\KK$.

For any $n \in \NN$, we define a polynomial%
\footnote{Note that we are within our rights to divide
by $n!$ here, since $\QQ$ is a subring of $\KK$.}
\[
\dbinom{x}{n} := \dfrac{x\tup{x-1}\tup{x-2}\cdots\tup{x-n+1}}{n!}
\in \KK\ive{x} .
\]
We also set $\dbinom{x}{n} := 0$ for every negative $n$.

Prove the following:

\begin{enumerate}

\item[\textbf{(c)}]
We have $\Delta^n \tup{\dbinom{x}{k}} = \dbinom{x}{k-n}$
for all $n \in \NN$ and $k \in \ZZ$.

\item[\textbf{(d)}]
If $m \in \NN$, and if $f \in \KK\ive{x}$ is a polynomial
of degree $\leq m$,
then there exist elements $a_0, a_1, \ldots, a_m \in \KK$
such that $f = \sum_{i=0}^m a_i \dbinom{x}{i}$.

\item[\textbf{(e)}]
Every polynomial $f \in \KK\ive{x}$ satisfies
\[
f \ive{x+a} = \sum_{n \in \NN} \tup{\Delta^n \tup{f}} \ive{a} \cdot \dbinom{x}{n}
\qquad \text{for all $a \in \KK$} .
\]
(The infinite sum on the right hand side has only
finitely many nonzero addends.)

\item[\textbf{(f)}]
Let $m \in \NN$, and let $f \in \KK\ive{x}$ be a polynomial
of degree $\leq m$.
Assume that $f\ive{k} \in \ZZ$ for each $k \in \set{0, 1, \ldots, m}$.
Then, there exist integers $a_0, a_1, \ldots, a_m$
such that $f = \sum_{i=0}^m a_i \dbinom{x}{i}$.

\end{enumerate}

[\textbf{Hint:} Part \textbf{(d)} is easiest to prove by
induction on $m$.
You can then prove part \textbf{(e)} for $f = \dbinom{x}{i}$
first (where $i \in \NN$), and then extend it to arbitrary $f$
by means of part \textbf{(d)}.
Part \textbf{(f)}, in turn, can be derived from part
\textbf{(e)} through a strategic choice of $a$.]

\subsection{Remark}

Just as $\Delta$ is an analogue of the differentiation
operator $D$ from Exercise 5,
we can define an analogue of the integration operator
$J$ from Exercise 5.
This will be a $\KK$-linear map $\Sigma : \KK\ive{x} \to \KK\ive{x}$
that sends each polynomial
$\sum_{i=0}^m a_i \dbinom{x}{i}$ to
$\sum_{i=0}^m a_i \dbinom{x}{i+1}$
(this definition makes sense, because part \textbf{(d)}
of this exercise
shows that each polynomial can be written in the form
$\sum_{i=0}^m a_i \dbinom{x}{i}$, uniquely except for
``leading zeroes'').
Again, we have $\Delta \circ \Sigma = \id$ but
$\Sigma \circ \Delta \neq \id$.

Moreover, if $f \in \KK\ive{x}$ is a polynomial, then
$\tup{\Sigma\tup{f}} \ive{0} = 0$
and
$\tup{\Sigma\tup{f}} \ive{n}
 = \tup{\Sigma\tup{f}} \ive{n-1} + f \ive{n-1}$
for each $n \in \ZZ$ (indeed, the former equality
follows easily from the definition of $\Sigma$,
while the latter follows from $\Delta \circ \Sigma = \id$).
Hence, by induction, we can see that
\[
\tup{\Sigma\tup{f}} \ive{n}
= f\ive{0} + f\ive{1} + \cdots + f\ive{n-1}
\qquad \text{for each polynomial $f \in \KK\ive{x}$
             and each $n \in \NN$}.
\]
In other words, the value of $\Sigma\tup{f}$ at an
$n \in \NN$ is the sum of the first $n$ values of
$f$ on nonnegative integers! (Whence the notation $\Sigma$.)
For example, if we set $f = x^2$, then it is easy to see
that $\Sigma\tup{f} = 2 \dbinom{x}{3} + \dbinom{x}{2}$
(to see this, just expand $f$ in the form
$\sum_{i=0}^m a_i \dbinom{x}{i}$ -- namely,
$f = x^2 = 2 \dbinom{x}{2} + \dbinom{x}{1}$ --, and
then apply the definition of $\Sigma$); thus we obtain
\[
2 \dbinom{n}{3} + \dbinom{n}{2}
= 0^2 + 1^2 + \cdots + \tup{n-1}^2 .
\]
Similarly you can find a formula for
$0^k + 1^k + \cdots + \tup{n-1}^k$ whenever $k \in \NN$.

Part \textbf{(e)} of this exercise is a result of Newton.

\subsection{Solution}

[...]

\begin{thebibliography}{99999999}                                                                                %

% Feel free to add your sources -- or copy some from the source code
% of the class notes ( http://www.cip.ifi.lmu.de/~grinberg/t/19s/notes.tex ).

% \bibitem[Clark07]{Clark07}
% Pete Clark, \textit{Gauss's circle problem},
% \url{http://math.uga.edu/~pete/4400gausscircle.pdf} .

\bibitem[Clark18]{Clark18}
Pete L. Clark, \textit{Number Theory: A Contemporary Introduction},
8 January 2018. \\
\url{http://math.uga.edu/~pete/4400FULL.pdf}

\end{thebibliography}

\end{document}


\XtoCBlock{Sign}
\label{block:Sign}
\begin{figure}[H]\includegraphics{Sign}\end{figure}

\begin{XtoCtabular}{Inports}
In & Input u\tabularnewline
\hline
\end{XtoCtabular}

\begin{XtoCtabular}{Outports}
Out & Value corresponding to sign of u\tabularnewline
\hline
\end{XtoCtabular}

\subsubsection*{Description:}
Signum function.

% include optional documentation file
\InputIfFileExists{\XcHomePath/Library/Math/Doc/Sign_Info.tex}{\vspace{1ex}}{}

\subsubsection*{Implementations:}
\begin{tabular}{l l}
\textbf{FiP8} & 8 Bit Fixed Point Implementation\tabularnewline
\textbf{FiP16} & 16 Bit Fixed Point Implementation\tabularnewline
\textbf{FiP32} & 32 Bit Fixed Point Implementation\tabularnewline
\end{tabular}

\XtoCImplementation{FiP8}
\index{Block ID!4896}
\nopagebreak[0]
% Implementation details
\begin{tabular}{l l}
\textbf{Name} & FiP8 \tabularnewline
\textbf{ID} & 4896 \tabularnewline
\textbf{Revision} & 0.1 \tabularnewline
\textbf{C filename} & Sign\_FiP8.c \tabularnewline
\textbf{H filename} & Sign\_FiP8.h \tabularnewline
\end{tabular}
\vspace{1ex}

8 Bit Fixed Point Implementation

% Implementation data structure
\XtoCDataStruct{Data Structure:}
\begin{lstlisting}
typedef struct {
     uint16        ID;
     int8          *In;
     int8          Out;
} SIGN_FIP8;
\end{lstlisting}

\ifdefined \AddTestReports
\InputIfFileExists{\XcHomePath/Library/Math/Doc/Test_Sign_FiP8.tex}{}{}
\fi
\XtoCImplementation{FiP16}
\index{Block ID!4897}
\nopagebreak[0]
% Implementation details
\begin{tabular}{l l}
\textbf{Name} & FiP16 \tabularnewline
\textbf{ID} & 4897 \tabularnewline
\textbf{Revision} & 0.1 \tabularnewline
\textbf{C filename} & Sign\_FiP16.c \tabularnewline
\textbf{H filename} & Sign\_FiP16.h \tabularnewline
\end{tabular}
\vspace{1ex}

16 Bit Fixed Point Implementation

% Implementation data structure
\XtoCDataStruct{Data Structure:}
\begin{lstlisting}
typedef struct {
     uint16        ID;
     int16         *In;
     int16         Out;
} SIGN_FIP16;
\end{lstlisting}

\ifdefined \AddTestReports
\InputIfFileExists{\XcHomePath/Library/Math/Doc/Test_Sign_FiP16.tex}{}{}
\fi
\XtoCImplementation{FiP32}
\index{Block ID!4898}
\nopagebreak[0]
% Implementation details
\begin{tabular}{l l}
\textbf{Name} & FiP32 \tabularnewline
\textbf{ID} & 4898 \tabularnewline
\textbf{Revision} & 0.1 \tabularnewline
\textbf{C filename} & Sign\_FiP32.c \tabularnewline
\textbf{H filename} & Sign\_FiP32.h \tabularnewline
\end{tabular}
\vspace{1ex}

32 Bit Fixed Point Implementation

% Implementation data structure
\XtoCDataStruct{Data Structure:}
\begin{lstlisting}
typedef struct {
     uint16        ID;
     int32         *In;
     int32         Out;
} SIGN_FIP32;
\end{lstlisting}

\ifdefined \AddTestReports
\InputIfFileExists{\XcHomePath/Library/Math/Doc/Test_Sign_FiP32.tex}{}{}
\fi


\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{geometry}
\usepackage{enumerate}
\usepackage{natbib}
\usepackage{float}%稳定图片位置
\usepackage{graphicx}%画图
\usepackage[english]{babel}
\usepackage{a4wide}
\usepackage{indentfirst}%缩进
\usepackage{enumerate}%加序号
\usepackage{multirow}%合并行
\title{\large UM-SJTU JOINT INSTITUTE\\DISCRETE MATHEMATICS\\(VE203)\\\ \\\ \\\ \\\ \\\ \\\ \\\ \\\ \\\ \\\ \\\
ASSIGNMENT 8\\\ \\\ \\\ \\\ \\\ \\\ }
\author{Name: Pan Chongdan\\ID: 516370910121}
\date{Date: \today}

\begin{document}
\maketitle
\newpage
\section{Q1}
\begin{enumerate}[(i)]
\item \textbf{Input}: $a_1,\cdots,a_n,n$ unsorted elements
\par \textbf{Output}: All the $a_i,1\leq i\leq n$ in an increasing order.

\par \textbf{for} $p=1$ to $n-1$
\par $x=a_{p+1};$
\par \setlength\parindent{2em}\textbf{If} $a_p>a_{p+1}$ \textbf{then}
\par \setlength\parindent{4em}$i=1;j=p;$
\par \textbf{while} $i<j$ \textbf{do}
\par \setlength\parindent{6em}$m\leftarrow\lceil(i+j/2）\rceil;$
\par \textbf{if} $x>a_m$ \textbf{then} $i\leftarrow(m+1);$
\par \textbf{else} $j\leftarrow m;$
\par \setlength\parindent{4em}\textbf{end while}
\par \textbf{for} $k=p$ to $i$
\par \setlength\parindent{6em}$a_{k+1}=a_k;$
\par \setlength\parindent{4em}\textbf{end for}
\par $a_i=x;$
\par \setlength\parindent{2em}\textbf{end if}
\par \setlength\parindent{0em}\textbf{end for}
\par \textbf{return} $(a_1\cdots a_{n+1});$
\item
For the Insertion Sort Algorithm, $n=\sum_1^7=28$
\par For the Binary Insertion Sort Algorithm, $n=1+1+1+2+2+2+3=12$
\item $f(n)=\sum_1^{n-1}=\frac{n^2-n}{2}$, which is order $n^2$
\item $f(n)$ is $O(\log_2n)$, which is faster than Insertion Sort.
\end{enumerate}
\section{Q2}
\begin{enumerate}[(i)]
\item Assume $n=b^k,k=\log_bn$ then
$$f(n)=b^d\cdot f(b^{k-1})+cb^{kd}$$
$$f(n)=b^d\cdot[b^d\cdot f(b^{k-2})+cb^{kd-d}]+cb^{kd}=b^{2d}f(b^{k-2})+2cb^{kd}$$
$$f(n)=b^{2d}f(b^{k-2})+2cb^{kd}=b^{3d}f(b^{k-3})+3cb^{kd}$$
$$\cdots$$
$$f(n)=b^{kd}f(1)+kcn^d=f(1)n^d+cn^d\log_bn$$
\item Assume $n=b^k,$ where $k=A+B,A\in\mathbb{Z}$ and $0<B<1$, then similarly to (i)
$$f(n)=f(\frac{n}{b^A})b^{Ad}+Acn^d$$
$$\lim_{n\to\infty}|\frac{f(n)}{n^d\log_bn}|=c$$
$$\therefore f\quad\mathrm{is}\quad O(n^d\log_b(n))$$
\item Assume $n=b^k,k=\log_bn$ then
$$f(n)=a\cdot f(b^{k-1})+cb^{kd}$$
$$f(n)=a\cdot[a\cdot f(b^{k-2})+cb^{kd-d}]+cb^{kd}=a^2f(b^{k-2})+(1+\frac{a}{b^d})cb^{kd}$$
$$\cdots$$
$$f(n)=a^kf(1)+[1+\frac{a}{b^d}\cdots(\frac{a}{b^d})^{k-1}]cb^{kd}=a^kf(1)+\frac{a^k-b^{kd}}{ab^{kd-d}-b^{kd}}\cdot cn^d$$
$$f(n)=a^kf(1)+c\cdot\frac{b^d(n^d-a^k)}{b^d-a}=a^k\cdot(f(1)+\frac{cb^d}{a-b^d})+c\cdot\frac{b^dn^d}{b^d-a}$$
$$f(n)=c_1n^d+c_2a^k$$
$$a^k=a^{\log_nb}=n^{\log_ba}$$
$$\therefore f(n)=c_1n^d+c_2n^{\log_ba}$$
\item $$\lim_{n\to\infty}|\frac{f(n)}{n^d}|=|c_1+c_2n^{\log_ba-d}|$$
$$\because a<b^d\Rightarrow\log_ba-d<0\Rightarrow|c_1+c_2n^{\log_ba-d}|<|c_1+c_2|$$
$$\therefore f\quad\mathrm{ is }\quad O(n^d)$$
\item Similarly to last question,
$$\lim_{n\to\infty}|\frac{f(n)}{n^{log_ba}}|=|c_1n^{d-\log_ba}+c_2|$$
$$\because a>b^d\Rightarrow\log_ba-d>0\Rightarrow|c_1n^{d-\log_ba}+c_2|<|c_1+c_2|$$
$$\therefore f\quad\mathrm{ is }\quad O(n^{\log_ba})$$
\end{enumerate}
\section{Q3}
Since there is only on real root then
$$a_n=2\alpha a_{n-1}-\alpha^2a_{n-2}$$
$$2\alpha a_{n-1}-\alpha^2a_{n-2}=2\alpha(q_1\alpha^{n-1}+q_2n\alpha^{n-1})-\alpha^2(q_1\alpha^{n-2}+q_2n\alpha^{n-2})=q_1\alpha^n+q_2n\alpha^n=a_n$$
\section{Q4}
$$\lambda^3-2\lambda^2-\lambda+2=0$$
$$\lambda_1=2,\lambda_2=1,\lambda_1=-1$$
$$\therefore a_n=q_12^n+q_2+q_3(-1)^n$$
$$3=q_1+q_2+q_3$$
$$6=2q_1+q_2-q_3$$
$$0=4q_1+q_2+q_3$$
$$q_1=-1,q_2=6,q_3=-2$$
$$a_n=-2^n+6-2(-1)^n$$
\section{Q5}
$$\lambda^2-5\lambda+6=0$$
$$\lambda_1=2,\lambda_2=3$$
$$p_n=bn2^n+cn^2+dn+e$$
$$p_n=5p_{n-1}-6p_{n-2}$$
$$b=-2,c=1,d=\frac{15}{2},e=\frac{67}{4}$$
$$a_n=q_12^n+q_23^n-2n2^n+n^2+\frac{15}{2}n+\frac{67}{4}$$
$$q_1=-33,q_2=\frac{65}{4}$$
$$a_n=-33\cdot2^n+\frac{65}{4}\cdot3^n-2n2^n+n^2+\frac{15}{2}n+\frac{67}{4}$$
\section{Q6}
$$\lambda^3-7\lambda^2+16\lambda-12=0$$
$$\lambda_1=3,\lambda_2=\lambda_3=2$$
$$p_n=kn4^n+b4^n$$
$$kn4^n+b4^n=7k(n-1)4^{n-1}-16k(n-2)4^{n-2}+12k(n-3)4^{n-3}+n4^n+3b4^n$$
$$k=16,b=-80$$
$$a_n=q_13^n+q_22^n+q_3n2^n+16n4^n-80\cdot4^n$$
$$a_n=49\cdot3^n+28\cdot2^n+27.5n2^n+16n4^n+\frac{5}{2}4^n$$
\section{Q7}
$$a_{n+1}=a_n+(n+1)^4$$
$$a_n=an^5+bn^4+cn^3+dn^2+en+f$$
$$a(n+1)^5+(b-1)(n+1)^4+c(n+1)^3+d(n+1)^2+e(n+1)+f=an^5+bn^4+cn^3+dn^2+en+f$$
$$a=\frac{1}{5},b=\frac{1}{2},c=\frac{1}{3},d=0,e=-\frac{1}{30},f=0$$
$$a_n=\frac{n^5}{5}+\frac{n^4}{2}+\frac{n^3}{3}-\frac{n}{30}$$
\section{Q8}
$$a_n-b_n=2a_{n-1}\Rightarrow b_n=a_n-2a_{n-1}\Rightarrow a_{n}=5a_{n-1}-4a_{n-2}$$
$$\lambda^2-5\lambda+4=0$$
$$\lambda_1=4,\lambda_2=1$$
$$a_n=q_14^n+q_2\Rightarrow a_n=2\cdot4^{n}-1$$
$$\therefore b_n=4^n+1$$
\section{Q9}
$$\lambda^2-2\lambda+2=0$$
$$\lambda_1=1+i,\lambda_2=1-i$$
$$p_n=k3^n\Rightarrow k=\frac{2}{3}k-\frac{2}{9}k+1\Rightarrow k=\frac{9}{5}\Rightarrow p_n=\frac{9}{5}\cdot3^n$$
$$a_n=(\sqrt{2})^n(q_1\cos\frac{n\pi}{4}+q_2\sin\frac{n\pi}{4})+\frac{9}{5}\cdot 3^n\Rightarrow q_1=-\frac{4}{5},q_2=-\frac{13}{5}$$
$$a_n=(\sqrt{2})^n(-\frac{4}{5}\cos\frac{n\pi}{4}-\frac{13}{5}\sin\frac{n\pi}{4})+\frac{9}{5}\cdot 3^n$$
\end{document}


\documentclass[11pt,a4paper]{article}
\usepackage{jheppub}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{float}
\usepackage{amssymb}
\usepackage{youngtab}

\newcommand{\fund}{$\Yboxdim{6pt}\yng(1)$}
\newcommand{\barfund}{$\bar{\Yboxdim{6pt}\yng(1)}$}

\title{MTC from Argyres-Douglas theory}
\author[a]{Hao-Rong Feng,}
\author[a]{Satoshi Nawata,}
\author[a]{Hao Derrick Zhang}
\author[b]{and Rui-Dong Zhu}
\affiliation[a]{Department of Physics and Center for Field Theory and Particle Physics, Fudan University, 220, Handan Road, 200433 Shanghai, China}
\affiliation[b]{Institute for Advanced Study and School of Physical Science and Technology, Soochow University, 215006 Suzhou, China}
\emailAdd{snawata@gmail.com,haozhangphys@gmail.com}
\abstract{}
\keywords{}

\begin{document}
\maketitle

\section{Argyres-Douglas theory}
For a generalized Argyres-Douglas theory $\mathcal T$, we can construct $3d$ TQFT by choosing the four-dimensional spacetime to be $M_4 = S^1 \times M_3$. $\mathcal T$ possesses a $\mathbb{Z}_F$ global symmetry.
\begin{table}[H]
\centering
\begin{tabular}{c|cccc}
    $\mathcal T$ & $(A_1, A_{2N})$ & $(A_1, A_{2N-1})$ & $(A_1, D_{2N})$ & $(A_1, D_{2N+1})$ \\
    \hline
    $F$ & $2N + 3$ & $N + 1$ & $N$ & $2N + 1$\\
    fixed points of $\mathcal M_{\mathcal T}$ & $N+1$ & $\frac12N(N+1)$ & $N^2$ & $2N+1$
\end{tabular}
\end{table}
We can turn on a non-trivial holonomy $\gamma \in \mathbb Z_F$ along the $S^1$.
Further, the theory is topologically twisted along $M_3$ by identifying the Riemannian holonomy group Spin(3) with $SU(2)_R \subset SU(2)_R \times U(1)_r$ of the R-symmetry of the $4d$ $\mathcal N = 2$ Argyres-Douglas theory.
When the holonomy is co-prime to $F$, $\gamma \in \mathbb Z_F^{\times}$, the TQFT is expected to be semisimple and is associated to a modular tensor category (MTC), $\mathcal C_{\mathcal T}^\gamma$.

While most Argyres-Douglas theories are believed to be non-Lagrangian, one might reach them by RG flows starting from $4d$ $\mathcal N = 1$ Lagrangian theories.

\subsection{$SU(N)$ with $2N$ flavors to $(A_1, A_{2N-1})$ theory}
$\mathcal T$ is $\mathcal N = 2 ~SU(N)$ gauge theory with $2N$ fundamental hypermultiplets. This theory has $SU(2N) \times U(1)$ flavor symmetry. The central charges are
\begin{equation}
    a = \frac{7N^2 - 5}{24}, \qquad c = \frac{2N^2 - 1}{6}, \qquad k_{SU(N)} = 2N.
\end{equation}
Upon coupling the $SU(N)$ adjoint chiral multiplet $M$, and Higgsing via nilpotent vev, the remaining components of $M$ are $M_j$, where $j = 1, \cdots, 2N - 1$ with charge $(J_+, J_-) = (0, 2+2j)$. $J_+$ is just the $R$-charge, $R = J_+$ and the flavor charge is given by $\mathcal F = \frac12 (J_+ - J_-)$.

$\mathrm{Tr}\phi^i$ ($i = 2, 3, \cdots, N$) and the $M_j$ with $j = 1, 2, \cdots, N$ will decouple. We are left with $M_j$ with $j=N+1, \cdots, 2N-1$. The matter content is given by
\begin{table}[H]
\centering
\begin{tabular}{c|cccc}
    ~        & $q$        & $\tilde q$      & $\phi$     & $M_j$ \\
    \hline
    $SU(N)$  & \fund      & \barfund  & adj        & 1   \\
    $U(1)_B$ & 1          & -1        & 0          & 0   \\
    %$(J_+, J_-)$ & $(1, -2N+1)$  & $(1,-2N+1)$ & $(0,2)$ & $(0,2j+2)$\\
    $U(1)_R$ & 1 & 1 & 0 & 0\\
    $U(1)_{\mathcal F}$ & $N$ & $N$ & $-1$ & $-(j+1)$
\end{tabular}
\end{table}
The superpotential is given by
\begin{equation}
    W = \sum_{j = 1}^{2N - 1} M_j(\phi^{2N - 1 - j}q \tilde q).
\end{equation}

\subsection{$Sp(N)$ with $2N+2$ flavors to $(A_1, A_{2N})$ theory}
$\mathcal T$ is $\mathcal N =2~Sp(N)$ gauge theory with $2N+2$ fundamental hypermultiplets. This theory has the $SO(4N+4)$ flavor symmetry. The central charges are
\begin{equation}
    a = \frac{1}{24}N(14 N + 9),\qquad c = \frac{1}{6}N(4 N + 3), \qquad k_{SO(4N+4)} = 4N.
\end{equation}
We now couple a chiral multiplet $M$ transforming in the adjoint representation of $SO(4N+4)$ and give the principal nilpotent vev to $M$. This will break the $SO(4N + 4)$ flavor symmetry completely, and the remaining components of $M$ would be $M_j$ with $j = 1, 3, \cdots, 4 N + 1$; $2 N + 1$ having charges $(J_+, J_-) = (0, 2j + 2)$. Note there are two $M$'s with $j = 2 N + 1$. The decoupled operators are all the Coulomb branch operators $\mathrm{Tr}\phi^{2i}$ with $i = 1, 2, \cdots, N$ and $M_j$ with $j = 1, 3, \cdots, 2 N + 1$ (there are two $M_j$'s with $j = 2 N + 1$) so we are left with $N$ singlet $M_j$ with $j = 2 N + 3, 2 N + 5, \cdots, 4 N + 1$. The matter content is
\begin{table}[H]
\centering
\begin{tabular}{c|ccccc}
    ~        & $q$        & $q'$      & $\phi$     & $M_j$  & $M'_{2N+1}$\\
    \hline
    $Sp(N)$  & \fund      & \fund     & adj        & 1      & 1\\
    %$(J_+, J_-)$ & $(1, 0)$  & $(1,-4 N - 2)$ & $(0,2)$ & $(0,2j+2)$ & $(0, 4 N + 4)$ \\
    $U(1)_R$ & 1 & 1 & 0 & 0 & 0\\
    $U(1)_{\mathcal F}$ & $\frac12$ & $\frac12(4N+3)$ & $-1$ & $-(j+1)$ & $-(2N + 2)$\\
    %$(R_0, \mathcal F)$ & $(\frac12, \frac12)$ & $(\frac12(-4N-1), \frac12(4N + 3))$ & $(1,-1)$ & $(j + 1, - j - 1)$ & $(2 N + 2, - 2 N - 2)$
\end{tabular}
\end{table}
The superpotential is given by
\begin{equation}
    W = \phi q q + \sum_{i=1}^{2N+1}M_{2i-1}(\phi^{4N+3-2i} q' q') + M'_{2N+1}qq'~.
\end{equation}

\subsection{$(A_1,D_{2N})$ theory}
Matter content of $(A_1, D_{2N})$ theory is given by
\begin{table}[H]
\centering
\begin{tabular}{c|cccccc}
    ~ & $q_1$ & $\tilde q_1$ & $q_2$ & $\tilde q_2$ & $\phi$ & $M_j$\\
    \hline
    $SU(N)$ & \fund & \barfund & \fund & \barfund & adj & 1\\
    $U(1)_1$ & 1 & $-1$ & 1 & $-1$ & 0 & 0 \\
    $U(1)_2$ & $2N-1$ & $-(2N-1)$ & $-1$ & 1 & 0 & 0\\
    $U(1)_R$ & $1$ & $1$ & $1$ & $1$ & $0$ & $0$\\
    $U(1)_{\mathcal F}$ & $\frac12$ & $\frac12$ & $\frac{2N-1}{2}$ & $\frac{2N-1}{2}$ & $-1$ & $-(j+1)$
\end{tabular}
\end{table}
where $N \le j \le 2N-2$.

\subsection{$(A_1,D_{2N+1})$ theory}
Matter content of $(A_1, D_{2N+1})$ theory is given by
\begin{table}[H]
\centering
\begin{tabular}{c|cccc}
    ~ & $q_1$ & $q_2$ & $\phi$ & $M_j$\\
    \hline
    $Sp(N)$ & \fund & \fund & adj & 1\\
    $SO(3)$ & 3 & 1 & 1 & 1\\
    $U(1)_R$ & $1$ & $1$ & $0$ & $0$\\
    $U(1)_{\mathcal F}$ & $\frac12$ & $\frac{4N+1}{2}$ & $-1$ & $-(j+1)$
\end{tabular}
\end{table}
where $j = 2k+1$ and $N\le k \le 2N-1$.

\subsection{Examples}
In the following examples, we multiply the previous $U(1)_{\mathcal F}$ charge by a factor $2/F$.
\subsubsection{$(A_1, A_2)$ theory}
Superpotential is given by
\begin{equation}
    W = q \phi q + u q' \phi q'~.
\end{equation}
The matter content is given by
\begin{table}[H]
\centering
\begin{tabular}{c|cccc}
    ~        & $q$        & $q'$      & $\phi$     & $M_5$ \\
    \hline
    $SU(2)$  & \fund      & \fund     & adj        & 1   \\
    $U(1)_R$ & 1          & 1         & 0          & 0   \\
    $U(1)_\mathcal F$     & $\frac15$ & $\frac75$  & $-\frac25$ & $-\frac{12}{5}$
\end{tabular}
\end{table}
\noindent Number of fixed points is $2$. Decoupled operator: $\mathrm{Tr}\phi^2$.

\subsubsection{$(A_1, A_3)$ theory}
Superpotential is given by
\begin{equation}
    W = u q \tilde q~.
\end{equation}
The matter content is given by
\begin{table}[H]
\centering
\begin{tabular}{c|cccc}
    ~        & $q$        & $\tilde q$& $\phi$   & $M_3$ \\
    \hline
    $SU(2)$  & \fund      & \fund     & adj      & 1   \\
    $U(1)_B$ & 1          & -1        & 0        & 0   \\
    $U(1)_R$ & 1          & 1         & 0        & 0   \\
    $U(1)_\mathcal F$     & $\frac43$ & $\frac43$  & $-\frac23$ & $-\frac{8}{3}$
\end{tabular}
\end{table}
\noindent Number of fixed points is $3$. Decoupled operator: $\mathrm{Tr}\phi^2$.

\subsubsection{$(A_1, A_4)$ theory}
The matter content is given by
\begin{table}[H]
\centering
\begin{tabular}{c|ccccc}
    ~        & $q$        & $\tilde q$& $\phi$     & $M_7$ & $M_9$ \\
    \hline
    $Sp(2)$  & \fund      & \fund     & adj        & 1     & 1     \\
    $U(1)_R$ & 1          & 1         & 0          & 0     & 0     \\
    $U(1)_\mathcal F$     & $\frac17$ & $\frac{11}{7}$  & $-\frac27$ & $-\frac{16}{7}$ & $-\frac{20}{7}$
\end{tabular}
\end{table}
\noindent Number of fixed points is $3$. Decoupled operator: $\mathrm{Tr}\phi^2, \mathrm{Tr}\phi^4$.

\subsubsection{$(A_1, A_5)$ theory}
The matter content is given by
\begin{table}[H]
\centering
\begin{tabular}{c|ccccc}
    ~ & $q$ & $\tilde q$ & $\phi$ & $M_4$ & $M_5$\\
    \hline
    $SU(3)$ & \fund & \barfund & adj & 1 & 1\\
    $U(1)_B$ & 1 & $-1$ & 0 & 0 & 0\\
    $U(1)_R$ & 1 & 1 & 0 & 0 & 0\\
    $U(1)_{\mathcal F}$ & $\frac32$ & $\frac32$ & $-\frac12$ & $-\frac52$ & $-3$
\end{tabular}
\end{table}
\noindent Number of fixed points is 6. Decoupled operator: $\mathrm{Tr}\phi^2, \mathrm{Tr}\phi^3$.

\subsubsection{$(A_1, D_3)$ theory}
The matter content is given by
\begin{table}[H]
\centering
\begin{tabular}{c|cccc}
    ~        & $q_1$      & $q_2$     & $\phi$     & $M_3$ \\
    \hline
    $SU(2)$  & \fund      & \fund     & adj        & 1     \\
    $SO(3)$  & 3          & 1         & 1          & 1     \\
    $U(1)_R$ & 1          & 1         & 0          & 0     \\
    $U(1)_\mathcal F$     & $\frac13$ & $\frac{5}{3}$  & $-\frac23$ & $-\frac83$
\end{tabular}
\end{table}
\noindent Number of fixed points is $3$. Decoupled operator:

\subsubsection{$(A_1, D_4)$ theory}
The matter content is given by
\begin{table}[H]
\centering
\begin{tabular}{c|cccccc}
    ~ & $q_1$ & $\tilde q_1$ & $q_2$ & $\tilde q_2$ & $\phi$ & $M_2$ \\
    \hline
    $SU(2)$ & \fund & \fund & \fund & \fund & adj & 1\\
    $U(1)_1$ & 1 & $-1$ & 1 & $-1$ & 0 & 0\\
    $U(1)_2$ & 3 & $-3$ & $-1$ & 1 & 0 & 0\\
    $U(1)_R$ & 1 & 1 & 1 & 1 & 0 & 0\\
    $U(1)_{\mathcal F}$ & $\frac12$ & $\frac12$ & $\frac32$ & $\frac32$ & $-1$ & $-3$
\end{tabular}
\end{table}
\noindent Number of fixed points is 4. Decoupled operator: $\mathrm{Tr} \phi^2$.

\section{$\mathcal{N} = 1$ gauge theories on $\mathbb{R}^2 \times T^2$}
The effective twisted superpotential, $\mathcal{W}(u,\nu;\tau)$ and the effective dilaton $\Omega(u,\nu;\tau)$ are locally holomorphic in all variables.
The Bethe equations are
\begin{equation}
    \exp\left(2\pi i \partial_{u_a} \mathcal{W}(u,\nu;\tau)\right) = 1, \quad a = 1, \cdots, \mathrm{rk}(\mathfrak{g})
\end{equation}
We can build some operators as
\begin{itemize}
    \item $\Pi_a = \exp(2\pi i \partial_{u_a} \mathcal W)$, the \emph{gauge flux operator};
    \item $\Pi_\alpha = \exp(2\pi i \partial_{\nu_\alpha} \mathcal W)$, the \emph{flavor flux operator};
    \item $\mathcal{H}~ = \exp(2\pi i \Omega)\det(\partial_{u_a}\partial_{u_b}\mathcal W)$, the
    \emph{handle-gluing operator};
    \item $\mathcal{F}~ = \exp(2\pi i \partial_\tau \mathcal W)$, the \emph{fibering operator}.
\end{itemize}
The parameter $\nu$ and $\tau$ are related to the fugacities $y$ and $q$ by
\begin{equation}
    y = e^{2\pi i \nu}, \qquad q = e^{2\pi i \tau}.
\end{equation}

%-------------------- commented --------------------%
\iffalse
\subsection{The twisted superpotential}
The twisted superpotential only receives contributions from charged
chiral multiplets. For semisimple Lie algebras, the W-bosons and their superpartners do not contribute.

\subsubsection{Chiral multiplet contribution}
Consider chiral multiplet of charge 1 under some $U(1)$ in the Cartan of the gauge group, with $u$ the $U(1)$ complexified flat connection.
Define the \emph{elliptic dilogarithm},
\begin{equation}
    \psi(u;\tau) \equiv -\frac{1}{2\pi i}\int_0^u du' \log\theta(u';\tau),
\end{equation}
where the theta-function is defined as
\begin{equation}
    \theta(u;\tau) = e^{-\pi i u} q^{\frac{1} {12}}\prod_{k=0}^\infty (1 - x q^k) (1 - x^{-1} q^{k+1})
\end{equation}
Then the contribution to twisted superpotential is
\begin{equation}
    \mathcal W_\Phi(u; \tau) = -\frac{u^3}{6 \tau} + \psi(u; \tau).
\end{equation}

\subsubsection{W-boson contribution}
\begin{equation}
    \mathcal{W}_{\mathrm{vec}} = -\rho_W(u), \qquad \rho_W \equiv \frac12 \sum_{\alpha>0}\alpha.
\end{equation}

\subsubsection{General gauge theory}
Consider chiral multiplets $\Phi_i$ in representations $R_i$ of semisimple Lie algebra $\mathfrak{g}$. We also turn on generic background parameters $\nu_\alpha$ for any flavor symmetry, then
\begin{equation}
    \mathcal{W}(u,\nu;\tau) = \sum_i \sum_{\rho \in R_i} \mathcal{W}_\Phi (\rho_i(u) + \nu_i; \tau)
\end{equation}
\fi
%----------------------------------------
\subsection{Flux operators}
For a single chiral multiplet, we have the contribution
\begin{equation}
    \Pi^\Phi(u; \tau) \equiv e^{2\pi i(-\frac{u^2}{2\tau}+\frac u 2 - \frac{\tau}{12})} \frac{1}{\theta_0(u; \tau)},
\end{equation}
with $\theta_0$ the reduced theta function
\begin{equation}
    \theta_0(u;\tau) = \prod_{k=0}^\infty(1-x q^k)(1-x^{-1}q^{k+1})
\end{equation}
Then we obtain
\begin{align}
    \Pi_a(u,\nu; \tau) &= e^{2\pi i \partial_{u_a}\mathcal W}
    = \prod_i\prod_{\rho_i \in R_i} \Pi^\Phi(\rho_i(u)+\nu_i)^{\rho_i^a}, \\
    \Pi_\alpha(u,\nu; \tau) &= e^{2\pi i \partial_{\nu_\alpha}\mathcal W}
    = \prod_i\prod_{\rho_i \in R_i} \Pi^\Phi(\rho_i(u)+\nu_i)^{\omega_i^\alpha}
\end{align}
for the gauge and flavor flux operators, respectively.

\subsection{Fibering operators}
\subsubsection{Chiral multiplet contribution to $\mathcal{F}$}
Define
\begin{equation}
    \Gamma_0(u;\tau) \equiv \prod_{n=0}^\infty
    \left(\frac{1-x^{-1}q^{n+1}}{1-xq^{n+1}}\right)^{n+1}
\end{equation}
Then
\begin{equation}
    \mathcal F^\Phi(u;\tau) = \exp\left(2\pi i \left(\frac{u^3}{6 \tau^2} - \frac{u}{12}\right)\right) \Gamma_0(u; \tau).
\end{equation}

\subsubsection{General gauge theory}
The fibering operators are given by
\begin{equation}
    \mathcal F({\bf u};\tau) = \prod_I \mathcal{F}_I^\Phi(Q_I({\bf u}); \tau),
\end{equation}
where $I = (\rho_i)$ run over all the chiral multiplets (that is, over all weights $\rho_i$ for each $i$) and $Q_I$ is the $U(1)$ charge of $\Phi_I$, that is $Q_{\rho_i}^a = \rho_i^a$ and $Q^\alpha_{\rho_i} = \omega_i^\alpha$ in terms of the weights of the gauge and flavor representations.

\subsection{Effective dilaton and handle-gluing operator}
Consider matter fields in chiral multiplets $\Phi_i$ of $R$-charges $r_i \in \mathbb{Z}$, we have
\begin{equation}
    \Omega = \Omega_{\mathrm{mat}} + \Omega_{\mathrm{vec}},
\end{equation}
such that
\begin{equation}
\begin{aligned}
    \exp\left(2\pi i \Omega_{\mathrm{mat}}(u,\nu; \tau)\right) &= \prod_i \prod_{\rho_i \in R_i} \Pi^\Phi(\rho_i(u)+\nu_i;\tau)^{r_i - 1}\\
    \exp\left(2\pi i \Omega_{\mathrm{vec}}(u,\nu; \tau)\right) &= \eta(\tau)^{-2 \mathrm{rk}(\mathfrak{g})}\prod_{\alpha \in \mathfrak{g}} \Pi^\Phi(\alpha(u); \tau),
\end{aligned}
\end{equation}
where the Dedekind eta function is defined as
\begin{equation}
    \eta(\tau) \equiv q^{\frac{1}{24}} \prod_{k=1}^\infty(1 - q^k), \qquad q = e^{2\pi i \tau}.
\end{equation}
Then the Hessian determinant of the twisted superpotential,
\begin{equation}
    H(u, \nu; \tau) \equiv \det \frac{\partial^2 \mathcal{W}(u, \nu; \tau)}{\partial u_a \partial u_b} = \det \left(\frac{1}{2\pi i} \frac{\partial \log \Pi_a}{\partial u_b}\right).
\end{equation}
And the handle-gluing operator is given by
\begin{equation}
    \mathcal{H}(u,\nu; \tau) = e^{2 \pi i \Omega(u,\nu; \tau)} H(u, \nu; \tau).
\end{equation}

\section{Holonomy saddles}

\section{$\mathcal B_{n+1}$ algebra}

\section{$\mathcal W_n$ algebra}
This algebra can be obtained by a nonregular quantum Hamiltonian reduction of \\$\widehat{\mathfrak{sl}}(n+1)_{-\frac{(n-1)^2}{n}}$

\nocite{Dedushenko:2018bpp}
\nocite{Closset:2017bse}
\nocite{Maruyoshi:2016aim}
\nocite{Agarwal:2016pjo}
\nocite{Hwang:2018riu}
\nocite{Nekrasov:2014xaa}
\nocite{Fredrickson:2017yka}
\nocite{Auger:2019gts}
\nocite{Cho:2020ljj}
\bibliography{MTC.bib}
\bibliographystyle{JHEP}
\end{document}


\documentclass{article}

\usepackage[left=1.25in,top=1.25in,right=1.25in,bottom=1.25in,head=1.25in]{geometry}
\usepackage{amsfonts,amsmath,amssymb,amsthm}
\usepackage{verbatim,float,url,enumerate}
\usepackage{graphicx,subfigure,psfrag}
\usepackage{natbib}
\usepackage{environ}
\usepackage{hyperref}
\usepackage{pifont}
\usepackage{xcolor}

\newtheorem{algorithm}{Algorithm}
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}{Lemma}
\newtheorem{corollary}{Corollary}

\theoremstyle{remark}
\newtheorem{remark}{Remark}
\theoremstyle{definition}
\newtheorem{definition}{Definition}

\newcommand{\argmin}{\mathop{\mathrm{argmin}}}
\newcommand{\argmax}{\mathop{\mathrm{argmax}}}
\newcommand{\minimize}{\mathop{\mathrm{minimize}}}
\newcommand{\maximize}{\mathop{\mathrm{maximize}}}
\newcommand{\st}{\mathop{\mathrm{subject\,\,to}}}
\newcommand{\dist}{\mathop{\mathrm{dist}}}

\newcommand{\reals}{\mathbb R}
\newcommand{\prox}{\operatorname{prox}}
\newcommand{\dom}{\operatorname{dom}}
\def\R{\mathbb{R}}
\def\E{\mathbb{E}}
\def\P{\mathbb{P}}
\def\Cov{\mathrm{Cov}}
\def\Var{\mathrm{Var}}
\def\half{\frac{1}{2}}
\def\sign{\mathrm{sign}}
\def\supp{\mathrm{supp}}
\def\th{\mathrm{th}}
\def\tr{\mathrm{tr}}
\def\dim{\mathrm{dim}}
\def\hbeta{\hat{\beta}}

\begin{document}

\title{Underactuated Robotics 16-748: Project Proposal \\ iLQR for Probabalistic Vehicle Control and Maneuvering}
\author{
  Josh Bennett\\
  \texttt{jjbennet@andrew.cmu.edu}
  \and
  Ting Che Lin\\
  \texttt{tingchel@andrew.cmu.edu}
}
\maketitle

\section{Motivation}

Autonomous vehicles need to respond to detected obstacles quickly and handle sensor uncertainty in a safe, reliable way. Planning a path around obstacles is best accomplished by considering both a) the vehicle dynamics, and b) the probability of collision within a close-range window of time. Trajectory optimization effectively incorporates the dynamics model to constrain the set of potential control strategies, but must be augmented with additional constraints to incorporate collision information. The Iterative Linear Quadratic Regulator (ILQR) provides a way to optimize over the set of feasible trajectories due to vehicle dynamics.

\section{Proposal}

Chen et al. \cite{chen_zhan_tomizuka_2017} discuss the use of Constrained iLQR (CILQR) for motion planning in autonomous vehicles. We propose an extension of their work, where uncertainty in collision information is incorporated. Uncertainty in both current position and future trajectory of surrounding obstacles will enable the CILQR algorithm to generate trajectories that are robustified to poor sensor measurements, while enabling lower safety trajectories to stil be executed in the absence of safer paths. The resulting vehicular control system will be 1) robust to sensor noise and error, and 2) fast at finding feasible trajectories.

\section{Research Plan}

We will implement the CILQR algorithm with probabilistic collision constraints as a C++ library. Linking to this library using Python bindings, we will show effective trajectory planning in a set of simulated vehicle scenarios. The project will be considered a success if a) feasible trajectories are consistently generated, b) unavoidable collisions are handled without erratic behaviour, and c) the planner is able to operate at a cycle rate of 20 Hz on modern multi-core processor.

We will first establish a set of baseline navigation scenarios which will act as a gating set of tests for the planner. After establishing this baseline standard, we will implement CILQR and evaluate tests which cause a failure.

\bibliographystyle{plain}
\bibliography{bibliography.bib}
\small

\end{document}