\section{Declaration of Circuits}

The construction of RKQC is designed to be as similar as possible to C++ programs which contain a number of functions. To this end, circuits are specifiable through a main function, as well as through various submodules that are declared exactly as common C++ functions. Exactly one module must be named "int main", however this module, as well as any module, can call any other module at any time.

\section{Signal Types}

There is one major type of signal in RKQC, the \textbf{qint}. This type forms the basis for the five other types of signals that are derived from this main class:

\begin{itemize}
    \item qbit
    \item zero\_to\_garbage ancilla
    \item zero\_to\_zero ancilla
    \item one\_to\_garbage ancilla
    \item one\_to\_one ancilla
\end{itemize}

All of the above signals can be declared and used in the specification of gates and circuit descriptions. The primary differences are that the "\_to\_garbage" ancilla are ancilla signals that are not guaranteed to maintain their original state during computation, while the two other ancilla types do make this guarantee.

As will be explained later on, all of these signals are of a base type \textbf{qint}, which allows for circuit description flexibility when creating and passing parameters to submodules.

\section{Creating and Using Modules}

At the circuit level, both user defined modules as well as built in modules can be instantiated in the same fashion.

In the example circuit "e008\_swap.cpp", the built in function "cnot" is called, creating CNOT gates on the qubits passed in as parameters:

\begin{lstlisting}
    int main( int argc, char ** argv )
    {
        qbit a;
        qbit b;

        cnot(a, b);
        cnot(b, a);
        cnot(a, b);

        return 0;
    }
\end{lstlisting}

In exactly the same fashion, a circuit designer can create a submodule, and instantiate it within the main function, as in file "e009\_swap\_triples.cpp":

\begin{lstlisting}
    void swap_bits( qint x, qint y){
        cnot(x, y);
        cnot(x, y);
        cnot(x, y);
    }

    int main( int argc, char ** argv ){
        qbit a0;
        qbit a1;
        qbit a2;

        qbit b0;
        qbit b1;
        qbit b2;

        swap_bits(a0, b0);
        swap_bits(a1, b1);
        swap_bits(a2, b2);

        return 0;
    }
\end{lstlisting}

\section{Arrays}

RKQC also allows for multi-dimensional arrays of signals to be declared and used in circuits. To demonstrate this, file "e010\_swap\_triples\_2.cpp" replicates the functionality of "e009\_swap\_triples.cpp" with arrays:

\begin{lstlisting}
    void swap_bits( qint x, qint y){
        cnot(x, y);
        cnot(x, y);
        cnot(x, y);
    }

    int main( int argc, char ** argv ){
        qbit a(3);
        qbit b(3);

        swap_bits( a[0], b[0] );
        swap_bits( a[1], b[1] );
        swap_bits( a[2], b[2] );

        return 0;
    }
\end{lstlisting}

\section{Signals and Gates}

Gates are built in modules that can be instantiated in a variety of methods, with a variety of signal types. Specifically,
\begin{itemize}
    \item single qint signals,
    \item qint arrays,
    \item single qbit signals,
    \item qbit arrays,
    \item single ancilla signals, and
    \item ancilla arrays
\end{itemize}
all are capable of being passed through as parameters to built in gates. For an example of this, file "e002\_signals\_and\_gates.cpp" calls all of the intrinsic built in gates with all of the different signal types:
\begin{lstlisting}
    int main( int argc, char ** argv )
    {

        qbit a;
        qbit b;
        qbit c;
        qbit d(10);
    	qbit e(10);
    	qbit f(10);
    /*------------ Gates Called By Qubit --------------*/
        NOT(a);
        cnot(a,b);
        toffoli(a, b, c);
    /*------------ Gates Called By Register Index -----*/
        NOT(d[0]);
        cnot(d[1], d[9]);
        toffoli(d[0], e[0], c[0]);
    /*------------ Gates Called By Mixed Register Index & Qbits -----*/
        cnot(a, d[0]);
        cnot(e[0], b);
    	toffoli(d[0], a, b);
    	toffoli(a, d[0], b);
    	toffoli(a, b, d[0]);
    	toffoli(d[0], e[0], a);
    	toffoli(d[0], a, e[0]);
    	toffoli(a, d[0], e[0]);
    /*------------ Gates Called By Full Qbit Reg ------*/
    	NOT(d);
    	cnot(d, e);
    	toffoli(d, e, f);

        return 0;
    }
\end{lstlisting}

\section{Assign Value}

A commonly used function of assigning value of one signal to another is built into RKQC in the form of a function:
\begin{lstlisting}
    assign_value_of_b_to_a();
\end{lstlisting}

This function can be instantiated a number of different ways, with integer constants or with two \textbf{qint} signals. These instantiation methods are detailed in file "e004\_assign\_value.cpp":
\begin{lstlisting}
    int main( int argc, char ** argv )
    {
        qbit a;
        assign_value_of_b_to_a(a, "0", 1);

        qbit b(8);
        assign_value_of_b_to_a(b, "1", 8);

        qbit c(8);
        assign_value_of_b_to_a(c, b, 8);

        return 0;
    }
\end{lstlisting}

\section{Integer Arithmetic Modules}

RKQC comes with implementations of quantum adders and multipliers developed in recent theoretical work. For instance, the quantum ripple-carry adder implemented in the function:

\begin{lstlisting}
    a_eq_a_plus_b();
\end{lstlisting}

is derived from work by Wang et. al \cite{adder}, and an example of usage is contained in file "e005\_adder.cpp":

\begin{lstlisting}
    int main( int argc, char ** argv )
    {
        qbit a(32);
        qbit b(32);

        a_eq_a_plus_b(a,b,32);

        return 0;
    }
\end{lstlisting}

Alternatively, an implementation of an ancilla-free addition circuit is also contained within RKQC, derived from earlier work by Cuccaro \cite{Cuccaro}.


\section{Test Description and Success Criteria}

The unit test for the thruster\_dynamics module is located in:\\

\noindent
{\tt simulation/dynamics/Thrusters/$\_$UnitTest/unit$\_$ThrusterDynamicsUnit.py} \\

\subsection{Test inputs}

The thruster inputs that were used are:

\begin{itemize}
\item Earth's gravity on surface : $g=9.80665$ m s$^{-2}$
\item The specific impulse: $I_{sp} = 266.7$s. As seen previously, we use the definition of specific impulse defined by:

\begin{equation*}
F_{\mathrm{thrust}} = g_0 \dot{m} I_{sp}
\end{equation*}

This has the units of seconds, and uses the earths gravitational constant. It represents a thrusters potential to deliver force per mass flow rate.
\item The maximum thrust: $F_{\mathrm{max}} = 1.0$ N

The scaling factor yielding the thrust.
\item The minimum On time: $t_{\mathrm{min}} = 0.006$s

The minimum time that the thruster can be fired.
\end{itemize}

\subsection{Test sections}

\noindent This unit test is designed to functionally test the simulation model
outputs as well as get complete code path coverage.
The test design is broken
up into several parts, and the mass flow rate is tested at each of these subtests. :\\
\begin{enumerate}
\item{\underline{Instantaneous On/Off Factor:} The thrusters are fired with an
  instantaneous ramp to ensure that the firing is correct. This gives us a base case.}
