%!TEX root = thesis.tex
\chapter{Analysis of the Monitorability of Timing Constraints}

\section{Monitorability of the TADL2 Timing Constraints}
	In this chapter, each of the TADL2 constraints will be classified into the classes \emph{Simple Monitorable}, \emph{Simple Monitorable with Delay} and \emph{Not Simple Monitorable}, as defined in chapter~\ref{chapter-monitorability}. For the last class, it will be demonstrated if the constraint is not simple monitorable in any cases or just in worst-case scenarios.

\subsection{DelayConstraint}
	\label{monitorability_DelayConstraint}
	The \emph{DelayConstraint} is defined as\\[10pt]
	\begin{math}
		\forall x\in source:\exists y\in target: lower\leq y-x\leq upper.
	\end{math}\\[10pt]
	It describes there is at least one $target$ event for each $source$ event, which occurs between $lower$ and $upper$ after the $source$ event. Therefore, the state that needs to be stored to monitor the \emph{DelayConstraint} is the set of $source$ events that are younger than $upper$ and did not have a matching $target$ event yet. If this information is not stored, the constraint cannot be monitored correctly. Updates to this state and output of the monitor are done at $source$ and $target$ events and at delay timestamps $upper$ after the oldest stored $source$ event.\\
	The maximal required storage size of the state depends on the number of $source$ events, which can occur in any time interval of the length $upper$. An example of this worst-case situation can be seen in figure~\ref{fig:DelayConstraintWorstCase}. The attributes in this example are $lower=upper=5$, $source$ events occur in the timestamps $\{1, 1.1, ..., 5.9\}$ and $target$ events in the timestamps $\{6, 6.1, ..., 11\}$. At timestamp 6, all 49 $source$ events must be stored because they are all required to generate the correct output in this and in the following timestamps. At this timestamp, the oldest $source$ event can be removed from the storage because the matching $target$ event occurs in this timestamp. Other timestamps cannot be removed from the storage because they are younger than $lower$. With every following $target$ event, the oldest event can be removed from the storage until every $source$ had its matching $target$ event at timestamp 11.\\
	Because the time domain is understood as real numbers in TADL2, a possibly infinite number of events can be placed in any interval of the length $upper$. This means that the required storage space can grow infinitely. Therefore, the worst-case memory requirement is dependent on the events in the trace. Consecutively, the \textit{DelayConstraint} is not \textit{simple monitorable}.\\
	Because the $source$ events are removed from the state when a matching $target$ event occurs, the required storage space does not grow continuously and infinite resources are only required in worst-case scenarios. Therefore, the \emph{DelayConstraint} is \emph{worst-case not simple monitorable}.
	\begin{figure}
		\centering
		\begin{tikzpicture}[thick]
			\node at (0, 0){source};
			\node at (0, -3.1) {lower=upper};
			\node at (0, -6.2) {target};

			%lower = 5, upper = 5
			\foreach \x in {1.0,1.1, ...,  6}{
				% source
				\draw (\x, 0.2) -- (\x, -0.2);
				% target
				\draw (\x+5, -6) -- (\x+5, -6.4);
			}

			% lower/upper
			\foreach \x in {0, 0.1, ..., 5}{
				\draw[->] (1 + \x, -0.6-\x) -- (6+\x, -0.6-\x);
			}

			\foreach \y in {-6.75}{
				\foreach \x in {0, 1, ..., 11}{
					\draw (\x, \y+0.1) -- (\x,  \y-0.1);
					\node at(\x,  \y-0.4) {\x};
				}
				\foreach \x in {0.5, 1.5, ..., 10.5}
					\draw (\x, \y) -- (\x, \y-0.1);
				\draw[->] (0, \y) -- (11.5, \y);
			}
		\end{tikzpicture}
		\caption{\emph{DelayConstraint} or \emph{StrongDelayConstraint}  with $lower=upper=5$}
		\label{fig:DelayConstraintWorstCase}
	\end{figure}

\subsection{StrongDelayConstraint}
	The difference between the \emph{DelayConstraint} and the \emph{StrongDelayConstraint} is that for every $source$ event, there must be exactly one matching $target$ event in the \emph{StrongDelayConstraint}. Therefore, the state of the monitor is nearly the same. Like before, all $source$ events that did not have a matching $target$ event yet must be stored, but at matching $target$ events, only one $source$ event can be removed from the storage. The worst-case memory requirement remains unchanged and is still dependent on the number and the placement of the input events. Therefore the \emph{StrongDelayConstraint} is \textit{worst-case not simple monitorable} with the same argumentation as for the \textit{DelayConstraint}.

\subsection{RepeatConstraint}
	The \emph{RepeatConstraint} defines the time distance between each event and its $span^{th}$ successor. Therefore, the state that must be stored for monitoring consists of the timestamps of the $span+1$ latest events. The state is updated at every event, the oldest stored event is removed and the timestamp of the current event is placed in the storage. The output function checks if the time distance between the oldest stored event and the current timestamp is between $lower$ and $upper$. To monitor this constraint, a delay is required because a missing event, or an event that occurs too late, would not be determined in the earliest possible timestamp otherwise. The delay offset can be calculated by the time distance between the current timestamp and the timestamp that lays $upper$ behind the oldest stored event.\\
	Because the memory requirements are fixed ($span+1$ timestamps must be stored) and the state transition and output function can be programmed in a way that they are in  $\mathcal O(1)$ (e.g., if double linked lists are used), the \emph{RepeatConstraint} is \textit{simple monitorable with delay}.

\subsection{RepetitionConstraint}
	The \emph{RepetitionConstraint} is defined as\\[10pt]
		$RepetitionConstraint(s, lower, upper, span, jitter)$\\
		$\equiv \exists X\subset \mathbb{T}: RepeatConstraint (X, lower, upper, span)$\\
		\hspace{7cm}$\land$ $StrongDelayConstraint(X, s, 0, jitter)$\\[10pt]
	The elements of the set $X$ follow the RepeatConstraint and the events, which should be monitored, are following in an interval of the length $jitter$ after the elements of $X$. For each element of $X$, there is exactly one event in $s$ and vice versa.\\
	The monitoring algorithm for this constraint, which will be explained in detail in \ref{chapter-implementation}, stores the upper and lower bounds for the next $span$ elements of $X$.
	These borders are stored in a list and calculated by\\[10pt]
	$lowerBound:= List\_append(last(List\_tail(LowerBound), s), lowerBoundNow + lower)$ \\for the lower bound and\\
	$upperBound:= List\_append(last(List\_tail(UpperBound), s), upperBoundNow + upper)$ \\for the upper bound.\\[10pt]
	The oldest items in these lists (the head of these lists) are removed and the newly calculated bounds for the $span$ next element of $X$ is inserted at the end of the lists. $lowerBoundNow$ and $upperBoundNow$ are the describing limitations of the element of $X$ right before the current event. They are calculated using the list mentioned above and the timestamp of the current event by the following definition:\\[10pt]
	$lowerBoundNow:= max(List\_head(last(LowerBoundX, s)), time(s)-jitter)$\\
	$upperBoundNow:= min(List\_head(last(UpperBoundX, s)), time(s))$\\[10pt]
	If the timestamp of the current event is between $lowerBoundNow$ and $upperBoundNow$, the output of the monitor is $\top^p$, in any other case, or when the delay ran out, it is $\bot$.\\
	The size of these lists has a fixed upper limit ($span$) and the state transition and output functions are in $\mathcal{O}(1)$. Therefore they are independent of the trace and the \emph{RepetitionConstraint} is a property, which is \textit{simple monitorable with delay}.

\subsection{SynchronizationConstraint}
	The \emph{SynchronizationConstraint} describes groups of streams, which events occur in common clusters. Each of these streams must have at least one event in each of these intervals. Any events that lay outside of these intervals are prohibited.\\
	Figure~\ref{fig:SynchronizationConstraintWorstCase}, which is similar to the example for the \emph{DelayConstraint}, shows an example of this constraint, which is the worst-case scenario in terms of monitoring. The $tolerance$ interval is 5 timestamps long, the event set $s_1$ contains the events $\{1, 1.1, ..., 5.9\}$ and $s_2$ is containing $\{6, 6.1, ..., 11\}$. Each of the events of $s_1$ must be stored until the end of the $tolerance$ interval. Otherwise, it would be impossible to check the constraint correctly. As described in section~\ref{monitorability_DelayConstraint}, an arbitrary number of events can be placed in this interval and the memory requirements are dependent on the input streams. The required storage space is not growing continuously because the stored events can be removed at the end of the $tolerance$ interval. Therefore the \emph{SynchronizationConstraint} is \textit{worst-case not simple monitorable}.\\
	\\
	It should be noted that the illustration of the constraint in figure~\ref{fig:SynchronizationConstraintWorstCase} may be misleading because the $tolerance$ intervals are only shown after the events of $s_1$, not after the events of $s_2$. Every implementation of a monitor for this constraint must also store the events of $s_2$ for the length of $tolerance$, as they could be important for events following after them.
	\begin{figure}
		\centering
		\begin{tikzpicture}[thick]
			\node at (0, 0){$s_1$};
			\node at (0, -3.1) {tolerance};
			\node at (0, -6.2) {$s_2$};

			%lower = 5, upper = 5
			\foreach \x in {1.0, 1.1, ...,  6}{
				% source
				\draw (\x, 0.2) -- (\x, -0.2);
				% target
				\draw (\x+5, -6) -- (\x+5, -6.4);
			}

			% lower/upper
			\foreach \x in {0, 0.1, ..., 5}{
				\draw[->] (1 + \x, -0.6-\x) -- (6+\x, -0.6-\x);
			}

			\foreach \y in {-6.75}{
				\foreach \x in {0, 1, ..., 11}{
					\draw (\x, \y+0.1) -- (\x,  \y-0.1);
					\node at(\x,  \y-0.4) {\x};
				}
				\foreach \x in {0.5, 1.5, ..., 10.5}
					\draw (\x, \y) -- (\x, \y-0.1);
				\draw[->] (0, \y) -- (11.5, \y);
			}
		\end{tikzpicture}
		\caption{\emph{SynchronizationConstraint} or \emph{StrongSynchronizationConstraint}  with $tolerance=5$}
		\label{fig:SynchronizationConstraintWorstCase}
	\end{figure}

