%\begin{tcolorbox}[colback=exposed-colour!50,coltext=white,bottom=-35pt]
\chapter{Compartmental models}\label{ch:compartments}
%\end{tcolorbox}
\section{SIR model}
%\paragraph{Introduction}
We begin our study of mathematical epidemiology with the SIR model, a simple deterministic compartmental model that manages to provide some key insights into the spread of infectious disease. Compartmental models split a population into discrete groups called classes or compartments. Making assumptions about how individuals can transfer between these compartments allows us to formulate the systems in terms of differential equations\cite{models-epidemiology}.\\
\\
The SIR model is a special case of the Kermack-McKendrick model that was one of the first mathematical models of epidemics\cite{kermack-mckendrick}. Its simplicity makes it both a good introduction to some concepts and techniques in mathematical epidemiology as well as a flexible template for developing more specialised and nuanced compartmental models.
\subsection{Building the model}
Suppose there is a population of $N$ individuals. Let each individual belong to one of three classes: susceptibles, infective and removed\footnote{The less sinister `recovered' is also used in the literature but is more technically a subset of `removed'.}. They are denoted $S$, $I$ and $R$ respectively. The susceptibles are those who are \textit{at risk} of infection to the disease, the infectives are those who can \textit{currently} spread the disease and the removed can no longer infect others. Individuals who are removed can have already had the infection and recovered with full acquired immunity. They can also have been immunised against the disease, been quarantined or simply died. Whilst to an individual it clearly matters which of these states they are in, they are largely equivalent from the point of view of an applied mathematician.\\
\\
The SIR model supposes that individuals can move from class $S$ to $I$ and from $I$ to $R$. No other movement between classes is possible. Medically, the fact that infective individuals can only move to removed is equivalent to assuming that the disease gives immunity to recovered patients\footnote{A separate class of models called SIS models suppose that no immunisation is bestowed upon recovered patients and they simply move back to the susceptible class. This fundamentally different compartmental structure results in different long term dynamics. Notably SIS models allow the possibility of endemic disease. Endemic disease is a constant presence of disease in a population that does not have outbreaks but also does not die off. As will be seen, this is not possible in the SIR model.}\label{mmd}.\\
\\
Let $S(t),I(t),R(t)$ denote the number of individuals in class $S,I,R$ respectively at time $t$. We now need a host of assumptions to make the problem tractable\cite{models-epidemiology-2}. The first two are to allow us to use partial differential equations:
\begin{enumerate}[noitemsep, label=(\roman*)]
	\item\label{SIR-as-cont} \textit{The number of individuals is a continuous variable}. We assume that we can have fractions of people. This assumption allows us to use differential equations to study the system.
	\item\label{SIR-as-det} \textit{The spread of the epidemic is deterministic}. We assume that the outcome of the epidemic is determined completely by the past history of the system and the rules. This allows us to avoid any element of stochasticity which would suggest the need for more complicated techniques such as stochastic differential equations.
\end{enumerate}
The next assumptions relate to the infection and allow us to simplify the rules of the model:
\begin{enumerate}[resume, noitemsep, label=(\roman*)]
\item\label{SIR-as-pop} \textit{Population size is constant}. So $N=S+I+R$. This can be justified by saying that the time scale of the disease is much shorter than the time scale of demographic change.
\item\label{SIR-as-birth} \textit{There are no births and the only deaths are as a result of the disease}. Note that this is different to \ref{SIR-as-pop} as having a birth for each death would satisfy condition \ref{SIR-as-pop} but lead to different dynamics. Indeed it would amount to introducing a mechanism that allows some members of the removed population to transfer to the susceptible population.\label{mmd}
\item\label{SIR-as-ma} \textit{The law of mass-action applies to contacts between individuals\cite{mass-action}}. The probability of a random contact between two individuals is proportional to the product of the size of each of the groups they belong to. This means that, for example, both an infective and susceptible individual are just as likely to meet an infective individual.
\end{enumerate}
In practice \ref{SIR-as-cont} and \ref{SIR-as-ma} are the most problematic assumptions, particularly for modelling the beginning of the disease. \ref{SIR-as-cont} is acceptable when the population is large and the disease well-established. However at the beginning of a disease outbreak the discrete nature of individuals becomes critical. Similarly \ref{SIR-as-ma} ignores how an outbreak can be avoided by the disease dying out by failing to spread outside of a small infective population. The models in chapter \ref{ch:abms} address these problems by relaxing both of these assumptions as well as \ref{SIR-as-det}. The result is a model that is more effective at describing the outbreak of disease. With this caveat, let's continue.\\
\\
With the set-up described so far and the above assumptions, we can express the rate of change in the size of each class. This results in the system of differential equations:
\begin{eqnarray}
	\dot S=- \beta S I\label{SIR1}\\
	\dot I=\beta S I-\alpha I\label{SIR2}\\
	\dot R=\alpha I\label{SIR3}
\end{eqnarray}
\text{with initial conditions: }$S(0)=S_0\geq0, I(0)=I_0\geq0, R(0)=0$\\
\begin{figure}
	\centering
	\includegraphics[width=\linewidth]{compartmental-models/SIR-compartments.png}
	\caption{Flowchart of the Kermack–McKendrick SIR epidemic model. The circles represent the compartments and the arrows show allowed transfers between them with the associated parameters of transfer rates above.}
\end{figure}
\\
Eq. (\ref{SIR1}) is justified by noting that the infection rate is positively correlated to the number of contacts between $S$ and $I$. We then use the law of mass action from assumption \ref{SIR-as-ma} to say that the number of contacts between infectives and susceptibles is proportional to the product of the size of the two interacting classes, $SI$. Introducing a proportionality constant $\beta>0$, we can say that $\beta SI$ individuals are infected per unit time. Here $\beta$ denotes the \textit{transmission rate}\footnote{Note there are different ways of defining $\beta$ that lead to a different dynamical system. The other popular way is to define $\beta$ in a way that leads to $\dot S=-\frac{\beta S I}{N}$. This has some potential benefits but it obscures the pedagogy.}. $\beta$ is a parameter that is the product of how often contacts between susceptible and infective individuals occur, $c$, and the probability that a contact leads to infection, $p$.\\
\\
Eq. (\ref{SIR3}) is found by assuming that the number of individuals getting better is proportional to the amount of individuals who are ill. We let $\alpha>0$ be the proportionality constant. This in effect assumes that the infective period has an exponential distribution\footnote{Let $u(s)=$ number of infective individuals at time $s$ after having been infective. Then $\dot u=-\alpha u\implies u(s)=u(0)e^{-\alpha s}$}.  This is the \textit{transition (or removal) rate}, the rate that infective individuals are removed by either recovery and immunisation or death. Equivalently, it  means that the time of infectivity is exponentially distributed with mean $1/\alpha$.\\
\\
Finally, assumption \ref{SIR-as-pop} tells us that Eq. (\ref{SIR2}) is determined by the other two equations. Also, if we included any removed individuals at the start of system, they would play no part in the dynamics. So without loss of generality, we can assume $R_0=0$ in the initial conditions.
\subsection{Analysing the model}
Whilst it is possible to derive exact analytical solutions to this system\cite{exact-SIR}, it is simpler and far more instructive to explore the qualitative behaviour and derive some important quantitative properties.\\
\\
Note that $R$ plays no role in the equations of $\dot S$ or $\dot I$. Therefore we can consider just these two coupled equations\cite{martcheva}. If we need $R$ we can easily get it back by using assumption \ref{SIR-as-pop} that $R=N-S-I$. Decoupling $R$ gives the 2-dimensional system:
\begin{eqnarray}
	\dot S=-\beta S I\label{red-SIR1}\\
	\dot I=\beta S I-\alpha I=(\beta S-\alpha)I\label{red-SIR2}
\end{eqnarray}
with initial conditions: $S(0)=S_0,I(0)=I_0, S_0+I_0=N$.
%\paragraph{Basic Dynamics}
\begin{figure}
	\centering
	\includegraphics[width=1\linewidth]{compartmental-models/SIR-trajectory-fill.png}
	\caption{A typical SIR trajectory with $\beta=2\times10^{-3},\alpha=1/10, N=1000$}
\end{figure}
\subsubsection{Important quantities for epidemiologists}
Imagine you are the president of a country experiencing a significant epidemic. You have assembled a room full of leading epidemiologists to brief you. What do you ask them?
\subsubsection{Basic reproduction number, $R_0$}
Perhaps the first thing you will ask is: is the epidemic getting better or is it getting worse?\\
\\
As $\beta,S,I\geq 0$ it is immediate from Eq. (\ref{red-SIR1}) that $\dot S(t)=-\beta SI\leq 0$ for all $t$. That is the number of susceptibles is a decreasing function. Indeed if $S,I>0$ then it is strictly decreasing. So the number of susceptibles decreases until there are either no susceptibles or no infectives.\\
\\
Also, we have \[\dot I=(\beta S-\alpha)I>0\iff\beta S-\alpha>0\iff S>\alpha/\beta\] So $I$ increases only if $S>\alpha/\beta$. If $S_0<\alpha/\beta$, $I$ decreases for all $t$ and the infection dies without any increase in infection cases. Alternatively if $S_0<\alpha/\beta$, $I$ begins by increasing. But as established, $S$ is strictly decreasing for $I\neq0$ so $S$ decreases until eventually $S=\alpha/\beta$. At this point $I$ will reach a maximum. For all $t$ after this it will decrease to the limit $I=0$.\\
\\
From the arguments above $\beta S-\alpha$ plays a key role in the dynamics. We define the basic reproduction number $R_0=\beta S_0/\alpha$\cite{models-epidemiology-2}. Note that if $R_0>1$ the number of infective individuals will increase at time $t=0$. In this case we say that there is an epidemic. If $R_0\leq1$ the infection dies out without any increase in the number of infected individuals at any point.\\
\\
There is some disagreement among biologists and mathematicians over the exact definition and interpretation of $R_0$\cite{Heffernan281}. However, most models assume that $S_0\approx N$. This can be motivated by considering how an epidemic can begin. We can imagine a member getting infected through travel for example and returning to the population. Then $I_0=1$ and $S_0=N-1$. As we usually consider $N\gg1$ we have $S_0\approx N$. This assumptions allows us to consider $R_0$ as the number of infections passed on by a single infective individual during their infective period in a completely susceptible population.\label{mm}\\
\\
%Intuitively, $\beta S_0/\alpha$ is the number of infections passed on by a single infective individual during their infective period in the initial population.
%\textit{Mark's note- The population doesn’t need to be completely susceptible, does it? That would amount to defining $R_0$ as $R_0 = \beta N / \alpha$.}
%As models usually assume that $S_0\approx N$, it can also be considered as the number of infections passed on by a single infective individual during their infective period in a completely susceptible population\cite{models-epidemiology-2}.
This interpretation is easily understood. $\beta S$ is the rate of new infections caused by infections caused by a single infective individual. The mean length of an infective period is $1/\alpha$ by the assumption of exponentially distributed infections lengths. If an infected individual is, on average, not able to pass it on to at least one other person clearly the the infection will die out.
\subsubsection{Final size relation}
The next question you, as President, may ask is: how many people will the epidemic affect? This is given by the final size relation, an equation relating the number of affected individuals to $R_0$. Recalling that $\dot S\rightarrow0$ as $t\rightarrow0$, we can define $\lim_{t\rightarrow\infty}S(t)=S_\infty$. The number of individuals affected by the epidemic is the total number of individuals who have been infected at \textit{any} point. That is equal the size of the population minus the still susceptible population: $N-S_\infty$\label{mmd}. It can be shown that\cite{models-epidemiology} \[N-S_\infty=\frac{N}{R_0}\log(\frac{S_0}{S_\infty})\]
This is often written in the form \[\log(\frac{S_0}{S_\infty})=R_0(1-\frac{S_\infty}{N})\]\label{mmd} and called the \textit{final size relation}.
\subsubsection{Important quantities for revolutions}
The final size relation is an important quantity when studying infectious diseases because we care about the total number of affected individuals \textit{throughout} the diseases spread. However, in models of political revolutions it is of limited relevance. Instead we are interested in the amount of people active in sharing an idea at a single \textit{instant}. Instead of the epidemiological-minded \textit{final} size relation, we want a \textit{maximum} size relation. This would give a way of relating $R_0$ to the maximum size of the infective class $I_{\max}=\sup_{t\geq0}I(t)$.\\
\\
Firstly, let the infectious disease be the idea of a specific anti-regime group or movement. Let $S$ be the class of people who have not heard of this specific movement or have not been so far convinced by it. $I$ is the class of people who are convinced and actively sharing the ideas and taking part in revolutionary actions. Finally $R$ is the class of people who have been jailed, injured, fled the country or otherwise given up on actively supporting the cause.\\
%MM expand and slow down from here on out
\\
We assume that a revolution is successful if the proportion of active revolutionaries in a population is greater than some threshold value $r$ at some point. Formally, it is successful if there exists $t$ such that ${I(t)}/{N}\geq r$. This assumption of a threshold, whilst perhaps seeming oversimplistic, is backed by research\cite{logic-non-violence}. Further, this research suggests that the percentage of a population needed for a successful revolution is surprisingly small: just $3.5\%$\cite{logic-non-violence}. Some revolutions far surpass this number with an estimated $16\%$ of the Tunisian population actively participating in civil resistance in 2010\cite{arab-spring-percent}. While the analysis of this paper will not depend on the exact value of $r$, we will often use these two values $r=0.035$ and $r=0.16$ to get some values out of the derived equations.\\
\\
%MM expand a bit
As discussed, if $R_0\leq 1$ then no epidemic occurs and $I$ is decreasing for all $t$. In this case $I_{\max}=I_0$. So we assume $R_0>1$. Therefore we have $S_0>\alpha/\beta$. We define $t'>0$ to be the time such that $\dot S(t')=0$. Then $S(t')=\alpha/\beta$. From the previous arguments, $I(t)$ is increasing for $t$ when $0 \leq t<t'$ and decreasing for $t$ when $t'\leq t$. So $I$ reaches its maximum at $t'$. Formally, we have $I_{\max}=I(t')$.\\
\\
In mathematical epidemiology there is a classical equation to describe the maximum value of the infected class throughout the epidemic\cite{martcheva}:
\begin{equation}\label{eqn:imax}
	I_{\max}=S_0+I_0-\frac{\alpha}{\beta}+\frac{\alpha}{\beta}\ln\left(\frac{\alpha}{\beta}\right)-\frac{\alpha}{\beta}\ln(S_0)
\end{equation}\label{mmd}
This is very useful in modelling disease. If one can calculate $I_{\max}$ for a disease in its early stages, one is able to tell when the number of infections will decline\cite{martcheva}. However, we can adapt it to revolutions further.
\subsubsection{Maximum size relation}
Eq. (\ref{eqn:imax}) defines a subset of 4-dimensional space in $I_0\times S_0\times\alpha\times\beta$ with each point either leading to a revolution or not. This number of variables is acceptable if we know the specific parameters and are using it to calculate a value of $I_{\max}$. However, we can reduce it down further to 1-dimensional space in $R_0$ to obtain a more analytical insight.
\begin{align*}
I_{\max}&=S_0+I_0+\frac{\alpha}{\beta}\left(\ln\left(\frac{\alpha}{\beta}\right)-\ln(S_0)-1\right)\tab &\text{from \ref{eqn:imax}}\\
&=S_0+I_0+\frac{\alpha}{\beta}\left(\ln\left(\frac{\alpha}{\beta S_0}\right)-1\right)\tab &\text{by log rules}\\
&=S_0+I_0+\frac{\alpha}{\beta}\left(\ln\left(\frac{1}{R_0}\right)-1\right)\tab &\text{as } R_0=\frac{\beta S_0}{\alpha}\\
&=N+\frac{\alpha}{\beta}\left(\ln\left(\frac{1}{R_0}\right)-1\right)\tab &\text{as }S_0+I_0=N\\
&=N+\frac{\alpha}{\beta}(-\ln(R_0)-1)\tab &\text{by log rules}
\end{align*}
Recalling that a revolution happens if $I_{\max}/N\geq r$, we divide through by $N$:
\begin{align*}
\frac{I_{\max}}{N}&=\frac{N}{N}+\frac{\alpha}{\beta N}(-\ln(R_0)-1)\\
&=1+\frac{\alpha}{\beta N}(-\ln(R_0)-1).
\end{align*}
This is now in 3D space $\alpha\times\beta\times R_0(\alpha,\beta,S_0)$. To reduce it further we need to make an assumption. We assume that $I_0\ll S_0$ and thus that $S_0\approx N$. This can be motivated by supposing that, as we did for interpreting $R_0$, the revolutionary idea or movement comes from an individual or very small group or alternatively comes from outside the population of $N$ individuals. This allows us to write $\alpha/(\beta N)\approx \alpha/(\beta S_0)=1/R_0$. Then we can write \[\frac{I_{\max}}{N}=1+\frac{1}{R_0}(-\ln(R_0)-1)\]
Finally with a small rearrangement, we have what we can baptise \textit{the maximum size relation}:
\begin{equation}\label{eq:max-size}
	\frac{I_{\max}}{N}=\frac{R_0-1-\ln(R_0)}{R_0}:=m(R_0)
\end{equation}
valid for $R_0\geq1$.\\
\\
Bringing this together, we say a revolution occurs if and only if \[m(R_0)=\frac{R_0-1-\ln(R_0)}{R_0}\geq r \text{ for a given } r\]
\begin{figure}
	\centering
	\includegraphics[width=0.95\linewidth, trim={0, 0 0 0.7cm}, clip]{/compartmental-models/maximum-size-relation.png}
	\caption{Graph showing how the maximum fraction of infectives in the population varies with the basic reproduction number $R_0$ in the SIR model. This is derived from the maximum size relation (Eq. (\ref{eq:max-size})). Note in particular how small values of $R_0$ can result in significant fractions of the population being active at the revolution's peak.}
\end{figure}
We can check that the proposed maximum size relation has desirable properties in relating $R_0$ to $I_{\max}/N$. The domain should be $R_0\geq 1$ as we excluded lower values in the derivation. Also as $I_{\max}/N$ is a proportion, we need to ensure that the codomain is restricted to $0\leq m(R_0) \leq 1$. We also presume that the higher $R_0$, the higher the value of $m(R_0)$. So to summarise this, we want an increasing function $m:[1,\infty]\rightarrow[0,1]$.\\
\\
It is increasing as \[\frac{d(I_{\max}/N)}{dR_0}=\frac{\ln R_0}{R_0^2}\geq0, \forall R_0\geq1\]
We also have $m(R_0=1)=0$. Further, as $R_0$ tends to infinity, $\lim_{R_0\rightarrow\infty}m(R_0)=1$\label{mmd}. As $m$ is an increasing function, these give the minimum and maximum respectively. So the proposed maximum size relation has all the desired properties.\\
\\
We can provide some intuition for the maximum size relation by interpreting the $\frac{R_0-1}{R_0}$ term as how much over the threshold of $1$ $R_0$ is. Clearly the larger it is, the higher we can expect $I_{\max}$ to be. However, this potentially unlimited growth is inhibited by the ${-\ln(R_0)}/{R_0}$ term, representing the depletion of the susceptible population and thus a reduction in transfer rate $\beta S I$.\\
\\
Note that this analysis holds for the SIR model in general and can be used to roughly predict the number of infective cases that will be occurring at an infection's peak severity. This is useful in telling when an epidemic will begin to decay away. However if a researcher was calculating $I_{\max}$ from the SIR model, they would find estimate values of $\alpha,\beta,S_0,I_0$ and calculate $I_{\max}$ from Eq. (\eqref{eqn:imax}). In practice they would not use the SIR model but instead base these calculations on a more specialised model. However, for our analytical purposes it is very useful. We can interpret $R_0$ as the amount of people the average revolutionary would have to convince to be part of their movement if no one in the population had yet heard of the movement.\\
\\
If we desire a quick estimate of some values, we can naively apply the SIR model to the study of revolutions. As discussed earlier, research suggests that the threshold is given by $r=0.035$. Using the freshly created maximum size relation we see that to get to the critical value of an engaged populace needed for a revolution we need a basic reproduction number of $R_0=1.338$ . In other words, each revolutionary must be able to, if in a fully susceptible population, convince $1.338$ people to join the revolution before they are removed. For the Tunisian revolution in 2010 with $16\%$ of the population involved in the revolution\cite{arab-spring-percent}, solving Eq. (\ref{eq:max-size}) yields $R_0=2.04$.\label{mmd} This is a basic reproduction number comparable to that of the relatively uninfective Ebola\cite{b-r-n}.
\section{SEIR Model}
A simple and instructive modification we can make to the SIR model is to add a new class. Many infectious diseases have a period in which an individual can be \textit{infected} but not yet \textit{infective}. We call this state being \textit{exposed}. In our revolutionary interpretation, exposed individuals are those who have heard and are convinced by the revolutionary idea but are not yet presenting as active. We can represent this in a compartmental model by adding the exposed class $E$ to the SIR model, creating the SEIR model.
\begin{figure}[h]
	\centering
	\includegraphics[width=\linewidth]{compartmental-models/SEIR-compartments.png}
	\caption{Flowchart of the SEIR epidemic model. Note that this is an extension of the SIR model that introduces an extra compartment $E$ and the transfer rate $\gamma$ between $E$ and $I$.}
\end{figure}

\subsection{Building the model}
We assume the exposed period is exponentially distributed with mean $1/\gamma$. Again this is equivalent to assuming that the rate of moving from $E$ to $I$ is proportional to the number of exposed individuals. This gives the dynamical system:\\
\begin{eqnarray}
\dot S=-\beta S I\\
\dot E=\beta S I-\gamma E\\
\dot I=\gamma E-\alpha I\\
\dot R=\alpha I
\end{eqnarray}
As before, we remove R to reduce the system by a dimension to give:\label{mmd}\\
\begin{eqnarray}
\dot S=-\beta S I\label{SEIR1}\\
\dot E=\beta S I-\gamma E\label{SEIR2}\\
\dot I=\gamma E-\alpha I\label{SEIR3}
\end{eqnarray}
\subsection{Analysing the model}
\begin{figure}
	\centering
	\includegraphics[width=\linewidth]{compartmental-models/SEIR-trajectory-fill.png}
	\caption{A typical SEIR trajectory with $\beta=3,\alpha=1/10,\gamma=1/300$}
\end{figure}
In the SIR model we could tell if an epidemic would occur simply by seeing if there was initial growth in the infective class. This worked because, if the infective class did not grow initially, it could not grow at any later time. However, the SEIR model is more complex and can have initial decline yet still see an epidemic. As we can no longer use our previous definition of an epidemic occurring we are motivated to develop a new, more general one.\\
\\
%Instead it is characterised by the equilibrium with all individuals of the population susceptible
One possibility is to consider the disease-free equilibrium (DFE). This is the equilibrium that occurs when the whole population is in the susceptible class. In the SEIR system (\ref{SEIR1}-\ref{SEIR3}) the DFE is given by $(S,E,I)=(N,0,0)$. It is easy to see that this is in fact an equilibrium in the SEIR system and gives $\dot S=\dot E=\dot I=0$. In fact in all reasonable deterministic epidemic models this is an equilibrium: if there is no-one with the infectious disease and no randomness in the model, there is no way for the disease to enter the population and so everyone will stay susceptible. So if no-one is infective with the disease no-one ever will be.\\
\\
We say that an epidemic occurs if a small divergence from the DFE results in the system moving away from the DFE. Otherwise if the system does not move further away from the DFE, we say no epidemic occurs. One way to motivate this is to consider what would happen if a small number of infectives were released into the population. If they are able to infect more people, an epidemic occurs and we move from the DFE. Otherwise, the number of infective individuals decreases until there are no more. Translating this into mathematics we say an epidemic occurs if the DFE is unstable and an epidemic does not occur if the DFE is asymptotically unstable \footnote{See Section \ref{dynamical-systems} for a primer on dynamical systems}\cite{models-epidemiology-2}.\label{aa}\\
\\
The stability of SEIR can be investigated by linearising about the DFE. To do this we calculate the Jacobian at the DFE, $\bf{x}^*=(N,0,0)$,\\
\[
\bf{J}_{(\bf{x}^*)}=
{\begin{bmatrix}
	{\partial \dot S \over \partial S} &
	{\partial \dot S \over \partial E} &
	{\partial \dot S \over \partial I} \cr
	{\partial \dot E \over \partial S} &
	{\partial \dot E \over \partial E} &
	{\partial \dot E \over \partial I} \cr
	{\partial \dot I \over \partial S} &
	{\partial \dot I \over \partial E} &
	{\partial \dot I \over \partial I}
\end{bmatrix}}
_{(\bf{x}^*)}
={\begin{bmatrix}
	{-\beta I} &
	{0} &
	{-\beta S} \cr
	{-\beta I} &
	{-\gamma} &
	{\beta S} \cr
	{0} &
	{\gamma} &
	{-\alpha}
	\end{bmatrix}}
_{(\bf{x}^*)}
={\begin{bmatrix}
	{0} &
	{0} &
	{-\beta N} \cr
	{0} &
	{-\gamma} &
	{\beta N} \cr
	{0} &
	{\gamma} &
	{-\alpha}
	\end{bmatrix}}
\]
\\
Then finding the eigenvalues we get the determinant and resulting characteristic equation
\[{\begin{vmatrix}
	{-\lambda} &
	{0} &
	{-\beta N} \cr
	{0} &
	{-\gamma-\lambda} &
	{\beta N} \cr
	{0} &
	{\gamma} &
	{-\alpha-\lambda}
	\end{vmatrix}}=-\lambda\big((-\gamma-\lambda)(-\alpha-\lambda)-\beta N\gamma \big)\]
So $\lambda=0$ is an eigenvalue. This corresponds to the line of equilibria in which $E=I=0$. This is the system in which every individual is either susceptible or removed.\label{mmd}\\
\\
The other eigenvalues are the eigenvalues of the matrix:
\[{\begin{vmatrix}
	{-\gamma} &
	{\beta N} \cr
	{\gamma} &
	{-\alpha}
	\end{vmatrix}}\]
These have negative real part if and only if the determinant of the matrix is positive\cite{models-epidemiology-2}. The determinant $\gamma(\alpha-\beta N)$ is positive if and only if $R_0<1$. Note that the trace of the matrix is negative and so the negative eigenvalues correspond to the stability of the equilibrium and the failure of an epidemic to develop\cite{models-epidemiology-2}. Hence again, the stability of the equilibrium in the SEIR model again depends on if $R_0$ is greater or less than $1$.

%This has determinant $\gamma(\alpha-\beta N)$. As $\gamma>0$, the determinant is positive if and only if $\alpha-\beta N$ is positive which is equivalent to $R_0<1$. An equilibrium point is unstable if there exists an eigenvalue with positive real part. We also know that a matrix's eigenvalues have negative real part if and only if the determinant is positive. And so if $R_0<1$, the DFE is stable. Otherwise it is unstable. \label{aa}
%\textit{Mark's note: Your claim about the value of the determinant and the signs of the real parts of the eigenvalues is too strong and actually false for matrices of odd dimension. The simplest way to fix this is to say something like:
%“The eigenvalues of a two-by-two matrix may have negative real part only if the determinant is positive”.}
\label{mmd}
\section{Model of revolution}\label{sec:rev-compartment}
%We can adapt the SEIR model to make an explicit compartmental model of revolution. A natural question is to consider if the basic flow should be the same. \label{mmd}
\subsection{Building the model}
% need a bit introducing E and also the analogy explicitly.
% also should I change the names of the compartments? Or does that make it more complicated?
The intrinsic difference between the spread of an infection and the spread of an idea is an individual's agency. With a general idea, this agency is not particularly important and can be bundled up with the transmission rate $\beta$. This parameter $\beta$ tells us about the average individuals likelihood of spreading an idea. However, with a revolutionary idea this agency is intrinsic. Most people who hold a revolutionary idea do not only consider the idea and see if they want to share it. They will also check the surrounding environment to see if others are sharing the idea, what the danger to them is and what the likelihood of a successful revolution is. To account for this we need an activation rate that is a function of the population demographic.\\
\\
Specifically, exposed individuals who are thinking about becoming active revolutionaries will look at what percentage of the population are already active revolutionaries. This is given by $I/N$. Fellow exposed individuals are invisible as they are not making any actions that display their support for a revolution. So we want the activation rate to be a function solely of $I/N$. So far, we do not know the nature of this function. For now we denote it $g(x):[0,1]\rightarrow\mathbb{R}$.\\
\\
Given the context it is natural to wonder if our model should allow transfers from $E\rightarrow R$. This corresponds to people who became convinced that the revolution is desirable but have since gone off the idea without ever having become revolutionaries. Whilst this is certainly possible it turns out that this is neither conceptually nor mathematically necessary. Conceptually, an exposed individual, while exposed has no effect on the wider population, much like a removed individual. In particular, they do not contribute to the size of the infective class which is the value we care most about. As the outwards effect on the dynamics between exposed and removed is negligible, an exposed individuals change to removed has no outward effect on the dynamics. Mathematically, we can account for this by making the value we give for $N$ smaller by a fraction corresponding to the fraction of people we expect to move directly from exposed to removed.\label{mmd}
\begin{figure}[h]
	\centering
	\includegraphics[width=\linewidth]{compartmental-models/rev-compartments.png}
	\caption{Flowchart of the compartmental model of revolution}
\end{figure}\\
\\
Adapting the SEIR model but allowing potential non-linear movement between the exposed and infective compartments, we get a dynamical system:
\begin{eqnarray}
\dot S=-\beta S I\\
\dot E=\beta S I- \gamma E g(I/N)\\
\dot I= \gamma E g(I/N)-\alpha I\\
\dot R=\alpha I
\end{eqnarray}
where $g(x)$ is the as yet unknown function.
\subsubsection{In search of $g(x)$: a naive approach}
The dynamics of collective behaviour are complex but there are some findings that are well-supported. People's proclivity towards behaving in a certain way often depends on how many people are already behaving that way. One of the dominant models of this in social psychology has been the threshold model. This holds that we tend to act in a certain way only if a certain number of other individuals are acting in that way\cite{threshold-models-social-influence}.\\
\\
Let $k$ be some threshold value with $0\leq k\leq1$. Then one option is to adapt the function from Granovetter's original paper on threshold models from absolute numbers of people to proportions of people. This would mean we have a discontinuous step function:\\
	\[
g_1(x) = \left\{\begin{array}{lr}
1, & \text{if } x\geq k\\
0, & \text{if } x< k
\end{array}\right\}
\]
where $k$ represents the threshold.\\
\\
A continuous alternative is given by:
\[g_2(x)=\frac{x^n}{k^n + x^n}\]
\begin{figure}
	\centering
	\begin{subfigure}{.46\textwidth}
		\centering
		\includegraphics[width=\linewidth]{compartmental-models/rev-transfer-rate1.png}
		\caption{$n=2$}
	\end{subfigure}%
	\begin{subfigure}{.46\textwidth}
		\centering
		\includegraphics[width=\linewidth]{compartmental-models/rev-transfer-rate2.png}
		\caption{$n=7.5$}
	\end{subfigure}
	\begin{subfigure}{.46\textwidth}
		\centering
		\includegraphics[width=\linewidth]{compartmental-models/rev-transfer-rate3.png}
		\caption{$n=20$}
	\end{subfigure}
	\caption{The effect of different values of $n$ on the transfer rate $g_2(x)$ with $k=0.2$.}
	\label{fig:transfer-rate-n}
\end{figure}
Here $k$ controls the threshold value with $g_2(x)={1\over2}$ at $x=k$. $n$ controls the severity of the threshold with a higher $n$ giving a steeper curve and a more sudden phase change. $g_2$ is preferable to $g_1$ both practically and theoretically. Practically, the continuity allows us to analyse the function at all points of the domain using standard calculus. Theoretically, it better represents the non-uniformity of a population's attitude to risk and the fuzzy boundary around giving an \textit{exact} threshold for active participation.\\
\\
We allow the possibility of scaling by a factor $\gamma$. Then $\gamma g(I/N)$ is the probability that an exposed individual will become active in one unit time. So if $I/N\approx1$, the probability of an exposed individual becoming active per unit time is roughly $\gamma$. This gives the number of individuals leaving $E$ per unit time as $\gamma Eg_2(I/N)$. So we have the dynamical system:
\begin{eqnarray}
\dot S=-\beta S I\\
\dot E=\beta S I- \gamma E \frac{(I/N)^n}{k^n + (I/N)^n}\\
\dot I= \gamma E \frac{(I/N)^n}{k^n + (I/N)^n}-\alpha I\\
\dot R=\alpha I\label{rev1eq4}
\end{eqnarray}
\subsubsection{Finding suitable parameters}
There are now 6 parameters in our model. We justify the default values used in Table \ref{tab:parameters1}. Unless otherwise stated, all simulations and graphs will use the values of the parameters as given in this table. For the initial conditions we start with a single revolutionary giving $I_0=1$ and $S_0=N-1$.
\begin{table}
	\captionof{table}{Default Parameter Values} \label{tab:parameters1}
	\centering
	\begin{tabular}{| l | l | p{7.5cm} |}
		\hline
		Parameter (units) & Chosen Value & Justification \\ \hline
		N (people) & 2 million & $1/5$ of the population of Tunisia in 2010 (10.6 million). This is an estimate of how many people were potentially open to protesting (based on political orientation, age, medical history etc.).\\ \hline
		$\alpha$ (1/days) & 1/300 & Noting the exponential distribution inferred by Eq. (\ref{rev1eq4}), this assumes that a protester is removed through some means, on average, after 300 days of protesting. \\ \hline
%		$\beta$ (1/days$\cdot$people) & $2.04\cdot \alpha/N$ & Using $\alpha,N$ and the value of $R_0=2.04$ we calculated for the Tunisian revolution using the maximum size relation we get $\beta\approx\alpha R_0/N$. \\ \hline
		$\beta$ (1/days$\cdot$people) & $40\cdot \alpha/N$ & We assume that a revolutionary could expose around $50$ people to the idea in a completely susceptible population. Using the basic reproduction number we have $\beta\approx\alpha R_0/N$. \\ \hline
		$\gamma$ (1/days) & 1/5 & If conditions are right, it takes $5$ days on average for someone to move from exposed to active. \\ \hline
		$n$ (dimensionless) & 3 & This corresponds to a slightly steep curve of $g(x)$. \\ \hline
		$k$ (dimensionless) & 3/50 & The Asch conformity experiments found that an individual is highly influenced by 3 people to act in a way so as to conform with them\cite{asch-conformity}. However, increases to four and beyond have little effect. We assume each person is influenced by around $50$ people. \\ \hline
		$\delta$ (days) & $\gamma/200=1/1000$ &
		We guess that around one in every 200 people is a potential `zealot'. If conditions are right, there are $1/\gamma$ people converting to active each unit time because of observing the population. There are 1/200 of the population converting who would have converted regardless of the political situation. \\ \hline
	\end{tabular}
\label{tab:parameters-compartments-1}
\end{table}

\subsubsection{Results and failure of the naive approach}
To keep things clean, we write \[\theta(I)=\frac{\partial g_2(I/N)}{\partial I}=\frac{k^n n (I/N)^n}{I(k^n+(I/N)^n)^2}\]
Decoupling $R$ as before, the Jacobian at the DFE
\[
\bf{J}_{(\bf{x}^*)}
={\begin{bmatrix}
	{-\beta I} &
	{0} &
	{-\beta S} \cr
	{-\beta I} &
	{-\gamma g_2(I/N)} &
	{\beta S-\gamma E\theta(I)} \cr
	{0} &
	{\theta g_2(I/N)} &
	{\gamma E \theta(I)-\alpha}
	\end{bmatrix}}
_{(\bf{x}^*)}
={\begin{bmatrix}
	{0} &
	{0} &
	{-\beta N} \cr
	{0} &
	{0} &
	{\beta N} \cr
	{0} &
	{0} &
	{-\alpha}
	\end{bmatrix}}
\]
The resulting zero eigenvalues mean that we cannot ascertain whether it is a stable equilibrium. So we have to get creative. We could look at the Hessian, the square matrix of second order partial derivatives. However, this is a $9\times9$ matrix and we now have 6 parameters so this is neither fun nor informative. Instead we go exploring.\\
\\
The fact that there are zero eigenvalues suggests that the DFE is in fact part of an infinite number of equilibrium points. From observation, we can see that $(S^*,E^*,0)$ are all equilibrium points. These are the equilibriums in which there are varying degrees of revolutionary powder but no spark.\\
\\
To have an increase in the number of infectives we need the number of invididuals becoming infective to be greater than the number of those ceasing to be infective. Noting that $g_2(x)$ behaves like $n(\frac{x}{k})^n$ for small perturbations $x$ from $0$
\footnote{$g_2(x)$ has a Taylor expansion about $0$ of
\[g_2(x)=0+\frac{nk^nx^{n-1}}{(k^n+x^n)^2}\cdot x+...\approx \frac{nk^nx^{n}}{(k^n+x^n)^2}\] Noting that a small perturbation $x$ is much less than the threshold value $k$ we have $x\ll k$. Hence $k^n+x^n$ is dominated by the $k$ term. This gives the formula \[g_2(x)\approx\frac{nk^nx^n}{(k^n)^2}=\frac{nk^nx^{n}}{k^{2n}}=n\left(\frac{x}{k}\right)^n\]}. Therefore to have an increase in infectives we require that:
\begin{alignat}{2}
\gamma E n &\left( \frac{I/N}{k} \right)^n &&> \hspace{1.5em}\alpha I\label{eq:gamma-1}\\
&\hspace{1em}\gamma &&> \sqrt[n]{\frac{\alpha I}{E n}}k\frac{N}{I}\label{eq:gamma-2}
\end{alignat}
We know that $E<N$ and also that for $I$ to grow Eq. (\ref{eq:gamma-2}) must hold initially at $t=0$. So we can require $I=I_0=1$. Making these substitutions gives the requirement that
\begin{align*}
\gamma >& \sqrt[n]{\frac{\alpha}{N n}}k N
\end{align*}
If we use the default values to solve for $\gamma$, Eq. (\ref{eq:gamma-2}) gives a requirement that $\gamma>386$. This means that, on average, individuals become active less than $1/386$ of a day after having been exposed to the revolutionary idea. That is equal to four minutes which is barely enough to time to finish your cuppa.\\
\\
Therefore, we assume that with reasonable parameters the number of infectives is decreasing. So the only change can be that the active revolutionary dies and maybe some people become exposed to the idea. As we have $I_0=1$, the number of people who will be exposed is approximately equal to the number of people the active revolutionary can inform. That is exactly $R_0=\beta N/\alpha$.\\
\\
So we expect for any reasonable values, introducing a single revolutionary into the system will result in $I\rightarrow0$ as $t\rightarrow\infty$ while $E\rightarrow R_0$. This is in fact exactly what happens. With default parameters $R_0=2.04$ and so the revolutionary exposes two people to the idea before being snuffed out. Using a high value of $\beta$ as in Fig. \ref{fig:rev-naive-beta-high} we can visually see the system coming to its equilibrium point $(S^*,E^*,0)=(N-R_0,R_0,0)$.
\begin{figure}[!h]
	\centering
	\begin{subfigure}{0.8\textwidth}
	\includegraphics[width=\linewidth]{compartmental-models/failure-naive-approach3.png}
	\caption{A high, but still humanly possible, value of $\beta=1000/N$. This corresponds to each revolutionary exposing $1,000$ people a day to the revolutionary idea.}
	\label{fig:rev-naive-beta-high}
	\end{subfigure}
	\begin{subfigure}{0.8\textwidth}
		\includegraphics[width=\linewidth]{compartmental-models/failure-naive-approach2.png}
		\caption{A superhuman value of $\beta=1$. This corresponds to a revolutionary exposing roughly $1,000,000$ people to the revolutionary idea in a day.}
		\label{fig:rev-naive-beta-vhigh}
	\end{subfigure}
\caption{The compartmental revolution model with default parameters and high values of $\beta$. The resulting figures show the problems with the naive approach to the transfer rate $g(x)$.}
\end{figure}
\\
\\
Even if the active revolutionary is supernaturally effective, able to convince millions of people each day of the need for a revolution, he still suffers the same fate: dying whilst no other individual becomes active. This would involve having an unusually high transmission rate $\beta$. We set $\beta=1$, more than a million times the default parameter (Fig. \ref{fig:rev-naive-beta-vhigh}). Within two days we merely end up with the whole population convinced that they $\textit{should}$ do something. Meanwhile, the lonely active revolutionary becomes half a person, a third, reducing in size until he is infinitesimal. There is a powder keg of two million people but the only spark was left to die. Unfortunately, an idea without action remains just an idea.
%
\begin{tcolorbox}
	\paragraph{Lesson for revolutionaries:} An idea alone will never cause outward action. You must act in line with your beliefs to show others \textit{what} you believe. Otherwise everyone can believe in change yet do nothing about it.
\end{tcolorbox}
So in this model the most the revolutionary can hope for is to inform a lot of people that there \textit{should} be a revolution. Due to a limit on how quickly people move from being convinced of something to acting on it, there can never be an increase in the number of active revolutionaries.  This is a fatal problem for a model of revolution.\\
\\
Intuitively what has gone wrong is that when there is only one lone revolutionary, it's not particularly tempting to join them. The threshold model we have incorporated reflects the truth that most people do not want to be trend-starters. Most people, for better or worse, are sheep. However, fortunately change is possible. \textit{Most} people is not \textit{all} people.
\subsubsection{Improving $g(x)$: Thank God for the Zealots!}\label{sssec:zealots}
Some proportion of every society are zealots. They are the ones who are not afraid to stick their head above the pulpit. The fact that no one else is doing it does not faze them. In fact, they might actively enjoy it. These are the people who, upon hearing an idea they agree with, do not check to see if others hold and are expressing the idea. They simply express the idea. To get ourselves out of our rut, we assume that some proportion of the population are zealots.\\
\\
One option would be to introduce zealots as a category, with the majority of the population taking the traditional route route $S\rightarrow E\rightarrow I\rightarrow R$ and zealots perhaps moving directly $S\rightarrow I\rightarrow R$. However an alternative is to adopt this fraction of the population into the transfer rate $g$. This allows us to keep much of the analysis from the SEIR model.
%\textit{ Mark's note: This seems a good idea, but perhaps you should introduce zealots as a separate category of person who progress S -> I -> Rand then have the E -> I process depend on the sum of the population of ordinary Exposed people and the Infective Zealots.}
\label{mmd}
Then we choose instead \[g_3(x)=\delta+\gamma\frac{x^n}{k^n + x^n}\]
Note that this absorbs $\gamma$ into $g(x)$ so that it does not interfere with $\delta$. We can calculate a value of $\delta$ from imagining the transfer from $E$ to $I$ when the proportion of infectives $I/N$ is well past the threshold $k$. Then ${x^n}/({k^n + x^n})\approx1$ and the number of `ordinary' people per unit time who look at the population before deciding to be active is $\sim\gamma$. That is $\gamma$ people are converting for these reasons when the revolution is flowing per unit time. Similarly, $\delta$ people per unit time convert as `zealots' to the cause for reasons unrelated to the state of the revolution. Then we have have that the proportion of zealots in the initial population is given by $\delta/{(\delta+\gamma)}$\footnote{$\frac{\# \text{ zealots}}{\# \text{ individuals}}=\frac{\# \text{ zealots}}{\# \text{ zealots}+\# \text{ non-zealots}}=\frac{\delta}{\delta+\gamma}
%	=\frac{\gamma}{\delta+\gamma}$
$
}.
This gives us a way to find a meaningful value of $\delta$ (Table \ref{tab:parameters-compartments-1}).\\
\\
With this adoption the change in $E$ per unit time is given by:
\begin{equation*}\label{eq:g_3}
Eg_3(I/N)=E\cdot \big(\delta + \gamma\frac{(I/N)^n}{k^n + (I/N)^n}\big)
\end{equation*}
We can justify this term. The number of conversions to activity is proportional to the number of exposed individuals $E$. The first term in the brackets, $\delta$, represents those who, upon hearing an idea they agree with, become active regardless of the situation. The second term in the brackets $\gamma {(I/N)^n}/({k^n + (I/N)^n})$ represents the others who do a calculation by looking at what percentage of the population is active.\\
\\
It is worth noting that the value of $\delta$ is calculated using the fraction of zealots in the initial population. However this fraction changes as zealots are leaving the susceptible population at a different rate to the non-zealots in general this proportion will change during the revolution. This divergence is potentially a problem and difficult to justify analytically. However in practice, given the parameter values we use in the simulation, it has a negligible effect. Mathematically, the number of zealots who have become infective by time $t$ is $\int_0^t E\delta dt$. We will see in the model that in the early stages when zealots play the key role, $\int_0^t E\delta dt$ is very small compared to $N$ and so only a small amount of the total zealots have left the population.
%Similarly, the total number of individuals who have become infective is $\int_0^t Eg_3(I/N) dt$.
%Therefore, the fraction of the susceptible population that are zealots after time $t$ is at least as big as \[\frac{\delta}{\delta+\gamma}-\frac{\int_0^t E\delta dt}{N}\]
%in a population $\delta/{(\delta+\gamma)}$ should be altered by a factor that is at least close to $1$ as ${(N-\int_0^t E\delta dt)}/{N}$.
%So the effect of depleting zealots is only significant if $\int_0^t E\delta dt$ is comparable to $N$. We will return to see if this is the case in the simulations.
\label{mm}
\\
\\
Using $g_3$ results in the dynamical system:
\begin{eqnarray}
\dot S=-\beta S I\\
\dot E=\beta S I- E \left(\delta + \gamma\frac{(I/N)^n}{k^n + (I/N)^n}\right)\\
\dot I= E \left(\delta + \gamma\frac{(I/N)^n}{k^n + (I/N)^n}\right)-\alpha I\\
\dot R=\alpha I
\end{eqnarray}

\subsection{Analysing the model}
\subsubsection{Analytic results}
Reducing to three dimensions as before, the Jacobian at the DFE
$\bf{x}^*=(N,0,0)$ is\\
\[
\bf{J}_{(\bf{x}^*)}
={\begin{bmatrix}
	{-\beta I} &
	{0} &
	{-\beta S} \cr
	{-\beta I} &
	{-\delta-\gamma g_3(I/N)} &
	{\beta S} \cr
	{0} &
	{\delta+\gamma g_3(I/N)} &
	{-\alpha}
	\end{bmatrix}}
_{(\bf{x}^*)}
={\begin{bmatrix}
	{0} &
	{0} &
	{-\beta N} \cr
	{0} &
	{-\delta} &
	{\beta N} \cr
	{0} &
	{\delta} &
	{-\alpha}
	\end{bmatrix}}
\]
The addition of the `zealots' term makes the stability conditions of the revolution model reduce  to the conditions for the SEIR model. So by the arguments there, for a small disturbance from the DFE, there is no epidemic if $R_0<1$. However, from this we do not know how large the active population will grow. Further, it does not say anything about a large disturbance $I_0>0$ such that the non-zealot population becomes significant. To understand some of these details we need to create a simulation of the system.
\subsubsection{Simulation and qualitative results}
If we create a simulation of this system with the default values of the parameters we get something that looks a lot like how we may expect a revolution to occur (Fig. \ref{fig:rev-traj-default}). We can describe the course of the revolution in three distinct stages:
\begin{enumerate}
	\item\label{groundwork} \textit{The Groundwork}. Initially, the most notable increase is in the exposed population as the small infective population are able to make lots of contacts with the dominant susceptible population. However, there are not enough infectives to encourage others to become infective. Nevertheless, there is a small but reliable movement into the infective department through the existence of zealots. As this increases, the non-zealot term becomes non-negligible and the bolder non-zealots begin to crossover into the infective population.
	\item\label{explosion} \textit{The Explosion}. Eventually the infective population becomes large enough to approach the threshold $k$ and suddenly the revolution sparks. The exposed population is quickly depleted, feeding quickly into the rapidly expanding infective population. The authorities are not quick enough to make a significant dint in the infective population so the removed population remains low. Within a short time, the susceptible population has been depleted and almost all of the population are active.
	\item\label{easy-pickings} \textit{Endgame} At this stage there are two possible outcomes.
	\begin{inparaenum}
		\item \textit{Change} If the infective class is large enough such that $I/N>k$ at some point, the revolution will have been successful. The dynamics go into another, far more difficult to model, phase of political movement: regime change.
		\item \textit{Easy Pickings} However, if the revolution is not able to pass the threshold, the regime stays in control. They are then free to pick at the revolutionaries who showed support for the revolution until they feel they have made a sufficient example of future would-be revolutionaries\footnote{Consider, for example, the 2016 Turkish coup d'\'etat attempt.}.
	\end{inparaenum}
\end{enumerate}
\begin{figure}[h!]
	\begin{subfigure}{\textwidth}
	\centering
	\includegraphics[width=\linewidth]{compartmental-models/rev-trajectory-fill1.png}
	\caption{With default parameters as given in table \ref{tab:parameters-compartments-1}.}
	\label{fig:rev-traj-default}
	\end{subfigure}
	\begin{subfigure}{\textwidth}
	\centering
	\includegraphics[width=\linewidth]{compartmental-models/rev-trajectory-fill2.png}
	\caption{With default parameters except $\gamma$ altered to $1/500$.
	}
	\label{fig:rev-traj-diff-gamma}
	\end{subfigure}
\caption{Trajectories of the compartmental revolution model.}
\end{figure}
\bigskip
Interestingly this story follows a similar narrative to George Lakey's strategy for nonviolent revolution in `A Manifesto for Nonviolent Revolution'\cite{lakey_1972}. In this he identifies five distinct stages for a successful revolution. The first two are cultural preparation or "conscientization" and building organizations. This educational phase roughly aligns with the `groundwork' stage we observe in our model. He sees confrontation and mass non-cooperation as the second two stages. This has a clear parallel with our 'explosion'. Finally the revolutionaries hope to enter the period `change' which Lakey identifies with the process of developing new institutions.\\
\\
%Returning to the discussion on the validity of our constant $\delta$ assumption we can see that in the early stages when it is mainly zealots converting, the total number of individuals who have been exposed by the time the zealots are the main contributors is very small. In later stages the effect of zealots is overran by the effect of zealots. So the assumption causes only a negligble change.\\
%\\
The simulation confirms the theoretical findings that $R_0$ plays a key role in the existence of an `epidemic'. That is, an increase in the number of active individuals. We can see that for $R_0<1$ no epidemic occurs whilst for values of $R_0$ even slightly above $R_0$ there is an increase in the infective population.
\subsubsection{The role of the contact rate $\beta$}
Further, the importance of $\beta$ is not surprising. A catchy idea catches on. It determines the size of the revolution and also how soon it happens. However, notice the danger of the \textit{good enough} idea as in Fig. \ref{fig:rev-R0-2}. This has $R_0>1$ but only just. As a result, the number of active revolutionaries sustains itself and can even have a small increase. However the amount leaving the cause or being picked off by the regime is almost equal to the amount joining at every point. This is a movement without momentum. It causes no major change but puts people at risk of the regime's wrath. In terms of wasted time and, depending on the nature of individual's removal, lives it is potentially worse than no agitation at all.
%\\
\begin{figure}[h!]
	\centering
	\includegraphics[width=1\linewidth]{compartmental-models/rev-R0-2.png}
	\caption{A graph showing the danger of the `good enough' idea on the revolution model. This has $R_0>1$ but only just.}
	\label{fig:rev-R0-2}
\end{figure}

\begin{tcolorbox}
	\paragraph{Lesson for revolutionaries:} Beware of the \textit{good enough} idea. It will not have the momentum needed to cause change. In the meantime it will put you in danger.
%	 If you're going to be active, make sure it's with a catchy idea. Otherwise you might die without seeing anything come of it.
\end{tcolorbox}
\subsubsection{The role of the removal rate $\alpha$}
There is an interesting link between $\alpha$ and $I_{\max}$, the key value we are interested in. Plotting $1/\alpha$ against $I_{\max}$ reveals that $1/\alpha$ has a non-linear effect on the maximum level of infection (Fig. \ref{fig:rev-alpha-not-log}). This suggests a logarithmic relationship. Indeed plotting this confirms this relationship for a large range of parameter values that includes our default value (Fig. \ref{fig:rev-alpha-log}).
\begin{figure}[h!]
	\begin{subfigure}{\textwidth}
		\centering
		\includegraphics[width=0.8\linewidth]{compartmental-models/rev-alpha-not-log.png}
		\caption{There is a rapid increase in the value of $I_{\max}$ for small increases in $1/\alpha$ but this quickly settles.}
		\label{fig:rev-alpha-not-log}
	\end{subfigure}
	\begin{subfigure}{\textwidth}
		\centering
		\includegraphics[width=0.8\linewidth]{compartmental-models/rev-alpha-log.png}
		\caption{There is an approximate log relationship between $1/\alpha$ and $I_{\max}$.}
		\label{fig:rev-alpha-log}
	\end{subfigure}
\caption{Graphs showing the effect the value of $1/\alpha$ has on the maximum infected class size. $1/\alpha$ represents the number of days on average it takes for a revolutionary to be removed.}
\end{figure}
%Investigate number of $I_0,E_0$ vs. $\alpha$ removal rate. Might be interesting to see relationship necessary to make something happen.\\
\\
\\
Perhaps even more interesting is the effect of $\alpha$ on the time of the peak of the revolution. Or better said, the lack of effect on it. It might be expected that if more people are leaving the revolution it will take longer to happen. However, this is not the case (Fig. \ref{fig:rev-alpha-time}). If the regime is picking people off any slower than a very fast rate, the peak of the revolution will tend to happen at a similar time. In our model this is around day $162$. In fact, even when $\alpha=0$, that is when no-one leaves the revolution, the peak of the revolution happens on day 162. So as $\alpha\rightarrow0$, the time of peak revolutionary activity $t$ tends to a limit and approaches it very quickly. Hence the time of revolution is not sensitive at all to our choice of $\alpha$.
\begin{figure}[h!]
	\centering
	\includegraphics[width=1\linewidth]{compartmental-models/rev-alpha-time.png}
	\caption{A graph showing the lack of effect $\alpha$ has on the time at which the revolution peaks. That is the time $t$ at which $I(t)=I_{\max}$.}
	\label{fig:rev-alpha-time}
\end{figure}
\begin{tcolorbox}
	\paragraph{Lesson for revolutionaries:} The regime can't slow you down (unless they're really, really nasty). However, they will limit the size of the revolution.
\end{tcolorbox}
Note being nasty can be the same as increasing $\alpha$ but this might be intrinsic to the message of the revolutionaries. Therefore it might also involve increasing $\beta$. So tyrants play a tricky balancing act.
\begin{tcolorbox}[colback=removed-colour!30]
	\paragraph{Lesson for tyrants:} Being nasty (i.e. locking people up) will not move the revolution further away. Fortunately for you it will make the revolution smaller. However, it may also make it easier for revolutionaries to gather support against you. Maybe just be nice...?
\end{tcolorbox}
%\paragraph{$\gamma$ and $I_{\max}$}
\subsubsection{The role of the incubation rate $\gamma$}
$\gamma$, the parameter that controls the rate at which non-zealots convert to active revolutionaries, plays a key role in the time it takes for the revolution to happen and, for related reasons, the value of $I_{\max}$. $\gamma$ changes the relative heights of the peaks of $E,I$. If low ($\gamma\sim 1/500$), the growth of $E$ carries on for a long time and has time to grow very high (Fig. \ref{fig:rev-traj-diff-gamma}). Then $\sim1/\gamma$ days later we have the peak of the revolution where $I$ reaches $I_{\max}$. However, as $500$ days is a long time, the build-up to $I_{\max}$ takes a long time. As a result $I_{\max}$ is lower because people were picked off over a longer time. Compare this to Fig. \ref{fig:rev-traj-default}. Similarly, if $\gamma$ is even higher than default ($\gamma\sim1$), $I$ reaches the threshold quickly and then there is no time to remove people during the explosion period and so $I_{\max}\approx N$.
\begin{tcolorbox}
	\paragraph{Lesson for revolutionaries:} Pay attention to the political situation and other peoples' activity. Be ready to join quickly if the time is right.
\end{tcolorbox}
\subsubsection{Shortcomings of the model}
Exploring the simulation also shows the shortcomings of the model. With some parameter values we can witness values of $I<1$ that nevertheless result in an `epidemic'. In a discrete model, less than one revolutionary is no revolutionary. However, the continuity of the compartmental model can allow strange artefacts in which this fraction of a revolutionary manages to cause a revolution. We need something a bit more realistic.


\chapter{Discretisation induced stiffness in the Landau-Lifshitz-Gilbert equation}
\chaptermark{Discretisation induced stiffness}
\label{cha:stiffn-llg-equat}

For continuum mechanics models of the LLG equation stiffness (the restriction of time step size by stability rather than by the desired accuracy) has long been recognised as an issue, at least for some problems \cite{Nakatani1989}.

Stiffness in time-dependent PDEs has at least two possible sources:
firstly a problem may be physically stiff due to large differences in the characteristic time scales of different (physical) components of the solution \cite[Chap. 4]{Iserles2009};
secondly the choice of spatial discretisation method may be the cause of stiffness.
In particular a fine spatial discretisation often results in a stiff system of ODEs.
An intuitive explanation for this is that a finer mesh resolves shorter wavelength modes, even if they have almost no effect on the resulting solution.
Shorter wavelength implies higher frequency, \ie shorter characteristic time scales.
These modes interact with the solution, and the large variation in time scales causes stiffness in a similar way to physical effects.
For a more rigorous discussion of this effect in terms of the eigenvalues of the time integration operator see e.g. \cite[Sec 8.2]{Atkinson2009}.

As discussed in \cref{sec:time-discretisation} time integration methods can be roughly divided into two classes: those which are inefficient when applied to the solution of stiff problems and those which are not.
These two classes correspond to \emph{explicit} methods that calculate the value at the next time exclusively in terms of previous values and \emph{implicit} methods in which a system of equations must be solved.
Typically one step of an implicit method requires more computational effort than a step of an explicit method because of this solve.
However good implicit methods are unconditionally stable, allowing them to take much larger time steps when applied to stiff problems \cite[Chap. 4]{Iserles2009}.
Hence there is a trade-off between time step size and the computation time per step.
Since the optimal choice of method depends on the stiffness it is important to understand its origins in micromagnetic simulations.

In \thisref{cha:stiffn-llg-equat} we examine numerically the relationship between stiffness and spatial discretisation size for a simple micromagnetic problem where stiffness due to physical effects can be ruled out.
We also explore how stiffness is affected by the use of the FEM/BEM method for magnetostatic calculations.
Finally, we study the effects of discretisation on stiffness in methods which combine explicit magnetostatic calculations with implicit exchange field and LLG calculations (\ie semi-implicit methods).

The results in this chapter have also been published in the IEEE Transactions on Magnetics journal \cite{Shepherd2014}.

\section{Problem definition}

As our case study we choose a sphere with a radius of one exchange length.
The initial magnetisation is $\mv = [0.2, 0, 1.0]/|\mv|$, the applied field is $\happ =[0, 0, -1.1]$.
We considered three values for the Gilbert damping constant: $\alpha = 1, 0.1$ and $0.01$.
With this geometry and uniform magnetisation the magnetostatic field can be analytically shown to be $\hms = -\mv/3$ throughout the domain (as mentioned in \cref{sec:imr-ode-llg-numer-exper}) \cite[112]{Aharoni1996}, and so, due to energy considerations, the magnetisation remains uniform for spheres of radius $R < 2.082 \sqrt{3} \sim 3.606$ exchange lengths \cite[211]{HubertSchafer}.

% Note that analytically the magnetostatic field has no effect on the dynamics because it is always anti-parallel to $\mv$ (the cross product of anti-parallel vectors is zero).
The dynamics are therefore very simple: the magnetisation processes around the $z$-axis while gradually damping towards the applied field (along the negative $z$-axis).
This simplicity means that the problem can also be written as an ODE, allowing for useful comparisons.
Additionally exact solutions for the switching time are known \cite{Mallinson2000}, allowing quantification of the error.

% The spherical mesh is generated using a face splitting algorithm: begin with an icosahedron (a polygon with 20 triangular faces) then divide each face into three triangles and move the newly created node onto the surface of the sphere.
% Repeat the division to generate progressively more accurate (and expensive) approximations to the surface of a sphere.
% The list of faces is then used as input to tetgen \cite{tetgen-website} to generate an unstructured tetrahedral mesh.

As mentioned above, the simple geometry of this problem means that the physics can be captured, without any loss of accuracy, by an ODE version of the LLG:
\begin{equation}
  \label{eq:ode-llg}
  \begin{aligned}
    \dmdt (1 + \dampc^2) &= - \mv \times \hv - \dampc \mv \times \left( \mv \times \hv \right), \\
    \hv &= \happ - \mv/3,
  \end{aligned}
\end{equation}
where $\mv = \mv(t)$ and we have used the Landau-Lifshitz form for ease of implementation.

\section{Implementation details}

In these experiments we use the FEM discretisation of the non-dimensional LLG as discussed in \cref{sec:galerk-meth-llg}.
Magnetostatics calculations (when in use) are handled using either the FEM/BEM discretisation as discussed in \cref{sec:hybr-finit-elem} or the analytical formula $\hms = -\mv/3$.
We use three time integration schemes.
The first is the standard IMR as discussed in \cref{sec:some-implicit-time-integrators}, with monolithic coupling to the magnetostatic calculations as described in \cref{sec:fully-implicit-bem}.
The second scheme is IMR with semi-implicit (decoupled) magnetostatic calculations as discussed in \cref{sec:semi-implicit-bem}.

The third scheme is an explicit method.
For explicit time integration we use the mathematically equivalent Landau-Lifshitz form of the LLG, \cref{eq:ll-nd} because the time derivative can be written explicitly, avoiding a non-linear solve.
We use a two stage Runge-Kutta method (RK2), also known as Heun's method \cite[58]{Atkinson2009}:
\begin{equation}
  \label{eq:heunn}
  \begin{aligned}
    \mvtemp &= \mv_n + \dtn f(t_n, \mv_n), \\
    \mv_{n+1} &= \mv_n + \frac{\dtn}{2} \left( f(t_n, \mv_n) + f(t_{n+1},
      \mvtemp) \right).
  \end{aligned}
\end{equation}
The time derivatives required in \cref{eq:heunn} are calculated by inverting the finite-element mass matrix using a diagonally preconditioned conjugate gradient solver.
The magnetostatic potential $\phim$ is recalculated using the FEM/BEM method at appropriate time and magnetisation values during each stage of \cref{eq:heunn}.
The Poisson solves required for the evaluation of the potentials $\phione$ and $\phim$ use the methods and parameters discussed in \cref{sec:solution-strategies}.

Good quality (radius-to-edge ratio $ > 2$) quasi-uniform unstructured tetrahedral meshes of a sphere were generated using TetGen \cite{tetgen-website}.
Meshes were refined by decreasing the maximum element volume parameter.

All simulations were run for 4 time units ($\approx 20\text{ps}$) with a full reversal taking between 8 and 400 time units depending on the damping.
We ran the simulations without magnetostatics, with FEM/BEM magnetostatics, and with the analytical magnetostatic field for each value of the Gilbert damping constant.

To find bounds for the maximum stable step size, $\dtmax$ we use a simple heuristic algorithm:
The computation is repeated with a sequence of decreasing step sizes (halved each time) until a stable solution is observed, this stable step size is denoted $\dtx{a}$.
A solution is considered to be unstable if the maximum angle between the magnetisation of neighbouring nodes is greater than $\pi/4$.
This provides bounds on the maximum stable step of $\dtmax \in [\dtx{a}, 2\dtx{a})$. To tighten these bounds we then use two steps of a standard binary search algorithm: the computation is run with $\dtn{} = 3\dtx{a}/2$, if it is successful then $\dtmax \in [\frac{3\dtx{a}}{2}, 2\dtx{a})$ otherwise $\dtmax \in [\dtx{a}, \frac{3\dtx{a}}{2})$.

The initial step size, $\dtinitial$, is selected such that the temporal error is sufficiently small to obtain good accuracy (so any reduction in step size below this value is wasteful.

To assess physical stiffness and to find a time step size which gives sufficiently accurate results we solved the ODE form of the problem, \cref{eq:ode-llg}, using the RK2 and IMR methods with $\dtx{} = 0.1$.
Using IMR with $\alpha = 0.01$ we found a relative error in the final switching time of $0.3\%$ (absolute error  $1.2 \text{ time units} \approx 6\text{ps}$), for other values of $\alpha$ the percentage error is even smaller.
The relative error in switching time with $\alpha = 0.01$ using RK2 was $2.25\%$.
Since these results are from an ODE calculation the error is only due to the time integration, with no contributions from spatial discretisation.
Based on these results we conclude that $\dtinitial = 0.1$ gives a sufficiently small temporal error to be a reasonable time step size.
Additionally, since no stability issues were seen for any value of $\alpha$, we conclude that any lack of stability when integrating the equivalent PDE must arise purely from the spatial discretisation rather than the underlying physics.

% and forward Euler needs dt=0.0001 to get comparable error!!

\section{Numerical results}

\begin{figure}
  \centering
  \includegraphics[width=\textwidth]{images/stability_disabled}
  \caption{Maximum stable time step as a function of discretisation size for LLG without magnetostatics. Data points are $\dtmax$, the largest stable time step found. Error bars represent the range in which the largest stable time step is contained. The horizontal dashed line shows the time step where RK2 and IMR are equally efficient (IMR is more efficient when the maximum stable step of the RK2 method moves below this line). The maximum time step is limited to 0.1 for accuracy reasons.
}
  \label{fig:no-hms-stability}
\end{figure}

The results of the experiments with $\hms = \zerov$ are shown in \cref{fig:no-hms-stability}.
Results with full FEM/BEM magnetostatics and results with the analytical formula for magnetostatics are shown in \cref{fig:hms-stability} and \ref{fig:analytic-hms-stability} respectively.

In all cases we find that as the damping constant is reduced by an order of magnitude, stable explicit time step sizes are reduced by approximately a factor of two (\ie an increase in the stiffness).

\begin{figure}
  \centering
  \includegraphics[width=\textwidth]{images/stability_decoupled}
  \caption{Stable time step against discretisation size for LLG with FEM/BEM magnetostatics.
  }
  \label{fig:hms-stability}
\end{figure}

\begin{figure}
  \centering
  \includegraphics[width=\textwidth]{images/stability_sphere}
  \caption{Stable time step against discretisation size for LLG with $\hv_{\text{ms}} = - \mv / 3$.
  }
  \label{fig:analytic-hms-stability}
\end{figure}

Comparing \cref{fig:no-hms-stability} and \ref{fig:hms-stability} we see that using FEM/BEM magnetostatics significantly increases the stiffness, requiring roughly an order of magnitude smaller explicit time steps for stability.
However, from \cref{fig:analytic-hms-stability} we see that adding the exact field does not induce stiffness, so we can conclude that this effect is due to the numerical methods used and not the magnetostatic field itself.
From our data we cannot predict whether other methods of calculating the magnetostatic field, such as multipole methods, will result in similar increases in the number of explicit time steps required.
However we expect that the effect is due to the coupling with the additional Poisson problems (which means that the semi-discretised equation is a differential algebraic equation \cite[371]{HairerWanner} rather than an ODE), thus any potential based method is likely to exhibit similar behaviour.

\cref{fig:hms-stability} shows that using a semi-implicit method with explicit magnetostatic calculations (SIMR) imposes no stability restrictions on the time step due to spatial discretisation at the spatial resolutions relevant for micromagnetic problems for this example.

To further analyse our results we need an estimate of the ratio of computational effort for explicit vs implicit time steps. Without magnetostatics we find that each step of IMR takes on average 5.86 times more computation time than a step of RK2. With magnetostatics each step of SIMR only takes 3.40 times more computation time than a step of RK2 (the difference is due to the cost of solving multiple Poisson problems at each Runge-Kutta stage). Using these ratios we can calculate the stable RK2 time step required to have equivalent computational efficiency to IMR with step size 0.1. This stable step size is marked on \cref{fig:no-hms-stability}, \ref{fig:hms-stability} and \ref{fig:analytic-hms-stability} with a dashed line.

Based on these results we say that a problem is ``stiff'', and that an implicit method will perform significantly better than an explicit one, if the ratio of the desired time step, $\dtinitial$ to the maximum stable explicit time step, $\dtmax$ is greater than 20.
% This roughly agrees with the results of Suess \etal \cite{Suess2002}, who used the widely used (and presumably heavily optimised) CVODE package to solve the \mumag standard problem 4 using similar techniques to ours. % Their bdf2 steps are extremely slow, probably bad preconditioner.
A caveat is that both types of model could be further optimised using, for example parallelism, improved preconditioning, mass lumping, hierarchical boundary matrix representations, etc.

Typical advice for the number of elements per exchange length is that an absolute minimum is one, and in order to show that the results are mesh independent the mesh should be refined a few times \cite[Sec. 11]{nmag-manual}.
This leads to a reasonable finest mesh with around three elements per exchange length.

We see that with FEM/BEM magnetostatics, realistic damping ($\alpha = 0.01$) and at least three elements per exchange length our case study is stiff.
Without FEM/BEM magnetostatics stiffness only occurs if refinement to around five or more elements per exchange length is needed for any part of the domain.
Problems that require this level of refinement include resolving the geometry in studies of granular or patterned media \cite{Suess2002} and resolving vortex-core-like structures \cite{Andreas2014b}.
% also \cite[App. D]{Knittel2011} found he needed this level of refinement for some parts of model to be accurate.

On the other hand LLG problems can be only moderately stiff if refinement is only needed up to the level around one element per exchange length, as is often required for simple geometries.
This is consistent with the fact that the \mumag standard problem \#4 is often solved using explicit time integration methods \cite{mumag-website}.

Similar experiments with the standard 4th order Runge-Kutta method \cite[41]{Iserles2009} and $\alpha=1.0$ (plots not shown) give essentially the same results as for RK2. As $\alpha$ is reduced the maximum stable step size $\dtmax$ is reduced, but not as rapidly as for RK2. However due to the increased computational cost per time step (a factor of two) the onset of stiffness for RK4 (for all $\alpha$) occurs at roughly the same spatial discretisation as for RK2 with $\alpha = 0.1$.

Finally we point out that the discussion above assumes that the accuracy obtained with $\dtx{} = \dtinitial$ is sufficient.
If a higher temporal accuracy than this is required then smaller time steps are needed regardless of stability, so the limitations imposed by stiffness are proportionally less significant.

\section{Conclusions}
Our results show that the LLG equation without magnetostatics or with analytical magnetostatic field calculations becomes stiff (\ie implicit methods are significantly more efficient) as the number of elements per exchange length decreases below around 5.
If FEM/BEM magnetostatic calculations are used stiffness occurs at much coarser discretisations, beginning at around $2\dash 3$ elements per exchange length.
In all cases decreasing the damping constant also increases the stiffness.

The results for the ODE version of the problem indicate that the observed stiffness is due to the spatial discretisation and not the physics of the problem.
Since more complex physics is unlikely to ever reduce the stiffness, we expect that these results will extend to other, more complex, problems.

We also found that our semi-implicit FEM/BEM method does not suffer from discretisation induced stiffness in this simple test case.

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:


%!TEX program = xelatex
% 完整编译: xelatex -> bibtex -> xelatex -> xelatex
\documentclass[lang=cn,11pt,a4paper,cite=numbers]{elegantpaper}
\usepackage{xfp}
\usepackage{tikz}

\title{Hyperbolic growth}
\author{Hui Zheng}
% \institute{}

% \version{0.09}
\date{\zhtoday}

% 本文档命令
\usepackage{array}
\newcommand{\ccr}[1]{\makecell{{\color{#1}\rule{1cm}{1cm}}}}

\begin{document}

\maketitle

\begin{abstract}
When a quantity grows towards a \href{https://en.wikipedia.org/wiki/Mathematical_singularity}{singularity} under a finite variation(a \href{https://en.wikipedia.org/wiki/Finite-time_singularity}{"finite-time singularity"}), it is said to undergo hyperbolic growth\cite{korotaev2006introduction}. More precisely, the \href{https://en.wikipedia.org/wiki/Reciprocal_function}{reciprocal function} $\frac{1}{x}$ has a \href{https://en.wikipedia.org/wiki/Hyperbola}{hyperbola} as a graph, and has a singularity at 0, meaning that the \href{https://en.wikipedia.org/wiki/Limit_of_a_function}{limit} as $x{\to}0$ is infinite: any similar graph is said to exhibit hyperbolic growth.
\begin{figure}[!htb]
  \centering
  \includegraphics[width=0.4\textwidth]{figs/hyperbolic-growth.png}
  \caption{figs:hyperbolic-growth}
  \label{figs:hyperbolic-growth}
\end{figure}
\keywords{hyperbolic growth}
\end{abstract}

\section{Description}
  If the output of a function is \href{https://en.wikipedia.org/wiki/Inversely_proportional}{inversely proportional} to its input, or inversely proportional to the difference from a given value $x_{0}$, the function will exhibit hyperbolic growth, with a singularity at $x_{0}$.

  In the real world, hyperbolic growth is created by certain non-linear \href{https://en.wikipedia.org/wiki/Positive_feedback}{positive feedback} mechanisms\cite{markov2007phanerozoic}.

\subsection{Comparisons with other growth}
  Like \href{https://en.wikipedia.org/wiki/Exponential_growth}{exponential growth} and \href{https://en.wikipedia.org/wiki/Logistic_growth}{logistic growth}, hyperbolic growth is highly \href{https://en.wikipedia.org/wiki/Nonlinear_system}{nonlinear}, but differs in important respects. These functions can be confused, as exponential growth, hyperbolic growth, and the first half of logistic growth are \href{https://en.wikipedia.org/wiki/Convex_function}{convex functions}; however their \href{https://en.wikipedia.org/wiki/Asymptotic_behavior}{asymptotic behavior}(behavior as input gets large) differs dramatically.
\begin{itemize}
  \item logistic growth is constrained(has a finite limit, even as time goes to infinity),
  \item exponential growth grows to infinity as time goes to infinity (but is always finite for finite time),
  \item hyperbolic growth has a singularity in finite time (grows to infinity at a finite time).
\end{itemize}

\section{Mathematical example}
  The function
\begin{equation}
  x(t)=\frac{1}{t_{c}-t}
\end{equation}
exhibits hyperbolic growth with a singularity at time $t_{c}$: in the limit as $t{\to}t_{c}$, the function goes to infinity.

  More generally, the function
\begin{equation}
  x(t)=\frac{K}{t_{c}-t}
\end{equation}
exhibits hyperbolic growth, where $K$ is a scale factor.

  Note that this algebraic function can be regarded as analytical solution for the function's differential\cite{korotaev2006introduction}:
\begin{equation}
  \frac{dx}{dt}=\frac{K}{(t_{c}-t)^{2}}=\frac{x^{2}}{K}
\end{equation}

  This means that with hyperbolic growth the absolute growth rate of the variable $x$ in the moment $t$ is proportional to the square of the value of $x$ in the moment $t$. Respectively, the quadratic-hyperbolic function looks as follows:
\begin{equation}
  x(t)=\frac{K}{(t_{c}-t)^{2}}
\end{equation}

\section{See also}
\begin{itemize}
  \item \href{https://en.wikipedia.org/wiki/Exponential_growth}{Exponential growth}
  \item \href{https://en.wikipedia.org/wiki/Logistic_growth}{Logistic growth}
  \item \href{https://en.wikipedia.org/wiki/Mathematical_singularity}{Mathematical singularity}
\end{itemize}

\nocite{*}
\bibliography{ref/refs}

\end{document}


\section{Local Search}

Idea: keep a single “current” state, and try to improve it.  Move
only to neighbors of that node.
Advantages:
\begin{itemize}
  \item No need to maintain a search tree.
  \item Use very little memory.
  \item Can often find good enough solutions in continuous or large
state spaces.
\end{itemize}

\subsection{Hill climbing (greedy local search)}

\begin{itemize}
  \item Looks only to immediate good neighbors and not beyond.
  \item Search moves uphill: moves in the direction of increasing elevation/value to find the top of the mountain.
  \item Terminates when it reaches a pick.
  \item Can terminate with a local maximum, global maximum or can get stuck and no progress is possible.
  \item A node is a state and a value.
\end{itemize}

\paragraph{Variants}
\begin{itemize}
  \item Sideways moves: escape from plateaux where best successor
    has same value as the current state
  \item Random-restart: overcomes local maxima,
    either find a goal or get several possible solution
    and pick the max
  \item Stochastic hill climbing chooses at random among the
    uphill moves.
\end{itemize}

\subsection{Local Beam Search}

\begin{itemize}
  \item Maintains $k$ states instead of one state.
  \item Select the $k$ best successor, and useful information is
    passed among the states.
\end{itemize}

\paragraph{Stochastic beam search}
\begin{itemize}
  \item Choose $k$ successors are random.
  \item Helps alleviate the problem of the the states
    agglomerating around the same part of the state space
\end{itemize}

\subsection{Genetic algorithms}

\begin{itemize}
  \item A variant of stochastic beam search.
  \item Successor states are generated by combining two parents
    rather by modifying a single state.
  \item Starts with $k$ randomly generated states, called
    \textbf{population}. Each state is an \textbf{individual}.
  \item The objective function is called \textbf{fitness
    function}
  \item Better states have high values of fitness function
\end{itemize}

\paragraph{Implementation}
\begin{itemize}
  \item Pairs of individuals are selected at random for
    reproduction w.r.t. some probabilities.
  \item A \textbf{crossover point} is chosen randomly in the string.
  \item Offspring are created by crossing the parents at the
    crossover point.
  \item Each element in the string is also subject to some
    \textbf{mutation} with a small probability.
\end{itemize}