\item{\underline{Short Instantaneous Firing:} A "short" firing that still respects the
  rule of thumb above is fired to ensure that it is still correct.}
 \item{\underline{Short Instantaneous Firing with faster test rate:} A "short" firing that still respects the
  rule of thumb above but with a faster test rate to see the jump.}
 \item{\underline{Instantaneous On/Off Factor with faster test rate:} The thrusters are fired with an
  instantaneous ramp to ensure that the firing is correct given a different test rate. This shouldn't modify the physics.}
 \item{\underline{Thruster Angle Test:} The output forces/torques from the simulation
  are checked with a thruster pointing in a different direction.}
   \item{\underline{Thruster Position Test:} The output forces/torques from the simulation
  are checked with a thruster in a different position.}
   \item{\underline{Thruster Number Test:} The output forces/torques from the simulation
  are checked with two thruster in different positions, with different angles.}
\item{\underline{Ramp On/Ramp Off Firing:} A set of ramps are set for the thruster to ensure
  that the ramp configuration is respected during a ramped firing.}
  \item{\underline{Short ramped firing:} A thruster is fired for less than the amount of time it
   takes to reach the end of its ramp.}
\item{\underline{Ramp On/Ramp Off Firing with faster test rate:} A set of ramps are set for the thruster to ensure
  that the ramp configuration is respected during a ramped firing with different test rate.}
\item{\underline{Cutoff firing:} A thruster is commanded off (zero firing time) in the middle
   of its ramp up to ensure that it correctly cuts off the current firing}
\item{\underline{Ramp down firing:} A thruster is fired during the middle of its ramp down
   to ensure that it picks up at that point in its ramp-up curve and reaches
   steady state correctly.}
\end{enumerate}

These scenarios create a set of different runs. These are run in the same test using pytest parameters. Therefore 12 different parameter sets were created to cover all of the listed parts.

\subsection{Test success criteria}

This thrusters test is considered successful if, for each of the scenarios, the output data matches exactly the truth data that is computed in python. This means that at every time step, the thrust is the one that is expected down to near machine precision ($\epsilon = 10^{-9}$).

This leaves no slack for uncertainty in the thrusters module.

\section{Test Parameters}

In order to have a rigorous automated test, we have to predict the forces and torques that will apply on the spacecraft. We use the following equations to compute the thrust at each time step. We call $\alpha$ the angle in which the thruster is pointing, $\bm r = r \hat{\bm e_r}= \left(r_x, r_y, r_z \right)$ it's position vector in the body frame,

\begin{enumerate}

	\item{\underline{Mass flow rate}}:

	We compute the mass flow rate using the following equation:

	\begin{equation}
	\dot{m} = \frac{F}{g I_{sp}}
	\end{equation}

	Since we are using constant $I_{sp}$, thrust, and $g$ is constant, this is the same value throughout the tests. $\dot{m}$ is therefore either zero (when the thruster is not firing) or set to the previous value.

	\item{\underline{With one thruster}}: The forces are simply the projections of the thrust force on the axes of interest. The torque along $x$ is the arm along $z$ times the projection of the force along $y$, the torque along $z$ is the arm along $x$ times the projection of the force along $y$, the torque along $z$ is the arm along $x$ times the projection of the force along $y$.

	\begin{align}
		\leftexp{B}{\bm F} =\leftexp{B}{\begin{pmatrix} F_x, & F_y & F_z \end{pmatrix}}^T&\hspace{1cm} \leftexp{B}{\bm T} =\leftexp{B}{\bm r} \times \leftexp{B}{\bm F}  \\
	\end{align}

	\item{\underline{With two thrusters}}: By giving indices $1$ and $2$ for each of the thrusters, we just need to add the Forces and torques defined above to get the total Forces and Torques:

	\begin{align}
		\leftexp{B}{\bm F} = \leftexp{B}{\bm F_1}  + \leftexp{B}{\bm F_2} &\hspace{1cm} \leftexp{B}{\bm T} = \leftexp{B}{\bm T_1}  + \leftexp{B}{\bm T_2} \\
	\end{align}

	\item{\underline{With ramps thruster}}: When the thrusters now ramp up and down, we create a normalized ramp function $\rho$. An example is given in \ref{fig:Ramp_function} in the case of a cutoff fire and renewed fire. \par

	\input{AutoTex/Ramp_function.tex}

	We then prolong the force and torque end times as a function of the ramp slope, and multiply the initial functions by this ramping function:

	\begin{align}
		\tilde{\bm F} = \rho \bm F &\hspace{1cm} \tilde{\bm T} =\rho \bm T  \\
	\end{align}

\end{enumerate}

\section{Test Results}

\subsection{Pass/Fail}

\begin{center}
	\begin{tabular}{|c|c|c|}
		\hline
		Parameter Sets & Test Result & Error Tolerance \\ \hline \hline
		1  &\input{AutoTeX/Result0.tex} & $10^{-9}$ \\ \hline
		2  &\input{AutoTeX/Result1.tex} & $10^{-9}$ \\ \hline
		3  &\input{AutoTeX/Result2.tex} & $10^{-9}$ \\ \hline
		4  &\input{AutoTeX/Result3.tex}& $10^{-9}$ \\ \hline
		5  &\input{AutoTeX/Result4.tex}& $10^{-9}$ \\ \hline
		6  & \input{AutoTeX/Result5.tex} & $10^{-9}$ \\ \hline
		7  &\input{AutoTeX/Result6.tex}& $10^{-9}$ \\ \hline
		8  &\input{AutoTeX/Result7.tex} & $10^{-9}$ \\ \hline
		9  &\input{AutoTeX/Result8.tex} & $10^{-9}$ \\ \hline
		10  &\input{AutoTeX/Result9.tex}& $10^{-9}$ \\ \hline
		11  &\input{AutoTeX/Result10.tex} & $10^{-9}$ \\ \hline
		12  &\input{AutoTeX/Result11.tex} & $10^{-9}$ \\
		\hline

	\end{tabular}
\end{center}

\begin{enumerate}
	\item{\underline{ Instantaneous On/Off Factor}:}

	\input{AutoTex/Snippet1Thrusters_5s_30deg_Loc2_Rate10.tex}

	Figures \ref{fig:Force_1Thrusters_5s_30deg_Loc2_Rate10} and \ref{fig:Torque_1Thrusters_5s_30deg_Loc2_Rate10} show the force and torque behaviors (respectfully) for the thruster unit test.

	\input{AutoTex/Force_1Thrusters_5s_30deg_Loc2_Rate10.tex}
	\input{AutoTex/Torque_1Thrusters_5s_30deg_Loc2_Rate10.tex}
	\input{AutoTex/1Thrusters_5s_30deg_Loc2_Rate10.tex}

	As Figure \ref{fig:1Thrusters_5s_30deg_Loc2_Rate10} shows, the desired behavior is captured exactly for each
	firing in the test for all of the forces and torques. This is validated by the exact same predicted and simulated thrust arrays.

	\item{\underline{Short Instantaneous Firing: }}

	\input{AutoTex/Snippet1Thrusters_0s_30deg_Loc2_Rate10.tex}

	Figure \ref{fig:Force_1Thrusters_0s_30deg_Loc2_Rate10} shows the force behavior given this short input. We see that the test rate begin small next to the thrust duration, doesn't capture the jump quite well.

	\input{AutoTex/Force_1Thrusters_0s_30deg_Loc2_Rate10.tex}
	\input{AutoTex/1Thrusters_0s_30deg_Loc2_Rate10.tex}

	As Figure \ref{fig:1Thrusters_0s_30deg_Loc2_Rate10} shows, the desired behavior is captured exactly for each
	firing in the test for all of the forces and torques. Despite the lower test rate, the forces and torques behave appropriately. This is validated by the exact same predicted and simulated thrust arrays.

	\item{\underline{Short Instantaneous Firing with faster test rate: }}

	\input{AutoTex/Snippet1Thrusters_0s_30deg_Loc2_Rate1000.tex}

	Figure \ref{fig:Force_1Thrusters_0s_30deg_Loc2_Rate1000} shows the force behavior given the same short input as previously. We now see that the jump is well resolved.

	\input{AutoTex/Force_1Thrusters_0s_30deg_Loc2_Rate1000.tex}
	\input{AutoTex/1Thrusters_0s_30deg_Loc2_Rate1000.tex}

	As Figure \ref{fig:1Thrusters_0s_30deg_Loc2_Rate1000} shows, the desired behavior is captured exactly for each
	firing in the test for all of the forces and torques. This is validated by the exact same predicted and simulated thrust arrays.

	\item{\underline{Instantaneous On/Off Factor with faster test rate:} }

	\input{AutoTex/Snippet1Thrusters_5s_30deg_Loc2_Rate100.tex}

	The thrust command given is now 5 seconds long, as in the base test. The difference is that the test rate is now augmented in order to guarantee that it does not affect the test.

	\input{AutoTex/1Thrusters_5s_30deg_Loc2_Rate100.tex}

	As Figure \ref{fig:1Thrusters_5s_30deg_Loc2_Rate100} shows, the desired behavior is captured exactly for each
	firing in the test for all of the forces and torques. This is validated by the exact same predicted and simulated thrust arrays.

	\item{\underline{Thruster Angle Test:}}

	\input{AutoTex/Snippet1Thrusters_5s_10deg_Loc2_Rate10.tex}

	The test now shows that the simulation still behaves with different thruster orientations.

	\input{AutoTex/1Thrusters_5s_10deg_Loc2_Rate10.tex}

	As Figure \ref{fig:1Thrusters_5s_10deg_Loc2_Rate10} shows, the desired behavior is captured exactly for each
	firing in the test for all of the forces and torques. This is validated by the exact same predicted and simulated thrust arrays.

	\item{\underline{Thruster Position Test:} }

	\input{AutoTex/Snippet1Thrusters_5s_30deg_Loc0_Rate10.tex}

	This test shows that different locations still give correct values for forces and torques.

	\input{AutoTex/1Thrusters_5s_30deg_Loc0_Rate10.tex}

	As Figure \ref{fig:1Thrusters_5s_30deg_Loc0_Rate10} shows, the desired behavior is captured exactly for each
	firing in the test for all of the forces and torques. This is validated by the exact same predicted and simulated thrust arrays.

	\item{\underline{Thruster Number Test:} }

	\input{AutoTex/Snippet2Thrusters_5s_30deg_Loc2_Rate10.tex}

	This test shows that the thruster model can incorporate several thrusters correctly. We add a second thruster and use the modified truth function for the forces and torques. These thrusters are not aligned and not in the same position, giving a general multi-thruster result.

	\input{AutoTex/2Thrusters_5s_30deg_Loc2_Rate10.tex}

	As Figure \ref{fig:2Thrusters_5s_30deg_Loc2_Rate10} shows, the desired behavior is captured exactly for each
	firing in the test for all of the forces and torques. This is validated by the exact same predicted and simulated thrust arrays.

	\item{\underline{Ramp On/Ramp Off Firing:} }

	\input{AutoTex/SnippetRamp_10steps_5s_CutoffOFF_Rate10_CutoffOFF.tex}

	This test now ramps the thrust up and down. We use a 10 step ramp that takes $0.1$s to climb and fall. This ramp time is slightly exaggerated in order to see the ramp clearly.
	\input{AutoTex/Ramp_10steps_CutoffOFF_5s_testRate10.tex}

	As Figure \ref{fig:Ramp_10steps_CutoffOFF_5s_testRate10} shows, the desired behavior is captured exactly for each
	firing in the test for all of the forces and torques. This is validated by the exact same predicted and simulated thrust arrays.

	\item{\underline{Short ramped firing:} }

	\input{AutoTex/SnippetRamp_10steps_0s_CutoffOFF_Rate10_CutoffOFF.tex}

	Using the same ramp, the thruster fires for $0.5$s. We expect to see a climb and immediate fall of the thrust factor.

	\input{AutoTex/Ramp_10steps_CutoffOFF_0s_testRate10.tex}

	As Figure \ref{fig:Ramp_10steps_CutoffOFF_0s_testRate10} shows, the desired behavior is captured exactly for each
	firing in the test for all of the forces and torques. This is validated by the exact same predicted and simulated thrust arrays.

	\item{\underline{Ramp On/Ramp Off Firing with faster test rate:} }

	\input{AutoTex/SnippetRamp_10steps_5s_CutoffOFF_Rate100_CutoffOFF.tex}

	Using once again the same ramp, we run the test for $5$ seconds with a faster test rate. We seek to validate that the test rate has no impact on the simulation.

	\input{AutoTex/Ramp_10steps_CutoffOFF_5s_testRate100.tex}

	As Figure \ref{fig:Ramp_10steps_CutoffOFF_5s_testRate100} shows, the desired behavior is captured exactly for each
	firing in the test for all of the forces and torques. This is validated by the exact same predicted and simulated thrust arrays.

	\item{\underline{Cutoff firing:}}

	\input{AutoTex/SnippetRamp_10steps_CutoffON_Rate10_CutoffON.tex}

	Using the same ramp, we start firing the thruster with an initial command of 5 seconds. After just $0.2$ seconds of thrust ramping, we change the test command and thrust for $0.3$ seconds. This leads to a total thrust of $0.5$ seconds, and validates the fact that the command was properly overridden.

	\input{AutoTex/Ramp_10steps_CutoffON_5s_testRate10.tex}

	As Figure \ref{fig:Ramp_10steps_CutoffON_5s_testRate10} shows, the desired behavior is captured exactly for each
	firing in the test for all of the forces and torques. This is validated by the exact same predicted and simulated thrust arrays.

	\item{\underline{Ramp down firing:}}

	\input{AutoTex/SnippetRamp_10steps_CutoffON_Rate10rampDownON.tex}

	In this test, the initial command is of $0.5$ seconds. On the falling side of the ramp, a new command is given for $1.5$s. We expect to see the thrust climb again to steady state and last for the expected command time.

	\input{AutoTex/Ramp_10steps_CutoffONrampDownON_testRate10.tex}

	As Figure \ref{fig:Ramp_10steps_CutoffONrampDownON_testRate10} shows, the desired behavior is captured exactly for each
	firing in the test for all of the forces and torques. This is validated by the exact same predicted and simulated thrust arrays.

\end{enumerate}

\subsection{Test Coverage}
The method coverage for all of the methods included in the spice\_interface
module are tabulated in Table~\ref{tab:cov_met}

\begin{table}[htbp]
	\caption{Test Analysis Results}
	\label{tab:cov_met}
	\centering \fontsize{10}{10}\selectfont
	\begin{tabular}{c | r | r | r} % Column formatting,
		\hline
		Method Name    & Unit Test Coverage (\%) & Runtime Self (\%) & Runtime Children (\%) \\
		\hline
		SelfInit & 100.0 & 0.0 & 0.0 \\
		CrossInit & 100.0 & 0.0 & 0.0 \\
		AddThruster & 100.0 & 0.0 & 0.0 \\
		UpdateState & 100.0 & 0.0 & 0.0 \\
		WriteOutputMessages & 100.0 & 0.0 & 0.0 \\
		ReadInputs & 100.0 & 0.0 & 0.0 \\
		ConfigureThrustRequests & 100.0 & 0.0 & 0.0 \\
		ComputeDynamics & 100.0 & 0.0 & 9.8 \\
		ComputeThrusterFire & 100.0 & 0.0 & 0.0 \\
		ComputeThrusterShut & 100.0 & 0.0 & 0.0 \\
		updateMassProperties & 100.0 & 0.0 & 0.6 \\
		\hline
	\end{tabular}
\end{table}

For all of the methods in the spice\_interface modules, the code coverage
percentage is 100\% which meets our test requirements.  Additionally, 100\% of
all code branches in the thruster\_dynamics source code were executed by this
test.

%The test that was run to calculate thruster CPU usage was deliberately selected as
%a stressing case for the thruster model.  The MOI burn was executed 9000 seconds
%after the simulation was initialized and that maneuver takes 2000 seconds, so
%approximately 20\% of the simulation was run with the vehicle under thrust.
%With this stressing case, the ThrusterDynamics model accounted for 10\% of the
%overall processing, which is certainly acceptable at this time.

The main CPU usage of the thruster\_dynamics source code occurs in the
ComputeDynamics method that is called by the dynamics source.  The
ThrusterDynamics methods themselves account for very little of the processing
and it is the vector/matrix manipulation utilities called from the source that
are the main culprits.  While the thruster model's ComputeDynamics function is
using 50\% of the dynamics processing, that is only amounting to 10\% of the
overall simulation processing.  The rest of the architecture in Basilisk should
allow us to take the processing hit that we are getting from the
ThrusterDynamics module without issue.

\subsection{Conclusions}
The thruster module has sufficient fidelity to accomplish the analysis
that we need to perform thrust maneuvers.  All model capabilities were
tested and analyzed in this document with all observed performance being nominal
compared to the going-in expectation. Every line of source code was successfully tested and the integrated model
performance was analyzed and is acceptable. Furthermore many thrust scenarios were tested in order to cover all outcomes of a maneuver and the robustness of the simulation.


\subsubsection{Benchmark Default Curve}\label{ss:benchmark_default_curve}

Default curves can be set up as a difference curve of two yield curves as shown in listing
\ref{lst:defaultcurve_benchmark}. A typical use case is to back out a default curve from an all-in discounting curve
fitted to a series of liquid bond prices (the ``source curve'') and a benchmark curve representing a benchmark funding
level. The default curve can then be used in models consuming a benchmark curve and a default curve.

If $P_B(0,t)$ and $P_S(0,t)$ denote the discount factors of the given benchmark
and source curve respectively the resulting default term structures has survival probabilities

\begin{equation}
S(t) = \left( P_S(0,t) / P_B(0,t) \right) ^ { 1/(1-R) }
\end{equation}

on the given pillar times. Her, $R$ is the specified recovery rate. If the recovery rate is zero, which is the usual
case, the formula simplifies to

\begin{equation}
  S(0,t) = P_S(0,t) / P_B(0,t)
\end{equation}

The interpolation is backward flat in the hazard rate. The meaning of each node is as follows:

\begin{itemize}
\item CurveId: The curve id.
\item CurveDescription: The curve description.
\item Currency: The currency of the curve.
\item Type: Must be set to Benchmark.
\item DayCounter: The day counter used to convert dates to times.
\item RecoveryRate [optional]: The recovery rate for the resulting default curve. Defaults to zero. The recovery rate
  can be a market quote as usual or also a fixed numeric value for this curve type.
\item BenchmarkCurve: The benchmark yield curve, typically this is the standard Ibor curve in the currence
  (e.g. EUR-EURIBOR-6M, USD-Libor-3M, ...)
\item SourceCurve: The all-in discounting curve.
\item Pillars: The pillars on which to match the source curve
\item SpotLag: The pillar dates are derived using the spot lag and the tenors as specified in the Pillars node using the
  specified calendar.
\item Calendar: The calendar used to derive the pillar dates.
\item Extrapolation [Optional]: If set to true, the curve is extrapoalted beyond the last pillar. Defaults to true.
\item AllowNegativeRates [Optional]: If set to true, the check for non-negative instantaneous hazard rate in the result
  curve is disabled, i.e. the relation $P_S(0,t) \leq P_B(0,t)$ is not enforced. This flag should be enabled with care,
  i.e.  a model consuming the resulting default curve must be able to handle negative hazard rates appropriately. On the
  other hand in some situations it is natural that the source curve rates are below the benchmark rates. Defaults to
  false.
\end{itemize}

\begin{longlisting}
%\hrule\medskip
\begin{minted}[fontsize=\footnotesize]{xml}
    <DefaultCurve>
      <CurveId>BOND_YIELD_EUR_OVER_OIS</CurveId>
      <CurveDescription>Default curve derived as bond yield curve over Eonia</CurveDescription>
      <Currency>EUR</Currency>
      <Type>Benchmark</Type>
      <DayCounter>A365</DayCounter>
      <RecoveryRate>RECOVERY_RATE/RATE//SNR/USD</RecoveryRate>
      <BenchmarkCurve>Yield/EUR/EUR6M</BenchmarkCurve>
      <SourceCurve>Yield/EUR/BOND_YIELD_EUR</SourceCurve>
      <Pillars>1Y,2Y,3Y,4Y,5Y,7Y,10Y</Pillars>
      <SpotLag>0</SpotLag>
      <Calendar>TARGET</Calendar>
      <Extrapolation>true</Extrapolation>
      <AllowNegativeRates>false</AllowNegativeRates>
    </DefaultCurve>
  </DefaultCurves>
\end{minted}
\caption{Benchmark default curve}
\label{lst:defaultcurve_benchmark}
\end{longlisting}

\subsubsection{Multi-Section Default Curve}\label{ss:multisection_default_curve}

Default curves can be build by stitching together instantaneous hazard rates from multiple source curves for multiple
date ranges as shown in listing \ref{lst:defaultcurve_multisection}.

The hazard rate of the resulting curve is taken from the $i$th input curve ($i=0,1,2,\ldots$) for dates before the $i$th
switch date and (if $i>0$) on or after the $i-1$th switch date. The day counter of all input curves should be equal to
the day counter of the result curve. The interpolation is hardcoded as backward flat in the hazard rate.

If not given, the recovery rate $R$ is assumed to be zero. The result default curve's survival probabiltiies are
computed as

\begin{equation}
  S(t) = \left[ \left(\frac{P_{S,n}(t)}{P_{S,n}(t_{n})}\right)^{(1-R_n)} \Pi_{i=0}^{n-1} \left(\frac{P_{S,i}(t_{i+1})}{P_{S,i}(t_{i})}\right)^{(1-R_i)} \right] ^ { \frac{1}{1-R} }
\end{equation}

where $P_{S,i}$ is the survival probability of the $i$th source curve, $R_i$ is the associated recovery rate for the
$i$th source curve, $n$ is chosen such that $P_{S,n}$ is the relevant source curve for time $t$ according to the given
switch dates and curve $i$ is relevant for times in $[t_i,t_{i+1}]$.

The meaning of each node is as follows:

\begin{itemize}
\item CurveId: The curve id.
\item CurveDescription: The curve description.
\item Currency: The currency of the curve.
\item Type: Must be set to MutliSection.
\item SourceCurves: The list of input default curves.
\item SwitchDates: The list of dates where we switch from one input curve to the next. The number of switch dates must
  be one less than the number of source curves.
\item DayCounter: The day counter used to convert dates to times.
\item RecoveryRate [optional]: The recovery rate for the resulting default curve. Defaults to zero. The recovery rate
  can be a market quote as usual or also a fixed numeric value for this curve type.
\item Extrapolation [Optional]: If set to true, the curve is extrapoalted beyond the last pillar. Defaults to true.
\end{itemize}

\begin{longlisting}
%\hrule\medskip
\begin{minted}[fontsize=\small]{xml}
<DefaultCurve>
   <CurveId>MyMultiSectionDefaultCurve</CurveId>
   <CurveDescription>Default curve with multiple sections</CurveDescription>
   <Currency>USD</Currency>
   <Type>MultiSection</Type>
   <SourceCurves>
     <SourceCurve>Default/USD/Generic_AA_Curve</SourceCurve>
     <SourceCurve>Default/USD/Generic_B_Curve</SourceCurve>
     <SourceCurve>Default/USD/Generic_C_Curve</SourceCurve>
   </SourceCurves>
   <SwitchDates>
     <SwitchDate>2020-10-01</SwitchDate>
     <SwitchDate>2021-12-01</SwitchDate>
   <SwitchDates>
   <Extrapolation>true</Extrapolation>
   <DayCounter>A365</DayCounter>
   <RecoveryRate>RECOVERY_RATE/RATE/NAME/SR/USD</RecoveryRate>
</DefaultCurve>
\end{minted}
\caption{Multi-Section default curve}
\label{lst:defaultcurve_multisection}
\end{longlisting}


\subsection{Extending the interface}
\label{sec:extending-interface}
With the |ArrowParallel| type class in place and implemented, we can now define other parallel interface functions. These are basic algorithmic skeletons that are used to define more sophisticated  skeletons.

\subsubsection{Lazy |parEvalN|}
\begin{figure}[tb]
	\includegraphics[scale=0.7]{images/parEvalNLazy}
	\caption{|parEvalNLazy| depiction.}
	\label{fig:parEvalNLazyImg}
\end{figure}
The function |parEvalN| fully traverses the list of passed Arrows as well as their inputs. Sometimes this might not be feasible, as it will not work on infinite lists of functions like \eg |map (arr . (+)) [1..]| or just because we need the Arrows evaluated in chunks. |parEvalNLazy| (Figs.~\ref{fig:parEvalNLazyImg},~\ref{fig:parEvalNLazy}) fixes this. It works by first chunking the input from |[a]| to |[[a]]| with the given |chunkSize| in |arr (chunksOf chunkSize)|. These chunks are then fed into a list |[arr [a] [b]]| of chunk-wise parallel Arrows with the help of our lazy and sequential |evalN|. The resulting |[[b]]| is lastly converted into |[b]| with |arr concat|.
\begin{figure}[t]
\begin{code}
parEvalNLazy :: (ArrowParallel arr a b conf, ArrowChoice arr, ArrowApply arr) =>
	conf -> ChunkSize -> [arr a b] -> (arr [a] [b])
parEvalNLazy conf chunkSize fs =
	arr (chunksOf chunkSize) >>>
    evalN fchunks >>>
    arr concat
    where
      fchunks = map (parEvalN conf) (chunksOf chunkSize fs)
\end{code} %$ %% formatting
\caption{Definition of |parEvalNLazy|.}
\label{fig:parEvalNLazy}
\end{figure}

\subsubsection{Heterogeneous tasks}
\begin{figure}[tb]
	\includegraphics[scale=0.7]{images/parEval2}
	\caption{|parEval2| depiction.}
	\label{fig:parEval2Img}
\end{figure}
We have only talked about the parallelization of Arrows of the same set of input and output types until now. But sometimes we want to parallelize heterogeneous types as well. We can implement such a |parEval2| combinator (Figs.~\ref{fig:parEval2Img},~\ref{fig:parEval2}) which combines two Arrows |arr a b| and |arr c d| into a new parallel Arrow |arr (a, c) (b, d)| quite easily with the help of the |ArrowChoice| type class. Here, the general idea is to use the |+++| combinator which combines two Arrows |arr a b| and |arr c d| and transforms them into |arr (Either a c) (Either b d)| to get a common Arrow type that we can then feed into |parEvalN|.

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "main"
%%% End:


\section{Structure}
\label{sec:transformation_framework:structure}

Creating a transformation function between Ecore models and GROOVE graphs is a difficult task because there are infinitely many possible transformations that vary in complexity. Complexity in these transformation functions is created by the validity constraints of Ecore models and GROOVE graphs. Another factor that adds complexity is the possibility to mix encodings. For example, a transformation function might encode enumeration type \texttt{A} different from enumeration type \texttt{B}.

The transformation framework presented in this chapter deals with the complexity by providing a structure for building transformation functions out of smaller building blocks. The framework starts with a trivial transformation (the transformation between an empty model and an empty graph). It then adds elements to this transformation, such that we build the model and graph iteratively. When applying each building block, the transformation function is extended while preserving its correctness. Furthermore, the framework ensures that when applying each building block, the correctness of both the model and graph is preserved.

\begin{figure}[H]
    \centering
    \begin{tikzpicture}
    \path
    (-3,4) node[circle,draw,minimum size=10mm,inner sep=0pt](ME) {$E$}
    (-4.5,2) node[circle,draw,minimum size=10mm,inner sep=0pt](MA) {$M_A$}
    (-1.5,2) node[circle,draw,minimum size=10mm,inner sep=0pt](MB) {$M_B$}
    (-3,0) node[circle,draw,minimum size=10mm,inner sep=0pt](MAB) {$M_{AB}$}

    (3,4) node[circle,draw,minimum size=10mm,inner sep=0pt](GN) {$N$}
    (1.5,2) node[circle,draw,minimum size=10mm,inner sep=0pt](GA) {$G_A$}
    (4.5,2) node[circle,draw,minimum size=10mm,inner sep=0pt](GB) {$G_B$}
    (3,0) node[circle,draw,minimum size=10mm,inner sep=0pt](GAB) {$G_{AB}$};

    \path[]
    (ME) [-, black, out=240, in=90] edge node[above] {} (MA)
    (ME) [-, black, out=300, in=90] edge node[above] {} (MB)

    (MA) [-{Latex[width=5]}, black, out=270, in=90] edge node[above] {} (MAB)
    (MB) [-{Latex[width=5]}, black, out=270, in=90] edge node[above] {} (MAB)

    (GN) [-, black, out=240, in=90] edge node[above] {} (GA)
    (GN) [-, black, out=300, in=90] edge node[above] {} (GB)

    (GA) [-{Latex[width=5]}, black, out=270, in=90] edge node[above] {} (GAB)
    (GB) [-{Latex[width=5]}, black, out=270, in=90] edge node[above] {} (GAB)

    (ME) [-{Latex[width=5]}, black, out=25, in=155] edge node[above] {$f$} (GN)
    (GN) [-{Latex[width=5]}, black, out=165, in=15] edge node[above] {} (ME)

    (MA) [-{Latex[width=5]}, black, out=35, in=145] edge node[above] {$f_A$} (GA)
    (GA) [-{Latex[width=5]}, black, out=155, in=25] edge node[above] {} (MA)

    (MB) [-{Latex[width=5]}, black, out=35, in=145] edge node[above] {$f_B$} (GB)
    (GB) [-{Latex[width=5]}, black, out=155, in=25] edge node[above] {} (MB)

    (MAB) [-{Latex[width=5]}, black, out=25, in=155] edge node[above] {$f_{A} \sqcup f_{B}$} (GAB)
    (GAB) [-{Latex[width=5]}, black, out=165, in=15] edge node[above] {} (MAB)
    ;
    \end{tikzpicture}
    \caption{General structure for building a transformation function}
    \label{fig:transformation_framework:general_structure}
\end{figure}

In order for the framework to guarantee these properties, the smaller building blocks are applied in a general structure. A visualisation of this structure is given in \cref{fig:transformation_framework:general_structure}. The structure assumes that we have a partially build model $M_A$, which is valid and corresponds to a valid graph $G_A$ under a certain bijective transformation function $f_A$. In other words, $f_A$ transforms model $M_A$ to graph $G_A$ and the inverse of $f_A$ transforms graph $G_A$ to model $M_A$.

The next step is to add a building block. This building block is represented by valid model $M_B$, which corresponds to a valid graph $G_B$ under a specific bijective transformation function $f_B$. Furthermore, we assume that $M_A$ and $M_B$ are entirely distinct except for some set of elements $E$, which are the only shared elements among the models $M_A$ and $M_B$. In the same way, we assume that graphs $G_A$ and $G_B$ are entirely distinct except for a set of nodes $N$, which are the only shared nodes between graphs $G_A$ and $G_B$. Finally, there also exists a specific bijective transformation function $f$, which transforms the set of elements $E$ to the set of nodes $N$ and vice-versa.

Within the framework, we will present a way to merge models $M_A$ and $M_B$ into a model $M_{AB}$, while preserving validity. We also present a way to merge graphs $G_A$ and $G_B$ intro graph $G_{AB}$, again while preserving validity. Then we present a way to merge two transformation functions $f_A$ and $f_B$ in order to create a transformation function $f_{A} \sqcup f_{B}$, which transforms the combined model $M_{AB}$ to the combined graph $G_{AB}$. By performing these operations, a larger transformation function is created which can transform the larger model $M_{AB}$ to the larger graph $G_{AB}$. Since $M_{AB}$ and $G_{AB}$ are valid and $f_{A} \sqcup f_{B}$ is a bijective transformation function between model $M_{AB}$ and graph $G_{AB}$, it is possible to reuse them as the next $M_{A}$, $G_{A}$ and $f_{A}$ in the model and add another building block. This way, complex model structures and transformation functions are created iteratively while each step in the process maintains a formal proof.

In the following sections, the explained structure is applied to type models and type graphs, and then also to instance models and instance graphs. These sections also discuss the necessary definitions and proofs needed to apply the framework.


\section{Quantificational Logic}
\subsection{Quantifiers}


% !TeX spellcheck = en_GB
\documentclass[a4paper, 11pt]{article}
\usepackage[english]{babel}
\usepackage{newtxtext,newtxmath}

\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{dramatist}
\usepackage{dirtytalk}
\usepackage{multicol}
\usepackage{soul}
\usepackage{xcolor}

\usepackage[round]{natbib}

\usepackage{geometry}
\geometry{
	a4paper,
	total={150mm,257mm},
	top=20mm,
}
\usepackage{adjustbox}

\usepackage{hyperref}
\hypersetup{
	colorlinks=true,
	linkcolor=blue,
	filecolor=blue,
	urlcolor=blue,
	citecolor=blue
}

\setlength\parindent{0pt}

%opening
\title{\textbf{Natural Language Processing}\\Portfolio II}
\author{\textbf{Leon F.A. Wetzel}\\ Information Science \\ Faculty of Arts - University of Groningen\\ \texttt{l.f.a.wetzel@student.rug.nl}}

\begin{document}

\maketitle

\begin{abstract}

	In this document, you can find the results and explanations for the assignments of the second part of the portfolio for the course Natural Language Processing, taught at the University of Groningen. The corresponding Python code can be found at \url{https://github.com/leonwetzel/natural-language-processing}\footnote{All code will be published after the course has been completed}. Note that version control of Jupyter notebooks is done via \texttt{jupytext}, so do not forget to convert the relevant Python scripts to notebooks yourself!

\end{abstract}

\section{Week 5 - Neural Language Models}

\subsection{Neurons}

\noindent\fbox{%
	\parbox{\textwidth}{%
Consider the basic neuron $y$ with a sigmoid activation $\sigma$ ($g$ in the image).

$$y = \sigma(x*w+b) \qquad \sigma = s(z) = \frac{1}{1 + e^{-z}} \qquad y = \sigma(x*w+b) = \frac{1}{1 + e^{-(x*w+b)}}$$

Given the weight and bias values $x = [0.3, 0.9, 0.1]$, $w = [-0.2, 0.8, -0.6]$, $b = 0.4$ compute the value of $y$ and provide intermediate calculations.
	}%
}\\

\begin{equation} \label{eq1}
	\begin{split}
		y & = \frac{1}{1 + e^{-(w*x+b)}} = \frac{1}{1+e^{-(0.3*-0.2 + 0.9*0.8 + 0.1*-0.6 + 0.4)}} \\
		& = \frac{1}{1 + e^{-0.06 + 0.72 + -0.06 + 0.4}} = \frac{1}{1 + e^{-1}} \\
		& = \frac{1}{1 + 0.36787944117} = 0.73105857863
	\end{split}
\end{equation}

\subsection{Relu}

\noindent\fbox{%
	\parbox{\textwidth}{%
Assume the same basic neuron as in 5.1, but now with ReLU activation, where

$$\sigma = \text{relu}(z) = max(z,0)$$

Give the updated formula for computing $y$, as well as the new value of $y$ (with intermediate calculations).
	}%
}\\

$$y = \sigma(x*w+b) \qquad \sigma = \text{relu}(z) = max(z,\theta) \qquad y = \sigma(x*w+b) = max(x*w+b, 0)$$

\begin{equation} \label{eq1}
	\begin{split}
		y & = max(x*w+b, 0) = max(0.3*-0.2 + 0.9*0.8 + 0.1*-0.6 + 0.4, 0) \\
		& = max(-0.06 + 0.72 + -0.06 + 0.4, 0) \\
		& = max(1, 0) = 1
	\end{split}
\end{equation}

\subsection{Model size}

\noindent\fbox{%
	\parbox{\textwidth}{%
The feed-forward neural network below with a vocabulary of 50.000 words represented by one-hot vectors, a context window of 3 words, a projection layer with $d=100$, a hidden layer $d_h=500$, like the one below, has a total of $P = E + W + U$ trainable parameters. Which of the following has a bigger impact on the number of parameters:

\begin{enumerate}
	\item increasing context-size from 3 to 4, or
	\item increasing vocabulary from 50.000 to 51.000 words
\end{enumerate}
Give the calculations of $P$ to motivate your answer.
	}%
}\\

\begin{equation}
	\left.\begin{aligned}
		E &= d*|V| = 100 * 50.000 = 5.000.000\\
		W &= d_h * 3d = 500 * 3 * 100 = 150.000\\
		U &= |V| * d_h = 50.000 * 500 = 25.000.000\\
		P &= E + W + U = 5.000.000 + 150.000 + 25.000.000 = 30.150.000
	\end{aligned}
	\right\}
	\qquad \text{CS = 3}
\end{equation}

\begin{equation}
	\left.\begin{aligned}
		E &= d*|V| = 100 * 50.000 = 5.000.000\\
		W &= d_h * 4d = 500 * 4 * 100 = 200.000\\
		U &= |V| * d_h = 50.000 * 500 = 25.000.000\\
		P &= E + W + U = 5.000.000 + 200.000 + 25.000.000 = 30.200.000
	\end{aligned}
	\right\}
	\qquad \text{CS = 4}