\subsection{StrongSynchronizationConstraint}
	The difference between the \emph{StrongSynchronizationConstraint} and the \emph{SynchronizationConstraint} is that in the StrongSynchronizationConstraint, only one event per stream is allowed per synchronization cluster. Overlapping of these clusters is still possible. Therefore, this constraint can be classified as \textit{worst-case not simple monitorable} following the same argumentation as the previous constraint.

\subsection{ExecutionTimeConstraint}
	The \emph{ExecutionTimeConstraint} ensures that the time distance between the $stop$ and $start$ events, not counting interruptions (specified by the $preempt$ and $resume$ events), is between $lower$ and $upper$.\\
	Under the assumption that the input events are in a logical order (every execution is started by a $start$ event and finished by a $stop$ event, every $preempt$ event is followed by a $resume$ event with no other event in between and no $preempt$ or $resume$ events occur outside of the intervals spanned by $start$ and $stop$ events), three time values must be stored to monitor this constraint. First, the timestamp of the latest $start$ event. Second, the timestamp of the latest $preempt$ event and third, the sum of the time distances between the $resume$ and $preempt$ events. This sum is reset at every $start$ event.\\
	These values are updated on events in $start$, $preempt$ and $resume$.\\
	For the output function, the runtime can be calculated by\\ $runtime = time(now) - time(start) - (sum(time(resume) - time(preempt))$.\\
	This value must be smaller or equal to $upper$ at any event. Additionally, at events in stop, the runtime must be greater or equal to $lower$.\\
	To monitor this constraint correctly, a delay is required when a $stop$ event is late or missing. The delay duration is the distance between the current timestamp and $upper$ minus $runtime$ after the current timestamp.\\
	The required storage space is fixed(remind that we limited the memory size of timestamps in \ref{monitorability_timestamps}), and also the runtime of the state transition and output function can be implemented in constant runtime. Consecutively the \emph{ExecutionTimeConstraint} is \textit{simple monitorable with delay}.

\subsection{OrderConstraint}
	The \emph{OrderConstraint} describes that an $i^{th}$ $target$ event must exist if an $i^{th}$ $source$ event exists and that the $i^{th}$ $target$ event occurs after the $i^{th}$ $source$ event.  Because an arbitrarily large number of $source$ events may occur before the first $target$ event, a possibly arbitrary large distance between the number of events must be stored. Therefore, the required storage space is dependent on the input streams.  Because this is only a worst-case scenario and the size of the stored number can be decreased, when a $target$ event occurs, the \emph{OrderConstraint} is \textit{worst-case not simple monitorable}.

\subsection{ComparisonConstraint}
	The \textit{ComparisonConstraint} defines an ordering relation between two single timestamps and does not describe relations of streams or their events. Therefore, the definition of \textit{simple monitorability} is not applicable. However, because of the restrictions to timestamps made in section~\ref{monitorability_timestamps}, the maximal required storage space and the runtime of the operators $\leq, <, \geq, >, =$ have a fixed upper limit.

\subsection{SporadicConstraint}
	The \emph{SporadicConstraint} is defined via the \emph{Repetition-} and \emph{RepeatConstraint} without introducing any new timestamps in the definition of the \emph{SporadicConstraint}. These Constraints are \textit{simple monitorable with delay}. Therefore the \emph{SporadicConstraint} is also \textit{simple monitorable with delay}.

\subsection{PeriodicConstraint}
	The \emph{PeriodicConstraint} is a special application of the \emph{SporadicConstraint}. Therefore it is also \textit{simple monitorable with delay}.

\subsection{PatternConstraint}
	The \emph{PatternConstraint} was redefined to\\[10pt]
	\begin{math}
		\exists X: PeriodicConstraint(X, period, 0, 0)\\
		\text{\hspace{.5cm}} \land \forall i: StrongDelayContraint(X, event, offset_i, offset_i+jitter)\\
		\text{\hspace{.5cm}} \land RepeatConstraint(event, minimum, \infty, 1)
	\end{math}\\[10pt]
	in section~\ref{sec:patterConstraintDefinition}. The input events occur after the strictly periodic timestamps of $X$. The distances between the elements of $X$ and the following events are defined by \textit{offset}.\\
	This constraint can be monitored by storing the upper and lower limit of the current latest element of $X$ and the number of event occurrences, reset to 0 at every |\emph{offset}|$^{th}$ event. The limits of the elements of $X$ can be narrowed down at every event occurrence because the valid distance between the event and the element of $X$ is known by \emph{offset} and $jitter$. At every $|\text{\emph{offset}}|^{th}$ event occurrence, the limitations of the current $X$ must be increased by $period$. The validity of the constraint can be tested by checking that the current event has the correct distance to the limitations of the current latest element of $X$. To be able to recognize late or missing events, a delay is required. The timestamp, where the delay must occur, can be calculated by adding $jitter$ and the entry of \textit{offset} for the next expected event to the current upper limit of latest $X$.\\
	Because the memory requirements (two timestamps and an integer) are constant and the mentioned state transition, delay calculation and evaluation functions can be implemented in constant time, the \emph{PatternConstraint} is \textit{simple monitorable with delay}.\\[10 pt]
	If the redefinition of the \emph{PatternConstraint} is not done, the constraint can be reduced to\\[10pt]
	\begin{math}
		RepeatConstraint(event, minimum, \infty, 1)
	\end{math}\\[10pt]
	as stated before in section~\ref{sec:patterConstraintDefinition}. Because the \textit{RepeatConstraint} is \textit{simple monitorable with delay} and the $upper$ parameter is $\infty$, the constraint is \textit{simple monitorable} (without delay) in this variant.

\subsection{ArbitraryConstraint}
	The \emph{ArbitraryConstraint} is defined as a combination of the \emph{RepeatConstraint}:\\[10pt]
	\begin{math}
		ArbitraryConstraint(event, minimum_1, ..., minimum_n, maximum_1, ..., maximum_n)\\
		\Leftrightarrow \forall i\in{1, ..., n}: RepeatConstraint(event, minimum_i, maximum_i, i).
	\end{math}\\[10pt]
	The \emph{RepeatConstraint} is \textit{simple monitorable with delay}. Therefore the \emph{ArbitraryConstraint} is also \textit{simple monitorable with delay}.

\subsection{BurstConstraint}
	The \emph{BurstConstraint} is defined as as combination of the \emph{RepeatConstraint}:\\[10pt]
	\begin{math}
		RepeatConstraint(event, length, \infty, maxOccurrences)\\
		\text{\hspace{.5cm}}\land RepeatConstraint(event, minimum, \infty, 1)
	\end{math}\\[10pt]
	The \emph{RepeatConstraint} is \textit{simple monitorable with delay}. The $upper$ parameter in both applications of the \textit{RepeatConstraint} is $\infty$. Therefore, the timeout always occurs infinite timestamps after the latest input events, which means the timeout is dispensable and the \emph{BurstConstraint} can be monitored without any delay or timeout operator. Consecutively, the \emph{BurstConstraint} is a \textit{simple monitorable} property.

\subsection{EventChains}
	The \textit{ReactionConstraint} and all following Constraints are defined on \textit{EventChains}, defined as $stimulus$ and $response$ stream. Each event of these streams has a color attribute, which describes the causal connection of individual events.  It is required that any $stimulus$ event of a specific color must occur before the first $response$ event with the same color. Further restrictions are not defined. The data type of this attribute is not specified, except that it may be infinite and an equality test must exist.\\
	Monitoring this property is difficult because it is required to store every color which has occurred in $response$. The reason for this can be seen in figure~\ref{fig:colorExample}. In the interval between the timestamps 1 and 2, there are 5 events of different colors in $stimulus$. Their counterparts in $response$ occur in the interval between 4 and 5. In timestamp 6, there is an event in $response$ of the color black. After that, not black is allowed in $stimulus$. To check this properly for all colors, the color of all events, which occurred in $response$ must be stored until the end of the observation.\\
	The memory consumption to monitor this property is growing continuously with any event that introducing a new color in $response$. Therefore the correctness of \textit{EventChains} is an \textit{always not simple monitorable} property.
	\begin{figure}
		\begin{tikzpicture}[thick]
		\node at (0, 0){$stimulus$};
		\node at (0, -1.2) {$response$};
		%stimulus
		\foreach \x in {0}{
			\draw[green]	(\x + 1  , 0.2) -- (\x + 1  , -0.2);
			\draw[blue]		(\x + 1.2, 0.2) -- (\x + 1.2, -0.2);
			\draw[purple]	(\x + 1.4, 0.2) -- (\x + 1.4, -0.2);
			\draw[red]		(\x + 1.6, 0.2) -- (\x + 1.6, -0.2);
			\draw[orange]	(\x + 1.8, 0.2) -- (\x + 1.8, -0.2);
		}
		%\draw[green]	(8  , 0.2) -- (8 , -0.2);
		%\draw[black]	(9.5  , 0.2) -- (9.5 , -0.2);
		%response
		\foreach \x in {3}{
			\draw[purple]	(\x + 1  , -1) -- (\x + 1  , -1.4);
			\draw[green]		(\x + 1.2, -1) -- (\x + 1.2, -1.4);
			\draw[blue]	(\x + 1.4, -1) -- (\x + 1.4, -1.4);
			\draw[red]		(\x + 1.6, -1) -- (\x + 1.6, -1.4);
			\draw[orange]	(\x + 1.8, -1) -- (\x + 1.8, -1.4);
		}
		\draw[black]	(6, -1) -- (6, -1.4);
		\foreach \y in {-2}{
			\foreach \x in {0, 1, ..., 11}{
				\draw (\x, \y+0.1) -- (\x,  \y-0.1);
				\node at(\x,  \y-0.7) {\x};
			}
			\foreach \x in {0.5, 1.5, ..., 10.5}
			\draw (\x, \y) -- (\x, \y-0.1);
			\draw[->] (0, \y) -- (11.5, \y);
		}
		\end{tikzpicture}
		\centering
		\caption{Event Chain example}
		\label{fig:colorExample}
	\end{figure}

\subsection{ReactionConstraint}
	If we assume the correctness of the \textit{EventChains}, a monitor would be similar to a monitor of the \textit{DelayConstraint}. The only difference is that the color attribute of the stored $stimulus$ events must also be stored. Removing events from the storage is only possible when the time distance and the color between the $stimulus$ and $response$ events are correct.  Like for the \textit{DelayConstraint}, the required worst case storage space is dependent on the input streams. Therefore the \textit{ReactionConstraint} is \textit{worst case not simple monitorable} if the correctness of the \textit{EventChain} is assumed.

\subsection{AgeConstraint}
	Similar to the analysis of the \textit{ReactionConstraint}, we assume the correctness of the \textit{EventChain}.\\
	The \textit{AgeConstraint} is very similar to the \textit{ReactionConstraint}. The main difference is that every $response$ event requires a $stimulus$ event in a matching color in the right distance, not the other way around. Because the $response$ events always occur after the $stimulus$ event(s) in the same color, no delay is required, but the number of events in $stimulus$ that must be stored in worst cases remains the same as in the \textit{ReactionConstraint}. Therefore, the \textit{AgeConstraint} is \textit{worst-case not simple monitorable} if the correctness of the \textit{EventChain} is assumed.

\subsection{OutputSynchronizationConstraint}
	Again, the correctness of the \textit{EventChain} is assumed in the analysis.\\
	The definition of the \textit{OutputSynchronizationConstraint} does not limit the time distance between $stimulus$ events and their associated synchronization clusters in the $response$ streams, but the first occurrences of the color of the $stimulus$ event in the $response$ streams must form a valid synchronization cluster. The correctness of these synchronization clusters is not \textit{simple monitorable}, which is argued the same way as in the simple \textit{SynchronizationConstraint}. An arbitrarily large number of new synchronization clusters can be placed in a time interval with the length $tolerance$, which has to be stored until all $response$ streams have fulfilled this cluster. A key difference to the \textit{SynchronizationConstraint} is that only the first occurrence of each color must form a synchronization cluster. After this cluster, events of this color may occur independently. Because of this characteristic, the color of any finished synchronization cluster must be stored for the entire rest of the observation, which means the \textit{OutputSynchronizationConstraint} is an \textit{always not simple monitorable} property.

\subsection{InputSynchronizationConstraint}
	Like before, the correctness of the \textit{EventChains} is assumed.\\
	In the \textit{InputSynchronizationConstraint}, synchronization clusters in the $stimulus$ streams must only be fulfilled if the associated events are the last of their color in their streams before an associated $response$ event. This means, at least some information for every color, which occurred in the $stimulus$ streams, must be stored until the $response$ color with the same color.  Because several $response$ events of this color may occur, the information about a fulfilled or unfulfilled synchronization cluster may not be removed from the storage. Otherwise, it could not be checked correctly if there was a synchronization cluster with a matching color. Consecutively, the required storage space grows continuously with every new stimulus color and the constraint is \textit{always not simple monitorable}.

\section{Conclusion}

\begin{figure}
	\centering
	\includegraphics[width=\linewidth]{relationBetweenConstraint}
	\caption{Overview over constraints - \textcolor{green}{Simple Monitorable} - \textcolor{red}{Not Simple Monitorable}}
	\label{fig:relationbetweenconstraint}
\end{figure}
Figure~\ref{fig:relationbetweenconstraint} gives an overview, which TADL2 timing constraints are \textit{simple monitorable} and which are not. The \textit{ComparisonConstraint} is not defined on streams. Therefore the definition of \textit{simple Monitorability} is not applicable. All simple monitorable constraints, except the \textit{BurstConstraint} require the creation of new timestamps. The other constraints are not simple monitorable, of which the \emph{Input-} and \emph{OutputSynchronizationConstraint} are always not simple monitorable. If the correct order of the \textit{EventChains} is assumed, the \textit{Reaction-} and \textit{AgeConstraint} are only not simple monitorable in worst cases, like the other not simple monitorable constraints.\\
The arrows show which constraint is defined via other constraints. For example, the \emph{RepetitionConstraint} is defined via the \emph{StrongDelay-} and \emph{RepeatConstraint}. It should be noted that constraints, which are defined via not simple monitorable constraints, can be simple monitorable because of further restrictions, which limit the required storage space or runtime.

%\section{ReactionConstraint}
%	The \emph{ReactionConstraint} is defined as:
%	\\[10pt]
%	\begin{math}
%		\forall x\in scope.stimulus: \exists y\in scope.response:\\
%		\text{\hspace{.5cm}}x.color=y.color\\
%		\text{\hspace{.5cm}}\land (\forall y'\in scope.response: y'.color=y.color\Rightarrow y\leq y')\\
%		\text{\hspace{.5cm}}\land minimum \leq y-x \leq maximum
%	\end{math}\\[10pt]
%	%For every event $x$ in $scope.stimulus$, there is an event $y$ in $scope.response$ with the same color. The distance between $x$ and $y$ is specified by $minimum$ and $maximum$.
%	The third line is the most relevant for the classification of monitorability. It says, that additional events in $scope.response$ with the same color of $y$ must occur at or after $y$. Other restrictions to additional events in $scope.response$ are not defined.\\
%	\ref{fig:WorstCaseReactionConstraint} visualizes, where this leads to problems in terms of monitoring. Between the timestamps 1 and 7, there are many events with different colors in $scope.response$ and the constraint is satisfied. In timestamp 8, there is an event in $scope.stimulus$ that has a color that matches with one of the $scope.response$ events, therefore the constraint is not fulfilled anymore.\\
%	The Example shows, that every color of the events that have occurred in $scope.response$ must be stored, to monitor the constraint correctly. Any new $scope.response$ event with a new color will extend the required storage space, but it is not possible to release this storage and still monitor the constraint correctly, therefore the memory requirements grows continuously. The definition of the color attribute of events says, that there is an infinite number of possible colors, therefore infinite memory resources are required for this constraint.
%	These characteristics show that this constraint is always non-finite monitorable.
%	\begin{figure}
%		\begin{tikzpicture}[thick]
%			\node at (0, 0){$stimulus$};
%			\node at (0, -1.2) {$response$};
%			%stimulus
%			\draw[green] (8, 0.2) -- (8, -0.2);
%			%response
%			\foreach \x in {0, ..., 5}{
%				\draw[green]	(\x + 1  , -1) -- (\x + 1  , -1.4);
%				\draw[blue]		(\x + 1.2, -1) -- (\x + 1.2, -1.4);
%				\draw[purple]	(\x + 1.4, -1) -- (\x + 1.4, -1.4);
%				\draw[red]		(\x + 1.6, -1) -- (\x + 1.6, -1.4);
%				\draw[orange]	(\x + 1.8, -1) -- (\x + 1.8, -1.4);
%			}
%			\foreach \y in {-2}{
%				\foreach \x in {0, 1, ..., 10}{
%					\draw (\x, \y+0.1) -- (\x,  \y-0.1);
%					\node at(\x,  \y-0.7) {\x};
%				}
%				\foreach \x in {0.5, 1.5, ..., 9.5}
%				\draw (\x, \y) -- (\x, \y-0.1);
%				\draw[->] (-0.1, \y) -- (10.2, \y);
%			}
%		\end{tikzpicture}
%		\caption{ReactionConstraint - Example with additional events and $minimum=maximum=3$}
%		\label{fig:WorstCaseReactionConstraint}
%	\end{figure}
%%TODO response events before stimulus allowed?
%
%\newpage
%\section{AgeConstraint}
%	The \emph{AgeConstraint} is defined as \\[10pt]
%	\begin{math}
%	\forall y\in scope.response: \exists x\in scope.stimulus:\\
%	\text{\hspace{.5cm}}x.color=y.color\\
%	\text{\hspace{.5cm}}\land (\forall x'\in scope.stimulus: x'.color=x.color\Rightarrow x'\leq x)\\
%	\text{\hspace{.5cm}}\land minimum \leq y-x \leq maximum
%	\end{math}\\[10pt]
%	It is a turned around counterpart to the \emph{ReactionConstraint}, where each event $y$ of $scope.response$ is preceded by an event $x$ in $scope.stimulus$ with matching color. The distance between these events is defined by the attributes $minimum$ and $maximum$. After the latest event $x$, that matches color with $y$ and is in the right distance (hence after $y-minimum$), no more events with this color are allowed. To monitor this property correctly, it is necessary to store, amongst other things, every color of events, that occurred in $scope.response$.  Figure~\ref{fig:WorstCaseAgeConstraint} visualizes this. In the interval from 5 to 6 there are 5 events in $scope.response$, their matching $scope.stimulus$ events are in the interval from 2 to 3. In timestamp 10, there is an event in $scope.stimulus$, which has a color that matches with an color, that has already been used in $scope.response$. The \emph{AgeConstraint} is not satisfied anymore after this, but to find that out, it is required to know every color, which  has already been used in $scope.response$. Like in the \emph{ReactionConstraint}, the memory requirements for this is growing continuously, therefore the \emph{AgeConstraint} is always non-finite monitorable.
%
%	\begin{figure}
%		\begin{tikzpicture}[thick]
%		\node at (0, 0){$stimulus$};
%		\node at (0, -1.2) {$response$};
%		%stimulus
%		\draw[green]	(2  , 0.2) -- (2  , -0.2);
%		\draw[blue]		(2.2, 0.2) -- (2.2, -0.2);
%		\draw[purple]	(2.4, 0.2) -- (2.4, -0.2);
%		\draw[red]		(2.6, 0.2) -- (2.6, -0.2);
%		\draw[orange]	(2.8, 0.2) -- (2.8, -0.2);
%
%		\draw[green]	(10, 0.2) -- (10, -0.2);
%
%		\foreach \x in {0, 0.1, 0.2, 0.3, 0.4}
%			\draw[<-] (2+\x+\x, -0.5-\x) -- (5+\x+\x, -0.5-\x);
%		%response
%		\draw[green]	(5  , -1) -- (5  , -1.4);
%		\draw[blue]		(5.2, -1) -- (5.2, -1.4);
%		\draw[purple]	(5.4, -1) -- (5.4, -1.4);
%		\draw[red]		(5.6, -1) -- (5.6, -1.4);
%		\draw[orange]	(5.8, -1) -- (5.8, -1.4);
%		\foreach \y in {-2}{
%			\foreach \x in {0, 1, ..., 10}{
%				\draw (\x, \y+0.1) -- (\x,  \y-0.1);
%				\node at(\x,  \y-0.7) {\x};
%			}
%			\foreach \x in {0.5, 1.5, ..., 9.5}
%			\draw (\x, \y) -- (\x, \y-0.1);
%			\draw[->] (-0.1, \y) -- (10.2, \y);
%		}
%		\end{tikzpicture}
%		\caption{AgeConstraint - Example with additional events and $minimum=maximum=3$}
%		\label{fig:WorstCaseAgeConstraint}
%	\end{figure}
%
%
%\section{OutputSynchronizationConstraint}
%	The \emph{OutputSynchronizationConstraint} is defined as\\[10pt]
%	\begin{math}
%		\forall x\in scope_1.stimulus: \exists t: \forall i: \exists y\in scope_i.response:\\
%			\text{\hspace{.5cm}} x.color = y.color\\
%			\text{\hspace{.5cm}}\land (\forall y'\in scope_i.response: y'.color=y.color \Rightarrow y\leq y')\\
%			\text{\hspace{.5cm}}\land 0\leq y-t\leq tolerance,
%	\end{math}\\[10pt]
%	where every $scope_i$ has the same $stimulus$ events.\\
%	Each $scope_1.stimulus$ event $x$ has an event $y$ in every $scope_i.response$ with the same color. This event $y$ is the first occurrence of this color in $scope_i.response$ and the $y$-events of all $scope_i.response$ do not lay more than $tolerance$ time apart.\\
%	A worst case scenario can be constructed, in which any number of events with different colors is placed in $scope_1.stimulus$. To monitor this constraint correctly, the color of all of these events must be stored, until the $response$ event with matching colors occur. Because an infinite number of colors is possible, infinite storage space is needed to monitor this constraint correctly. The colors of the events can be removed from the storage, after the first occurrence of them in the $response$ events, therefore the required memory is not growing continuously and the constraint is worst case Non-Finite monitorable.
%
%\section{InputSynchronizationConstraint}
%	The \emph{InputSynchronizationConstraint} is defined as\\[10pt]
%	\begin{math}
%		\forall y\in scope_1.response: \exists t: \forall i: \exists x\in scope_i.stimulus:\\
%		\text{\hspace{.5cm}} x.color = y.color\\
%		\text{\hspace{.5cm}}\land (\forall x'\in scope_i.stimulus: x'.color=x.color \Rightarrow x\leq x')\\
%		\text{\hspace{.5cm}}\land 0\leq x-t\leq tolerance
%	\end{math}\\[10pt]
%	and offers an turned around counterpart to the \emph{OutputSynchronizationConstraint}. The synchronized event clusters occur in the $scope_i.stimulus$ events and the latest events of them must be part of the synchronization. Like for the \emph{OutputSynchronizationConstraint} a worst case scenario, where an possibly infinite number of event colors must be stored, can be constructed, by putting a possibly infinite large number of synchronized events into the $scope_i.stimulus$ event sets, before the first event occurs in $scope_1.response$. Similar to the  \emph{OutputSynchronizationConstraint}, the colors of these events must be stored, until they are released by the $response$ events with a matching color, therefore infinite memory resources are required to monitor this constraint correctly and the \emph{InputSynchronizationConstraint} is worst case Non-Finite monitorable.


\section{Models}
Different models and model architectures are the result of (restricted) computational resources, new ideas and algorithms, specific tasks, and so on. To approach our problem, we figured that experimenting with different models would likely point us into a direction of certain architectural features which work well with the data at hand.

\subsection{AlexNet}
\citeauthor{Krizhevsky2012} have presented their influential \emph{AlexNet} in \citeyear{Krizhevsky2012}. It consists of only five convolutional layers, some additional max-pooling layers and three fully connected layers at the end, so its structure is rather simple. Nonetheless, it is packed with more than 40 million trainable parameters (the fully connected layers at the end are very large), making it not exactly computationally cheap to train. An AlexNet was supposed to serve as our baseline model from which we wanted to build things up.

\subsection{EfficientNet}
We then implemented a pre-trained EfficientNet with custom top layer. The EfficientNet model family was first introduced in 2019 (\citeauthor{Tan2019}) with the idea of providing scalable CNN architectures. Their architecture is largely based on MobileNets inverted residual blocks, in which bottlenecks serve as in- and output of the residual connections \citep{Sandler2018}. Multiple networks of different size for image classification purposes were introduced, many achieving better results than state-of-the-art models like the MobileNet it built upon and ResNet while being significantly smaller in terms of depth, width, and image resolution \citep{Tan2019}. Two years later, a second, even more powerful and efficient generation was introduced: EfficientNetV2 \citep{Tan2021}. For our purposes, given the low input resolution of $224\times224$, the model of choice is the EfficientNetV2-B0 -- the smallest model of the ensemble. The model is pre-trained on ImageNet21k and we implemented a custom fully-connected layer at the end to match our classification task.

\subsection{InceptionNet}
For an additional comparison, we implemented yet another supposedly very efficiently designed CNN, the InceptionV3 as introduced by \citeauthor{Szegedy2015} in \citeyear{Szegedy2015}. Its computational low cost makes the Inception architecture an attractive choice when resources are limited, e.g. in mobile scenarios. The inception network was a milestone in the development of CNN classifiers. It achieved extremely high accuracies on the ImageNet dataset with InceptionV3 reaching $78.1\%$ accuracy.
The fundamental idea behind the inception network is the inception block. In a traditional convolutional neural network layer, the previous layer's output is the input of the next layer until the state of prediction is accomplished. The inception block takes apart the individual layers. The previous layer's output is passed to four different operations in parallel and their outputs is concatenated -- the network is made wider instead of deeper. The naïve approach consists of a $1\times1$ convolution layer, a $3\times3$ convolution layer and a $5\times5$ convolution layer followed by a maximum pooling operation and a concatenation layer. Due to the high computational cost especially of the $5\times5$ filter, the $1\times1$ filter is first added to the naïve inception module. This leads to a reduction in computations of $90\%$.
Additionally, the $1\times1$ convolutional filters allow learning cross-channel patterns across the depth of the input data.

%picture of Convolution
\begin{figure}[htb]
    \centering
    \includegraphics[width=7cm]{images/InceptionNet.jpg}
    \caption{Inception Block}
    \label{fig:incepblock}
\end{figure}


\chapter{Operational amplifier based circuits}

\section{Basic stages}

	Basic stages include:
	\begin{itemize}
		\item the follower (\cref{fig__opamp__basic_stage__follower}),
		\item the inverting amplifier (\cref{fig__opamp__basic_stage__amp_inv}), and
		\item the non-inverting amplifier (\cref{fig__opamp__basic_stage__amp_ninv}).
	\end{itemize}

	\begin{figure}[htb]
		\centering
		\input{opamp/basic_stages/follower.tex}
		\caption{Follower amplifier.%
			\label{fig__opamp__basic_stage__follower}}
	\end{figure}

	\begin{figure}[htb!]
		\centering
		\begin{subfigure}[b]{0.8\textwidth}
			\centering
			\input{opamp/basic_stages/amp_inv.tex}
			\caption{Inverting.%
				\label{fig__opamp__basic_stage__amp_inv}}
			\vspace*{3ex}
		\end{subfigure}
		\begin{subfigure}[b]{0.8\textwidth}
			\centering
			\input{opamp/basic_stages/amp_ninv.tex}
			\caption{Non-inverting.%
				\label{fig__opamp__basic_stage__amp_ninv}}
		\end{subfigure}
		\caption{Amplifiers.%
			\label{fig__opamp__basic_stage__amp}}
	\end{figure}

\section{Electrical arithmetic operators}

	\begin{figure}[htb]
		\centering
		\input{opamp/arithmetic_op/V_sum.tex}
		\caption{Voltage sum.%
			\label{fig__opamp__arithm_op__Vsum}}
	\end{figure}

\section{First order active filters}

	First order active filters include low-pass and high-pass filters, either with infinite (\cref{fig__opamp__filter_1st_ord_Ginf}) or limited (\cref{fig__opamp__filter_1st_ord_Glim}) gain.

	\begin{figure}[htb]
		\centering
		\begin{subfigure}[b]{0.8\textwidth}
			\centering
			\input{opamp/filter_1st_order/low_pass__Ginf.tex}
			\caption{Low-pass.%
				\label{fig__opamp__filter_1st_ord_Ginf__low_pass}}
			\vspace*{3ex}
		\end{subfigure}
		\begin{subfigure}[b]{0.8\textwidth}
			\centering
			\input{opamp/filter_1st_order/high_pass__Ginf.tex}
			\caption{High-pass.%
				\label{fig__opamp__filter_1st_ord_Ginf__high_pass}}
		\end{subfigure}
		\caption{First order active filters op amps architectures with infinite gain.%
			\label{fig__opamp__filter_1st_ord_Ginf}}
	\end{figure}

	\begin{figure}[htb]
		\centering
		\begin{subfigure}[b]{1\textwidth}
			\centering
			\input{opamp/filter_1st_order/low_pass__Glim.tex}
			\caption{Low-pass.%
				\label{fig__opamp__filter_1st_ord_Glim__low_pass}}
			\vspace*{3ex}
		\end{subfigure}
		\begin{subfigure}[b]{1\textwidth}
			\centering
			\input{opamp/filter_1st_order/high_pass__Glim.tex}
			\caption{High-pass.%
				\label{fig__opamp__filter_1st_ord_Glim__high_pass}}
		\end{subfigure}
		\caption{First order active filters op amps architectures with limited gain.%
			\label{fig__opamp__filter_1st_ord_Glim}}
	\end{figure}


\subsection{Miscellaneous}
This section decribes all the functions in the file ``ptwXY\_misc.c''.

\subsubsection{ptwXY\_limitAccuracy}
This function returns accuracy limited between \highlight{ptwXY\_minAccuracy} and 1. Ergo, it is similar to the pseudo code
\begin{equation}
    {\rm accuracy} = {\rm min}( \ 1, \ {\rm max}( \ {\rm accuracy,}\ {\rm ptwXY\_minAccuracy} \ ) \ ) \ \ \ .
\end{equation}
\CallingC{void ptwXY\_limitAccuracy(}{ double accuracy ); }
    \argumentBox{accuracy}{The desired accuracy.}

\subsubsection{ptwXY\_update\_biSectionMax --- Not for general use}
This function is used by \highlight{ptwXY} functions to update the member \highlight{biSectionMax} base on the prior length, given
by \highlight{oldLength}, and the current length of \highlight{ptwXY}.
\CallingCLimited{void ptwXY\_update\_biSectionMax(}{ptwXYPoints *ptwXY,
    \addArgument{double oldLength );}}
    \argumentBox{ptwXY}{A pointer to the \highlight{ptwXYPoints} object.}
    \argumentBox{oldLength}{The prior length of \highlight{ptwXY}.}

\subsubsection{ptwXY\_createFromFunction}
This function creates a \highlight{ptwXYPoints} whose domain ranges from xs[0] to xs[n-1] and whose y-values
are obtained from \highlight{func}. All values of \highlight{xs} are added
and infill between them is done until either \highlight{accuracy} or \highlight{biSectionMax} is satisfied.
\setargumentNameLengths{checkForRoots}
\CallingC{ptwXYPoints *ptwXY\_createFromFunction(}{statusMessageReporting *smr,
    \addArgument{int N,}
    \addArgument{double *xs,}
    \addArgument{ptwXY\_createFromFunction\_callback func,}
    \addArgument{void *argList,}
    \addArgument{double accuracy,}
    \addArgument{int checkForRoots,}
    \addArgument{int biSectionMax );}}
    \argumentBox{smr}{The \highlight{statusMessageReporting} instance to record errors.}
    \argumentBox{N}{Number of values in \highlight{xs}}
    \argumentBox{xs}{Minimum list of x-values to add.}
    \argumentBox{func}{A function called to calculate $y(x)$.}
    \argumentBox{argList}{A pointer passed to \highlight{func}.}
    \argumentBox{accuracy}{The desired accuracy.}
    \argumentBox{checkForRoots}{If true, points where $y = 0$ are searched and added.}
    \argumentBox{biSectionMax}{Maximum number of bisections between consecutive points of \highlight{xs}.}
The function \highlight{func} is called as:
\begin{verbatim}
    nfu_status func( statusMessageReporting *smr, ptwXYPoint *point, void *argList );    .
\end{verbatim}

Often, only 2 values in \highlight{xs} are needed. However, in some cases more values help with the bisection algorithm.
For example, if the function is $y = \sin(x)$ for $0 \le x \le 2 \pi$ and \highlight{xs} only contains the points
0 and $2 \pi$, then bisection will not add the point at $\pi$ as it, like the bounding points, is 0.0. In this case,
\highlight{xs} should contain the values 0.0, $\pi$ and $2 \pi$.

\subsubsection{ptwXY\_applyFunction}
This function is used by other functions to map $y_i$ to func( $x_i$, $y_i$ ) with infilling as needed. For example,
this function is used by \highlight{ptwXY\_pow}.
\setargumentNameLengths{argList}
\CallingC{nf\_status ptwXY\_applyFunction(}{statusMessageReporting *smr,
    \addArgument{ptwXYPoints *ptwXY,}
    \addArgument{ptwXY\_applyFunction\_callback func,}
    \addArgument{void *argList );}}
    \argumentBox{smr}{The \highlight{statusMessageReporting} instance to record errors.}
    \argumentBox{ptwXY}{A pointer to the \highlight{ptwXYPoints} object.}
    \argumentBox{func}{A function called to calculate $y(x)$.}
    \argumentBox{argList}{A pointer passed to \highlight{func}.}
This function infills to maintain the initial accuracy. The function \highlight{func} is called as:
\begin{verbatim}
    nfu_status func( statusMessageReporting *smr, ptwXYPoint *point, void *argList );    .
\end{verbatim}

\subsubsection{ptwXY\_fromString}
This function creates a \highlight{ptwXYPoints} from the string of double values in \highlight{str}. There must be an even number
of string doubles in \highlight{str}.
\setargumentNameLengths{interpolationString}
\CallingC{ptwXYPoints *ptwXY\_fromString(}{statusMessageReporting *smr,
    \addArgument{char const *str,}
    \addArgument{char sep,}
    \addArgument{ptwXY\_interpolation interpolation,}
    \addArgument{char const *interpolationString,}
    \addArgument{double biSectionMax,}
    \addArgument{double accuracy,}
    \addArgument{char **endCharacter,}
    \addArgument{int useSystem\_strtod );}}
    \argumentBox{smr}{The \highlight{statusMessageReporting} instance to record errors.}
    \argumentBox{str}{The list of double values as a string.}
    \argumentBox{sep}{The separator character between each double.}
    \argumentBox{interpolation}{The interpolation of the data.}
    \argumentBox{interpolationString}{The string representation of the string.}
    \argumentBox{biSectionMax}{The biSectionMax of the returned \highlight{ptwXYPoints}.}
    \argumentBox{accuracy}{The accuracy of the returned \highlight{ptwXYPoints}.}
    \argumentBox{endCharacter}{The pointer to the character after the last character converted.}
    \argumentBox{useSystem\_strtod}{See the function \highlight{nfu\_stringToListOfDoubles}.}

\subsubsection{ptwXY\_showInteralStructure --- Not for general use}
This function writes out details of the data in a \highlight{ptwXYPoints} object, including much of the
internal data normally not useful to a user. This function is intended for debugging.
\setargumentNameLengths{printPointersAsNull}
\CallingCLimited{void ptwXY\_showInteralStructure(}{ptwXYPoints *ptwXY,
    \addArgument{FILE *f,}
    \addArgument{int printPointersAsNull );}}
    \argumentBox{ptwXY}{A pointer to the \highlight{ptwXYPoints} object.}
    \argumentBox{f}{The stream where the structure is written.}
    \argumentBox{printPointersAsNull}{If true, all pointers are printed as if their value is NULL.}

\subsubsection{ptwXY\_simpleWrite}
This function writes out the (x,y) points of the \highlight{ptwXYPoints} object to a specified stream.
\setargumentNameLengths{format}
\CallingC{void ptwXY\_simpleWrite(}{ptwXYPoints *ptwXY,
    \addArgument{FILE *f,}
    \addArgument{char *format );}}
    \argumentBox{ptwXY}{A pointer to the \highlight{ptwXYPoints} object.}
    \argumentBox{f}{The stream where the points are written.}
    \argumentBox{format}{The format specifier to use for writing an (x,y) point.}
    \vskip 0.05 in \noindent
The \highlight{format} must contain two C double specifier (e.g., \texttt{"\%12.4f \%17.7e$\backslash$n"}), one each for the x- and y-values of a point.
No line feed characters (e.g., \texttt{"$\backslash$n"}) are printed, except those in \highlight{format}.

\subsubsection{ptwXY\_simplePrint}
This function calls \highlight{ptwXY\_simpleWrite} with stdout as the output stream.
\CallingC{void ptwXY\_simplePrint(}{ptwXYPoints *ptwXY,
    \addArgument{char *format );}}
    \argumentBox{ptwXY}{A pointer to the \highlight{ptwXYPoints} object.}
    \argumentBox{format}{The format specifier to use for writing an (x,y) point.}


\documentclass{warpdoc}
\newlength\lengthfigure                  % declare a figure width unit
\setlength\lengthfigure{0.158\textwidth} % make the figure width unit scale with the textwidth
\usepackage{psfrag}         % use it to substitute a string in a eps figure
\usepackage{subfigure}
\usepackage{rotating}
\usepackage{pstricks}
\usepackage[innercaption]{sidecap} % the cute space-saving side captions
\usepackage{scalefnt}
\usepackage{amsmath}
\usepackage{bm}

%%%%%%%%%%%%%=--NEW COMMANDS BEGINS--=%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\alb}{\vspace{0.2cm}\\} % array line break
\newcommand{\mfd}{\displaystyle}
\newcommand{\nd}{{n_{\rm d}}}
\newcommand{\M}{{\bf M}}
\newcommand{\N}{{\bf N}}
\newcommand{\B}{{\bf B}}
\newcommand{\BI}{\wbar{{\bf B}}}
\newcommand{\A}{{\bf A}}
\newcommand{\C}{{\bf C}}
\newcommand{\T}{{\bf T}}
\newcommand{\Dstar}{D^{\!\star}}
\newcommand{\Fstar}{F^{\!\star}}
\newcommand{\Ustar}{U^{\!\star}}
\newcommand{\Sstar}{S^{\!\star}}
\newcommand{\Kstar}{K^{\!\star}}
\newcommand{\Ystar}{Y^{\!\star}}
\newcommand{\co}{,~~}
\newcommand{\band}{{\rm Band}}
\renewcommand{\fontsizetable}{\footnotesize\scalefont{1.0}}
\renewcommand{\fontsizefigure}{\footnotesize}
\renewcommand{\vec}[1]{\bm{#1}}
\setcounter{tocdepth}{3}
\let\citen\cite

%%%%%%%%%%%%%=--NEW COMMANDS BEGINS--=%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\setcounter{tocdepth}{3}

%%%%%%%%%%%%%=--NEW COMMANDS ENDS--=%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\author{
  Bernard Parent
}

\email{
  bernparent@gmail.com
}

\department{
  Dept. of Aerospace Engineering
}

\institution{
  Pusan National University
}

\title{
  Successive Over Relaxation
}

\date{
  April 2018
}

%\setlength\nomenclaturelabelwidth{0.13\hsize}  % optional, default is 0.03\hsize
%\setlength\nomenclaturecolumnsep{0.09\hsize}  % optional, default is 0.06\hsize

\nomenclature{

  \begin{nomenclaturelist}{Roman symbols}
   \item[$a$] speed of sound
  \end{nomenclaturelist}
}

\abstract{
abstract
}

\begin{document}
  \pagestyle{headings}
  \pagenumbering{arabic}
  \setcounter{page}{1}
%%  \maketitle
  \makewarpdoctitle
%  \makeabstract
%  \tableofcontents
%  \makenomenclature
%%  \listoftables
%%  \listoffigures
\sloppy

\section{Description of the Method}

The Successive Over Relaxation (SOR) method was first outlined in Frankel \cite{moc:1950:frankel} and Young \cite{thesis:1950:young}. It can be summarized as follows.
Say that we want to solve for the system of equations
%
\begin{equation}
A X = B
\end{equation}
%
with $A$ a $n\times n$ square matrix, and $X$ and $B$ some vectors with $n$ rows each. We can split $A$ as a sum of a lower-diagonal, a diagonal, and an upper-diagonal matrix as follows:
%
\begin{equation}
A=L+D+U
\end{equation}
%
Then:
%
\begin{equation}
(L+D+U) X = B
\end{equation}
%
Multiply all terms by the relaxation factor $\alpha$:
%
\begin{equation}
(\alpha L+\alpha D+ \alpha U) X = \alpha B
\end{equation}
%
Add $(1-\alpha)DX$ on both sides:
%
\begin{equation}
(\alpha L+ D+ \alpha U) X = \alpha B + (1-\alpha)DX
\end{equation}
%
Substract $\alpha U X$ from both sides:
%
\begin{equation}
(\alpha L+ D) X = \alpha B + (1-\alpha)DX- \alpha UX
\end{equation}
%
Regroup:
%
\begin{equation}
(\alpha L+ D) X = \alpha B + \left((1-\alpha)D - \alpha U \right)X
\end{equation}
%
Let's evaluate $X$ on the LHS at the iteration count $m+1$ and $X$ on the RHS at the iteration count $m$:
%
\begin{equation}
(\alpha L+ D) X^{m+1} = \alpha B + \left((1-\alpha)D - \alpha U \right)X^m
\end{equation}
%
In the latter, the relaxation factor $\alpha$ must be set to a value greater than 1 and less than 2.
We can express the latter in tensor form:
%
\begin{equation}
\sum_{k} (\alpha L_{rk} + D_{rk}) X_k^{m+1} = \alpha B_r + \sum_k\left((1-\alpha)D_{rk} - \alpha U_{rk} \right)X_k^m
\end{equation}
%
But $D$ is zero except when $r=k$. Thus:
%
\begin{equation}
D_{rr} X_r^{m+1} + \sum_{k} \alpha L_{rk}  X_k^{m+1} = \alpha B_r + (1-\alpha)D_{rr}X_r^m - \sum_k \alpha U_{rk} X_k^m
\end{equation}
%
But $L$ is zero wherever $k$ is higher or equal to $r$, and $U$ is zero wherever $k$ is less or equal to $r$:
%
\begin{equation}
D_{rr} X_r^{m+1} + \sum_{k=1}^{r-1} \alpha L_{rk}  X_k^{m+1} = \alpha B_r + (1-\alpha)D_{rr}X_r^m - \sum_{k=r+1}^{n} \alpha U_{rk} X_k^m
\end{equation}
%
When $k<r$, $L=A$. Also, when $k>r$, $U=A$. Also, when $k=r$, $D=A$. Thus:
%
\begin{equation}
A_{rr} X_r^{m+1} + \sum_{k=1}^{r-1} \alpha A_{rk}  X_k^{m+1} = \alpha B_r + (1-\alpha)A_{rr}X_r^m - \sum_{k=r+1}^{n} \alpha A_{rk} X_k^m
\end{equation}
%
Regroup:
%
\begin{equation}
A_{rr} X_r^{m+1} = A_{rr}X_r^m -  \alpha A_{rr}X_r^m + \alpha\left(B_r - \sum_{k=1}^{r-1}  A_{rk}  X_k^{m+1}    - \sum_{k=r+1}^{n}  A_{rk} X_k^m \right)
\end{equation}
%
Divide by $A_{rr}$:
%
\begin{equation}
 X_r^{m+1} = X_r^m -  \alpha X_r^m + \frac{\alpha}{A_{rr}}\left(B_r - \sum_{k=1}^{r-1}  A_{rk}  X_k^{m+1}    - \sum_{k=r+1}^{n}  A_{rk} X_k^m \right)
\end{equation}
%
or
%
\begin{equation}
 X_r^{m+1} = (1-\alpha) X_r^m  + \frac{\alpha}{A_{rr}}\left(B_r - \sum_{k=1}^{r-1}  A_{rk}  X_k^{m+1}    - \sum_{k=r+1}^{n}  A_{rk} X_k^m \right)
\end{equation}
%

  \bibliographystyle{warpdoc}
  \bibliography{all}

\end{document}


\documentclass[main.tex]{subfiles}
\newcommand{\Pn}[1]{\mathbb{P}^{#1}}
\begin{document}

\section{Algebraic Geometry}
There are many different types of Algebraic Geometry problem, roughtly, there is enumerative geometry (incidence, containment, intersections problems), projective geometry (blowups), curves (hyperelliptic, Riemann-Roch), smoothness (show rings not equal by looking at resolutions) . Note that this review is personal and reflect things I am comfortable and uncomfortable with.

\todo[inline]{In you have time (which you don't), write down the other parts, namely cohomology, curve theory etc.}

\subsection{Projective Geometry}
Let $\mathbb{P}^n$ be the projective $n$-space.

Note that we have following important theorem:
\begin{theorem}
If $X \rightarrow Y$ is a projective map (for example if $X$ is projective variety, then the image is a closed subvariety of $Y$.
\end{theorem}

\begin{example}[Veronese Embedding]
then considering degree $d$ polynomials (that is, the sheaf $\mathcal{O}(d)$) gives an embedding
$$
v_d: \mathbb{P}^n \rightarrow \mathbb{P}^N
$$
with $N = h^0(\mathcal{O}(d)) = \binom{d+n}{n}$, it is degree $d$ and cut out by quadratic polynomials.
\end{example}

\begin{example}[Segre Embedding]
We have the sheaf $\mathcal{O}(1) \boxtimes \mathcal{O}(1)$ on $\mathbb{P}^n \times \mathbb{P}^m$, giving the segre maps:
$$
\sigma_{n,m} \mathbb{P}^n \times \mathbb{P}^m \rightarrow \mathbb{P}^{(n+1)(m+1) - 1}
$$
It is also cut out by quadratic equations, in fact they are vanishing of $2\times 2 $minors.
\end{example}

The Segre variety $\Sigma_{1,1}$ is the surface in $\mathbb{P}^3$ cut out by $Z_0 Z_3 - Z_1 Z_2$, at each point, the fibers of $\mathbb{P}^1 \times \mathbb{P}^1$ to the projection maps gives lines on the Segre variety.

\begin{example}[Cones]
Take $X \subset \Pn{n}$ and a point $q \in \Pn{n}$ not on $X$, then we can define the cone to be the variety of all the points lying on $\overline{xq}$ with $x \in X$.

Now given complementary linear subspaces $\Gamma$ and $\Phi$, then given any $X \subset \Phi$, we can define $\overline{X, \Gamma}$ to be union of all $(k+1)$-planes $\overline{x, \Gamma}$ with $x \in X$. This is doing the point cone construction $dim \Gamma + 1$ times. In coordinates, this is adding a coordinate.
\end{example}

\begin{example}[Quadratics]
Given a quadric hypersurface $X$ in $\Pn{V}$ (away from char $2$), $Q$ is the polynomial cutting it out. Then we have associated linear form $Q_0$:
$$
Q(v) = Q_0(v, v), Q_0(v, w) = \frac{Q(v+w) - Q(v) - Q(w)}{2}
$$
$Q_0$ symmetric and bilinear, thus we also have $Q': V \rightarrow V^*$. By classification of symmetric bilinear forms on $V$, we have there are suitable basis $Q(X) = X_0^2 + X_1^2 + ... + X_k ^2$.  We say $Q$ has rank $k+1$. Rank $1$ gives double plane $Q = L^2$. $X$ is smooth iff $Q$ has maximal rank $n+1$. The associated bilinear form is nondegerate. In general:
All quadric with polynoof rank $k \geq 2$ is the cone, with vertex $\Gamma \cong \Pn{n-k}$, the subspace of the kernel of $Q'$, over a smooth quadric $\overline{X}$ in $\Pn{k-1}$.

This gives subvarieties by the theory of resiultant.

This genearlized to given complementary linear subspaces $V, U$, and we project away from $U$ to $V$: $\Pn{n} - U \rightarrow V$.
\end{example}

\begin{examle}[Projections]
We can also project away from a point, and generally, a linear subspace.

Given a hyperplane $\Pn{n-1}$ and a point $p$, then we have
$$
\pi_p: \Pn{P}^n - \{p\} \rightarrow \Pn{n-1}
$$
by sending $q$ to the point that lies on both $\Pn{n-1}$ and $\overline{pq}$. In coordinates, this is just dropping a coordinate (ofc this means that all the other ones can't be all zero).
\end{examle}

\begin{theorem}[Hilbert's Nullstenatz]
In nice (say quasi-projective) situations, then the functions that vanish on all points where an ideal $I$ vanish is the radical of $I$.
\end{theorem}

\subsection{Grassmannian}
Grassmannian parametrizes $k + 1$ planes in $V$ (through the origin) = $k$ planes in $\Pn{V}$, we denote it as $G(k+1, dim V) = \mathbb{G}(k, dim V -1)$

We have the Plucker's embedding: given $W \subset V$ a $k$-dimensional linear subspace spanned by $v_1, ..., v_k$, then we have
$$
\lambda = v_a \wedge ... \wedge v_k \in \bigwedge^k (V)
$$

Different basis just changes this by the determinant of the change of matrix. This gives map
$$
\phi: G(k, V) \rightarrow \Pn(\bigwedge^k V)
$$
this is an inclusion as given any $[\omega]$, we can recover $W$ as the space of vector $v$ such that $v \wedge w = 0$.

We get the Plucker coordinates, which given the plane $W$ as $k \times n$ matrix, then the Plucker coordiantes are just the maximal minors.

To show that it is a subvariety, we have to characterized totally decomposable vectors. They are precisely those such that the map
$$
- \wedge \omeage: V \rightarrow \bigwedge^{k+1} V
$$
is rank $n-k$, it is generally greater than $n-k$. Thus it is defined by vanishing of $(n-k + 1) \times (n-k + 1)$ minors of the matrix. However, they don't generate the relation, called the Plucker relations.

Note that we have the universal $k$-plane correspondence $E \subset \Pn(V) \times G(k, V)$. This shows that join of two varieties is another projective variety
\begin{example}
Given $X, Y \subset \Pn(V)$, then the join $\overline{XY}$ of $X$ and $Y$ is all the points lying on a line between a point of $X$ and a point of $Y$.
\end{example}

We also have the Fano varieties:
\begin{definition}
Let $X \subset \Pn{n}$, then the Fano variety associated to $X$ is the variety to $k$-planes contained in $X$, this is a subvariety of $\mathbb{G}(k,n)$.
\end{definition}

\subsection{Rational Maps and Blow ups}

\subsubsection{Rational Maps}

A rational map $X \rightarrow Y$ is a equivalence class of map $\phi$ defined on a (dense) open subset of $X$ to $Y$, any two are equivalent if they agree on their intersection.

Example of that is $\mathbb{A}^{n+1} \dashrightarrow \Pn{n}$.
Given a rational map, we have its graph to be the closure of any graph of any actual map from an open subset. This is independent of the choice of open subset. This allows us to define the domain of definition as the largest open subset $U$ in $X$ such that the restriction of the graph on $U$ is an iso (there are no indeterminancy). The complement is called the indeterminancy locus.

Two varieties are birational if there are rational maps going back and forth and they are equal, this is true iff there are open subsets that are isomorphic to each other, iff the field of fractions are the same.

A variety $X$ is rational iff it is birational to $\Pn(n)$ iff its field of fraction is $K(x_1, .., x_n)$ iff $X$ has an open subset iso to open subset of $\mathbb{A}^n$.

\begin{remark}
Using projection away from a point, we see that all irreducible varieties are birational to a hypersurface.
\end{remark}

\sbusubsection{Blowups}
There is a birational map $\pi: \tilde{X} \rightarrow X$ that is iso away from a subvariety $Y$. If $Y$ is locally cut out as $z_1 = .. z_n = 0$, then locally the blow-up is the subspace of $U \times \Pn{n-1}$, $\Pn{n-1}$ has coordinates $w_1...$ cut out by $z_i w_j = z_j w_i$. The exceptional divisor is the $\Pn{n-1}$ with $z_i = 0$.

It resolves singularity and indeterminancy of rational maps:
\begin{theorem}
Let $x$ be any variety and rational map $X \dashrightarrow \Pn{n}$, then $\phi$ can be resolved by a sequence of blow-ups to a regular map. Thus a rational map is a regular map on a blow-up of $X$.
\end{theorem}

\begin{example}
Given the quadric surface $Q$ cut out by $Z_0 Z_3 - Z_1 Z_2 = 0$, take $p \in Q$, then projecting away from $p$ is a rational map. Since general line goes through $p$ exactly at one other point, so it is generically one to one. So it has a partial inverse and is rational ($Q \cong \Pn{1} \times \Pn{1}$). To resolve the singularity at $p$, we blow up at that point, the blow up is exactly the graph of this rational function. In addition, the projection to $\Pn{2}$ is iso way from two points corresponding to the two lines containing $p$ in $Q$. So the blow up $\Gamma$ is also the blow up of $\Pn{2}$ at those two points.
\end{example}

\subsection{Dimensions}
Here's some foundational facts about dimensions (which is the Krull dimension aka the transcedental degree of the field of fractions over the base field):

\begin{theorem}
Given a map $X \rightarrow Z$ of quasi-projective varieties to a projective one. Let $Y$ be the closure of the image, then dimesion of the fiber, as a map on $Y$ is an upper-semicontinuous function on $Y$. In addition, if $\mu$ is the minimum value, then
$$
dim(X) = dim(Y) + \mu
$$
\end{theorem}

\begin{example}
An example of where the dimensions jumps up is blow-ups at subvarieties.
\end{example}

A corollary is that
\begin{theorem}
For $\pi: X \rightarrow Y$ be regular map of projective varities, with $Y$ irreducible. If all fibers are irreducible of the same dimesions $d$, then $X$ is irreducible.
\end{theorem}

This is super useful to proof that the total space of a fibration is irreducible.

\subsubsetion{examples}
Dimension of $\Pn{n}$ is ofc $n$. Dimension of Grassmannian is $G(k,n) = \mathbb{G}(k-1, n-1)$ is $k(n-k)$. Dimension of cone $\overline{pX}$ is $d+1$ unless $X$ is linear and $p \in X$.
Projection of a variety away from a point $p$ is $X$ unless $X$ is a cone with vertex $p$.

\begin{example}
Recall we have the secant variety of lines associated to $X \subset \Pn^n$, defined as the closure of rational map
$$
X \times X \dashrightarrow \mathbb{G}(1,n)
$$
mapping $p,q \mapsto \overline{pq}$.

If $X$ is not a linear subspace, then this is generically finite and thus secant line has dimension twice of $X$.

This implies that the secant variety of lines is a proper subvariety of the variety of incident lines for $X \subset \Pn{n}$ with dimension $k \leq n-1$ (the variety of lines containing a point of $X$). This in turns implies that for general projection maps $X$ birational to its image, thus every variety is birational to a hypersurface.

The secant variety is the image in $\Pn{n}$ of the universal plane of the secant variety of lines. It is irredcuible of dimension at most $2k+1$ with equality iff any general point $p \in \overline{qr}$ lies only on a finite number of secant lines.
\end{example}

\begin{example}
The Fano variety $F_k(X)$ parametrizes $k$-planes lying on $X$.

Consider the correspondence between hyperplane of degree $d$ and planes lying on it. The fiber over a point coresponding to a hyperplans is exactly the Fano variety $F_k(X)$.

We see that the expected dimension of the Fano variety over a generic hypersurface is
$$
dim(F_k(X)) = (k+1)(n-k) - \binom{k+d}{d}
$$
\end{example}

\subsection{Hilbert Function and Polynomials}

Given $X \subset \Pn^n$, then we have the corresponding graded ring of functions $S(X) = k[Z_0, ..., Z_n]/I(X)$, with $I(X)$ the ideal associated to $X$.

Then we define $h_X(m) \coloneqq dim(S(X)_m)$ called the Hilbert function of $X$. Note it heavily depends on the embedding (aka the very ample line bundle on $X$).

\begin{remark}
As we will see, the Hilbert polynomial is stable under perturbation but Hilbert function is more sensitive, the lower parts of it captures collinearity type information.
\end{remark}

\begin{example}
Let $X$ consists of three points in the plane, then $h_X(1)$ tells us if the three points are collinear.

In general, for $d$ points, there is a $d-1$ degree polynomial that vanishes in all but one point, this means that the map from $d-1$ polynomials to $K^d$ by evaluation on $p_i$ is surjective, thus $h_x(m) = d$ for $m \geq d-1$. However, the lower part of this describes how collinear the map is.
\end{example}

\begin{example}
If $X \subset \Pn{2}$ is a curve, vanishing of $F(Z)$ of degree $d$. Then its vanishing ideal generated by polynomial of degree $m$ divisible by $F$, so
$$
dim(I(X)_m) = \binom{m-d+2}{2}
$$
and for $m \geq d$,
$$
h_X(m) = d \times m - \frac{d(d-3)}{2}
$$
\end{example}
Note that there exists a polynomial $p_X$ such that for sufficiently large $m$, $h_X(m) = p_X(m)$; this is called the Hilbert polynomial and its degree is the dimension of $X$ and the top coefficient is $d/k!$ with $d$ called the degree of $X$. It is the number of points of intersection between $X$ and a general $n-k$ plane.

\subsection{Gauss Maps}
Given a variety $X \subset \Pn{n}$, then the assignment $x \mapsto \mathbb{T}_x(X)$ the projective tangent space on smooth points gives a rational map to $\mathbb{G}(k,n)$. If $X$ is smooth, this is a regular map, note that the projective tangent space is the kernel of linear map given by $\partial F/\partial Z_i$ with $F$ collection of generators of the ideal of $X$.

\begin{example}
If $X$ is a hypersurface associated to $F$, then the Gauss map $X \rightarrow \mathbb{G}(n-1, n) = \Pn{n}^*$ is given by
$$
p \mapsto [\frac{\partial F}{\partial Z_0}(p_0) ...]
$$
Note that when $F$ is degree $2$, then this is linear. In fact, we have a $F$ associated to the symmetric bilinear form $Q$ and when $X$ is smooth the form is nondegenerate, thus giving an iso $Q': V \cong V^*$.

For $F$ with degree $d \geq 2$, the fibers of finite thus it gives another hypersurface. In fact, the space of tangent $k$-planes is again $k$ for any $k$-dimensional variety that is not a linear space.
\end{example}

\subsubsection{Tangential Varieties}
$X \subset \Pn{n}$ dim $k$, then $TX$ the union of $k$-planes corresponding to the image to the Gauss map is called the tangential variety. It is at most dimension $2k$ with equality holding iff a general point $q$ on a general tangent plane only lies on finite many points.

\subsubsection{Dual Varieties}
A tangent hyperplane to a variety $X$ is a hyperplane that contains a tangent plane to $X$. The locus of all such hyperplane is called the dual varieties of $X$. It is hyperplanes $H$ such that the intersection $H \cup X$ is singular (when $X$ is smooth).

Here's a cool theorem:
\begin{theorem}
Let $X \subset \Pn{n}$ be an irreducible variety and $X^*$ its dual, then the incidence varieties associated to $X^*$ is the incidence varieties associated to $X$, thus the double dual of a variety of a variety is itself.
\end{theorem}

\subsection{Degree}
A projective variety $X \subset \Pn{n}$ has a fundamental notion called the degree.

Using cohomology theory, if $X$ has dimension $k$, then
$$
deg(X) = <\alpha^k, i_*[X]> = <i^*(\alpha)^k, [X]>
$$
this is helpful if we can get a handle on the Chern class of the line bundle corresponding to the inclusion map $i: X \rightarrow \Pn{n}$.
\begin{example}
The veronese varieties, that is, the image of $v_d: \Pn{n} \rightarrow \P{N}$ is $d^n$ as every hyperplane pulls back degree $d$ hypersurface.
\end{example}

\begin{example}
Now consider the Segre embedding, then $\mathcal{O}(1)$ pullsback to $\mathcal{O}(1) \boxtimes \mathcal{O}(1)$, thus
$$
deg(\Sigma_{m,n}) = <(\alpha + \beta)^{m+n}, [\Pn{m} \times \Pn{n}] = \binom{m+n}{n}
$$
\end{example}

\begin{example}
As the intersection of a cone $\overline{pX}$ is projectively equivalent to $X$, we see that the degree of the cone is same as the degree of $X$.
\end{example}
\subsection{Quadrics}
Quadrics shows up a lot in the qual exams.

Once again, we have $Q$ a homogeneous quadratic polynomial $Q: V \rightarrow K$, with associated bilinear form $Q_0$ and map $Q': V \rightarrow V^*$. The rank of $Q$ is the rank of $Q'$. Lower rank is a cone with vertex being the kervel of $Q'$, over a smooth quadric hypersurface on a nondengenerate complementary subspace.

The tangent space at $v$ us $2Q_0(v, -)$, thus \begin{enumerate}
    \item If $Q'(v) \neq 0$, then it is smooth at $v$ with tangent plane $Q'(v)$.
    \item if $Q(v) = 0$, it is singular at $v$.
\end{enumerate}
The Gauss map is the restriction of the linear map $Q': \Pn{V} \rightarrow \Pn(V^*)$

The intersection of $Q$ with its projective tangent plane $T_x Q$ at smooth point $x \in Q$ is a rank $rank(Q)-2$ hypersurface in $T_x Q. \cong \Pn{n-1}$.

For a general hypersurface $H$ and $Q' = Q \cap H$, then
$$
rank(Q) -2 \leq rank(Q') \leq rank(Q)
$$
with equality hold iff $H$ is tangent to $Q$. This obviously generalizes.

\begin{example}
All plane conics are projective equivalent to $v_2: \Pn{1} \rightarrow \Pn{2}$, giving a conic, we simply project away from a point $x \in Q$, it extends to an iso with $x$ mapped to infinity.
\end{example}

\begin{example}
Quadric Surfaces: image of Segre map $\sigma_{1,1}: \Pn{1} \times \Pn{1} \rightarrow \Pn{3}$ is a smooth quadric. Every smooth quadric is obtained this way. It has two rulings by line with unique ruling passing through each point $x \in Q$. There is two lines passing through two points as the the quadric intersects the tangent plane to is a rank 1 quadric in the tangent plane, that is, a union of two lines.
\end{example}

\subsubsection{Quadrics in \Pn{n}}
Take $x$ not in $Q$ and project away, any line will intersect in one (nonreduced) or two points, so it is a two-sheeted branch cover over $H \cong \Pn{n-1}$. The branch points are where $\overline{xp}$ is tangent to $p \in Q$, equivalently, $p$ lies in the hyperplane $Q'(x)$. Since $x$ is not in $Q$, the hyperplane $Q'(x)$ is not tangent to $Q$, and they intersect in a smooth quadric $C$, which project isomorphically to a smooth quadric $\overline{C} \subset H$. Thus it is a double cover branched over a smooth quadric.

We can also project from a point $x \in Q$, this is a rational map, and does not extend. The graph is the blow-up of $Q$ at the point $x$, with projection carry the exceptional divisor $E$ to to the hyperplane $T_x Q \subset H$. This projection also collapse all the lines on $Q$ through the point $x$. The intersection is of rank $n-1$ so it is a cone over a smooth quadric hypersurface inside $T_x Q \subset H \cong \Pn{n-2}$. In fact the graph $\Gamma$ is the blow-up of the pyperplane along the quadric $C$.

\subsubsection{Linear Spaces on Quadrics}
We want to understand the Fano variety
$$
F_k(Q) = \{\Gamma: \Gamma \subset Q\} \subset \mathbb{G}(k,n)
$$

A plane $\Gamma = \Pn{W}$ lies in a quadric $Q$ means that the subspace $W \subset V$ is isotropic, that is, $Q|_W = 0$, or that $Q'(W) \subset Ann(W)$. If $Q$ is smooth, then $Q'$ is an iso and $2 dim(W) \leq dim(V)$. And in fact converse is true.

The Fano variety are nonempty when $k \leq m/2$ and irreducible for $k < m/2$, in the case $k = m/2$ there are two connected component, each one iso to $F_{k-1, 2k-1}$
\end{document}