\title{\bf Stellar Evolution}

\section{Basics \& Nomenclature}

Stars are formed from interstellar gas, through gravitational collapse
within molecular clouds. A spectrum of objects are formed from below
the hydrogen burning limit of 0.08 $M_\odot$ up to 100--200
$M_\odot$. Stars spend most of their lifetime on a {\it main
sequence}, burning hydrogen in their cores. Depending on their mass
they then proceed through a sequence of post-main sequence phases and
leave remnants in the form of white dwarfs, neutron stars, or black
holes (or in some cases no permanent remnant). In any system of stars,
their history is encoded in their distribution of luminosities and
colors, which can be measured directly in resolved stellar populations
or inferred from spectra and/or broad band imaging. Stellar evolution
processes are responsible for most of the elements higher mass than
helium.

The {\it stellar initial mass function}, or {\it IMF}, defines the
spectrum of initial masses of stars. This spectrum is difficult to
determine observationally, because almost all systems we observe have
been altered dynamically or by stellar evolution. For many decades,
the standard was the {\it Salpeter IMF}:
\begin{equation}
\Phi(M) \propto M^{-2.35}.
\end{equation}
This form leads to a large fraction of mass between $0.08$ and $0.5$
$M_\odot$. However, evidence from local systems implies that in many
cases, the true IMF has a flatter slope at lower masses
(\citealt{bastian10a}. This difference is significant because low mass
stars emit very little luminosity, so their presence is very difficult
to directly detect, and therefore inferences of total mass in stars
depend strongly on the assumptions of how many low mass stars are in
the system.

The first and usually longest phase of stellar evolution is core
hydrogen burning on the main sequence. The cores are typically
millions to billions of Kelvin and fully ionized. Hydrogen is burned
to helium through two major processes, the {\it p-p chain} at low
masses and the {\it CNO cycle} at high masses ($M>2 M_\odot$). Each
process yields one ${}^4$He nucleus with a mass of 3.96$m_p$ from 4
protons; the one percent difference yields the energy for stellar
luminosity. Numerous other nuclear processes are occurring
simultaneously that contribute to the luminosity (and to the neutrino
output). The nuclear processes depend on the tail of nuclei in the
Maxwell-Boltzman distribution that are sufficiently high energy to
tunnel through the Coulomb repulsion of the nuclei. They are therefore
strongly temperature sensitive.

Stellar structure is controlled by the following equations:
\begin{itemize}
\item Mass conservation:
\begin{equation}
\frac{{\rm d}M}{{\rm d}r} = 4 \pi r^2 \rho
\end{equation}
\item Energy conservation:
\begin{equation}
\frac{{\rm d}L}{{\rm d}r} = 4 \pi r^2 \rho \epsilon
\end{equation}
\item Hydrostatics:
\begin{equation}
\frac{{\rm d}P}{{\rm d}r} = - \frac{GM(r) \rho}{r^2}
\end{equation}
\item Energy transport, which comes in the form of radiative transfer:
\begin{equation}
\frac{{\rm d}T}{{\rm d}r} = \frac{L(r)\kappa(r) \rho(r)}{16\pi r^2 c a T^3}
\end{equation}
or in the form of convection.
\end{itemize}
$\kappa(r)$ is the opacity defined as the cross-section to absorption
per unit mass (so is $1/\rho l$, where $l$ is the mean free path of a
photon). Opacity is a critical parameter, as it strongly affects the
structure of the star, and therefore its size. The higher the
metallicity, the higher the opacity, the larger the star, and
therefore the lower the surface temperature at a given luminosity.

The most important contributions to opacity inside the bulk of the
star come from Thomson scattering, free-free absorption, and
bound-free absorption. The latter two effects scale according to {\it
Kramer's Law}, which scales as follows:
\begin{equation}
\kappa \propto Z \rho T^{-7/2}
\end{equation}
The scaling results from just the consideration of the effects of
brehstrahhlung on a Planck spectrum, and the density of free
electrons. Because of the temperature dependence, at high temperatures
($T> 10^6$ K) Thomson scattering dominates, for which $\kappa$ is
constant. There are two other major sources of opacity, bound-bound
absorption, which is subdominant over most of the star, and H$^{-}$
absorption, which is only possible in the outer layers.

In the exercises, we will show that these equations imply a scaling of
luminosity with mass of approximately $L\propto M^4$ and with surface
temperature of $L\propto T_s^8$ on the main sequence.  The former
relationship implies that the stellar lifetimes on the main sequence
scale as $M^{-3}$.

After the main sequence, stellar evolution depends on the mass of the
star. At high luminosities (canonically above 8 $M_\odot$), stars have
short main sequence lifetimes (10s of Myrs) and thereafter undergo a
series of nuclear burning phases in their cores: He, C, Si, and so
on. Each burning phase is shorter than the last.  Shell burning is
occurring at the same time. Once Fe and Ni form in the core, energy
cannot be further released, and the core collapses. The result in many
and potentially all cases is a core-collapse supernova. The Fe and Ni
produced in the core is disintegrated in this process and most of that
mass becomes part of the neutron star or black hole that forms at the
center. However, the elements remaining from burning in the regions
outside the core, which are rich in $\alpha$ elements like O, Mg, and
so on, can be returned to the interstellar medium.

At lower masses, stars instead start burning hydrogen in a shell
around the inert helium core. This shell burning yields tremendous
luminosity and also induces the outer layers of the stars to expand up
to AU or greater size. The result is a red giant. The red giant
evolves up the red giant branch, increasing in luminosity until the
tip of the red giant branch. The color of the red giant branch is
largely set by the {\it Hayashi limit}, which determines how low a
temperature the atmosphere can become and still satisfy energy
transport constraints. In the red giant phase, stellar winds can be
active.

The maximum luminosity at the tip of the red giant branch is set by
the onset of helium burning. For stellar masses of $M>2M_\odot$, the
core is nondegenerate and expands, leading the envelope to contract
and the star to become blue; some loops in the color-magnitude diagram
can occur. For lower stellar masses, there is a thermal runaway
process called the {\it helium flash} and the stellar structure
readjusts, with the stars ending up on the {\it horizontal branch},
with a luminosity determined by the core mass (usually around 0.5
$M_\odot$) and the temperature determined by how much envelope was
lost through winds.

The net result of stellar evolution is that at early times the stellar
population is mostly on the main sequence and it is dominated by the
bluest stars. At late times it is dominated by the red giants, which
have recently (within $\sim$ a Gyr) left the main sequence.

Stars are normally classified according to their MK system: OBAFGKM,
which is in order of decreasing temperature. Subclassifications exist
(O1, O2, \ldots, O9, B1, \ldots). Hotter stars are referred to as
``early type'' and cooler stars are referred to as ``late type.''
These classifications are according to their spectra and the ordering
was originally based on the spectral phenomenology, which is why the
current nomenclature appears somewhat random.

Broadly speaking O and B stars have few lines, with He II lines in O
stars, He I lines in B stars, and weak Balmer lines in both. A stars
have strong Balmer lines. Balmer lines become weaker again for later
type stars. In F and G stars, lines of other neutral atoms become
important. Particularly in G stars the Ca II H and K lines (right
below 4000 \AA) appear. In G, K, and particularly M stars, molecular
lines become important as molecules like CH, CN, and TiO become able
to survive in the cooler atmospheres.

In galactic systems, the consequence of stellar evolution is that the
stellar continuum of young systems is dominated by hot stars, yielding
a blue spectrum with few clues to metallicity, whereas the stellar
continuum of old systems is dominated by cooler, old stars, with red
spectra that depend on metallicity (due to variations in the
abundances and their effects on the stellar opacity and therefore
temperature).

\section{Commentary}

The basic consequences of stellar evolution are well-established,
particularly on the main sequence. But the post-main sequence phases
are not well-constrained in terms of (for example) the temperatures to
expect for horizontal branch stars and the numbers and temperatures of
AGB stars (and how dust obscured they should be), among other
uncertainties. Furthermore, the prediction of stellar atmosphere
emission spectra for stars in a given phase and metallicity is not
perfect, nor well constrained by data in all regimes. In addition,
many stars are in binary systems (perhaps the majority of high mass
stars) and the extent to which this matters for the interpretation of
stellar populations is not known.

\section{Key References}

\begin{itemize}
  \item {\it Nucleosynthesis and Chemical Evolution of
  Galaxies, \citet{pagel09a}}; this textbook gives a good introduction
  to the aspects of stellar evolution relevant to galaxies.
\end{itemize}

\section{Important numbers}

\begin{itemize}
\item $M_{\odot} = 1.989 \times 10^{30} {\rm ~kg} $
\item $R_{\odot} = 6.955 \times 10^{8} {\rm ~m} $
\item $T_{\odot}{\rm (surface)} = 5500 {\rm ~K} $
\item $T_{\odot}{\rm (core)} = 1.5 \times 10^7 {\rm ~K} $
\item $L_{\odot} = 3.828 \times 10^{33} {\rm ~erg} {\rm ~s}^{-1}$
\end{itemize}

\section{Order-of-magnitude Exercises}

\begin{enumerate}
\item Argue why higher mass stars produce more of their energy through
    the CNO cycle than lower mass stars do.
\item Detailed stellar evolution calculations predict a main sequence
    lifetime for the Sun of 10 billion years. What fraction of the
    total hydrogen in the Sun needs to be converted to helium to
    provide this lifetime?

\begin{answer}[Author: Matthew Daunt]
If time in the main sequence is T, and the luminosity of the Sun is L,
roughly the total energy spent is:
\begin{equation}
E =  T L
\end{equation}
And since this energy primarily comes from converting the hydrogen to
helium, with the loss of one percent mass,
\begin{eqnarray}
(.01) m_c c^{2} & =&  T L \cr
m_c & =&  \frac{T L}{.01 c^2}
\end{eqnarray}
where $m_c$ is the mass converted in the reaction. For 10 Gyr and
$L\sim 4 \times 10^{33}$ erg s$^{-1}$, a total of $1.3\times 10^{32}$
g of hydrogen is converted to helium. The mass of the Sun is $2\times
10^{33}$ g, of which 75\%, or $1.5\times 10^{33}$ g, is hydrogen at
the beginning of the process. Thus, about 10\% of the hydrogen in the
Sun is converted to helium over its lifetime. Note that the helium ash
created increases the mass fraction from 0.25 to around 0.35, but that
ash is in the core so not apparent in spectra, which reflect the
stellar atmospheric abundances. It also will not be returned to the
interstellar medium, since in the Sun's later phases it will be
burnt mostly into carbon and oxygen.
\end{answer}

\item Estimate the scaling relations between luminosity, mass, and
    surface temperature on the main sequence from the equations of
    stellar structure. Assume that the central temperature $T_c$ is
    approximately constant (it is more like $T\propto M^{-1/2}$ in
    reality). Calculate the scaling separately for high mass stars,
    assuming their opacity is dominated by Thomson scattering, and low
    mass stars, assuming their opacity is dominated by Kramer's Law.

\begin{answer}
Using dimensional analysis, the energy transport equation implies the
relations:
\begin{eqnarray}
\frac{T_c}{R} &\propto& \frac{L \rho}{R^2T_c^3} \mathrm{\quad high~mass}\cr
\frac{T_c}{R} &\propto& \frac{L \rho^2}{R^2T_c^{7.5}} \mathrm{\quad low~mass}
\end{eqnarray}
and we can rearrange these:
\begin{eqnarray}
  L &\propto& \frac{T_c^4 R}{\rho} \propto \frac{T_c^4
  R^4}{M} \mathrm{\quad high~mass} \cr
  L &\propto& \frac{T_c^{8.5} R}{\rho^2} \propto \frac{T_c^{8.5}
  R^7}{M^2} \mathrm{\quad low~mass}
\end{eqnarray}
The hydrostatic equation implies:
\begin{equation}
P \propto \frac{M^2}{R^4}
\end{equation}
and we can convert the ideal gas law ($P = nkT$) to:
\begin{equation}
P \propto \frac{MT_C}{R^3}.
\end{equation}
Equating the two expressions, balancing temperature and density
against gravity leads to:
\begin{equation}
T_c \propto \frac{M}{R}
\end{equation}
or $M\propto R$. Then plugging into the energy transport equation:
\begin{eqnarray}
  L &\propto& M^3 \mathrm{\quad high~mass} \cr
  L &\propto& M^5 \mathrm{\quad low~mass}
\end{eqnarray}
Now we can use the Stefan-Boltzmann law to relate the surface
temperature to the luminosity:
\begin{equation}
L \propto R^2 T_s^4
\end{equation}
If we just average the high and low mass exponents and assert
$L\propto M^4$, it is simple to show that
\begin{equation}
L \propto T_s^8,
\end{equation}
explaining the extremely strong dependence of luminosity on surface
temperature in the Hertzsprung-Russell diagram. Note that using $T_c$
that varies with mass changes these exponents somewhat but only
weakly. Of course getting things right in detail requires detailed
numerical calculations.
\end{answer}
\end{enumerate}

%\section{Analytic Exercises}
%
%\begin{enumerate}
%\end{enumerate}

\section{Numerics and Data Exercises}

\begin{enumerate}
\item Using Gaia, for a relatively nearby open cluster,
plot the HR diagram around it (do not use the parallaxes --- just
leave use the apparent magnitudes). Can you understand its published
age based on what you see in the diagram? How can you determine what
in the diagram is from background or foreground stars and what is from
the open cluster itself?
\item Using Gaia, for a relatively nearby globular cluster, do the
same.
\item Using Gaia and its high signal-to-noise ratio parallaxes,
make a plot of the HR diagram locally. What can you conclude about the
star formation history around us in the Milky Way.
\item Identify a luminous galaxy on the red sequence at low redshift
(say $z<0.03$) from the SDSS spectroscopic survey. Then find a star
(in a low reddening region) with similar $g-r$ colors that has a
spectrum. Compare the spectra in the rest frame.
\end{enumerate}

\bibliographystyle{apj}
\bibliography{exex}


\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{esvect}
\usepackage{graphicx}
\usepackage{float}

\usepackage[a4paper]{geometry}
\newgeometry{left=2.5cm, right=2.5cm, bmargin=3.5cm}

\usepackage{enumitem}
\setlist{topsep=0pt, itemsep=0pt}

\parindent 0pt
\parskip 8pt
%\setlist[itemize]{noitemsep, topsep=0pt}
%\usepackage{multicol}

\usepackage{csquotes}
\usepackage{hyperref}
\title{Simulating the phototaxis response in C. Elegans}
\author{Clemens Hutter \\ chutter [at] uos.de}

%\setlist[itemize]{noitemsep, topsep=0pt}

\begin{document}

\maketitle
\begin{abstract}
The nematode C. elegans will move back once light is shown on its head. This behaviour know as phototaxis was quantified by Ward et al. \cite{Ward2008}. They looked at the timing (onset and duration) of the backward movement after light stimuli of different intensity and wavelength are applied to the worm. With the final goal to replicate the timings for all nine different stimulus configurations tested in the paper I started out with the arbitrary specific case of 350 nm and an intensity of $-1.73 \cdot log(\frac{I}{I_O})$.
In this case the backwards movement starts roughly 1.7 seconds after stimulus onset and will last for about 7 seconds \cite{Ward2008}.
\end{abstract}

\section{Methodology} % (fold)
\label{sec:methodolegy}
I simulated the activity after the stimulus in a simplified neural network \cite{Appiah} based on the C. elegans connectome and used an evolutionary algorithm to arrive at parameters that replicate the response timing in two target motor neurons. The full source code is available here: https://github.com/rauwuckl/CElegansPhototaxis

\subsection{Network} % (fold)
\label{sub:network}
	\begin{figure}
	\centering
	\includegraphics[width=0.5\linewidth]{network}
	\caption{Full inter neural connectivity for the sensory, interneuron and muscle neurons used in our phototaxis model.
	IV.}
	\label{fig:network}
	\end{figure}

The network (Figure \ref{fig:network}) consists of 4 sensory neurons, 4 interneurons and 2 motor neurons \cite{Appiah}. All of the neurons are modelled as Izhikevich quadratic integrate-and-fire spiking neural models \cite{izi}. (with a = 0.02, b= 0.2, c= -65, d= 6). Additionally the 4 sensory neurons receive an additive input current related to surrounding light as
\[I_{light} = \frac{|750- \lambda| \cdot (30+i)}{\lambda}\]
where $\lambda$ is the wavelength of light (in this case 350 nm) and $i$ is the intensity (here $10^{-1.73} \cdot 20 = 0.37$) \cite{Appiah}.

Chemical synapses are modelled as Instantaneous Rise and Single-Exponential Decay synapses:
\begin{align*}
	\frac{dg}{dt} &= -\frac{1}{\tau}\cdot g  \\
	I_{syn} &= w \cdot g \cdot (V_{reversal} - V_{post})
\end{align*}
where g is the exponentially decaying conductivity which is set to 1 at each arriving presynaptic spike, $\tau$ is a time constant fixed for all synapses, $w$ is a synaptic strength constant (different value for each synapse), $V_{reversal}$ is the reversal potential ( $-70 mV$ for inhibitory and $0 mV$ for excitatory synapses), $V_{post}$ is the current membrane potential in the postsynaptic neuron and $I_{syn}$ the synaptic current that will be added to the postsynaptic neuron ($g(t) = w \cdot e ^ {-(t-t_0)/\tau} $ is an equivalent formulation). If there are connections between 2 neurons going back and forth (eg. ASJ$\rightarrow$ASK and ASK$\rightarrow$ASJ) they are explicitly modelled as 2 synapses.

Electrical synapses are modelled symmetrical as
\[I_{syn} = w \cdot(V_{pre} - V_{post})\]
where $w$ is again the strength for a given synapse and $V_{pre}/V_{post}$ the membrane potential in the presynaptic/postsynaptic neuron.

There are 27 chemical and 5 electrical connections (see arrows in Figure \ref{fig:network}). Each of these connections is formed by different numbers of actual synapses (see numbers in the Figure \ref{fig:network}). Since we are assuming a global value for $\tau$ we can (for a given connection between two neurons) just add up all the synaptic currents into one combined synaptic model. The strength of theses `virtual' synapses (simply synapse from now on) will then be proportional to the number of actual synapses (numbers in Figure \ref{fig:network}). i.e. we have only one `virtual' synapse instead of 12 actual synapses from ASH to AVD but the $w$ for this synapse will be 12 times stronger. \\
Therefore our parameter space consists of 32 synaptic weights plus $\tau$. These are represented in a 33-dimensional vector $\vec{w}$ with all elements between 0 and 1. Each value of the parametervector is then mapped into a reasonable range for the corresponding  parameter:
\begin{align*}
	w^{syn}_i &= | \vec{w}_i - 0.5 |  \cdot N^{synapses}_i \cdot 0.5\\
	w^{electrical}_j &= (\vec{w}_j \cdot N^{synapses}_j) \in [0;1] \\
	\tau &= \vec{w}_{33} \cdot 19 + 0.1
\end{align*}
Chemical synapses are set to excitatory for $\vec{w}_i \geq 0.5$ and inhibitory otherwise. Weights for electrical synapses are clipped such that they do not exceed [0:1].

The network is implemented for the brian2 simulator in Python.

% subsection network (end)

\subsection{Parameter finding with evolutionary algorithms} % (fold)
\label{sub:parmeter_finding_with_evolutionary_algorithms}
I was looking for spike patterns in the motor neurons DA and VA that could plausibly cause backwards movement starting 1.7 seconds after stimulus onset and lasting for 7 seconds \cite{Ward2008}. I argue that this would require them to start spiking before the start of the actual movement and to spike for approximately the same duration as the duration of the backward movement. Furthermore the spiking should be regular. The fitness function derived from these constrains is:
\begin{align*}
 differenceStart &= max((FirstSpike - StartResponse),0)^2\\
 differenceEnd &= max((LastSpike - EndResponse),0)^2\\
 differenceDuration &= ((LastSpike - FirstSpike) - DurationResponse)^2\\
 variance &= \textrm{variance of interspike intervals} \\
 fitness &= - (20 \cdot differeceStart + 20 \cdot differenceEnd \\&+ 20 \cdot differenceDuration + 25 \cdot variance)
\end{align*}
where the first two terms will only be non-zero if the spiking occurs after the response. The fitness is assessed for DA and VA independently in this way and then summed.

This fitness function is optimized by the following evolutionary algorithm (adapted from \cite{Luke2013Metaheuristics}):

\begin{figure}[H]
\includegraphics[width=\linewidth]{evolution}
\caption{Pseudocode for the evolutionary algorithm}
\end{figure}

\textbf{selectParent} draws 2 random individuals from the population with replacement and selects the fitter of the two. The \textbf{mutate} function simply adds independent Gaussian noise to each element of $\vec{w}$ ($\sigma = 0.001$). The \textbf{crossover} function performs \textit{Intermediate (Line) Recombination} to produce two children based on two based on two parents:

\begin{figure}[H]
\includegraphics[width=\linewidth]{lineRecombination}
\caption{Pseudocode for Intermidiate Recombination \cite[p. 42]{Luke2013Metaheuristics}}
\end{figure}

The algorithm is implemented in Python and currently employs a multiprocess architecture to make full use of the strong PC available at the lab. To achieve this the entire population is divided into multiple subsets and the fitness in each subset is evaluated by a different job on a different CPU (Data Parallelism). For machines with only 1 or 2 cores a single threaded architecture might be faster. This can be easily changed in the source code.

% subsection subsection_name (end)'
\section{Results} % (fold)
\label{sec:results}
If no noise is added to the membrane potential of the neurons a very good fit is quite easily achievable. But real neurons will undoubtedly be subject to some noise. In this case the quality of a given parameter set $\vec{w}$ will vary considerably from run to run. So the fitness function for a given individual (parameter set) is extremely stochastic.

For this summery I left the evolution running for 82 generations, while evaluating the fitness for each individual at each generation 4 times and averaging over it to achieve a somewhat reliable value.
Then I simulated the network for the fittest individual nine times to give a rough idea of the different activity patterns that arise.

\begin{itemize}
	\item In the best case scenario the network very precisely replicated the response timing (Figure \ref{fig:optimalRun}).
	\item The most common outcome however can be seen in Figure \ref{fig:noStop}. Here the network starts spiking but does not calm back down to rest within the simulation time of 10.5 seconds.
	\item Also common is that the response will last exactly as long as the stimulus exiting the network (Figure \ref{fig:imideateStop}).
\end{itemize}

\begin{figure}[H]
\includegraphics[width=\linewidth]{perfect}
\caption{Trace of optimal run. (3 out of 9 runs with response durations of 7.0, 7.1 and 6.0 seconds)}
\label{fig:optimalRun}
\end{figure}
\begin{figure}[H]
\includegraphics[width=\linewidth]{noStop}
\caption{Most common trace. Spiking does not stop. (5 out of 9 runs)}
\label{fig:noStop}
\end{figure}
\begin{figure}[H]
\includegraphics[width=\linewidth]{imideateStop}
\caption{Spiking stops immediately. (1 out of 9 runs)}
\label{fig:imideateStop}
\end{figure}

\section{Discussion} % (fold)
\label{sec:discussion}
I believe that the target response we are trying to achieve within the network is very unstable. The network has to get excited by external input which then is turned off after which the spiking response must not change. Then it has to stay excited for a set amount of time and after that it autonomously has to calm down without any change in input. \\
This I think happens once a short interval occurs in which all neurons in the highly recursive network are \textit{`by chance'} in their refractory period. Then the self sustaining circle of excitation is stopped and the activity fades away. But as soon as we add even a little noise the exact spike times of all neurons will be shifted a little against each other. The interval of accidental silence can now occur at a completely different time (or not at all). Because of this intuition I figure that it is impossible to find parameters which are able to reproduce the behaviour reliable over multiple runs.

Also it is still unclear how higher activity in those two motorneurons actually relates to backward movement.

\small{Disclaimer: \textit{What is referred to as neurons (DMA, AVA, etc.) in this paper are actually neuron classes.}}

\bibliographystyle{unsrt}%alternative alpha
\bibliography{bibliography}

\end{document}


\documentclass[12pt]{article}
\usepackage[usenames]{color} %used for font color
\usepackage{amsmath, amssymb, amsthm}
\usepackage{wasysym}
\usepackage[utf8]{inputenc} %useful to type directly diacritic characters
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{float}
\usepackage{mathtools}
\usepackage [english]{babel}
\usepackage [autostyle, english = american]{csquotes}
\MakeOuterQuote{"}
\graphicspath{ {./} }
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\prob}{\mathbb{P}}
\newcommand{\M}{\mathcal{M}}
\newcommand{\degrees}{^{\circ}}
\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}

\author{Tianshuang (Ethan) Qiu}
\begin{document}
\title{Math 74, Week 10}
\maketitle

\section{Mon Lec, 6c}
$$z^{n-1}-1 = \prod_{k=0}^{n-1}(z-\omega_k)$$
As shown in class, the complex roots are evenly spaced across the unit circle, $2\pi/n$ apart. So we have
$$\omega_k = e^{2\pi i \frac{k}{n}}$$

\section{Mon Lec, 6f}
$$(z-1)(z^{n-1}+z^{n-2}+...+z^{2}+z+1) = (z^n+z^{n-1}+...+z^2+z)-(z^{n-1}+z^{n-2}+...+z+1)=z^n-1$$
Therefore we can switch our statement to $\frac{z^n-1}{z-1}$
\newline
Now we subsitute our answer from the previous question in, and since $\omega_0=1$, it cancels out with the first term.
\newline
We can factor the expression into
$$\prod_{k=1}^{n-1}(z-\omega_k)$$
where
$$\omega_k = e^{2\pi i \frac{k}{n}}$$
Essentially the same as 6c but with $z=1$ removed.

\section{Mon Lec, 7b}

\subsection{6c}
Sum: $-\frac{0}{1}=0$
\newline
Product: $(-1)^n\frac{1}{1} = (-1)^n$

\subsection{6f}
Sum: $-\frac{1}{1}=-1$
\newline
Product: $(-1)^n\frac{0}{1} = 0$
\newpage

\section{Mon Dis, 1a}
$$|A_0A1|...|A_0A_8|=\prod_{k=0}^{8}|1-\omega_k|=|\prod_{k=0}^{8}(1-\omega_k)|$$
The last equivalency is due the fact that multiplication of the modulus is equal to the modulus of the product.
\newline
We have proven above that $(z-1)(z^{n-1}+z^{n-2}+...+z^{2}+z+1)=z^n-1$, so consider
$$\frac{z^n-1}{z-1}=\frac{(z-1)(z^{n-1}+z^{n-2}+...+z^{2}+z+1)}{z-1}=z^{n-1}+z^{n-2}+...+z^{2}+z+1$$
Now using the roots of the polynomial we know that $z^9-1=(z-1)(z-\omega)...(z-\omega^8)$, in this case we have divided out $z-1$, so we have
$$z^8+z^7+...+1=(z-\omega)...(z-\omega^8)$$
Let $z=1$, and we have $9=(z-\omega)...(z-\omega^8)$, since $|9|=9$, we have shown that $|A_0A1|...|A_0A_8|=9$

\section{Mon Dis, 3f}
Let $x=y-2$, so $x^3=y^3-6y^2+12y-8$. Now we plug $y$ back
$$y^3-6y^2+12y-8 = -6(y-2)^2-12y+24-6$$
$$y^3-6y^2+12y-8 = -6y^2+12y-6$$
$$y^3 = 2$$
Now since we know that $2^3=8$, we can directly solve:
$y_1= \sqrt[3]{2}, x_1=\sqrt[3]{2}+2$
\newline
Then we factor $(y^3)/(y-\sqrt[3]{2})=y^2+\sqrt[3]{2}y+\sqrt[3]{4}$ Now we apply the quadratic formula to get
$$y_2=\frac{-1-\sqrt3i}{\sqrt[3]{2}}, y_3=\frac{-1+\sqrt3i}{\sqrt[3]{2}}$$
So we have $x_2=\frac{-1-\sqrt3i}{\sqrt[3]{2}}-2, x_3=\frac{-1+\sqrt3i}{\sqrt[3]{2}}-2$

\end{document}


\newpage
\input{Title}
\section{Blocks and Community structure}

\begin{textbox}{Blocks and Communities: Definition}
The general idea of blocks and communities is that nodes of a network can be grouped together in homogeneous sets, based on the network topology. The problem of automatically discovering those groups is one of the most studied problem of network science, but also one of the most poorly defined.

\end{textbox}

\begin{textbox}{Block structure}
The general idea of the block structure is that the probability to observe an edge between two nodes is a function of the blocks they belong to. Usually, no assumption is made apriori about those probabilities: they can be high between nodes belonging to the same blocks or to different blocks, and can differ for each pair of block.

This definition thus defines a random graph model, related to the ER random model, known as the \textbf{Stochastic block model}.
\end{textbox}

\begin{textbox}{Community structure}
The idea of having a network structured in \textbf{communities} is defined as an analogy with communities in social networks. Communities are therefore defined (informally) as groups of nodes that are strongly connected between themselves (\textbf{high internal density}) and more weakly connected to the rest of the network \textbf{low external density}.

This definition however cannot be translated unambiguously into a mathematical formulation. The problem of \textbf{community detection}, or community discovery, is therefore complicated to define.
\end{textbox}

\begin{textbox}{Partitions/Overlap}
We must differentiate two types of node grouping:
\begin{enumerate}
    \item A \textbf{Partition} of a graph is a division of its nodes such as each of them belong to one and only one group.
    \item Overlapping communities/blocks allow, on the contrary, nodes belonging to several groups. Unless specified differently, they also allow nodes to belong to no group.
\end{enumerate}
Algorithms searching partitions are much more common than those searching for overlapping groups, due to the increased complexity of the later task. Overlapping community detection is, nevertheless, an active field of research.
\end{textbox}

\begin{textbox}{Definition}
\begin{tabular}{p{0.08\textwidth}|p{0.8\textwidth}}\scriptsize

$C$ & a \textit{community partition}, or, more generally, a set of set of nodes \\
$c_i$ & community $i$, a set of nodes \\
\end{tabular}
\end{textbox}

\begin{textbox}{Modularity}
The most famous quality function to measure the \textit{quality} of partitions is called the \textbf{Modularity}. Introduced in \footcite{girvan2002community}, it is defined for a partition $C$ and a graph $G$ as the difference between the fraction of observed internal edges and the expected fraction of internal edges if $G$ were rewired according to a configuration model, i.e., preserving the degrees of nodes.

More formally,
\[
Q=\frac{1}{L}\sum_{i=1}^{|C|}(L_{i}-\frac{1}{2}K_i^2)
\]
with $L_{i}=L(H(c_i))$ the number of edges inside community $i$ and $K_i=\sum_{u \in c_i}k_u$ the sum of degrees of nodes in community $i$.

The original formulation of modularity, often found in the literature, is:
\[
Q=\frac{1}{2L}\sum_{uv}\left[ A_{uv}-\frac{k_uk_v}{2L}\right] \delta(c_u,c_v)
\]
with $\delta(c_u,c_v)$ the kronecker delta between communities, i.e., $\delta(c_u,c_v)=1$ if nodes $u$ and $v$ belongs to the same community, 0 otherwise.

\end{textbox}

\begin{textbox}{Modularity: null model}
The modularity as expressed above compares the number of edges inside communities to the expected number of edges in a \textbf{null model}, i.e., a randomized version of the graph. In the original version, this null model is the \textbf{configuration model} (as easily recognized in the $\frac{k_uk_v}{2L}$ of the original formula-.

Variants of the modularity have been proposed using different null models \footcite{jutla2011generalized}, for instance an ER null model, or a gravity model to take into account the effect of physical distance \footcite{expert2011uncovering}
\end{textbox}

\begin{textbox}{Modularity: null model}
The modularity as expressed above compares the number of edges inside communities to the expected number of edges in a \textbf{null model}, i.e., a randomized version of the graph. In the original version, this null model is the \textbf{configuration model} (as easily recognized in the $\frac{k_uk_v}{2L}$ of the original formula-.

Variants of the modularity have been proposed using different null models \footcite{jutla2011generalized}, for instance an ER null model, or a gravity model to take into account the effect of physical distance \footcite{expert2011uncovering}
\end{textbox}

\begin{textbox}{Modularity: resolution limit}
It is important to remember that the Modularity is (only a) \textbf{quality function}, not a definition of the quality of communities. An important drawback is known as the \textbf{limit of resolution}\footcite{fortunato2007resolution}. It says that partitions of maximal modularity are biased toward a particular \textit{scale}, i.e., for a graph of a give size (\#nodes, \#edges), communities smaller or larger than a certain size cannot be found. The typical example of this limit is the clique-ring structure (set of cliques connected by a single edge), in which the expected partition is to have one community by clique, while the solution of highest modularity put several cliques in the same community, when we increase the number of cliques.

\includegraphics[width=0.7\textwidth]{ringclique.png}
\end{textbox}

\begin{textbox}{Modularity and random networks}
Another well known limitation of a Modularity maximization approach is that it finds communities with high scores in random networks: since it is not \textit{adjusted for chance}, random flucutations in a random network are mistaken for meaningful structure in the network.
\end{textbox}

\begin{textbox}{Multi-resolution Modularity}
A simple solution has been proposed to the limit of resolution, consisting in adding a resolution parameter $\lambda$ to \textit{tune} the desired resolution\cite{reichardt2006statistical}, i.e., $(L_{i}-\frac{1}{2}K_i^2)$ becomes $(L_{i}-\lambda \frac{1}{2}K_i^2)$. It raises of shrink the expected number of edges inside communities. It requires, however, to choose a proper value for $\lambda$, i.e., to choose arbitrarily a scale for communities.
\end{textbox}

\begin{textbox}{Modularity maximization: Girvan Newman}
Several of the most popular community detection algorithms have as objective to discover the partition of highest modularity. This is a difficult problem, and thus existing approaches are based on heuristics.

The first method by Girvan and Newman \footcite{girvan2002community} first build a dendromgram by iteratively removing edges of highest betweenness. It is called a \textit{divise} approach: At the top of the dendrogram, there is a single community, then 2, 3, 4 etc., until each node is in its own community. Modularity is used as a criterium to \textit{cut} the dendrogram.

\centering
\includegraphics[width=0.7\textwidth]{dendrogram.jpg}

\end{textbox}

\begin{textbox}{Modularity maximization: Louvain method}
The Louvain method\footcite{blondel2008fast} is certainly the most used method for community detection. Its objective is to optimize the modularity using a greedy, agglomerative approach, composed of two steps:

\textbf{Step 1}: Optimizing modularity at a hierarchical level
\begin{itemize}
    \item Each node starts in its own community
    \item Repeat until convergence:
    \begin{enumerate}
        \item \textbf{FOR} each node, compute the gain in modularity of adding it to the community of each of its neighbors
        \item choose the decision that increase the most the modularity (the best decision can be to remain in the same community
    \end{enumerate}
\end{itemize}

\textbf{Step 2}: Global algorithm
\begin{itemize}
    \item Repeat until convergence:
    \begin{enumerate}
        \item Optimize modularity for the current hierarchical level
        \item Move to a higher hierarchical level by computing an \textbf{induced network}: Each community becomes a node, the weight of the edge between nodes/communities $i$ and $j$ corresponds to the number of edges between nodes of $c_i$ and nodes of $c_j$.
    \end{enumerate}
\end{itemize}

The result of Louvain algorithm is therefore a \textbf{hierarchy} of communities.

The main reason explaining the popularity of the Louvain method to this day is its
   \textbf{scalability}: The algorithm is very efficient in practice on real graphs, for several reasons: 1)It is a greedy approach,2) By checking only the interest of moving to neighbor's communities, it benefits from the sparsity of networks, 3)Modularity gains of a partition change can be computed locally, using its definition as a sum of independent values for each community.

\end{textbox}

\begin{textbox}{Infomap}
Infomap\cite{rosvall2008maps} is a method based on an objective function different from the Modularity. Its objective is to \textbf{Minimize the description of an average random walk} in the network, i.e. maximize the \textbf{compression} of the description of such a walk. More formally, the code length to minimize for partition $M$ is described as:
\[
H(M)=qH(\curvearrowright)+\sum_i^Cp^iH(\circlearrowright_i)
\]
with $q$ the probability for a move to be between modules,$H(\curvearrowright)$ the information required to encode a move between modules, $p^i$ the probability for a move to be inside community $i$ and $H(\circlearrowright_i)$ the information required to encode a move inside community $i$

A greedy optimization algorithm, similar in nature to the one of Louvain, is then used to minimize this description length.

Compared with Modularity, the main advantage of this approach is that it does not find communities in random networks. It is known also to suffer from a resolution limit, although not exactly similar to the one of Modularity.
\end{textbox}

\begin{textbox}{Stochastic Block Models (SBM)}
A stochastic block model is a random graph model defined by:
\begin{itemize}
\item $k$: number of blocks
    \item $b$ a $n\times 1$ vector such as $b_i$ describes the index of the block of node $i$.
    \item $E$ a $k\times k$ \textbf{stochastic block matrix}, such as $E_{ij}$ gives the number of edges between blocks $i$ and $j$ (or equivalently, the probability to observe an edge between any pair of nodes chosen with one node in each of the two blocks).
\end{itemize}
\end{textbox}

\begin{textbox}{SBM inference}
The objective of a community/block detection algorithm based on this principle is thus to perform \textbf{SBM inference}, i.e., to find the parameters of the SBM that best explain the observed graph, usually in term of maximizing the likelihood. Said differently, we search --among a certain class of models-- the model that has the highest probability to generate the observed graph. Note that for an observed graph, for each partition in blocks $b$, there is a single block matrix $E$ that is relevant to consider, that can be found simply by counting the number of edges actually present between blocks in the graph.

More formally, the objective is:
\[
b:=\argmax_{b} P(A|b)
\]

Note that with this formulation, it is not possible to infer the number of clusters $k$, since the trivial solution in which each node belongs to its own block, with $E=A$ has a maximal probabity (1) to generate the observed graph. The desired number of clusters is thus a necessary parameter of SBM inference.
\end{textbox}

\begin{textbox}{SBM with inference of the number of blocks}
Recently, new approaches\footcite{peixoto2019bayesian} have been proposed to be able to infer also the number of blocks. They adopt an approach from Information Theory called the Minimum Description Length (MDL), whose principle is to find the description which reduces the total cost of describing a graph, by minimizing both 1)The quantity of information needed to encode the graph, knowing that it is generated by a given model, and 2)The quantity of information needed to encode the model itself. Intuitively, a model with few blocks requires little information to be described, contrary to a model with many blocks. But a model with many block is more \textbf{constrained}, the graphs it generates are more \textit{specific}, and therefore can be described at a lesser cost, knowing the model.

More formally, we can decompose the probability of observing a graph and a model as $P (A, k, e, b) = P (A|k, e, b)P (k|e, b)P (e|b)P (b)$ with the last three probability being \textit{priors}.  Said differently, we can define the number of bits required to encode a model as $L = -log_2 P(k,b)$, the number of bits necessary to encode a graph knowing the model as $S = -log_2 P(A|k,b)$ and thus the total cost to minimize as $S+L$. The objective thus becomes:
\[
b:=\argmin_{b} - log_2 P(k,b) - log_2 P(A|k,b)
\]

\end{textbox}

\begin{textbox}{Variants of the SBM}
Group inference using SBM is a very active field of research, and many variants have been proposed, including degree-corrected, nested, Overlapping, Mixed membership SBM, etc.

An introduction to the state of the art can be found for instance in \footcite{lee2019review}.

A python library \footnote{https://graph-tool.skewed.de} exists to apply recent methods to observed graphs.
\end{textbox}

\begin{textbox}{Evaluation of Community structures}
Since there isn't a unique accepted definition of what are good communities, the evaluation of the quality of a partition or set of communities is not a trivial task.

There are two main approaches:
\begin{itemize}
    \item \textbf{Internal evaluation} consists in using \textit{quality functions} (e.g., Modularity) to give a score for a pair partition-graph
    \item \textbf{External evaluation} consists in comparing a computer partition to a \textbf{ground truth} reference partition.
\end{itemize}
\end{textbox}

\begin{textbox}{Internal Evaluation}
Several quality functions exist to evaluation the quality of a community partition of a graph. They can therefore be understood as different \textit{definitions} of communities. While some methods try directly to optimize one of those quality functions, some other methods are based on different principles (e.g., clique-based communities, consensus reaching based on game-theory, etc.). Quality functions can therefore be used a posteriori to assess the quality of communities they found.

The most popular are:
\begin{itemize}
    \item \textbf{Modularity}
    \item \textbf{Information compression}, as in Infomap or SBM
    \item \textbf{Surprise} \cite{aldecoa2013surprise} evaluates the departure of the observed partition from the expected distribution of nodes and links into communities given a null model, and is therefore related to modularity
\end{itemize}, Conductance, , cut-ratio, and Surprise.

Some other quality functions are defined \textbf{for individual communities}, although they can be combined to provide a global score. The most popular are\footnote{leskovec2010empirical}:
\begin{itemize}
    \item \textbf{Conductance}, the fraction of all stubs of nodes in the community that points outside of it
    \item \textbf{ODF}, Out Degree Fraction, the average for every node of its fraction of neighbors inside the community
    \item \textbf{Internal Transitivity}, the clustering coefficient inside the community
    \item \textbf{Scaled density}, the ratio of the node density to the total graph density
\end{itemize}

\end{textbox}

\begin{textbox}{External Evaluation}
Partitions obtained by a given method can be compared with a ground truth. This approach is used on real networks, with a ground truth coming from metadata (e.g., classes in a network of social interactions between students), and on synthetic networks, with communities known by construction.

Although this is still discussed in the literature, it is mostly accepted that the evaluation on real networks using this approach is problematic\footcite{peel2017ground}, because there is no guarantee that the labels used as ground truth are indeed related to the \textbf{topological structure} of the network, which is what communities are about.

Most popular methods for partitions comparisons are:
\begin{itemize}
\item \textbf{NMI}, Normalized Mutual Information, and its adjusted for chance variant, \textbf{AMI}.
\item \textbf{ARI}, Adjusted Rand Index
\end{itemize}
But more generally, any method for cluster comparison can be used\footcite{dao2020community}
\end{textbox}

\begin{textbox}{Overlapping communities}
For many types of networks, the real organization of networks is thought to be overlapping, i.e., each node can belong to several communities. Think of your personal social networks: some of your family members might also be part of a group of friends, or some of your friends from high school might also be part of your friends from university, which are otherwise distinct groups.

Detecting overlapping clusters is considered harder than non-overlapping ones, for two reasons: the search space (number of possible solutions) is much larger (and even infinite), and defining what good communities are is even harder, since there isn't the natural limit for each edge to be either internal or external.

A large number of methods have nevertheless been proposed\footcite{xie2013overlapping}. Extensions of non-overlapping quality functions have been proposed, such as the overlapping Modularity \footcite{nicosia2009extending}, or overlapping NMI \footcite{mcdaid2011normalized}.
\end{textbox}

\begin{textbox}{Other meso-scale structures}
Beyond the community structures we have alredy defined, other types of network structural organization have been proposed and studied. Some of the most widely known are:
\begin{itemize}
    \item \textbf{Link communities}, in which communities are defined as \textit{sets of links}. Searching for (non-overlapping) partitions of edges yield a structure in which nodes naturally belong to several groups, i.e., a community can correspond to \textit{familial} edges, another to \textit{professional} edges, etc. (\cite{ahn2010link})
    \item \textbf{Fuzzy communities}, in which nodes belong to (often several) communities with a certain probability or strength (\cite{liu2010fuzzy})
    \item \textbf{Core-Periphery structure}, already defined when we introduce the notion of \textit{k-cores}
    \item \textbf{Nestedness}, corresponding to a network with a hierarchical organization such as elements with few connections tends to be connected to a subset of the neighbors of a \textit{parent} node. (\cite{pawar2014plant})
    \item \textbf{Spatial organization}, in which the probability of observing an edge between nodes depends on their distance. (\cite{barthelemy2011spatial})
\end{itemize}
\end{textbox}


% Created 2021-11-15 Mon 07:24
% Intended LaTeX compiler: pdflatex
\documentclass[presentation,aspectratio=1610]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{khpreamble}
\usepackage{amssymb}
\DeclareMathOperator{\shift}{q}
\DeclareMathOperator{\diff}{p}
\usetheme{default}
\author{Kjartan Halvorsen}
\date{\today}
\title{Discretizing continuous-time controllers}
\hypersetup{
 pdfauthor={Kjartan Halvorsen},
 pdftitle={Discretizing continuous-time controllers},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 26.3 (Org mode 9.4.6)},
 pdflang={English}}
\begin{document}

\maketitle

\section{Intro}
\label{sec:org9a2e388}

\section{Discretization}
\label{sec:orgee27423}
\begin{frame}[label={sec:orgd3c4ac1}]{Context}
\begin{itemize}
\item Controller \(F(s)\) obtained from a design in continuous time.
\end{itemize}
\pause
\begin{itemize}
\item Need discrete approxmation in order to implement on a computer
\end{itemize}

\begin{center}
 \includegraphics[width=0.7\linewidth]{../../figures/fig8-1.png}\\
 \footnotesize Source: Åström \& Wittenmark
\end{center}
\end{frame}

\section{Implementation}
\label{sec:orgdbdfb7b}
\begin{frame}[label={sec:org852548e}]{Stability for the disk drive arm}
\small
Case \(\frac{h^2}{J} = 1\). Suggested controller:

\begin{center}
\begin{tikzpicture}
\tikzset{node distance=2cm,
    block/.style={rectangle, draw, minimum height=12mm, minimum width=14mm},
    sumnode/.style={circle, draw, inner sep=2pt}
}

  \node[coordinate] (input) {};
  \node[block, right of=input] (TR) {$F_f(z) = 0.2K$};
  \node[sumnode, right of=TR, node distance=30mm] (sum) {\tiny $\sum$};
  \node[block,right of=sum, node distance=30mm] (plant) {$H(z) = \frac{z+1}{2(z-1)^2}$};
  %\node[sumnode, right of=plant, node distance=30mm] (sumdist) {$\sum$};
  %\node[coordinate, above of=sumdist, node distance=15mm] (dist) {};
  %\node[coordinate, right of=sumdist, node distance=15mm] (measure) {};
  \node[coordinate, right of=plant, node distance=30mm] (output) {};
  \node[coordinate, right of=plant, node distance=22mm] (measure) {};
  %\node[sumnode,below of=measure, node distance=25mm] (sumnoise) {$\sum$};
  %\node[coordinate, right of=sumnoise, node distance=15mm] (noise) {};
  \node[block,below of=plant, node distance=20mm] (SR) {$F_b(z)=K\frac{z-0.8}{z}$};
  \draw[->] (input) -- node[above, pos=0.2] {$y_{ref}(k)$} (TR);
  \draw[->] (TR) -- node[above] {$u_1(k)$} (sum);
  \draw[->] (sum) -- node[above] {$u(k)$} (plant);
  \draw[->] (plant) -- node[at end, above] {$y(k)$} (output);
  \draw[->] (measure) |- (SR);
  \draw[->] (SR) -| (sum) node[right, pos=0.8] {$u_2(k)$} node[left, pos=0.96] {$-$};
\end{tikzpicture}
\end{center}
\end{frame}

\section{Preliminaries}
\label{sec:orga443f1b}
\begin{frame}[label={sec:orgdde3b0a}]{Preliminaries}
\end{frame}

\begin{frame}[label={sec:org3c5baf1}]{Z-transform of a shifted sequence}
\[ x(k) \quad  \overset{\mathcal{Z}}{\longleftrightarrow} \quad X(z)= \sum_{k=0}^{\infty} x(k)z^{-k} \]
\pause
\[ x(k+1) \quad  \overset{\mathcal{Z}}{\longleftrightarrow} \quad zX(z) - zx(0)\]

\pause
\begin{block}{Proof}
\begin{align*} \ztrf{x(k+1)} &= \sum_{k=0}^{\infty} x(k+1)z^{-k} = \sum_{n=1}^{\infty} x(n)z^{-(n-1)}\\
&=  \sum_{n=1}^{\infty} x(n)z^{-n}z = -zx(0) + z\underbrace{\sum_{n=0}^{\infty} x(n)z^{-n}}_{X(z)}\\
&= zX(z) - zx(0).
\end{align*}
\end{block}
\end{frame}

\begin{frame}[label={sec:org207d837}]{Discrete-time delay}
\[ x(k-1) \quad  \overset{\mathcal{Z}}{\longleftrightarrow} \quad \frac{1}{z}X(z))\]
\end{frame}

\begin{frame}[label={sec:orge29d69a}]{Stability for the disk drive arm}
\small
Case \(\frac{h^2}{J} = 1\). Suggested controller:

\begin{center}
\begin{tikzpicture}
\tikzset{node distance=2cm,
    block/.style={rectangle, draw, minimum height=12mm, minimum width=14mm},
    sumnode/.style={circle, draw, inner sep=2pt}
}

  \node[coordinate] (input) {};
  \node[block, right of=input] (TR) {$F_f(z) = 0.2K$};
  \node[sumnode, right of=TR, node distance=30mm] (sum) {\tiny $\sum$};
  \node[block,right of=sum, node distance=30mm] (plant) {$H(z) = \frac{z+1}{2(z-1)^2}$};
  %\node[sumnode, right of=plant, node distance=30mm] (sumdist) {$\sum$};
  %\node[coordinate, above of=sumdist, node distance=15mm] (dist) {};
  %\node[coordinate, right of=sumdist, node distance=15mm] (measure) {};
  \node[coordinate, right of=plant, node distance=30mm] (output) {};
  \node[coordinate, right of=plant, node distance=22mm] (measure) {};
  %\node[sumnode,below of=measure, node distance=25mm] (sumnoise) {$\sum$};
  %\node[coordinate, right of=sumnoise, node distance=15mm] (noise) {};
  \node[block,below of=plant, node distance=20mm] (SR) {$F_b(z)=K\frac{z-0.8}{z}$};
  \draw[->] (input) -- node[above, pos=0.2] {$y_{ref}(k)$} (TR);
  \draw[->] (TR) -- node[above] {$u_1(k)$} (sum);
  \draw[->] (sum) -- node[above] {$u(k)$} (plant);
  \draw[->] (plant) -- node[at end, above] {$y(k)$} (output);
  \draw[->] (measure) |- (SR);
  \draw[->] (SR) -| (sum) node[right, pos=0.8] {$u_2(k)$} node[left, pos=0.96] {$-$};
\end{tikzpicture}
\end{center}
\end{frame}

\section{Warm-up: Differentiation}
\label{sec:orge452f6d}

\begin{frame}[label={sec:org21c3107}]{Differentiation}
\begin{center}
\includegraphics[width=0.5\linewidth]{../../figures/block-simple-derivative}
\end{center}
\end{frame}

\begin{frame}[label={sec:orgcb70291}]{Discrete-time differentiation}
\begin{columns}
\begin{column}{0.4\columnwidth}
\vspace*{5mm}

\includegraphics[width=\linewidth]{../../figures/block-simple-discrete-derivative-fwd-z}

\textcolor{white}{Space}

\begin{center}
\includegraphics[width=\linewidth]{../../figures/block-simple-discrete-derivative-z}
\end{center}

\alert{Activity} Write as difference equation \[ y(kh) = \]
\end{column}
\begin{column}{0.6\columnwidth}
\end{column}
\end{columns}
\end{frame}

\section{Implementing the}
\label{sec:org6dea8f3}
\section{Discretization}
\label{sec:org49d922d}
\begin{frame}[label={sec:org2985245}]{Discretization methods}
\begin{enumerate}
\item Forward difference. Substitute
\[ s = \frac{z-1}{h} \] in \(F(s)\) to get
\[ F_d(z) = F(s')|_{s'=\frac{z-1}{h}}. \]
\item Backward difference. Substitute
\[ s = \frac{z-1}{zh} \] in \(F(s)\) to get
\[ F_d(z) = F(s')|_{s'=\frac{z-1}{zh}}. \]
\end{enumerate}
\end{frame}
\begin{frame}[label={sec:orge7a582c}]{Discretization methods, contd.}
\begin{enumerate}
\setcounter{enumi}{2}
\item Tustin's method (also known as the bilinear transform). Substitute
\[ s = \frac{2}{h}\frac{z-1}{z+1} \] in \(F(s)\) to get
\[ F_d(z) = F(s')|_{s'=\frac{2}{h}\cdot \frac{z-1}{z+1}}. \]
\item Ramp invariance. This is similar to ZoH, which is step-invariant approximation.
Since a unit ramp has z-transform \(\frac{zh}{(z-1)^2}\) and Laplace-transform \(1/s^2\),  the discretization becomes
\[ F_d(z) = \frac{(z-1)^2}{zh} \ztrf{\laplaceinv{\frac{F(s)}{s^2}}}. \]
\end{enumerate}
\end{frame}

\begin{frame}[label={sec:org4083e78}]{Frequency warping using Tustin's}
\begin{center}
\includegraphics[width=0.6\linewidth]{../../figures/fig8_3.png}
\end{center}
The infinite positive imaginary axis in the s-plane is mapped to the finite-length upper half of the unit circle in the z-plane.
\end{frame}
\begin{frame}[label={sec:org76d75fe}]{Forward difference exercise}
\begin{center}
\includegraphics[width=\linewidth]{../../figures/forward-diff-exercise}
\end{center}
\end{frame}

\begin{frame}[label={sec:org2f76a46}]{Backward difference exercise}
\begin{center}
\includegraphics[width=\linewidth]{../../figures/backward-diff-exercise}
\end{center}
\end{frame}
\end{document}