\end{equation}

\begin{equation}
	\left.\begin{aligned}
		E &= d*|V| = 100 * 51.000 = 5.100.000\\
		W &= d_h * 3d = 500 * 3 * 100 = 150.000\\
		U &= |V| * d_h = 51.000 * 500 = 25.500.000\\
		P &= E + W + U = 5.100.000 + 150.000 + 25.500.000 = 30.750.000
	\end{aligned}
	\right\}
	\qquad \text{V = 51.000}
\end{equation}

Increasing the vocabulary size leads to a higher amount of trainable parameters, contrary to increasing the context-size. The size of vocabulary affects both $E$ and $U$ (opposed to only $W$ when changing the context size), which leads to higher values in the summation.
\subsection{Architectures}

\noindent\fbox{%
	\parbox{\textwidth}{%
Provide at least one example of an NLP application for each of the following task formulations. Try to come up with examples that are different from those mentioned in class.
	}%
}\\

\begin{table}[h]
	\centering
	\begin{tabular}{l|l}
	\textbf{Task formulation}	& \textbf{Example(s)} \\ \hline
	One-to-many	& Poem generation \\
	Many-to-one	& Language detection \\
	Many-to-many (seq2seq)	& Document summarization \\
	Many-to-many (sequence labelling) & Semantic tagging
	\end{tabular}
	\caption{Examples per task formulation for RNN's}
	\label{tab:examples_rnn}
\end{table}

\subsection{Probing}

\noindent\fbox{%
	\parbox{\textwidth}{%
Think of a grammatical phenomenon in a language of your choice, and come up with at least 10 example sentences to probe whether the model makes the correct predictions. Think of cases where the context makes it clear that the mask has to be plural or singular, that a verb has to have a particular form (like plural or singular, or participle or infinitive), that a specific (personal, possessive, reflexive) pronoun has to be used, that an adjective or noun has to have a specific inflection (like in German and more generally in languages with a rich case and/or gender marking system). There is a host of literature on this, see for instance Marvin and Linzen (for English) and Sahin et al (for multilingual probes).
	}%
}\\

\begin{enumerate}
	\item De minister-president heeft [MASK] handtekening gezet onder de bepaling.
		\begin{enumerate}
		\item de;
		\item een;
		\item geen;
		\item zijn;
		\item deze;
	\end{enumerate}
	\item De ontwikkelaars onthouden [MASK] van commentaar op hun code.
	\begin{enumerate}
		\item software;
		\item ook;
		\item gebruik;
		\item code;
		\item niet;
	\end{enumerate}
	\item Het ijsje begon met [MASK] toen de zon doorbrak.
		\begin{enumerate}
		\item ij;
		\item ,;
		\item zon;
		\item :;
		\item water;
	\end{enumerate}
	\item De universiteit investeerde [MASK] in onderzoeken naar kunstmatige intelligentie.
	\begin{enumerate}
		\item ook;
		\item verder;
		\item \#\#n;
		\item vooral;
		\item zich;
	\end{enumerate}
	\item Het zwaard van Damocles hing boven [MASK] hoofd.
	\begin{enumerate}
		\item zijn;
		\item het;
		\item de;
		\item haar;
		\item hun;
	\end{enumerate}
	\item De kaas uit Duitsland was niet [MASK] dan de kaas uit Nederland.
	\begin{enumerate}
		\item groter;
		\item meer;
		\item kleiner;
		\item anders;
		\item beter;
	\end{enumerate}
	\item De diplomaten dronken uit [MASK] bekers terwijl het ongeval plaatsvond.
	\begin{enumerate}
		\item de;
		\item in;
		\item het;
		\item uit;
		\item en;
	\end{enumerate}
	\item Het weer was onstuimig, het [MASK] namelijk vrij hard.
		\begin{enumerate}
		\item was;
		\item weer;
		\item is;
		\item kwam;
		\item had;
	\end{enumerate}
	\item De scholen sloten hun deuren [MASK].
		\begin{enumerate}
		\item in;
		\item aan;
		\item op;
		\item ';
		\item .;
	\end{enumerate}
	\item Jan had gisteren [MASK] voet gestoten tegen de tafelpoot.
		\begin{enumerate}
		\item en;
		\item met;
		\item van;
		\item aan;
		\item de;
	\end{enumerate}
\end{enumerate}

\noindent\fbox{%
	\parbox{\textwidth}{%
Give at least ten example sentences with a [MASK] and a list of targets that illustrate a specific grammatical phenomenon in a language of your choice. Describe what the grammatical phenomenon is you are investigating. Use the probe function for testing. Try to include both easy sentences (where the model should do well) as well as hard sentences (where there are words in the context that might lead to confusion, or where the clue words are far away from the mask). For languages other than Dutch or English, make sure to include enough explanation so that examples and tests are clear to a non-native speaker.

Describe how well the model did on your probe sentences. Where there any cases where the model made the wrong decision?
	}%
}\\

Please see the notebook for the sentences that were tested. The model did quite well on the provided probe sentences. There is a noticeable bias present in the model when it comes to gender and pronoun usage; him/his often comes on tops when such cases are masked. Although the model performs well in most cases, it did make a slight error in the sentence \texttt{The dog [MASK] hunting for food in the evenings.}, where \textit{are} apparently has a higher score than \textit{was}.

\section{Week 6 - Dependency Parsing}

\subsection{Evaluation}

We are given the following sentence: \texttt{I hate to put a little pressure on you}\\

Our total amount of nodes ($N$) is 8, so our formulas would look like...

	\begin{equation}
		UAS = \frac{\text{\# of nodes with correct parent}}{8}
	\end{equation}

	\begin{equation}
		LAS = \frac{\text{\# of nodes with correct parent and edge label}}{8}
	\end{equation}

For the example on the upper side, the scores are as follows:

\noindent\begin{minipage}{.5\linewidth}
	\begin{equation}
		UAS = \frac{8}{8} = 1
	\end{equation}
\end{minipage}%
\begin{minipage}{.5\linewidth}
	\begin{equation}
		LAS = \frac{8}{8} = 1
	\end{equation}
\end{minipage}\\

For the example on the lower side, the scores are as follows:

\noindent\begin{minipage}{.5\linewidth}
	\begin{equation}
		UAS = \frac{6}{8} = 0.75
	\end{equation}
\end{minipage}%
\begin{minipage}{.5\linewidth}
	\begin{equation}
		LAS = \frac{3}{8} = 0.375
	\end{equation}
\end{minipage}

\subsection{Transition-based Parsing}

\noindent\fbox{%
	\parbox{\textwidth}{%
Describe the states and actions that a transition-based parser has to go through to produce the gold standard (top) analysis of the sentence
in question 6.1. A state consists of a stack, input buffer, and set of dependency relations. An action is either SHIFT, RIGHTARC, or LEFTARC,
where you can assume that the RIGHTARC and LEFTARC actions also produce the correctly labeled dependency relations.
	}%
}\\

We are given the following sentence: \texttt{I hate to put a little pressure on you}\\

We assume that the upper example from exercise 2.1 is the gold standard.\\

\adjustbox{max width=\columnwidth}{
%\begin{table}[h]
	\begin{tabular}{l|l|l|l|l}
	Step & Stack & Word List & Action & Relation Added \\ \hline
	0	& [root] & [I, hate, to, put, a, little, pressure, on, you] & SHIFT &  \\
	1	& [root, I] & [hate, to, put, a, little, pressure, on, you] & SHIFT &  \\
	2	& [root, I, hate] & [to, put, a, little, pressure, on, you] & LEFTARC & (I $\leftarrow$ hate) \\
	3	& [root, hate] & [to, put, a, little, pressure, on, you] & SHIFT &  \\
	4	& [root, hate, to] & [put, a, little, pressure, on, you] & SHIFT &  \\
	5	& [root, hate, to, put] & [a, little, pressure, on, you] & LEFTARC & (to $\leftarrow$ put) \\
	6	& [root, hate, put] & [a, little, pressure, on, you] & SHIFT &  \\
	7	& [root, hate, put, a] & [little, pressure, on, you] & SHIFT &  \\
	8	& [root, hate, put, a, little] & [pressure, on, you] & SHIFT &  \\
	9	& [root, hate, put, a, little, pressure] & [on, you] & LEFTARC & (little $\leftarrow$ pressure) \\
	10	& [root, hate, put, a, pressure] & [on, you] & LEFTARC & (a $\leftarrow$ pressure) \\
	11	& [root, hate, put, pressure] & [on, you] & RIGHTARC & (put $\rightarrow$ pressure) \\
	12	& [root, hate, put] & [on, you] & SHIFT &  \\
	13	& [root, hate, put, on] & [you] & SHIFT &  \\
	13	& [root, hate, put, on, you] & [] & LEFTARC & (on $\leftarrow$ you) \\
	14	& [root, hate, put, you] & [] & RIGHTARC & (put $\rightarrow$ you) \\
	15	& [root, hate, put] & [] & RIGHTARC & (hate $\rightarrow$ put) \\
	15	& [root, hate] & [] & RIGHTARC & (root $\rightarrow$ hate) \\
	16	& [root] & [] & Done & \\ \hline
	\end{tabular}
\centering
%\caption{Transition-based parsing of the sentence \textit{I hate to put a little pressure on you}.}
%\end{table}
}

\subsection{Crossing arcs}

\noindent\fbox{%
	\parbox{\textwidth}{%
It is not possible to produce the analysis for the sentence below using a transition-based parser. Give the state and input buffer for the point where the problem arises and explain why there is no sequence of actions that leads to a correct parse.
	}%
}\\

We are given the following sentence: \texttt{Who did Kim talk to}\\

	\begin{table}[h]
	\begin{tabular}{l|l|l|l|l}
		Step & Stack & Word List & Action & Relation Added \\ \hline
		0	& [root] & [Who, did, Kim, talk, to] & SHIFT &  \\
		1	& [root, Who] & [did, Kim, talk, to] & SHIFT &  \\
		2	& [root, Who, did] & [Kim, talk, to] & SHIFT &  \\
		3	& [root, Who, did, Kim] & [talk, to] & SHIFT &  \\
		4	& [root, Who, did, Kim, talk] & [to] & LEFTARC & (Kim $\leftarrow$ talk) \\
		5	& [root, Who, did, talk] & [to] & LEFTARC & (did $\leftarrow$ talk) \\
		6	& [root, Who, talk] & [to] & LEFTARC & (Who $\leftarrow$ talk) \\
		\textbf{7}	& \textbf{[root, talk]} &\textbf{ [to]} & \textbf{SHIFT (?)} &  \\
		? & [root] & [] & Done &
	\end{tabular}
	\centering
	%\caption{Transition-based parsing of the sentence \textit{I hate to put a little pressure on you}.}
	\end{table}

As we can see in the table above, the problem arises near step 7. As a result of the previous LEFTARC action, we removed the word \textbf{Who} which would be needed for a later RIGHTARC operation. The remaining word \textbf{talk} cannot be coupled with \textbf{to}, as there is no sensible relation between these words. We cannot couple \textbf{root} and \textbf{talk} at this moment, as \textbf{to} is still part of either the stack or word list.

\subsection{Tiny-dependency parser}

\noindent\fbox{%
	\parbox{\textwidth}{%
Improve the oracle of the dependency parser in the notebook and train and evaluate it on the data. See notebook for details.
	}%
}\\

\section{Week 7 - Word Sense Disambiguation}

See the attached notebook for the results of the various experiments.

\end{document}


\documentclass[accentcolor=tud2c,usenames,dvipsnames,colorbacktitle,inverttitle,landscape,german,presentation,t]{tudbeamer}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{slashed}
\usepackage{color}
\usepackage{physics}
\usepackage{graphicx}
\usepackage{braket}
% \usepackage[utf8]{inputenc}

\begin{document}

  \input{macros.tex}

  \setbeamerfont{footline}{size=\fontsize{1}{1}\selectfont}

  \title{Chiral Green's functions and Ward identities}
  \subtitle{\small{Matthias Heinz}}
  \author{Matthias Heinz}
  \institute[Institut f\"ur Kernphysik, TU Darmstadt]{Institut f\"ur Kernphysik, TU Darmstadt}
  \date{January 30, 2020}

  \setbeamertemplate{section in toc}[ball unnumbered]
  \setbeamertemplate{subsection in toc}[ball unnumbered]

  \nocite{*}

  \begin{titleframe}
    \vskip3em
    \begin{columns}[c]
      \begin{column}{0.8\textwidth}
        Outline:
          \vskip2em
        \begin{enumerate}
          \item Ward identities in a $\U{1}$ example
          \vskip2em
          \item Chiral Ward identities via the algebra of currents
          \vskip2em
          \item The chiral generating functional
        \end{enumerate}
      \end{column}
    \end{columns}
      % \includegraphics[width=0.75\textwidth]{figures/05/critical_point_illustration}
      % \\\footnotesize{Stephanov 2009}
  \end{titleframe}

  \section{Ward identities in a $\U{1}$ example}

  \begin{frame}
    \frametitle{Scalar $\Phi^4$ theory with a global $\U{1}$ symmetry}
    \begin{equation*}
      \mathcal{L}^0 = \frac{1}{2}(\dmulop{\Phidag}\dmuhip{\Phi})
      - \frac{m^2}{2} \Phidag \Phi - \frac{\lambda}{4} (\Phidag \Phi)^2
    \end{equation*}

    \vskip3em

    \begin{columns}[c]
      \begin{column}{0.8\textwidth}
        Global $\U{1}$ symmetry:

        \begin{equation*}
        \begin{array}{cc}
          \Phi \rightarrow (1 + i \epsilon) \Phi, &
          \Phidag \rightarrow (1 - i \epsilon) \Phidag, \\
        \end{array}
        \end{equation*}

        \vskip1em

        Conserved Noether current:

        \begin{equation*}
          \Jmu = i (\dmuhip{\Phidag} \Phi - \Phidag \dmuhip{\Phi})
        \end{equation*}
      \end{column}
    \end{columns}
  \end{frame}

  \begin{frame}
    \frametitle{Scalar $\Phi^4$ theory with a global $\U{1}$ symmetry}

    \begin{columns}[c]
      \begin{column}{0.8\textwidth}
        Example Green's function:

        \begin{equation*}
          \Gmu(x,y,z) = \mel*{0}{\timeorder{\Phi(x)\Jmu(y)\Phidag(z)}}{0},
        \end{equation*}

        \vskip1em

        Symmetry constraint:

        \begin{equation*}
          \begin{array}{cc}
            \Jmu \rightarrow \Jmu, &
            \Gmu \rightarrow \Gmu, \\
          \end{array}
        \end{equation*}

        \vskip1em

        Example Ward identity:

        \begin{align*}
          \dmulox{\Gmu(x,y,z)}{y} = & (\delta^4(y-x) - \delta^4(y-z))\mel*{0}{\timeorder{\Phi(x) \Phidag(z)}}{0} \\
                                    & + \mel*{0}{\timeorder{\Phi(x) \dmulopx{\Jmu(y)}{y} \Phidag(z)}}{0},
        \end{align*}
      \end{column}
    \end{columns}
  \end{frame}

  % \begin{frame}
  %   \frametitle{Recap of path integral formalism \\ Maybe just skip and explain on actual generating functional}
  %   \begin{columns}[c]
  %     \begin{column}{0.8\textwidth}
  %       Green's functions via path integral:
  %
  %       \begin{equation*}
  %         \mel{0}{\timeorder{\Phidag(x) \Phi(y)}}{0} =
  %         \int \mathcal{D}\Phistar \mathcal{D}\Phi \Phistar(x) \Phi(y) \exp(i S[\Phi, \Phistar]),
  %       \end{equation*}
  %
  %       Generating functional:
  %
  %       \begin{equation*}
  %       W[j, j^{*}] = \mel*{0}{\timeorder{\exp(i\int d^4x[j(x) \Phidag (x) + j^{*}(x) \Phi(x)])}}{0},
  %       \end{equation*}
  %
  %       Green's functions via functional derivatives:
  %
  %       \begin{equation*}
  %         \mel{0}{\timeorder{\Phidag(x) \Phi(y)}}{0} = \left.\left(-i\frac{\delta}{\delta j(x)} \right) \left(-i\frac{\delta}{\delta j^{*}(y)} \right) W[j, j^{*}] \right\rvert_{j=0,j^{*}=0},
  %       \end{equation*}
  %     \end{column}
  %   \end{columns}
  % \end{frame}

  \begin{frame}
    \frametitle{Generating functional for $\Phi^4$}
    \begin{columns}[c]
      \begin{column}{0.8\textwidth}
        Generating functional:
        \begin{equation*}
          W[j, j^{*}, j_{\mu}] = \mel*{0}{\timeorder{\exp{i\int d^4x[j(x) \Phidag (x) + j^{*}(x) \Phi(x) + j_{\mu}(x) \Jmu(x)]}}}{0},
        \end{equation*}
        Our example Green's function:
        \begin{equation*}
          \Gmu(x,y,z) = \left.(-i)^3 \frac{\delta^3 W[j, j^{*}, j_{\mu}]}{\delta j^{*}(x) \delta j_{\mu}(y) \delta j(z)}\right\rvert_{j=0,j^{*}=0,j_{\mu}=0},
        \end{equation*}
        As path integral:
        \vskip-1em
    \begin{equation*}
      \only<1>{W[j, j^{*}, j_{\mu}] = \int \mathcal{D}\Phistar \mathcal{D}\Phi \exp(i \int d^4x[\mathcal{L}^{0}(x) + \mathcal{L}_{\textrm{ext}}(x)]),}
      \only<2>{W[j, j^{*}, j_{\mu}] = \int \mathcal{D}\Phistar \mathcal{D}\Phi \exp(i S[\Phi, \Phistar, j, j^{*}, j_{\mu}]),}
    \end{equation*}
    \only<1>{
      \begin{equation*}
        \mathcal{L}_{\textrm{ext}}(x) = j(x) \Phi^{*} (x) + j^{*}(x) \Phi(x) + j_{\mu}(x) \Jmu(x),
      \end{equation*}
    }
    \only<2>{Note: Only in the presence of external fields can we demand $\mathcal{L}$ remain invariant under \textit{local} transformations.}
      \end{column}
    \end{columns}

  \end{frame}

  \begin{frame}
    \frametitle{The master equation for $\Phi^4$}
    \begin{columns}[c]
      \begin{column}{0.8\textwidth}

    Demanding $S[\Phi, \Phidag, j, j^{*}, j_{\mu}] = S[\Phi^{\prime}, \Phi^{\prime \dagger}, j^{\prime}, j^{\prime*}, j^{\prime}_{\mu}]$ gives:
    \begin{align*}
    j(x) & \rightarrow (1 + i \epsilon(x))j(x), \\
    j^{*}(x) & \rightarrow (1 - i \epsilon(x))j^{*}(x), \\
    j_{\mu}(x) & \rightarrow j_{\mu} - \dmulop{\epsilon(x)},
    \end{align*}
    % \begin{equation*}
    %   \begin{array}{ccc}
    %     j(x) \rightarrow (1 + i \epsilon(x))j(x), &
    %     j^{*}(x) \rightarrow (1 - i \epsilon(x))j^{*}(x), &
    %     j_{\mu}(x) \rightarrow j_{\mu} - \dmulop{\epsilon(x)}, \\
    %   \end{array}
    % \end{equation*}
    We observe that this also means:
    \begin{equation*}
      W[j, j^{*}, j_{\mu}] = W[j^{\prime}, j^{\prime*}, j^{\prime}_{\mu}],
    \end{equation*}
    Master equation:
    \begin{equation*}
      \only<1>{0 = \int d^{4}x \epsilon(x) \left[ i j(x) \frac{\delta}{\delta j(x)} - i j^{*}(x) \frac{\delta}{\delta j^{*}(x)} + \dmulox{\frac{\delta}{\delta j_{\mu}(x)}}{x} \right] W[j, j^{*}, j_{\mu}],}
      \only<2>{0 = \left[ j(x) \frac{\delta}{\delta j(x)} - j^{*}(x) \frac{\delta}{\delta j^{*}(x)} - i \dmulox{\frac{\delta}{\delta j_{\mu}(x)}}{x} \right] W[j, j^{*}, j_{\mu}],}
    \end{equation*}
      \end{column}
    \end{columns}
  \end{frame}

  \begin{frame}
    \frametitle{QCD in the chiral limit}
    \begin{columns}[c]
      \begin{column}{0.8\textwidth}
        \begin{equation*}
\mathcal{L}_{\textrm{QCD}}^{0} = \sum_{l=u,d,s}(\bar{q}_{R,l}i\slashed{D}q_{R,l} + \bar{q}_{L,l}i\slashed{D}q_{L,l})
- \frac{1}{4} \mathcal{G}_{a\mu\nu} \mathcal{G}_{a}^{\mu\nu},
        \end{equation*}

        Symmetry group:
        \begin{equation*}
        \U{3}_{L}\times\U{3}_{R} \xrightarrow[]{\textrm{Quantization}}\suxsuxu
        \end{equation*}
      \end{column}
    \end{columns}

    \vskip3em
    \begin{columns}[t]
      \begin{column}{0.45\textwidth}
        Conserved currents:
        \begin{itemize}
          \item $\vecoct = R_{a}^{\mu} + L_{a}^{\mu} = \vecoctexpl$,
          \item $\axvoct = R_{a}^{\mu} - L_{a}^{\mu} = \axvoctexpl$,
          \item $\vecsing = R^{\mu} + L^{\mu} = \vecsingexpl$,
        \end{itemize}
      \end{column}
      \begin{column}{0.45\textwidth}
        Color-neutral quadratic forms:
        \begin{itemize}
          \item $\scalardensityx{a}{x} = \scalardensityexplx{a}{x}$,
          \item $\pscalardensityx{a}{x} = \pscalardensityexplx{a}{x}$,
        \end{itemize}
        Note: $a=0,...,8$
      \end{column}
    \end{columns}
  \end{frame}

  \begin{frame}
    \frametitle{Chiral Green's functions and Ward identities \\ \small{\textit{An example}}}
    \begin{columns}[c]
      \begin{column}{0.8\textwidth}
      Green's function:
\begin{equation*}
\Gmu_{APab}(x, y) = \mel*{0}{\timeorder{\axvoct(x)\pscalardensityx{b}{y}}}{0},
\end{equation*}

      Ward identity:
      \end{column}
    \end{columns}
    \vskip1em

\begin{equation*}
\dmulox{\Gmu_{APab}(x,y)}{x} = \delta(x_0 - y_0) \mel*{0}{\commutator{A_{a}^{0}(x)}{P_{b}(y)}}{0}
+ \mel*{0}{\timeorder{\dmulopx{\axvoct(x)}{x}\pscalardensityx{b}{y}}}{0},
\end{equation*}

\vskip1em

    \begin{columns}[c]
      \begin{column}{0.8\textwidth}
        Generalization to any $(n+1)$-point functions:
        \begin{align*}
        % \begin{equation*}
        \partial_{\mu}^{x} &\mel*{0}{\timeorder{\Jmu(x)A_1(x_1)\ldots A_n(x_n)}}{0} = \mel*{0}{\timeorder{\dmulopx{\Jmu(x)}{x}A_1(x_1)\ldots A_n(x_n)}}{0} \\
                           & + \delta(x^{0} - x_{1}^{0}) \mel*{0}{\timeorder{[J_{0}(x), A_{1}(x_{1})] A_{2}(x_2)\ldots A_n(x_n)}}{0} \\
                           & + \ldots \\
                           & + \delta(x^{0} - x_{n}^{0}) \mel*{0}{\timeorder{A_{1}(x_1)A_2(x_2) \ldots [J_{0}(x), A_{n}(x_{n})] }}{0},
        % \end{equation*}
        \end{align*}
      \end{column}
    \end{columns}
  \end{frame}

  \begin{frame}
    \frametitle{Algebra of currents}
    \begin{columns}[c]
      \begin{column}{0.8\textwidth}
        \begin{itemize}
          \item We could now evaluate $[J_{0}(x), A_{n}(x_{n})]$ commutators
          \item \textit{But we have to be careful}
          \item QED current example:
          \begin{itemize}
            \item $[J_0(t, \vec{x}), J_{i}(t, \vec{y})] = 0$
            \item from which one can show $\mel*{0}{J_0(t, \vec{x})}{n} = 0$
          \end{itemize}
          \item Fix: Schwinger term in original charge-current commutator
          \item In general, charge-current commutation relations only determined up to a derivative of a delta function
          \item Another problem: used naive time-ordered product rather than \textit{covariant} time-ordered product
          \item Seagull terms from covariant time-ordering cancel with Schwinger terms (Feynman)
        \end{itemize}
      \end{column}
    \end{columns}
  \end{frame}

  \begin{frame}
    \frametitle{Chiral generating functional}
    \begin{columns}[c]
      \begin{column}{0.8\textwidth}
        Extend chiral Lagrangian to include external fields (sources):
\begin{equation*}
\mathcal{L} = \mathcal{L}^{0}_{\textrm{QCD}} + \lext
\end{equation*}

with

\begin{equation*}
  \only<1>{\lext = \sum_{a = 1}^{8} v_a^{\mu} \vecoct + \frac{1}{3} v_{(s)}^{\mu} \vecsing + \sum_{a=1}^{8} a_a^{\mu} \axvoct
  - \sum_{a=0}^{8}s_{a} \scalardensity{a} + \sum_{a=0}^{8}p_{a} \pscalardensity{a},}
  \only<2>{\color{black}\lext = \bar{q} \gamma_{\mu} \left( \color{red}v^{\mu} \color{black}+ \frac{1}{3} \color{red}v_{(s)}^{\mu} \color{black}+ \gamma_5 \color{red}a^{\mu} \color{black}\right) q
  - \bar{q} ( \color{red}s \color{black}- i \gamma_5 \color{red}p\color{black}) q,}
\end{equation*}

\vskip1em

\pause
using definitions

\begin{equation*}
\begin{array}{cc}
  v^{\mu} = \sum_{a=1}^{8} v_{a}^{\mu} \frac{\lambda_a}{2}, &
a^{\mu} = \sum_{a=1}^{8} a_{a}^{\mu} \frac{\lambda_a}{2}, \\
\end{array}
\end{equation*}
\begin{equation*}
\begin{array}{cc}
s = \sum_{a=0}^{8} s_{a} \lambda_a, &
p = \sum_{a=0}^{8} p_{a} \lambda_a, \\
\end{array}
\end{equation*}

      \end{column}
    \end{columns}
  \end{frame}

  \begin{frame}
    \frametitle{Chiral generating functional \\ \small{\textit{Some examples}}}
    \begin{columns}[c]
      \begin{column}{0.8\textwidth}
        Generating functional:

\begin{equation*}
W[v,a,s,p] = \mel*{0}{\timeorder{\exp{i \int d^4x \lext(x)}}}{0}_{0},
\end{equation*}

\only<1>{Chiral limit example:}
\only<2>{Physical example:}

\begin{equation*}
  \only<1>{\bar{u} u = \frac{1}{2} \bar{q} \left(\sqrt{\frac{2}{3}} \lambda_0 + \lambda_3 + \frac{1}{\sqrt{3}} \lambda_8 \right) q,}
\end{equation*}
      \end{column}
    \end{columns}
\begin{equation*}
  \only<1>{\mel*{0}{\bar{u}(x) u(x)}{0}_{0} = \frac{i}{2} \left. \left[ \sqrt{\frac{2}{3}} \frac{\delta}{\delta s_0(x)} + \frac{\delta}{\delta s_3(x)} + \frac{1}{\sqrt{3}} \frac{\delta}{\delta s_8(x)} \right] W[v,a,s,p]\right\rvert_{v=a=s=p=0},}
  \only<2>{\mel*{0}{\timeorder{\axvoct(x)\pscalardensityx{b}{y}}}{0} = (-i)^2 \left. \frac{\delta^2}{\delta a_{a\mu}(x) \delta p_{b}(y)} W[v,a,s,p] \right\rvert_{v=a=p=0,s=\textrm{diag}(m_{u}, m_{d}, m_{s})},}
\end{equation*}

  \end{frame}

  \begin{frame}
    \frametitle{Constraining external fields}
    \begin{columns}[c]
      \begin{column}{0.8\textwidth}
        We demand of $\mathcal{L}$ that it is:
        \begin{itemize}
          \item Hermitian Lorentz scalar
          \item Even under $P$ and $C$
          \item Invariant under local chiral transformations
        \end{itemize}

        \pause

        Parity:
\begin{align*}
v^{\mu} &\xrightarrow[]{P} v_{\mu}, \\
v^{\mu}_{(s)} &\xrightarrow[]{P} v^{(s)}_{\mu}, \\
a^{\mu} &\xrightarrow[]{P} - a_{\mu}, \\
s &\xrightarrow[]{P} s, \\
p &\xrightarrow[]{P} -p,
\end{align*}

      \end{column}
    \end{columns}
  \end{frame}

  \begin{frame}
    \frametitle{Constraining external fields}
    \begin{columns}[c]
      \begin{column}{0.8\textwidth}
        We demand of $\mathcal{L}$ that it is:
        \begin{itemize}
          \item Hermitian Lorentz scalar
          \item Even under $P$ and $C$
          \item Invariant under local chiral transformations
        \end{itemize}

        Charge conjugation:
\begin{align*}
v_{\mu} &\xrightarrow[]{C} -v^{T}_{\mu}, \\
v_{\mu}^{(s)} &\xrightarrow[]{C} -v^{(s)T}_{\mu}, \\
a_{\mu} &\xrightarrow[]{C} a^{T}_{\mu}, \\
s &\xrightarrow[]{C} s^{T}, \\
p &\xrightarrow[]{C} p^{T},
\end{align*}

      \end{column}
    \end{columns}
  \end{frame}

  \begin{frame}
    \frametitle{Constraining external fields}
    \begin{columns}[c]
      \begin{column}{0.8\textwidth}
        Local chiral transformation:

        \begin{equation*}
          \begin{array}{cc}
            q_{R} \rightarrow \exp{-i\frac{\Theta(x)}{3}} V_{R}(x) q_{R}, &
q_{L} \rightarrow \exp{-i\frac{\Theta(x)}{3}} V_{L}(x) q_{L},
          \end{array}
\end{equation*}

        After splitting our external fields into $r_{\mu}=v_{\mu}+a_{\mu}$ and $l_{\mu}=v_{\mu}-a_{\mu}$:
\begin{align*}
  r_{\mu} &\rightarrow V_{R} r_{\mu} V_{R}^{\dagger} + i V_{R} \dmulop{V_{R}^{\dagger}}, \\
  l_{\mu} &\rightarrow V_{L} l_{\mu} V_{L}^{\dagger} + i V_{L} \dmulop{V_{L}^{\dagger}}, \\
  v_{\mu}^{(s)} &\rightarrow v_{\mu}^{(s)} - \dmulop{\Theta}, \\
  s + ip &\rightarrow V_{R} (s + ip) V_{L}^{\dagger}, \\
  s - ip &\rightarrow V_{L} (s - ip) V_{R}^{\dagger},
\end{align*}
      \end{column}
    \end{columns}
  \end{frame}

  \begin{frame}
    \frametitle{Key takeaways}
    \begin{columns}[c]
      \begin{column}{0.8\textwidth}
        $\U{1}$ example:
        \begin{itemize}
          \item Local invariance of generating functional contains all Ward identities of theory
        \end{itemize}

        Chiral Ward identities from algebra of currents:
        \begin{itemize}
          \item Using the algebra of currents, one must tread with caution (Schwinger and seagull terms)
        \end{itemize}

        Generating functional for chiral Green's functions:
        \begin{itemize}
          \item Allows one to compute Green's functions for chiral limit and ``real" world
          \item Can constrain transformation behavior of external fields by invariance of generating functional under local transformations
        \end{itemize}
      \end{column}

    \end{columns}
  \end{frame}

  %yank 7

  % \begin{frame}
  %   \frametitle{Frame template}
  %   \begin{columns}[c]
  %     \begin{column}{0.8\textwidth}
  %     \end{column}
  %   \end{columns}
  % \end{frame}

  \begin{frame}[allowframebreaks]
    \frametitle{References}
    \bibliographystyle{apalike}
    \bibliography{bibfile}
  \end{frame}

\end{document}


\documentclass[main.tex]{subfiles}
\begin{document}

\marginpar{Tuesday\\ 2020-10-6, \\ compiled \\ \today}

As we said earlier, massive stars go type-2 supernova: this corresponds to Core-Collapse.

Compact objects are quite common in the galaxy.

% Non si può preparare un matrimonio con i fichi secchi.

A compact object is one for which the ratio of the gravitational radius \(R_g = GM / c^2\) is comparable to the radius of the true object.
For a white dwarf, the ratio is of the order of \num{e3}.

We then need GR in order to deal with them.
Let us quickly go over exact solutions of the Einstein Field Equations.

\section{The Schwarzschild external solution}

This lecture, we consider the vacuum Schwarzschild solution.
The most general line element which is spherically symmetric (invariant under spatial rotations)
must be made up of elements which are themselves invariant under spatial rotations.
We will use spherical coordinates: \(r, \theta , \varphi , t\).

In flat spacetime, the line element reads
%
\begin{align}
\dd{s^2} = - c^2 \dd{t^2} + \dd{r^2} + r^2 \qty( \dd{\theta^2} + \sin^2 \theta \dd{\varphi^2})
\,,
\end{align}
%
and our Schwarzschild solution will need to reduce to this in some limit.

The spatial line element is given by
%
\begin{align}
\dd{\vec{r}} \cdot \dd{\vec{r}} =  \dd{r^2} + r^2 \qty( \dd{\theta^2} + \sin^2 \theta \dd{\varphi^2}) = g_{ij} \dd{x^{i}} \dd{x^{j}}
\,.
\end{align}

Then, the most general spherically symmetric line element will read
%
\begin{align}
\dd{s^2} =  F(r ,t) \dd{t^2} + M(r, t) \dd{r^2} + G(r, t) \dd{r} \dd{t} + C(r, t) r^2 \qty( \dd{\theta^2} + \sin^2 \theta \dd{\varphi^2})
\,,
\end{align}
%
however, we can redefine the radial coordinate in order to remove the function multiplying the angular term, so we get
%
\begin{align}
\dd{s^2} = F \dd{t^2} + M \dd{r^2}  + G \dd{r} \dd{t}
+ r^2 \qty(\dd{\theta^2} + \sin^2\theta \dd{\varphi^2})
\,.
\end{align}

We can also introduce a new time variable:
%
\begin{align}
\dd{t'} = \dd{t} + \psi (r, t) \dd{r}
\,.
\end{align}

If \(\psi = G / 2F\), then we remove the mixed term, and then we are left with the expression
%
\begin{align}
\dd{s^2} = -B (r, t) \dd{t^2} + A(r, t) \dd{r^2} + r^2 \dd{\Omega^2}
\,.
\end{align}

However, we have not yet determined the two functions, and we have not said anything about the Einstein Field Equations, which are
%
\begin{align}
R_{\mu \nu } - \frac{1}{2} g_{\mu \nu } R = 8 \pi G T_{\mu \nu }
\,.
\end{align}

In vacuo, the stress-energy tensor vanishes.
The curvature scalar must vanish (we can show this by contracting the EFE with the inverse metric), so the equations reduce to \(R_{\mu \nu } = 0\).
We restrict ourselves to the static case.

The linearly independent components of the Ricci tensor read
%
\begin{align}
R_{0}^{0} = \frac{B''}{2AB} - \frac{A' B'}{4 A'' B}
- \frac{B^{\prime 2}}{4AB^2} + \frac{B'}{rAB} &= 0 \\
R_{1}^{1} = \frac{B''}{2AB} - \frac{A' B'}{4 A'' B}
- \frac{B^{\prime 2}}{4AB^2} + \frac{A'}{rA^2} &= 0 \\
R_{2}^{2} = \frac{1}{4rA} \qty(\frac{B'}{B} - \frac{A'}{A})
+ \frac{1}{r^2} \qty( \frac{1}{A} - 1)
\,.
\end{align}

Computing \(R^{0}_{0} - R^{1}_{1} = 0\) we find
%
\begin{align}
\frac{1}{rA} \qty(\frac{B'}{B} + \frac{A'}{A} )&= 0  \\
\dv{\log (AB)}{r} &= 0
\,,
\end{align}
%
so \(AB\) is constant.
Without losing generality we can take \(A = 1/B\), since if this is not the case we can just rescale the radial or temporal coordinate until it is.

Then, we can compute
%
\begin{align}
R^{2}_{2} = \frac{B}{2r} \qty(\frac{B'}{B} + \frac{B'}{B}) + \frac{1}{r^2} (B-1) &= 0  \\
B' + \frac{B}{r} - \frac{1}{r} &= 0  \\
\dv{}{r} \qty(rB) &= 1
\,,
\end{align}
%
so \(r B(r) = r + C\) for some constant \(C\), or equivalently
%
\begin{align}
B (r) = \frac{C}{r} + 1
\,.
\end{align}

After this, we can already substitute into the metric:
%
\begin{align}
\dd{s^2} = - \qty(1 + \frac{C}{r}) \dd{t^2}
+ \frac{1}{1 + C/r} \dd{r^2} + r^2 \dd{\Omega^2}
\,.
\end{align}

For any value of \(C\), \(B \to 1\) as \(r \to \infty \): the metric reduces to the flat one asymptotically.
Right now \(C\) is an arbitrary constant, however in the weak field limit it is known that
%
\begin{align}
g_{00} = - \qty(1 + 2 \frac{\phi }{c^2})
\,,
\end{align}
%
where \(\phi = - GM / r\) is the Newtonian gravitational field.
Equating this expression to the one for \(g_{00} \), we find
%
\begin{align}
g_{00} = - \qty(1 - \frac{2 GM}{rc^2})
\implies C = - \frac{2GM}{c^2}
\,.
\end{align}

The constant \(M\) in the classical case is the mass of the source, however we are computing a vacuum solution. This is the mass we would compute if we were to measure the orbits of objects around the compact object.

% \todo[inline]{This is then surely a \emph{gravitational} mass, is it also an \emph{inertial} mass? Can we show this in GR?}

Then, we can write the Schwarzschild metric:
%
\begin{align}
\dd{s^2} = - \qty(1 - \frac{2GM}{c^2r}) \dd{t^2}
+ \qty(1 - \frac{2GM}{rc^2})^{-1} \dd{r^2} + r^2 \dd{\Omega^2}
\,.
\end{align}

This is derived by assuming time-independence, however the result is the same even in the time-dependent case by the Jebsen-Birkhoff theorem (which we will prove in a moment).
The element \(g_{rr} \) diverges as \(r \to R_g = 2GM/c^2\), however this does not represent any physical divergence: no component of the Riemann tensor \(R_{\mu \nu \rho \sigma }\) diverges there, while the Ricci tensor \(R_{\mu \nu }\) is identically zero by hypothesis.
On the other hand, the origin is a true singularity, since the scalar \(R^{\mu \nu \rho \sigma } R_{\mu \nu \rho \sigma } \propto r^{-6}\) diverges there.

There are coordinates which do not diverge near the horizon: one classical choice employs the ``tortoise'' coordinates, which are the same for \(r\), \(\theta \), \(\varphi \) as the Schwarzschild ones, while the time becomes (setting \(G = c =  1\))
%
\begin{align}
t = t' - 2M \log \qty(1 - \frac{r}{2M})
\,.
\end{align}

\begin{claim}
Substituting this into the metric yields (dropping the primes for clarity):
%
\begin{align}
\dd{s^2} = - \qty(1 - \frac{2M}{r}) \dd{t}^2
+ \frac{4M}{r} \dd{r} \dd{t} + \qty(1 + \frac{2M}{r}) \dd{r^2}
+ r^2 \dd{\Omega^2}
\,.
\end{align}
\end{claim}

\begin{proof}
The new time differential after the change of coordinates reads
%
\begin{align}
\dd{t} &= \pdv{t}{t'} \dd{t'} + \pdv{t}{r} \dd{r}  \\
&= \dd{t'} - 2M \frac{(-1/2M)}{1 - r/2M} \dd{r} = \dd{t}' + \frac{ \dd{r}}{1 - r / 2M}  \\
\dd{t}^2 &= \dd{t}^{\prime 2}
+2 \frac{ \dd{r} \dd{t'}}{1 - r/2M}
+ \frac{ \dd{r^2}}{(1 - r / 2M)^2}
\,,
\end{align}
%
therefore the new metric reads (omitting the angular part for brevity):
%
\begin{align}
\dd{s}^2
&= - \qty(1- \frac{2M}{r}) \dd{t}^2 + \frac{ \dd{r}^2}{1 - 2M / r}  \\
&= - \qty(1- \frac{2M}{r}) \qty(\dd{t}^{\prime 2}
+2 \frac{ \dd{r} \dd{t'}}{1 - r/2M}
+ \frac{ \dd{r^2}}{(1 - r / 2M)^2}) + \frac{ \dd{r}^2}{1 - 2M / r}  \\
&= - \qty(1 - \frac{2M}{r}) \dd{t^{\prime 2}} + \frac{4M}{r} \dd{r} \dd{t'} + \qty(1 + \frac{2M}{r}) \dd{r^2}
\,,
\end{align}
%
where we have used the following manipulations: setting \(x = 2M / r\), the coefficients of the \(\dd{r} \dd{t}'\) and \(\dd{r^2}\) terms are respectively
%
\begin{align}
2\frac{1 - x}{1 - x^{-1}} &= -2x  \\
-\frac{1 -x}{(1- x^{-1})^2} + \frac{1}{1-x} &= \frac{1}{1-x} \qty(-\qty(\frac{1-x}{1- x^{-1}})^2 + 1) =  \frac{1-x^2}{1-x} = 1+x
\,.
\end{align}
\end{proof}

There is no pathology at \(r = 2M\) anymore, so it was not a physical divergence.
The temporal coefficient \(g_{00} \) is the same: it can be shown that it is an invariant under coordinate transformations.

If we take two points which are very close along a particle trajectory, they must be separated by an interval \(\dd{s}^2 < 0\).

If we consider a radial path (not necessarily geodesic) described by \(r(t)\), we can compute the corresponding line element by neglecting the angular part:
%
\begin{align}
\dd{s^2} &= - \qty(1 - \frac{2M}{r}) \dd{t}^2
+ \frac{4M}{r} \dd{r} \dd{t} + \qty(1 + \frac{2M}{r}) \dd{r^2}  \\
\qty( \dv{s}{t})^2 &= - \qty(1- \frac{2M}{r})
+ \frac{4M}{r} \dv{r}{t} + \qty(1 + \frac{2M}{r} ) \qty(\dv{r}{t})^2
\,.
\end{align}

Now, the question we ask is: is it possible for the particle trajectory to be timelike or lightlike (\(\dd{s}^2 \leq 0\)) and outgoing (\(\dv*{r}{t} > 0\)) under these conditions? If this is the case, the signs of the three terms read
%
\begin{align}
\underbrace{\qty(\dv{s}{t})^2}_{< 0 ?}
=
- \qty(1- \frac{2M}{r})
\underbrace{+ \frac{4M}{r} \dv{r}{t}}_{> 0 } \underbrace{+ \qty(1 + \frac{2M}{r} ) \qty(\dv{r}{t})^2}_{> 0}
\,,
\end{align}
%
so we can see that the equality can be satisfied (a positive number cannot equal a negative one!) as long as the first term on the right-hand side is negative, which means \(r > 2M\).
If \(r \leq 2M\), on the other hand, this cannot be the case: a radial trajectory below the horizon \emph{cannot} be outward.

This is what ``horizon'' means: it is a \emph{semi-permeable} membrane, particles can surpass it only in one direction.

\paragraph{Jebsen-Birkhoff}

This theorem states that the Schwarzschild solution also describes the spacetime around an object in the spherically-symmetric but time-\emph{dependent} case. Let us give a sketch of its proof, omitting some tedious calculations.
If we write out the components of the Ricci tensor, we find something in the form
%
\begin{align}
R^{0}_{0} &= \eval{R^{0}_{0}}_{\text{static}} + \dot{A} \qty(\dots)\\
R^{1}_{1} &= \eval{R^{1}_{1}}_{\text{static}} + \dot{A} \qty(\dots)
\,,
\end{align}
%
while \(R^{2}_{2}\) and \(R^{3}_{3}\) are the same. Also, the term \(R^{1}_{0}\) does not vanish unlike the static case, and is equal to
%
\begin{align}
R^{1}_{0} = - \frac{\dot{A}}{r A^2} = 0
\,,
\end{align}
%
so \(\dot{A} = 0\): the equations then are the same as the static case ones!
This, however, is not the end, since now the equation
%
\begin{align}
\frac{A'}{A} + \frac{B'}{B} = 0
\,
\end{align}
%
is not necessarily solved by \(\log A = - \log B\), since a prime denotes a \emph{partial} derivative with respect to \(r\), so in general we will have \(\log A + \log B = f(t)\), some generic function of time.
The metric will then read
%
\begin{align}
\dd{s}^2 = - \qty(1 - \frac{2M}{r}) f(t)\dd{t^2} + \qty(1 - \frac{2M}{r}) \dd{r^2} + r^2 \dd{\Omega}^2
\,,
\end{align}
%
but we can simply rescale the time coordinate to \(t \to \sqrt{f} t\) in order for this to reduce to the usual expression.
This theorem was originally discovered by the Norwegian physicist Jebsen, and only later popularized in a textbook by Birkoff \cite{johansenDiscoveryBirkhoffTheorem2005}.

The source of the geometry can change in time while leaving the outside spacetime unperturbed, however this holds only as long as the variation remains spherically symmetric: collapse, expansion or pulsation.
Any asymmetry can lead to the emission of gravitational radiation.

\end{document}


\chapter{Preprocessing spectral data}
\label{ch:spectral_preprocessing}

\begin{wrapfigure}{o}{0.63\textwidth}
    \centering
    \vspace{-3.4cm}
    \includegraphics[scale=0.55]{spectral_preprocessing-fig1.png}
    \label{fig:spectral_preprocessing-fig1}
\end{wrapfigure}

Preprocessing spectra is a very important step of data analysis. \mutation\ has a widget, \textit{Preprocessing}, dedicated to different methods. The spectra from the ``Liver cirrhosis'' data set could use some preprocessing. There is some scattering visible and perhaps there are some artifacts due to sample thickness varying slightly.

\begin{figure}[h]
    \vspace{-0.2cm}
    \includegraphics[scale=0.28]{spectral_preprocessing-fig2.png}
    \caption{You can add preprocessing steps from the top dropdown menu of the left panel. Then, it is possible to drag them up and down to change their order. Each preprocessor has its own parameters. In the example here we show how the Baseline correction is done: you can simply change the baseline points by dragging the red lines in the top spectrum panel. Each stage can be previewed by clicking the small triangle.}
    \label{fig:spectral_preprocessing-fig2}
\end{figure}

Let's see the result of our preprocessing in a \textit{HyperSpectra} widget.

\begin{figure}[h]
    \vspace{-0.2cm}
    \includegraphics[scale=0.28]{spectral_preprocessing-fig3.png}
    \vspace{-1cm}
    \caption{The preprocessed data in \textit{HyperSpectra}. Did we gain anything? To investigate why the blue island disappeared, click on a pixel in it to see its spectrum.}
    \label{fig:spectral_preprocessing-fig3}
\end{figure}


\startreport{Network Influence Score}
\reportauthor{Ramesh Subramonian}
\section{Introduction}

We define the ``network influence score'' problem as follows. Let us assume that
we know 2 things for every user that we have (a) who referred that user (could
be zero or one user) (b) the revenue generated by that user.

We ``attribute''
the revenue of a user to every referrer along the chain of referrals ending at
that user. For example, if \(a\) referred \(b\) who referred \(c\) and \(c\)
generated \$210 of revenue, then \$140 is attributed to \(b\) and 70 to \(a\).
Note that the distribution of c's revenue depends on the length of the referral
chain ending at \(c\). So, if \(d\) had referred \(a\) in this example, then
\$120 is attributed to \(b\), \$60 to \(a\) and \$30 to \(d\).

Simply stated, the problem is to find the attributed revenue of each user.

\subsection{Selected Q operators}
See Table~\ref{tbl_q_ops}.

\begin{table}[ht]
\centering
\begin{tabular}{|l|l|l|} \hline \hline
{\bf ID} & {\bf operator} & {\bf explanation} \\ \hline \hline
1 & \(y = \mathrm{get\_val\_by\_idx}(f, x)\) & \(y_i \leftarrow x_{f_i}\) \\ \hline
2 & \(y = \mathrm{set\_sclr\_val\_by\_idx}(x, y, s)\) & \(x_i = j \Rightarrow y_j \leftarrow s\) \\ \hline
3 & \(z = \mathrm{add\_vec\_val\_by\_idx}(x, y, z)\) & \(x_i = j \Rightarrow z_j \leftarrow
z_j + y_i\) \\ \hline
4 & \(z = \mathrm{vvmul}(x, y)\) & \(z_i \leftarrow x_i \times y_i\) \\ \hline
5 & \(y = \mathrm{vsleq}(x, s)\) & {\bf if} \(x_i \leq s\) {\bf then} \(y_i \leftarrow 1\) {\bf else} \(y_i \leftarrow 0\)  \\ \hline
6 & \(w = \mathrm{ifxthenyelsez}(x, y,z)\) & {\bf if} \(x_i\) {\bf then} \(w_i \leftarrow y_i\) {\bf else} \(w_i \leftarrow z_i\)  \\ \hline
7 & \(x = \mathrm{const}(s)\) & \(x_i \leftarrow s\) \\ \hline
8 & \(z = \mathrm{where}(x, y)\) & \(z = \{x_i\}\) where \(y_i = 1\) \\ \hline
\hline
\end{tabular}
\caption{Selected Q operators}
\label{tbl_q_ops}
\end{table}

\section{Data Structures}
\subsection{T0}

\(T_0\) has the following columns, where each row refers to a person.
\be
\item \(x\) --- a sequence \(0, 1, \ldots\)
\item \(y\), person who did the referring.
\item id, original ID
\item \(r\), dollar amount spent
\item \(s\), dollar amount attributed, {\em created by algorithm}
\item \(d\), max depth of referral chain ending in this person, {\em created by algorithm}
\ee
Notes:
\bi
\item \(y[i] = j \Rightarrow\) \(i\) was referred by \(j\).
We also say that \(y\) is the 1-parent of \(i\)
\item \(y[j] < 0 \Rightarrow \) nobody referred \(j\)
\item a person can be referred by at most one person
\ei

\subsection{T1}

\(T_1\) is \(T_0\) restricted to persons who were refered. Specifically,
\bi
\item \(v = \mathbf{Q.vsgeq}(T_0.y, 0)\)
\item \(T_1.x = \mathbf{Q.where}(T_0.x, v)\)
\item \(T_1.y = \mathbf{Q.where}(T_0.y, v)\)
%% DELETE \item \(T_1.r = \mathbf{Q.where}(T_0.r, v)\)
%% DELETE \item \(T_1.d = \mathbf{Q.const}(1)\)
%% DELETE --- initial assumption on depth of chain ending in \(x\)
\ei

\subsection{Tk}

Tables \(T_k\) for \(k =  2, \ldots\) have the following columns
\be
\item \(x\), person who was referred
\item \(y\), person who did the referring at a distance of \(k\)
\ee

Note that if \(a\) referred \(b\) and \(b\) referred \(c\), then table \(T_2\)
would have a row of the form \((c, a)\)

\subsection{Sample Data}
An example is in Table~\ref{example_extend}.
\begin{table}[hp]
\centering
\begin{tabular} {|l|l|l|l|l|} \hline \hline
{\bf k} & {\bf x} & {\bf y} & {\bf z} & {\bf w} \\ \hline
0 & 0 & 1  & --- & --- \\ \hline
0 & 1 & 2  & --- & --- \\ \hline
0 & 2 & 3  & --- & --- \\ \hline
0 & 3 & 4  & --- & --- \\ \hline
0 & 4 & -1 & --- & --- \\\hline
0 & 5 & 6  &  --- & --- \\\hline
0 & 6 & 7  &  --- & --- \\\hline
0 & 7 & -1 &  --- & --- \\\hline
0 & 8 & -1 &  --- & --- \\\hline
\hline  \hline
1 & 0 & 1  & 2  & 1 \\ \hline
1 & 1 & 2  & 3  & 1 \\ \hline
1 & 2 & 3  & 4  & 1 \\ \hline
1 & 3 & 4  & -1 & 0 \\ \hline
1 & 5 & 6  & 2  & 1 \\ \hline
1 & 6 & 7  & -1 & 0 \\ \hline
\hline  \hline
2 & 0 & 2 & 3 & 1 \\ \hline
2 & 1 & 3 & 4 & 1 \\ \hline
2 & 2 & 4 & -1 & 0 \\ \hline
2 & 5 & 7 & -1 & 0 \\ \hline
\hline  \hline
3 & 0 & 3 & 4 & 1 \\ \hline
3 & 1 & 4 & -1 & 0 \\ \hline
\hline  \hline
4 & 0 & 4 & -1 & 0 \\ \hline
\end{tabular}
\caption{Sample data}
\label{example_extend}
\end{table}

\section{Algorithm}

The algorithm is presented in Figure~\ref{algo}. Some useful routines in
Section~\ref{aux_algo}
\subsection{Sub-routines}
\label{aux_algo}

\bi
\item The function {\bf Q.extend} is in Figure~\ref{extend}
\item The way the attribution diminishes with distance is in Table~\ref{attenuate}
\ei

\begin{figure}
\centering
\fbox{
\begin{minipage}{12 cm}
\centering
\begin{tabbing}
\hspace*{0.25in} \= \hspace*{0.25in} \= \hspace*{0.25in} \= \kill
Inputs: \+ \\
\(T_k.x\) \\
\(T_k.y\) \\
\(T_0.y\) \- \\
% Operation:  \+ \\
% Let \(T_k.x[i] = x', T_k.y[i] = y'\).  \\
% Let \(f' = T_0.y[y']\).  \\
% If \(z' \geq 0\), add \((x', z')\) to output; else, do nothing \- \\
Implementation in Q:  \+ \\
\(z = \mathbf{Q.get\_val\_by\_idx}(T_k.y, T_0.y)\) \\
\(w = \mathbf{Q.vsgeq}(z, 0)\) \\
\(T_{k+1}.x = \mathbf{Q.where}(T_k.x, w)\) \\
\(T_{k+1}.y = \mathbf{Q.where}(z, w)\) \- \\
\end{tabbing}
\caption{extend}
\label{extend}
\end{minipage}
}
\end{figure}

\begin{table}[hp]
\centering
\begin{tabular}{|l|l|l|l|l|l|l|} \hline \hline
\(d_{max}\) & \(\alpha_1\)  & \(\alpha_2\)  & \(\alpha_3\)  & \(\alpha_4\)
\\ \hline
1 & 1 & --- & --- & --- \\ \hline
2 & 2/3 & 1/3 & --- & --- \\ \hline
3 & 4/7 & 2/7 & 1/7 & --- \\ \hline
4 & 8/15 & 4/15 & 2/15 & 1/15 \\ \hline
\hline
\end{tabular}
\caption{Attenuation Factors for different \(d, d_{max}\)}
\label{attenuate}
\end{table}

\begin{figure}
\centering
\fbox{
\begin{minipage}{12 cm}
\centering
\begin{tabbing}
\hspace*{0.25in} \= \hspace*{0.25in} \= \hspace*{0.25in} \= \kill

\(T_0.d = \mathbf{Q.const}(1)\) --- initialize max depth to 1 \\
\(T_0.s = \mathbf{Q.const}(0)\) --- initialize attributed revenue to 0 \\
\(k = 1\) \\
{\bf repeat } \+ \\
\(T_{k+1} = \mathbf{Q.extend}(T_k.x, T_k.y, T_0.y)\) (Figure~\ref{extend})\\
{\bf if} \(T_{k+1} = \bot\) {\bf then break else} \(k = k+1\) {\bf end}\\
--- Update max depth of referral chain \\
\(\mathbf{Q.set\_sclr\_val\_by\_idx}(T_{k+1}.x, T_0.d, k+1)\) \- \\
{\bf until} --- not possible to extend any further \\
\(d_{max} = k\) \\
Load \(\alpha\) which contains attribution coefficients (Table~\ref{attenuate})\\
{\bf for} \(k = 1, \ldots d_{max}\) {\bf do} \+ \\
% {\bf for} \(k = 1, \ldots k\) {\bf do} \+ \\
  \(T_k.d       = \mathbf{Q.get\_val\_by\_idx}(T_k.x, T_0.d)\)  \\
  \(T_k.r       = \mathbf{Q.get\_val\_by\_idx}(T_k.x, T_0.r)\)  \\
  \(T_k.\alpha  = \mathbf{Q.get\_val\_by\_idx}(T_k.d, \alpha[k])\) \\
  \(s           = \mathbf{Q.vvadd}(T[k].r, T[k].\alpha)\) \\
  \(\mathbf{Q.add\_vec\_val\_by\_idx}(s, T_k.y, T_0.s)\) \- \\
{\bf endfor} \\
\end{tabbing}
\caption{Pseudo-code}
\label{algo}
  \end{minipage}
}
\end{figure}

\newpage

\appendix
Some bogus reference to make bibtex not complain \cite{Hastie2009}.
\bibliographystyle{alpha}
\bibliography{../../../DOC/ref}


\chapter{Anomaly Detection}

\section{Type of Anomaly}
\begin{enumerate}
\item Point Anomalies (Our Focus)
\item Contextual Anomalies
\item Collective Anomalies
\end{enumerate}

\section{Anomaly Detection Techniques}
\noindent General steps
\begin{table}[h!]
\begin{tabular}{r p{12cm}}
\hline
    1: & Build profile of normal behavior \\
    2: & Use the normal profile to detect anomalies \\
\hline
\end{tabular}
\end{table}

\begin{description}
\item[Graphical Approaches] Boxplot, Scatter plot, Spin plot
\item[Statistical Approaches] points are determined to be outliers depending on their relationship with this model
\item[Nearest Neighbor Based Approaches] Distance based methods or density based methods
\item[Classification Based Approaches] Supervised learning techniques
\end{description}
\textit{Evaluation of Anomaly Detection: Use F-measure and ROC curve}


\chapter{Another appendix}\label{ch:appendixB}
\begin{equation}
	H = \sum_{k}\epsilon_kc_k^\dagger c_k
\end{equation}
Here, the equation gets a ``B''.


\chapter{Complete Model}
Now describe the procedure to attach the tail rotor to two structure: the truss model and shell model, respectively.
In both base model we add a part that realize the nodes that represent rigid connection between the tail structure and tail rotor.
After call the macro to realize the component, realized connection by rigid elements between these and component previous realized.

\section{Truss model with rotor tail}
As previously introduced, we use the base model of the trellis structure, which serves as a base for attaching the tail rotor developed in detail in the chapter.
Two nodes are placed at the end of the tail and two new raised nodes of a certain offset are created that will act as a base for the bearing attachment.
Once the basic nodes are made, the macro \ref{lst:rotor} is used to make the rotor model.
To allow rotation of the tail rotor shaft, the rigid element \textsc{mpc184} with (keyopt, 6) was used in such a way as to produce joint revolutions placed in their respective nodes of attack.
This result allows the shaft to rotate along its axis and simultaneously limiting other movements.
Finally, the two structures are connected by rigid elements of the \textsc{mpc184} type, the final result is shown in the figure

%\listingautocaption[language=apdl-modified, label={lst:ShellModeldiskRun},firstline=170,lastline=236]{ShellModeldiskRun.txt}

%firstline=300,lastline=500
\section{Shell model with rotor Tail}