% declare document class and geometry
\documentclass[12pt]{article} % use larger type; default would be 10pt
\usepackage[margin=1in]{geometry} % handle page geometry

\input{../header2.tex}

\title{Phys 220A -- Classical Mechanics -- Lec04}
\author{UCLA, Fall 2014}
\date{\formatdate{14}{10}{2014}} % Activate to display a given date or no date (if empty),
         % otherwise the current date is printed

\begin{document}
\setlength{\unitlength}{1mm}
\maketitle

\section{Mechanical systems with constraints}

Another advantage of the Lagrangian formalism is that it makes the handling of constraints easier. Constraints are ubiquitous in physics --- some examples:

\begin{enumerate}
\item Atwood machine. Masses $m_1$ and $m_2$ attached to a pulley.
\item Motion constrained to a surface
\item Spherical pendulum
\item Double pendulum
\item Bead on a rotating rigid rod.
\item Rolling without slipping
\end{enumerate}

In Newtonian mechanics, to deal with these constraints we must make use of normal forces, string tensions, kinetic vs static friction etc. It is arguably simpler and more systematical in the Lagrangian approach. Let's attempt to classify the different constraints.

Imagine the motion of a particle in a potential $\Phi(\v x,t)$ (no dependence on velocity). Suppose the potential has a uniformly-valued valley along some curve $\v \gamma (\lambda,t)$, so that
\begin{eqn}
\Phi(\v \gamma, t) = c(t).
\end{eqn}
In the limit where $\Phi \to \infty$ away from $\v \gamma(\lambda,t)$, this determines a constraint for the particle's motion, which we can write as an isosurface
\begin{eqn}
\phi(\v x, t) = \Phi(\v x, t) - c(t) = 0.
\end{eqn}
A constraint like this that does not depend on velocity is called \emph{holonomic}. The constraint can be further classified as \emph{scleronomic} if it does not depend explicitly on time $t$, or \emph{rheonomic} if it does.

A \emph{nonholonomic} constraint is one that depends on the velocities,
\begin{eqn}
\phi(\v x, \vd x, t) = 0.
\end{eqn}
More generally, a \emph{nonholonomic system} is one whose state depends on the particular path taken. Nonholonomic constraints are generally difficult to treat in the Lagrangian formalism. For holonomic constraints, the general approach is to use \emph{Lagrange multipliers}. Another case may be that the constraint is an \emph{inequality} rather than an \emph{equality}, which may be treated \emph{Kuhn-Tucker method}. For now we will only treat holonomic equality constraints.

\subsection{Holonomic constraints}

Suppose we have $s$ linearly independent constraints $\phi_1, \dots, \phi_s$. There are generally two methods to treat the constraints.

\subsubsection{Lagrange multipliers}

Introduce $s$ new auxiliary coordinates $\lambda_1(t), \dots, \lambda_s(t)$ and modify the action,
\begin{eqn}
\widetilde{S} [q_i, \lambda_j] = \int_{t_1}^{t_2} \dif{t} \left[ L(q_i, \dot q_i, t) + \sum_{k=1}^s \lambda_k \phi_k (q_i, t) \right].
\end{eqn}
Varying the new action with respect to the coordinates $q_i, \lambda_j$, we find that the Euler-Lagrange equations give us
\begin{eqn}
0 = \pd{\widetilde{L}}{\lambda_j} = \phi_j
\end{eqn}
for the $\lambda_j$ coordinates, and
\begin{eqn}
0 = \od{}{t} \pd{L}{\dot q_i} - \pd{L}{q_i} - \sum_{k=1}^s \lambda_k \pd{\phi_k}{q_i}
\end{eqn}
for the $q_i$ coordinates, $i = 1, \dots, N$.

Counting, we have $N+s$ unknowns, with $N$ constrained EL equations and $s$ constraint equations, fully determining $q_i, \lambda_j$. From the EL equation, the gradient of $\phi_k$ looks like a force derived from potential $\phi_k$ with strength $\lambda_k$, which we can interpret as compensating for various normal forces arising on the constraint surfaces.

\subsubsection{Change coordinates}

In this method, we pick $N-s$ coordinates $\widetilde{q}_1, \dots, \widetilde{q}_{N-s}$ which parametrize the constrained surface, and make $\phi_1, \dots, \phi_s$ the remaining coordinates. Then our constraints are satisfied automatically by choice of coordinates, and we just have the usual EL equations on the constrained coordinates
\begin{eqn}
0 = \pd{L}{\widetilde{q}_m} - \od{}{t} \pd{L}{\widetilde{q}_m}.
\end{eqn}
This is best to use when the constraints are simple, but generally we need to rely on Lagrange multipliers.

\subsection{Simple example: Atwood machine}

In this example we have two masses $m_1$ and $m_2$ at either end of a string of length $\ell$ going over a pulley. The Lagrangian is given by
\begin{eqn}
L = \frac{1}{2} m_1 \dot x_1^2 + \frac{1}{2} m_2 \dot x_2^2 - m_1 g x_1 - m_2 g x_2
\end{eqn}
with constraint
\begin{eqn}
0 = \phi(x_1, x_2) = x_1 + x_2 - \ell.
\end{eqn}

First we will use Lagrange multipliers, so we have the new Lagrangian
\begin{align}
L' &= L + \lambda \phi \\
	&= \frac{1}{2} m_1 \dot x_1^2 + \frac{1}{2} m_2 \dot x_2^2 - m_1 g x_1 - m_2 g x_2 \\
	&\qquad + \lambda (x_1 + x_2 - \ell).
\end{align}
Then the constrained EL equations give us
\begin{gather}
0 = m_1 \ddot x_1 + m_1 g - \lambda \\
0 = m_2 \ddot x_2 + m_2 g - \lambda \\
0 = x_1 + x_2 - \ell.
\end{gather}
Then we know that $\dot x_1 = -\dot x_2$ so subtracting the equations of motion we have
\begin{eqn}
(m_1 + m_2) \ddot x_1 + (m_1 - m_2) g = 0,
\end{eqn}
or
\begin{eqn}
\ddot x_1 = - \frac{m_1 - m_2}{m_1 + m_2} g.
\end{eqn}
What about $\lambda$? Plugging back in our expression for $\ddot x_1$ we have
\begin{align}
\lambda &= m_1 \ddot x_1 + m_1 g \\
	&= - m_1 \frac{m_1 - m_2}{m_1 + m_2} g + m_1 g \\
	&= \frac{2 m_1 m_2}{m_1 + m_2} g,
\end{align}
which is just the string tension!

Next we can approach it directly using our second strategy of choosing new coordinates. Choosing
\begin{eqn}
\widetilde{x} = x_1 = L - x_2,
\end{eqn}
we have the Lagrangian in the single coordinate,
\begin{eqn}
L = \frac{1}{2} m_1 \dot x_1^2 + \frac{1}{2} m_2 \dot x_1^2 - m_1 g x_1 - m_2 g (L - x_1).
\end{eqn}
Then the EL equation gives us
\begin{eqn}
(m_1 + m_2) \ddot x_1 + (m_1 - m_2) g = 0
\end{eqn}
or, as before,
\begin{eqn}
\ddot x_1 = - \frac{m_1 - m_2}{m_1 + m_2} g.
\end{eqn}
So now we don't have to worry about $\lambda$, but we also don't get a direct way to calculate the string tension.

\subsection{Second example: Double pendulum}

Suppose we have a double pendulum with point mass $m_1$ a distance $\ell_1$ from a fixed point making angle $\varphi_1$ from the vertical, and another point mass $m_2$ a distance $\ell_2$ from $m_1$ making angle $\varphi_2$ from the vertical. We will use the angles $\varphi_1, \varphi_2$ as our generalized coordinates, making Cartesian coordinates
\begin{eqn}
x_1 = + \ell_1 \sin \varphi_1, \qquad
z_1 = - \ell_2 \cos \varphi_1
\end{eqn}
and
\begin{eqn}
x_2 = x_1 + \ell_2 \sin \varphi_2, \qquad
z_2 = z_1 - \ell_2 \cos \varphi_2.
\end{eqn}

The Lagrangian is then written
\begin{align}
L &= \frac{1}{2} m_1 (\dot x_1^2 + \dot z_1^2) + \frac{1}{2} m_2 (\dot x_2^2 + \dot z_2^2) - m_1 g z_1 - m_2 g z_2 \\
	&= \frac{1}{2} (m_1 + m_2) \ell_1^2 \dot \varphi_1^2 + \frac{1}{2} m_2 \ell_2^2 \dot \varphi_2^2 + \frac{1}{2} m_2 \ell_1 \ell_2 \dot \varphi_1 \dot \varphi_2 \cos (\varphi_1 - \varphi_2) \\
	&\qquad + (m_1 + m_2) g \ell_1 \cos \varphi_1 + m_2 \ell_2 g \cos \varphi_2,
\end{align}
which we can describe as almost being two distinct pendulums $(m_1+m_2,\varphi_1)$ and $(m_2, \varphi_2)$ but with an extra coupling between $\dot \varphi_1$ and $\dot \varphi_2$. We will not attempt to solve this now, but we will come back to it in our study of small oscillations.

\subsection{Third example: Bead on rotating rod}

Suppose we have a bead with mass $m$ constrained to move along a rod rotating with angular frequency $\omega$. Then the bead's Cartesian coordinates can be written
\begin{eqn}
x = d \sin \omega t, \qquad
y = d \cos \omega t
\end{eqn}
where $d$ is the radius from the axis of rotation. So the Lagrangian is given by
\begin{align}
L &= \frac{1}{2} m (\dot x^2 + \dot y^2) \\
	&= \frac{1}{2} m \left[ (\dot d \sin \omega t + \omega d \cos \omega t)^2 + (\dot d \cos \omega t - \omega d \sin \omega t)^2 \right] \\
	&= \frac{1}{2} m (\dot d^2 + \omega^2 d^2).
\end{align}
The EL equations give us a differential equation
\begin{eqn}
0 = \ddot d - \omega^2 d,
\end{eqn}
with solution
\begin{eqn}
d = d_0 \cosh \omega t.
\end{eqn}

\subsection{Holonomic vs non-holonomic constraints}

We know that the force $\v F_\phi$ a holonomic constraint $\phi$ imposes, i.e. the normal force, is orthogonal to the constraint surface. So for displacement $\delta \v x$ along the constraint surface, we have
\begin{eqn}
\v F_\phi \cdot \delta \v x = 0.
\end{eqn}
This is called \emph{D'Alambert's principle} and can be used as the starting point to ``derive'' the constrained Lagrangian formalism.

\subsection{Nonholonomic example: Rolling without slipping}

Sometimes nonholonomic constraints can be reduced to holonomic constraints. For example, consider a wheel with radius $R$ rolling without slipping. Denote the distance it rolls to the right by $x$ and the angle it rotates counterclockwise in the same distance by $\varphi$. Then we have
\begin{eqn}
\dot x = -R \dot \varphi.
\end{eqn}
This is a nonholonomic constraint, but it is also a total time differential
\begin{eqn}
\od{}{t} \left( x + R \varphi \right) = 0,
\end{eqn}
so that we can integrate the constraint to obtain a holonomic constraint
\begin{eqn}
x + R \varphi = x_0.
\end{eqn}

It is \emph{generally} not possible to integrate a nonholonomic constraint into a holonomic one. Consider the same wheel but now constrained to move along a circle in the $xy$-plane. Then the constraint becomes
\begin{eqn}
\dot x = R \dot \varphi \sin \theta, \qquad
\dot y = -R \dot \varphi \cos \theta.
\end{eqn}
If $\theta$ is constant, i.e. the wheel is not moving, then we could integrate but in general these constraints are not integrable. However, this case can still be treated since the constraints are linear in the velocities,
\begin{eqn}
\phi_k (q_i, \dot q_i, t) = \sum_j \psi_j^{(k)} (q_i) \, \dot q_j.
\end{eqn}
If the $\v \psi^{(k)}$s are gradients in $q_i$, i.e.
\begin{eqn}
\psi_j^{(k)} = \pd{\Omega^{(k)}}{q_j}
\end{eqn}
for some functions $\Omega^{(k)} (q_i)$, then we have
\begin{eqn}
\phi_k = \od{}{t} \Omega^{(k)}.
\end{eqn}
Thus we can define another Lagrangian
\begin{eqn}
L \to L' = L - \sum_k \lambda_k \Omega^{(k)},
\end{eqn}
which has EL equations similar to the holonomic case,
\begin{eqn}
0 = \od{}{t} \pd{L}{\dot q_i} - \pd{L}{q_i} - \sum_k \lambda_k \underbrace{\pd{\Omega^{(k)}}{q_i}}_{\psi_i^{(k)}}.
\end{eqn}
This is still valid even if $\psi$ is not itself a total differential!

\end{document}


\documentclass[11pt]{article}
\usepackage[margin=2cm]{geometry}
% amssymb load amsfonts
\usepackage{fancyvrb,amsmath,amssymb,graphicx}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{tikz}

\title{Eigenmath Manual}
\author{}
\date{November 15, 2020}

\begin{document}

\maketitle

\tableofcontents

\newpage

\input{nabokov}

\input{syntax}

\subsection{Testing for equality}
The infix operator \verb$==$ is used to test for equality of operands.
The operator evaluates to 1 if the operands are equal and 0 if the operands are not equal.

\begin{Verbatim}[formatcom=\color{blue}]
exp(i pi) == -1
\end{Verbatim}

\noindent
1

\newpage

\input{arithmetic}

\input{exponents}

\input{symbols}

\input{scripting}

\input{draw}

\input{complex}

\input{linear-algebra}

\input{derivative}

\input{integrals}

\input{integral-trick}

\input{fund-thm-of-calculus}

\input{line-integral}

\input{surface-area}

\input{surface-integral}

\input{greens-theorem}

\input{stokes-theorem}

\newpage

\input{help}

\newpage

\input{tricks}

\end{document}


\documentclass{article}
\usepackage{fullpage}
\usepackage{nopageno}
\usepackage{amsmath}
\allowdisplaybreaks

\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}

\begin{document}
\title{Notes}
\date{February 7, 2014}
\maketitle
\section*{homework}
due next friday 14 feb
\subsection*{lesson 7 number 1}
\subsubsection*{hw 10}
find general series solution for PDE and BC's.
\subsubsection*{hw 11}
solve the IC. Explain how orthogonality is used.
\subsection*{number 3}
\subsubsection*{hw 12}
find general series solution for PDE and BC's.
\subsubsection*{hw 13}
solve the IC. note questions about steady-state behavior.
\subsection*{lesson 9 number 4}
\subsubsection*{hw 14}
find the general series solution for PDE and BC's.
\subsubsection*{hw 15}
show the eigen functions are orthogonal and solve the IC.
\section*{lesson 9}
\begin{align*}
  &PDE&u_t&=\alpha^2u_{xx}+f(x,t),& 0<x<1,&0<t<\infty\\
  &BC's&0&=\alpha_1u_x(0,t)+\beta_1u(0,t),&&0<t<\infty\\
  &&0&=\alpha_2u_x(1,t)+\beta_2u(1,t),&&0<t<\infty\\
  &IC&u(x,0)&=\phi(x),&0<x<1\\
  &PDE&u_t=\alpha^2u_{xx}\to &u=T(t)X(x)\\
  &&&\frac{T'(t)}{\alpha^2T(t)}=\frac{X''(x)}{X(x)}\\
  &&&\text{separation constant}=-\lambda\\
  &&&\text{assume const $\leq$0}\\
  u&=e^{-\alpha^2\lambda t}X(x)\\
  0&=X''(x)+\lambda^2X(x)\\
  &=\alpha_1X'(0)+\beta_1X(x)\\
  &=\alpha_2X'(1)+\beta_2X(1)
\end{align*}
special case of sturm-louisville theorem (sp?)

\subsection*{results}
there are nontrivial solutions $X_n(x)$ for a sequence of values $\lambda=\lambda_n$
\[\lambda_1<\lambda_2<\lambda_3 \text{ and } \lambda_n\to\infty\]
for \[\lambda_m\neq\lambda_n,\int_0^1{X_m(x)X_n(x)\,\mathrm{d}x}=0\text{ (orthagonality)}\]

we have $u(x,t)=\sum\limits_{n=1}^\infty{c_ne^{-\alpha^2\lambda_n t}X_n(x)}$

How do we find $c_n$ in $u(x,t)=\sum\limits_{n=1}^\infty{c_ne^{-\alpha^2\lambda_n t}X_n(x)}$? because the original pde is linear, the sum of the solutions is a solution. similarly for the boundary conditions. Use orthogonality of $X_n(x)$'s and the initial condition $u(x,0)=\phi(x)$.

What about $u_t=\alpha^2u_{xx}+f(x,t)$? Try solutions $u=\sum\limits_{n=1}^\infty{u_n(t)X_n(x)}$. write $f(x,t)=\sum\limits_{n=1}^\infty{f(n(t)X_n(x)}$. In the PDE: $\sum\limits_{n=1}^\infty{{u_n}'(t)X_n(x)=\alpha^2\sum\limits_{n=1}^\infty{u_n(t){X_n}''(x)}}+\sum\limits_{n=1}^\infty{f_n(t)X_n(x)}$

Now ${x_n}''(x)=-\lambda_nX_n(x)$

For each $n$:
\[{u_n}'(t)=-\alpha^2\lambda_nu_n(t)+f_n(t)\]

\subsubsection*{note}
\[f_n(t)\int_0^1{(X_n(x))^2\,\mathrm{d}x}=\int_0^1{f(x,t)X_n(x)\,\mathrm{d}x}\]

since $f_n(t)$ is known we have
\[({u_n}'+\alpha^2\lambda_nu_n=f_n(t))e^{\alpha^2\lambda_nt}\frac{\mathrm{d}}{\mathrm{d}t}\left(e^{\alpha^2\lambda_nt}u_n(t)\right)=e^{\alpha^2\lambda_nt}f_n(t)\]
\[\to e^{\alpha^2\lambda_nt}u_n(t)-u_n(0)=\int_0^t{e^{\alpha^2\lambda_n u}f_n(u)\,\mathrm{d}u}\]
\[\to u_n(t)=u_n(0)e^{-\alpha^2\lambda_nt}+\int_0^t{e^{-\alpha^2\lambda_n(t-u)}f_n(u)\,\mathrm{d}u}\]
\subsubsection*{note}
initial condition is $\sum\limits_{n=1}^\infty{u_n(0)X_n(x)}=\phi(x)$
\end{document}


\documentclass[]{article}
\usepackage{amsmath}

%opening
\title{MTH 343 Numerical Analysis Lecture 9}
\author{Sheikh Abdul Raheem Ali}

\begin{document}

\maketitle

\section*{Müller's Method}

Based on approximating the function in the neighborhood of the root by a quadratic polynomial.

\section*{Technique}

A \underline{2nd} degree polynomial is made to fit 3 points near a root, $ (x_0, f(x_0)) $; $ (x_1, f(x_1)) $ \& $ (x_2, f(x_2)) $ \& the zero of the polynomial is found using the quadratic formula.

\end{document}


\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{float}
\usepackage{amsmath}
\usepackage{graphicx}

\usepackage[hmargin=3cm,vmargin=6.0cm]{geometry}
%\topmargin=0cm
\topmargin=-2cm
\addtolength{\textheight}{6.5cm}
\addtolength{\textwidth}{2.0cm}
%\setlength{\leftmargin}{-5cm}
\setlength{\oddsidemargin}{0.0cm}
\setlength{\evensidemargin}{0.0cm}

%misc libraries goes here
%\usepackage{fitch}

\begin{document}

\section*{Student Information }
%Write your full name and id number between the colon and newline
%Put one empty space character after colon and before newline
Full Name : Zeynep Özalp \\
Id Number : 2237691 \\

\section*{I}
\subsection*{a.}
Variables = \{CENG111, CENG213, CENG223, CENG315, CENG331, CENG351\} \\

Domain(var) = \{10930, 11330, 20930, 21330, 31330, 31630\} for all var in Variables. First digit encodes the classroom (e.g. 1 represents BMB1), the last for digit encodes the time (e.g. 0930 represents 09:30). Thus, 10930 means BMB1 at 09:30 a.m. \\

First of all, all variables must have different values i.e. no pair have the same values. Then, as you suggested, I will define a set of assignable pairs (SAP).\\
SAP = \{ \\
		(10930, 11330),
		(10930, 21330),
		(10930, 31330),
		(10930, 31630), \\
		(11330, 10930),
		(11330, 20930),
		(11330, 31630), \\
		(20930, 11330),
		(20930, 21330),
		(20930, 31330),
		(20930, 31630), \\
		(21330, 10930),
		(21330, 20930),
		(21330, 31630), \\
		(31330, 10930),
		(31330, 20930),
		(31330, 31630), \\
		(31630, 10930),
		(31630, 11330),
		(31630, 20930),
		(31630, 21330),
		(31630, 31330)\}\\

Pairs = \{(CENG213, CENG223), (CENG315, CENG331), (CENG315, CENG351), (CENG331, CENG351)\}\\

For all pairs in the set Pairs, the only possible assignments are in the SAT set. So, the constraint is that all pairs in Pairs must have the pair of values that is in SAP.
\subsection*{b.}
In the following tables, first column shows the assignment in each step and other show the set of legal values for that course. For simplicity, I have used the set All =\{10930, 11330, 20930, 21330, 31330, 31630\}. After the third assignment, there is no legal value for CENG315 course, so backtrack by forward checking.

\begin{table}[H]
\small
\centering
\label{table:example}
\scalebox{0.7}{
\begin{tabular}
{|c|c|c|c|c|c|c|}	%% specify column number and vertical lines
\hline 							%% line draw
\textbf{Assignment:} & \textbf{CENG111} & \textbf{CENG213} & \textbf{CENG223} & \textbf{CENG315} & \textbf{CENG331} & \textbf{CENG351}\\
\hline
1. CENG351 = 10930 & All - \{10930\} & All - \{10930\} & All - \{10930\} & All - \{10930, 20930\} & All - \{10930, 20930\} & \textbf{10930} \\
2. CENG331 = 11330 & All - \{10930, 11330\} & All - \{10930, 11330\} & All - \{10930, 11330\} & \{31630\} & \textbf{11330} & \textbf{10930} \\
3. CENG213 = 31630 & \{20930, 21330, 31330\} & \textbf{31630} & \{20930, 21330, 31330\} & \{\} & \textbf{11330} & \textbf{10930} \\
4. CENG315 = 31630 & \{20930, 21330, 31330\} & \{20930, 21330, 31330\}  & \{20930, 21330, 31330\} & \textbf{31630} & \textbf{11330} & \textbf{10930} \\
5. CENG213 = 20930 & \{21330, 31330\} & \textbf{20930}  & \{21330, 31330\} & \textbf{31630} & \textbf{11330} & \textbf{10930} \\
6. CENG223 = 21330 & \{31330\} & \textbf{20930}  & \textbf{21330} & \textbf{31630} & \textbf{11330} & \textbf{10930} \\
7. CENG111 = 31330 & \textbf{31330} & \textbf{20930}  & \textbf{21330} & \textbf{31630} & \textbf{11330} & \textbf{10930} \\
\hline
\end{tabular}}
\end{table}
\subsection*{c.}
After second assignment, value 31630 is deleted from CENG111, CENG213 and CENG223's domains because 31630 is the only legal value for CENG315. Another example is, after third assignment, the value 20930 is deleted from CENG111's domain because 20930 is the legal value for CENG223. There is no need to backtrack in these assignments.
\begin{table}[H]
\small
\centering
\label{table:example}
\scalebox{0.7}{
\begin{tabular}
{|c|c|c|c|c|c|c|}	%% specify column number and vertical lines
\hline 							%% line draw
\textbf{Assignment:} & \textbf{CENG111} & \textbf{CENG213} & \textbf{CENG223} & \textbf{CENG315} & \textbf{CENG331} & \textbf{CENG351}\\
\hline
1. CENG351 = 10930 & All - \{10930\} & All - \{10930\} & All - \{10930\} & All - \{10930, 20930\} & All - \{10930, 20930\} & \textbf{10930} \\
2. CENG331 = 11330 & \{20930,21330,31330\} & \{20930,21330,31330\} & \{20930,21330, 31330\} & \{31630\} & \textbf{11330} & \textbf{10930} \\
3. CENG213 = 21330 & \{31330\} & \textbf{21330} & \{20930\} & \{31630\} & \textbf{11330} & \textbf{10930} \\
4. CENG315 = 21330 & \{31330\} & \textbf{21330} & \{20930\} & \textbf{31630} & \textbf{11330} & \textbf{10930} \\
5. CENG223 = 20930 & \{31330\} & \textbf{21330} & \textbf{20930} & \textbf{31630} & \textbf{11330} & \textbf{10930} \\
6. CENG111 = 31330 & \textbf{31330} & \textbf{21330} & \textbf{21330} & \textbf{31630} & \textbf{11330} & \textbf{10930} \\
\hline
\end{tabular}}
\end{table}

\section*{II}
\begin{table}[H]
\small
\centering
\label{table:example}
\begin{tabular}
{|c|c|c|c|}	%% specify column number and vertical lines
\hline 							%% line draw
\textbf{Node} & \textbf{$v$} & \textbf{$\alpha$} & \textbf{$\beta$}\\
\hline
D & 5 & 5 & $\infty$ \\
E & 6 & $-\infty$ & 5 \\
B & 5 & $-\infty$ & 5 \\
F & 2 & 5 & $\infty$ \\
C & 2 & 5 & 5 \\
A & 5 & 5 & $\infty$ \\
\hline
\end{tabular}
\end{table}
The right child of E (node 10) and the right sub-tree of C (nodes G, 1, 0) is pruned. Pay attention to the alpha value of E node! According to alpha-beta search algorithm in p.170 in our textbook, the value v is returned (because v is greater than beta!) before the assignment of alpha value! Thus, our alpha value will be unchanged, it will still be $-\infty$.

\section*{III}
\subsection*{a.}
I have followed the representation on p.44-51 in our lecture slides.
\begin{table}[H]
\small
\centering
\label{table:example}
\begin{tabular}
{|c|c|c|}	%% specify column number and vertical lines
\hline 							%% line draw
\textbf{clause} & \textbf{count(clause)} & \textbf{Agenda}\\
\hline
$I \wedge J \Rightarrow K$ & 2 &\\
$G \wedge H \Rightarrow I$ & 2 &\\
$H \wedge D \Rightarrow J$ & 2 &\\
$E \wedge H \Rightarrow G$ & 2 &\\
$E \wedge F \Rightarrow H$ & 2 &\\
$G \wedge A \Rightarrow E$ & 2 &\\
$A \wedge B \Rightarrow E$ & 2 &\\
$B \wedge C \Rightarrow F$ & 2 & \{A,B,C,D\}\\
\hline
$I \wedge J \Rightarrow K$ & 2 &\\
$G \wedge H \Rightarrow I$ & 2 &\\
$H \wedge D \Rightarrow J$ & 2 &\\
$E \wedge H \Rightarrow G$ & 2 &\\
$E \wedge F \Rightarrow H$ & 2 &\\
$G \wedge A \Rightarrow E$ & 1 &\\
$A \wedge B \Rightarrow E$ & 1 &\\
$B \wedge C \Rightarrow F$ & 2 & \{B,C,D\}\\
\hline
$I \wedge J \Rightarrow K$ & 2 &\\
$G \wedge H \Rightarrow I$ & 2 &\\
$H \wedge D \Rightarrow J$ & 2 &\\
$E \wedge H \Rightarrow G$ & 2 &\\
$E \wedge F \Rightarrow H$ & 2 &\\
$G \wedge A \Rightarrow E$ & 1 &\\
$A \wedge B \Rightarrow E$ & 0 &\\
$B \wedge C \Rightarrow F$ & 1 & \{C,D,E\}\\
\hline
$I \wedge J \Rightarrow K$ & 2 &\\
$G \wedge H \Rightarrow I$ & 2 &\\
$H \wedge D \Rightarrow J$ & 2 &\\
$E \wedge H \Rightarrow G$ & 2 &\\
$E \wedge F \Rightarrow H$ & 2 &\\
$G \wedge A \Rightarrow E$ & 1 &\\
$A \wedge B \Rightarrow E$ & 0 &\\
$B \wedge C \Rightarrow F$ & 0 & \{D,E,F\}\\
\hline
$I \wedge J \Rightarrow K$ & 2 &\\
$G \wedge H \Rightarrow I$ & 2 &\\
$H \wedge D \Rightarrow J$ & 1 &\\
$E \wedge H \Rightarrow G$ & 2 &\\
$E \wedge F \Rightarrow H$ & 2 &\\
$G \wedge A \Rightarrow E$ & 1 &\\
$A \wedge B \Rightarrow E$ & 0 &\\
$B \wedge C \Rightarrow F$ & 0 & \{E,F\}\\
\hline
\end{tabular}
\end{table}

\begin{table}[H]
\small
\centering
\label{table:example}
\begin{tabular}
{|c|c|c|}	%% specify column number and vertical lines
\hline 							%% line draw
\textbf{clause} & \textbf{count(clause)} & \textbf{Agenda}\\
\hline
$I \wedge J \Rightarrow K$ & 2 &\\
$G \wedge H \Rightarrow I$ & 2 &\\
$H \wedge D \Rightarrow J$ & 1 &\\
$E \wedge H \Rightarrow G$ & 1 &\\
$E \wedge F \Rightarrow H$ & 1 &\\
$G \wedge A \Rightarrow E$ & 1 &\\
$A \wedge B \Rightarrow E$ & 0 &\\
$B \wedge C \Rightarrow F$ & 0 & \{F\}\\
\hline
$I \wedge J \Rightarrow K$ & 2 &\\
$G \wedge H \Rightarrow I$ & 2 &\\
$H \wedge D \Rightarrow J$ & 1 &\\
$E \wedge H \Rightarrow G$ & 1 &\\
$E \wedge F \Rightarrow H$ & 0 &\\
$G \wedge A \Rightarrow E$ & 1 &\\
$A \wedge B \Rightarrow E$ & 0 &\\
$B \wedge C \Rightarrow F$ & 0 & \{H\}\\
\hline
$I \wedge J \Rightarrow K$ & 2 &\\
$G \wedge H \Rightarrow I$ & 1 &\\
$H \wedge D \Rightarrow J$ & 0 &\\
$E \wedge H \Rightarrow G$ & 0 &\\
$E \wedge F \Rightarrow H$ & 0 &\\
$G \wedge A \Rightarrow E$ & 1 &\\
$A \wedge B \Rightarrow E$ & 0 &\\
$B \wedge C \Rightarrow F$ & 0 & \{J,G\}\\
\hline
$I \wedge J \Rightarrow K$ & 2 &\\
$G \wedge H \Rightarrow I$ & 0 &\\
$H \wedge D \Rightarrow J$ & 0 &\\
$E \wedge H \Rightarrow G$ & 0 &\\
$E \wedge F \Rightarrow H$ & 0 &\\
$G \wedge A \Rightarrow E$ & 0 &\\
$A \wedge B \Rightarrow E$ & 0 &\\
$B \wedge C \Rightarrow F$ & 0 & \{J,I\}\\
\hline
$I \wedge J \Rightarrow K$ & 1 &\\
$G \wedge H \Rightarrow I$ & 0 &\\
$H \wedge D \Rightarrow J$ & 0 &\\
$E \wedge H \Rightarrow G$ & 0 &\\
$E \wedge F \Rightarrow H$ & 0 &\\
$G \wedge A \Rightarrow E$ & 0 &\\
$A \wedge B \Rightarrow E$ & 0 &\\
$B \wedge C \Rightarrow F$ & 0 & \{J\}\\
\hline
\end{tabular}
\end{table}

\begin{table}[H]
\small
\centering
\label{table:example}
\begin{tabular}
{|c|c|c|}	%% specify column number and vertical lines
\hline 							%% line draw
\textbf{clause} & \textbf{count(clause)} & \textbf{Agenda}\\
\hline
$I \wedge J \Rightarrow K$ & 0 &\\
$G \wedge H \Rightarrow I$ & 0 &\\
$H \wedge D \Rightarrow J$ & 0 &\\
$E \wedge H \Rightarrow G$ & 0 &\\
$E \wedge F \Rightarrow H$ & 0 &\\
$G \wedge A \Rightarrow E$ & 0 &\\
$A \wedge B \Rightarrow E$ & 0 &\\
$B \wedge C \Rightarrow F$ & 0 & \{K\}\\
\hline
$I \wedge J \Rightarrow K$ & 0 &\\
$G \wedge H \Rightarrow I$ & 0 &\\
$H \wedge D \Rightarrow J$ & 0 &\\
$E \wedge H \Rightarrow G$ & 0 &\\
$E \wedge F \Rightarrow H$ & 0 &\\
$G \wedge A \Rightarrow E$ & 0 &\\
$A \wedge B \Rightarrow E$ & 0 &\\
$B \wedge C \Rightarrow F$ & 0 & \{\}\\
\hline
\end{tabular}
\end{table}

\subsection*{b.}
I have followed the representation on p.54-64 in our lecture slides.
\begin{table}[H]
\small
\centering
\label{table:example}
\begin{tabular}
{|c|c|c|}	%% specify column number and vertical lines
\hline 							%% line draw
\textbf{clause} & \textbf{Check?} & \textbf{Explored}\\
\hline
$I \wedge J \Rightarrow K$ & No &\\
$G \wedge H \Rightarrow I$ & No &\\
$H \wedge D \Rightarrow J$ & No &\\
$E \wedge H \Rightarrow G$ & No &\\
$E \wedge F \Rightarrow H$ & No &\\
$G \wedge A \Rightarrow E$ & No &\\
$A \wedge B \Rightarrow E$ & No &\\
$B \wedge C \Rightarrow F$ & No &\{\}\\
\hline
$I \wedge J \Rightarrow K$ & No &\\
$G \wedge H \Rightarrow I$ & No &\\
$H \wedge D \Rightarrow J$ & No &\\
$E \wedge H \Rightarrow G$ & No &\\
$E \wedge F \Rightarrow H$ & No &\\
$G \wedge A \Rightarrow E$ & No &\\
$A \wedge B \Rightarrow E$ & No &\\
$B \wedge C \Rightarrow F$ & No & \{K\}\\
\hline
$I \wedge J \Rightarrow K$ & No &\\
$G \wedge H \Rightarrow I$ & No &\\
$H \wedge D \Rightarrow J$ & No &\\
$E \wedge H \Rightarrow G$ & No &\\
$E \wedge F \Rightarrow H$ & No &\\
$G \wedge A \Rightarrow E$ & No &\\
$A \wedge B \Rightarrow E$ & No &\\
$B \wedge C \Rightarrow F$ & No & \{K,I\}\\
\hline
$I \wedge J \Rightarrow K$ & No &\\
$G \wedge H \Rightarrow I$ & No &\\
$H \wedge D \Rightarrow J$ & No &\\
$E \wedge H \Rightarrow G$ & No &\\
$E \wedge F \Rightarrow H$ & No &\\
$G \wedge A \Rightarrow E$ & No &\\
$A \wedge B \Rightarrow E$ & No &\\
$B \wedge C \Rightarrow F$ & No & \{K,I,G\}\\
\hline
$I \wedge J \Rightarrow K$ & No &\\
$G \wedge H \Rightarrow I$ & No &\\
$H \wedge D \Rightarrow J$ & No &\\
$E \wedge H \Rightarrow G$ & No &\\
$E \wedge F \Rightarrow H$ & No &\\
$G \wedge A \Rightarrow E$ & No &\\
$A \wedge B \Rightarrow E$ & No &\\
$B \wedge C \Rightarrow F$ & No & \{K,I,G,E\}\\
\hline
\end{tabular}
\end{table}

\begin{table}[H]
\small
\centering
\label{table:example}
\begin{tabular}
{|c|c|c|}	%% specify column number and vertical lines
\hline 							%% line draw
\textbf{clause} & \textbf{Check?} & \textbf{Explored}\\
\hline
$I \wedge J \Rightarrow K$ & No &\\
$G \wedge H \Rightarrow I$ & No &\\
$H \wedge D \Rightarrow J$ & No &\\
$E \wedge H \Rightarrow G$ & No &\\
$E \wedge F \Rightarrow H$ & No &\\
$G \wedge A \Rightarrow E$ & No &\\
$A \wedge B \Rightarrow E$ & No &\\
$B \wedge C \Rightarrow F$ & No & \{K,I,G,E,A\}\\
\hline
$I \wedge J \Rightarrow K$ & No &\\
$G \wedge H \Rightarrow I$ & No &\\
$H \wedge D \Rightarrow J$ & No &\\
$E \wedge H \Rightarrow G$ & No &\\
$E \wedge F \Rightarrow H$ & No &\\
$G \wedge A \Rightarrow E$ & No &\\
$A \wedge B \Rightarrow E$ & No &\\
$B \wedge C \Rightarrow F$ & No & \{K,I,G,E,A,H\}\\
\hline
$I \wedge J \Rightarrow K$ & No &\\
$G \wedge H \Rightarrow I$ & No &\\
$H \wedge D \Rightarrow J$ & No &\\
$E \wedge H \Rightarrow G$ & No &\\
$E \wedge F \Rightarrow H$ & No &\\
$G \wedge A \Rightarrow E$ & No &\\
$A \wedge B \Rightarrow E$ & No &\\
$B \wedge C \Rightarrow F$ & No & \{K,I,G,E,A,H,F\}\\
\hline
$I \wedge J \Rightarrow K$ & No &\\
$G \wedge H \Rightarrow I$ & No &\\
$H \wedge D \Rightarrow J$ & No &\\
$E \wedge H \Rightarrow G$ & No &\\
$E \wedge F \Rightarrow H$ & No &\\
$G \wedge A \Rightarrow E$ & No &\\
$A \wedge B \Rightarrow E$ & No &\\
$B \wedge C \Rightarrow F$ & No & \{K,I,G,E,A,H,F,B,C\}\\
\hline
$I \wedge J \Rightarrow K$ & No &\\
$G \wedge H \Rightarrow I$ & No &\\
$H \wedge D \Rightarrow J$ & No &\\
$E \wedge H \Rightarrow G$ & No &\\
$E \wedge F \Rightarrow H$ & No &\\
$G \wedge A \Rightarrow E$ & No &\\
$A \wedge B \Rightarrow E$ & No &\\
$B \wedge C \Rightarrow F$ & No & \{K,I,G,E,A,H,F,B,C\}\\
\hline
\end{tabular}
\end{table}

\begin{table}[H]
\small
\centering
\label{table:example}
\begin{tabular}
{|c|c|c|}	%% specify column number and vertical lines
\hline 							%% line draw
\textbf{clause} & \textbf{Check?} & \textbf{Closed}\\
\hline
$I \wedge J \Rightarrow K$ & No &\\
$G \wedge H \Rightarrow I$ & No &\\
$H \wedge D \Rightarrow J$ & No &\\
$E \wedge H \Rightarrow G$ & No &\\
$E \wedge F \Rightarrow H$ & No &\\
$G \wedge A \Rightarrow E$ & No &\\
$A \wedge B \Rightarrow E$ & Yes &\\
$B \wedge C \Rightarrow F$ & No & \{A,B\}\\
\hline
$I \wedge J \Rightarrow K$ & No &\\
$G \wedge H \Rightarrow I$ & No &\\
$H \wedge D \Rightarrow J$ & No &\\
$E \wedge H \Rightarrow G$ & No &\\
$E \wedge F \Rightarrow H$ & No &\\
$G \wedge A \Rightarrow E$ & No &\\
$A \wedge B \Rightarrow E$ & Yes &\\
$B \wedge C \Rightarrow F$ & Yes & \{A,B,C\}\\
\hline
$I \wedge J \Rightarrow K$ & No &\\
$G \wedge H \Rightarrow I$ & No &\\
$H \wedge D \Rightarrow J$ & No &\\
$E \wedge H \Rightarrow G$ & No &\\
$E \wedge F \Rightarrow H$ & Yes &\\
$G \wedge A \Rightarrow E$ & No &\\
$A \wedge B \Rightarrow E$ & Yes &\\
$B \wedge C \Rightarrow F$ & Yes & \{A,B,C,E,F\}\\
\hline
$I \wedge J \Rightarrow K$ & No &\\
$G \wedge H \Rightarrow I$ & No &\\
$H \wedge D \Rightarrow J$ & No &\\
$E \wedge H \Rightarrow G$ & Yes &\\
$E \wedge F \Rightarrow H$ & Yes &\\
$G \wedge A \Rightarrow E$ & No &\\
$A \wedge B \Rightarrow E$ & Yes &\\
$B \wedge C \Rightarrow F$ & Yes & \{A,B,C,E,F,H\}\\
\hline
$I \wedge J \Rightarrow K$ & No &\\
$G \wedge H \Rightarrow I$ & Yes &\\
$H \wedge D \Rightarrow J$ & No &\\
$E \wedge H \Rightarrow G$ & Yes &\\
$E \wedge F \Rightarrow H$ & Yes &\\
$G \wedge A \Rightarrow E$ & No &\\
$A \wedge B \Rightarrow E$ & Yes &\\
$B \wedge C \Rightarrow F$ & Yes & \{A,B,C,E,F,H,G\}\\
\hline
\end{tabular}
\end{table}
\begin{table}[H]
\small
\centering
\label{table:example}
\begin{tabular}
{|c|c|c|}	%% specify column number and vertical lines
\hline 							%% line draw
\textbf{clause} & \textbf{Check?} & \textbf{Closed}\\
\hline
$I \wedge J \Rightarrow K$ & No &\\
$G \wedge H \Rightarrow I$ & Yes &\\
$H \wedge D \Rightarrow J$ & No &\\
$E \wedge H \Rightarrow G$ & Yes &\\
$E \wedge F \Rightarrow H$ & Yes &\\
$G \wedge A \Rightarrow E$ & No &\\
$A \wedge B \Rightarrow E$ & Yes &\\
$B \wedge C \Rightarrow F$ & Yes & \{A,B,C,E,F,H,G,I\}\\
\hline
$I \wedge J \Rightarrow K$ & Yes &\\
$G \wedge H \Rightarrow I$ & Yes &\\
$H \wedge D \Rightarrow J$ & No &\\
$E \wedge H \Rightarrow G$ & Yes &\\
$E \wedge F \Rightarrow H$ & Yes &\\
$G \wedge A \Rightarrow E$ & No &\\
$A \wedge B \Rightarrow E$ & Yes &\\
$B \wedge C \Rightarrow F$ & Yes & \{A,B,C,E,F,H,G,I,K\}\\
\hline
\end{tabular}
\end{table}
\end{document}


\documentclass{book}

\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{hyperref}
\usepackage{ifthen}
\usepackage{makeidx}
\usepackage{mathrsfs}
\usepackage{shorttoc}

\renewcommand{\indexname}{General Index}
\makeindex

\usepackage[T1]{fontenc}
% \usepackage{lmodern}
% \usepackage{mathpazo}
\usepackage{courier}
% \usepackage{cmbright}
% \usepackage{ccfonts}
% \usepackage{fouriernc}

\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{titlesec}

\renewcommand{\partmark}[1]{ \markboth{#1}{} }

\fancyhf{}
\fancyhead[CE]{ \nouppercase{\leftmark} }
\fancyhead[CO]{ \nouppercase{\rightmark}}

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

% Use (A),(B),... for equations, not (1),(2),...
\numberwithin{equation}{subsection}
\renewcommand{\theequation}{\Alph{equation}}

\newcommand{\half}{ \frac{1}{2} }

\newcommand{\eps}{\epsilon}

%%%% Document Sectioning %%%%
% [Shorted title for Contents]{Chapter #}{Section #}{Title}
\newcommand{\Section}[4][]{%
  \ifthenelse{\equal{#1}{}}{ % Use chapter title in Contents
    \section*{\centering\normalfont #4}
    }{ % Use shortened title in Contents
      \section*[#1]{\centering\normalfont #4}
    }}
\newcommand{\Subsection}[4]{\subsection*{\centering\normalfont #4}}
\newcommand{\Subsubsection}[5]{\subsubsection*{\centering\normalfont #5}}

%%%% Named Operators %%%%
\DeclareMathOperator{\ArcCos}{arc\,cos}
\DeclareMathOperator{\ArcCosec}{arc\,cosec}
\DeclareMathOperator{\ArcCot}{arc\,cot}
\DeclareMathOperator{\ArcSec}{arc\,sec}
\DeclareMathOperator{\ArcSin}{arc\,sin}
\DeclareMathOperator{\ArcTan}{arc\,tan}
\DeclareMathOperator{\cosec}{cosec}
\DeclareMathOperator{\sech}{sech}
\DeclareMathOperator{\cosech}{cosech}

\DeclareMathOperator{\argcosh}{arg\,cosh}
\DeclareMathOperator{\argcoth}{arg\,coth}
\DeclareMathOperator{\argsinh}{arg\,sinh}
\DeclareMathOperator{\argtanh}{arg\,tanh}

\newcommand{\arccosec}{\ArcCosec}
\newcommand{\arccot}{\ArcCot}
\newcommand{\arcsec}{\ArcSec}

\renewcommand{\arccos}{\ArcCos}
\renewcommand{\arcsin}{\ArcSin}
\renewcommand{\arctan}{\ArcTan}

\DeclareMathOperator{\Cis}{Cis}
\DeclareMathOperator{\Log}{Log}
\DeclareMathOperator{\sgn}{\textit{sgn}\,}
\DeclareMathOperator{\am}{am}

\DeclareMathOperator{\Real}{\mathbf{R}}
\DeclareMathOperator{\Imag}{\mathbf{I}}
\renewcommand{\Re}{\Real}
\renewcommand{\Im}{\Imag}

\newcommand{\hardY}{\mathsf{Y}} %TODO:improve %17.6

\newcommand{\absval}[1]{\left| #1 \right|}
\newcommand{\thebrace}[1]{\left\{ #1 \right\} }
\newcommand{\thebracket}[1]{\left[ #1 \right] }
\newcommand{\theparen}[1]{\left( #1 \right) }

\newcommand{\wandwsectionsymbol}{\S}
\newcommand{\wandwsubsectionsymbol}{\ensuremath{\cdot}}
\newcommand{\hardchapterref}[1]{\wandwsectionsymbol #1}
\newcommand{\hardsectionref}[2]{\wandwsectionsymbol #1\wandwsubsectionsymbol#2}
\newcommand{\hardsubsectionref}[3]{\wandwsectionsymbol #1\wandwsubsectionsymbol#2#3}
\newcommand{\hardsubsubsectionref}[4]{\wandwsectionsymbol
#1\wandwsubsectionsymbol#2#3#4}

\newcommand{\miscexamples}{\textsc{Miscellaneous Examples}}

% Add W&W-style end-of-line example citations
%\newcommand{\addexamplecitation}[1]{\hfill (\textrm{#1 TODO})}
\newcommand{\addexamplecitation}[1]{%
  \pagebreak[0]%
  \hfil\allowbreak\null\nobreak\hfill\nobreak\mbox{(#1)}%
  \pagebreak[1]%
}

\newcommand{\ie}{\emph{i.e.}}
\newcommand{\bigo}{O}
\newcommand{\dd}{\mathbf{d}}
\newcommand{\dmeasure}{\, \dd}
\newcommand{\littleo}{o}
\newcommand{\binomialcoeff}[2]{ \binom{#1}{#2} }

\newcommand{\corollary}{Corollary}

\theoremstyle{remark}
\newtheorem{wandwexample}{Example}
% \numberwithin{wandwexample}{subsubsection}

%\newenvironment{wandwmiscexamples}{\miscexamples\begin{enumerate}}{\end{enumerate}}
\newenvironment{wandwmiscexamples}{\begin{enumerate}}{\end{enumerate}}
\newenvironment{wandwmiscexample}{\item}{ }

\newcommand{\wandwtypo}[2]{#2} %\wandwtypo{orig}{fix}

% Chapter 17 (Bessel functions)
\newcommand{\besselFont}[1]{\mathscr{#1}}
\newcommand{\besI}{\besselFont{I}}
\newcommand{\besJ}{\besselFont{J}}
\newcommand{\besK}{\besselFont{K}}
\newcommand{\besY}{\besselFont{Y}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Names
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\Bernoulli}{Bernoulli}
\newcommand{\Burmann}{B\"urmann}
\newcommand{\Dirichlet}{Dirichlet}
\newcommand{\Fejer}{Fej\'er}
\newcommand{\Jezek}{Je\v{z}ek}
\newcommand{\Lame}{Lam\'e}
\newcommand{\Poincare}{Poincar\'e}
\newcommand{\Schlafli}{Schl\"afli}
\newcommand{\Schlomilch}{Schl\"omilch}
\newcommand{\Teixeira}{Teixeira}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Begin document
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\input{wandw-frontmatter.tex}
%\shorttoc{Contents}{0}
\tableofcontents
\part{The Processes of Analysis}
\input{wandw-ch01.tex}
\input{wandw-ch02.tex}
\input{wandw-ch03.tex}
\input{wandw-ch04.tex}
\input{wandw-ch05.tex}
\input{wandw-ch06.tex}
\input{wandw-ch07.tex}
\input{wandw-ch08.tex} % First section done
\input{wandw-ch09.tex}
\input{wandw-ch10.tex}
\input{wandw-ch11.tex}

\part{The Transcendental Functions}
\input{wandw-ch12.tex}
\input{wandw-ch13.tex}
\input{wandw-ch14.tex}
\input{wandw-ch15.tex}
\input{wandw-ch16.tex}
\input{wandw-ch17.tex} % First pass complete; missing references
\input{wandw-ch18.tex}
\input{wandw-ch19.tex}
\input{wandw-ch20.tex}
\input{wandw-ch21.tex}
\input{wandw-ch22.tex}
\input{wandw-ch23.tex}

\appendix
\input{wandw-appendix.tex}

\input{wandw-index-todo.tex}
\printindex

\end{document}


\documentclass{article}

\usepackage{fancyhdr}
\usepackage{extramarks}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{syntax}
\usepackage{stmaryrd}
\usepackage{mathpartir}
\usepackage{tipa}

%
% Basic Document Settings
%

\topmargin=-0.45in
\evensidemargin=0in
\oddsidemargin=0in
\textwidth=6.5in
\textheight=9.0in
\headsep=0.25in

\linespread{1.1}

\pagestyle{fancy}
\chead{Globally Ordered Type System}
\lfoot{\lastxmark}
\cfoot{\thepage}

\renewcommand\headrulewidth{0.4pt}
\renewcommand\footrulewidth{0.4pt}

\setlength\parindent{30pt}

\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Zt}{$\Z$}

% Create a relational rule
% [#1] - Additional mathpartir arguments
% {#2} - Name of the rule
% {#3} - Premises for the rule
% {#4} - Conclusions for the rule
\newcommand{\relationRule}[4][]{\inferrule*[lab={\sc #2},#1]{#3}{#4}}

\newcommand{\rel}[1]{\ensuremath{\llbracket {#1} \rrbracket}}
\newcommand{\ttt}{\texttt}
\newcommand{\transform}{\rightsquigarrow}
\newcommand{\proj}{\pi}
\newcommand{\ttuple}{(\tau_1, \ldots, \tau_n)}
\newcommand{\etuple}{(e_1,\ldots,e_n)}
\newcommand{\bool}{\mathrm{bool}}
\newcommand{\integer}{\mathrm{int}}
\newcommand{\option}{\mathrm{option}}
\newcommand{\uoption}[1]{(\bool,#1)}
\newcommand{\opt}[1]{\texttt{opt-#1}}
\newcommand{\varOf}[1]{\texttt{varOf}(#1)}

\newcommand{\oktype}{valid}

\begin{document}
	\section*{The System}
	We begin by defining a grammar of "base types". These are the types which are eligible to be stored in global variables. The particular set of base types is not important, but we believe the following ones give a good overview.

	\begin{grammar}
		<$T$ (base types)> ::= Unit | Int | Bool | T * T
	\end{grammar}

	Everything in the rest of this document is defined with respect to an ordered set $\mathbb{G} = \{g_0, \dots, g_{n-1}\}$ of \emph{global variables}, each of which has an associated base type $T_i$. Our goal is to enforce that $g_0$ is always used before $g_1$, $g_1$ before $g_2$, and so on. For simplicity, we require that each global variable be used; however, we will later relax this restriction by adding subtyping.

	In our model, a global variable is not considered \emph{used} until it is actually accessed. Note that this is different from a normal ordered type system, where any appearance of the variable is considered a use. To distinguish appearances from memory accesses, we adopt ref-cell-like syntax for dereferencing or updating global variables. Note that this is different from the user model in actual dpt, where global variables are viewed as simple values. Instead of the ref-cell operators, dpt contains several built-in functions with appropriate type signatures.

	The \emph{effects} $\epsilon$ in this system specify which global variables have been used so far. Effects are represented as an integer from $0$ to $n$, where effect $i$ means that all global variables up to but not including $g_i$ have been used so far (that is, we expect to use $g_i$ next).

	We will also wish to allow users to define functions which are polymorphic in effect; for example, a function which takes in any global variable, dereferences it, and returns the value. Such a function would have an "effect signature" of something like $\alpha \rightarrow \alpha + 1$. To accommodate this, we will add polymorphic variables and a $+$ constructor to our effect grammar.

	Our effects are also intertwined with the language's value types $\tau$, in two ways. First, we have a special $\texttt{ref} (T, \epsilon)$ type for representing the value of a global variable. Second, function types must be altered to include their effect on the global variables. We do so by adding input and output effects to function types as well, using the form $\forall \overline \alpha. (\tau, \epsilon) \rightarrow (\tau, \epsilon)$.

	Finally, to facilitate type inference, it will be helpful to place additional information on functions
	in the form of \emph{constraints}. In particular, when we generate a polymorphic function, we will place restrictions on the polymorphic variables; for example, a function which takes and uses two global variables in order may have "effect type" $\forall a,b. (\texttt{ref}(int, a), a) \rightarrow ((\texttt{ref} (int, b), a) \rightarrow (int, b+1), a)$, but also implies that $a < b$. Thus attempting to call this function on the arguments $g_1$ and $g_0$ would fail, but we would not be able to catch this without the constraint that requires $1 < 0$. So we will augment our function types to include lists of constraints that are collected during typechecking of the function, and verified when the function is called.

	(Side note: In the constraint-less version, we would typecheck the above function as $\forall a,b. (\texttt{ref}(int, a), a) \rightarrow ((\texttt{ref} (int, a+b+1), a) \rightarrow (int, a+b+2), a)$.
	Note that this uses a more expressive grammar for effects.)

	All in all, we have the following grammar of types and effects.

	\begin{grammar}
		<$\epsilon$ (effects)> ::= 0 | 1 | \dots | n | $\alpha$ | $\alpha + \Z$

		<$c$ (constraint)> ::= $\epsilon \leq \epsilon$

		<$cs$ (constraint sets)> ::= sets of constraints

		<$\tau$ (types)> ::= T | ref (T, $\epsilon$) | $cs \Rightarrow (\tau, \epsilon) \rightarrow (\tau, \epsilon)$

		<$\nu$ (type annotations)> ::= T | ref (T) | $\nu \rightarrow \nu$

		<$\sigma$ (schemas)> ::= $\tau$ | $\forall \alpha.\sigma$
	\end{grammar}

	Note that we use the convention that when representing effects, $\epsilon$ represents any effect, Latin letters represent only integer effects, and Greek letters represent effect variables. Also note that our constraints reference the effect ordering relation defined below.

	Next, we define a simple functional language to use this system on:

	\begin{grammar}
		<$x$ (variables)> ::= alphanumeric

		<$v$ (values)> ::= () | $\Z$ | True | False | $(v, v)$ | $\texttt{fun}\ (x:\nu) \rightarrow e$ | $g_0$ | \dots | $g_{n-1}$

		<$e$ (expressions)> ::= $v$ | $x$ | $e + e$ | $(e,e)$ | fst $e$ | snd $e$ | let $x$ = $e$ in $e$ | if $e$ then $e$ else $e$ | !$e$ | $e := e$ | $e$ $e$
	\end{grammar}

	Note that we treat the global variables as values in their own right in this system.

	\clearpage
	\section*{Relations on Effects}
	\subsection*{Effect Equivalence}
	One may notice that our effect grammar allows us to write logically equivalent effects in different ways: for example, $1+1$ or $2$. To avoid this complication, we define an equivalence relation $\equiv$ on effects as follows, using $\oplus$ to represent integer addition:

	\begin{mathpar}
		\relationRule{effect-refl}{
			\
		}{
			\epsilon \equiv \epsilon
		}

		\relationRule{effect-sym}{
			\epsilon_2 \equiv \epsilon_1
		}{
			\epsilon_1 \equiv \epsilon_2
		}

		\relationRule{effect-trans}{
			\epsilon_1 \equiv \epsilon_2\\
			\epsilon_2 \equiv \epsilon_3
		}{
			\epsilon_1 \equiv \epsilon_3
		}

		\relationRule{int-plus}{
			i \oplus j = k
		}{
			i+j \equiv k
		}
		\\
		\relationRule{plus-comm}{
			\
		}{
			\epsilon_1 + \epsilon_2 \equiv \epsilon_2 + \epsilon_1
		}

		\relationRule{plus-assoc}{
			\
		}{
			(\epsilon_1 + \epsilon_2) + \epsilon_3 \equiv \epsilon_1 + (\epsilon_2 + \epsilon_3)
		}

		\relationRule{plus-cong}{
			\epsilon_1 \equiv \epsilon_3\\
			\epsilon_2 \equiv \epsilon_4
		}{
			\epsilon_1 + \epsilon_2 \equiv \epsilon_3 + \epsilon_4
		}
	\end{mathpar}

	\subsection*{Effect Substitution}
	In order to define our typing relation, we will need to be able to perform substitution on types to eliminate $\alpha$s. To do so, we define a standard capture-avoiding substitution relation $[\epsilon/\alpha]$, defined below.

	\begin{align*}
	\alpha[\epsilon/\alpha] & = \epsilon\\
	\beta[\epsilon/\alpha] & = \beta\ (\mbox{if }\beta \neq \alpha)\\
	i[\epsilon/\alpha] & = i\\
	(\epsilon_1 + \epsilon_2)[\epsilon/\alpha] & = \epsilon_1[\epsilon/\alpha] + \epsilon_2[\epsilon/\alpha]
	\\\hfill\\
	T[\epsilon/\alpha] & = T\\
	(\tau_1 * \tau_2)[\epsilon/\alpha] & = \tau_1[\epsilon/\alpha] * \tau_2[\epsilon/\alpha]\\
	\texttt{ref } (\tau, \epsilon_1)[\epsilon/\alpha] & = \texttt{ref } (\tau[\epsilon/\alpha], \epsilon_1[\epsilon/\alpha])\\
	\left(\forall \overline \alpha.(\tau_1, \epsilon_1) \rightarrow (\tau_2, \epsilon_2)\right)[\epsilon/\alpha] & = \forall \overline \alpha.(\tau_1, \epsilon_1) \rightarrow (\tau_2, \epsilon_2)\\
	\left(\forall \beta.(\tau_1, \epsilon_1) \rightarrow (\tau_2, \epsilon_2)\right)[\epsilon/\alpha] & = \forall\beta.(\tau_1[\epsilon/\alpha], \epsilon_1[\epsilon/\alpha]) \rightarrow (\tau_2[\epsilon/\alpha], \epsilon_2[\epsilon/\alpha]) \mbox{ (if $\beta \neq \alpha$ and $\beta$ does not appear in $\epsilon$) }
	\end{align*}

	We define this to operate on effects and types according to the above rules, and extend it to operate on expressions and environments in the obvious way.

	\subsection*{Effect Ordering}
	We define a standard $\leq$ order on effects so we can compare them, using the $\preceq$ symbol to indicate integer less-than-or-equals.

	\begin{mathpar}
		\relationRule{leq-trans}{
			\epsilon_1 \leq \epsilon_2\\
			\epsilon_2 \leq \epsilon_3
		}{
			\epsilon_1 \leq \epsilon_3
		}

		\relationRule{leq-equiv}{
			\epsilon_1 \equiv \epsilon_2
		}{
			\epsilon_1 \leq \epsilon_2
		}

		\relationRule{leq-int}{
			i \preceq j
		}{
			i \leq j
		}

		\relationRule{leq-plus-1}{
			\epsilon_1 \leq \epsilon_3\\
			\epsilon_2 \leq \epsilon_4
		}{
			\epsilon_1 + \epsilon_2 \leq \epsilon_3 + \epsilon_4
		}

		\relationRule{leq-plus-2}{
			\
		}{
			\epsilon_1 \leq \epsilon_1 + \epsilon_2
		}
	\end{mathpar}

	\clearpage

	The short version: Algorithm W, except with constraints. We instantiate all quantified type variables (QVars) with new free type variables (TVars) whenever we typecheck a variable. When we typecheck a deref/update of ref $\epsilon_2$ starting in state $\epsilon_1$, we add a constraint that $\epsilon_1 \leq \epsilon_2$. When we typecheck a function call $f\ x$, we unify the input of $f$ with $x$ as usual, then add all constraints on $f$ after unification to our constraint set (optionally, we check if it's SAT first).

	Essentially, all we're doing is taking every place where a user-provided effect was originally provided, replacing it with a free type variable, and doing instantiation. In hindsight, this is pretty obvious.

	\section*{The Typing Relation}
	Type inference in this system simultaneously reasons about effects and regular types. As a result, the typing relation has an extra input and output, representing the state of the global variables before and after the expression, respectively.

	Furthermore, we keep track of a list of constraints about all our effects. We check satisfiability of these constraints whenever we generalize a function type. One could also imagine doing this check at various other points (such as whenever we add a constraint), but the choice of whether or not to do so is an implementation decision that affects how errors are reported, not a correctness decisions.

	Finally, we also return a substitution $S$ of the form $[\alpha_1 \mapsto \tau_1, \dots, \alpha_n \mapsto \tau_n]$. We denote the composition of $S_1$ and $S_2$ (applied in that order) by $S_2S_1$, and the application of the substitution $S$ to a schema or environment by $S\sigma$ and $S\Gamma$. We denote the empty substitution by $[]$.

	Our typing relation will thus have the form $\Gamma, \epsilon \vdash e\ \colon \tau, \epsilon, cs, S$. As usual, $\Gamma$ represents our current collection of bound variables; we treat it as a map from variables to schemas. Our goal is that our program $p$ satisfies $\emptyset, 0 \vdash p\ \colon \tau, i, \emptyset$ for some $\tau, i$.

	When writing rules, we use the convention that the metavariable $x$ matches all \emph{non-global} variables. We will always denote global variables using symbols of the form $g_i$. For the rest of these rules we will treat effects as being equal if they are equivalent.

	We now define some auxiliary functions. The function $\texttt{inst} : \sigma \rightarrow \tau$ instantiates all quantified variables in $\sigma$ with \emph{fresh} type variables. The function $\texttt{mgu}(\tau_1, \tau_2)$ returns the most general unifier (a substitution) which turns $\tau_1$ and $\tau_2$ into the same thing, or fails (aborting the typechecking) if no such unifier exists. We define $\texttt{Gen}(\Gamma, \tau)$ which generalizes $\tau$ with respect to $\Gamma$; that is, $\texttt{Gen}(\Gamma, \tau) = \forall \alpha_1...\alpha_k.\tau$, where $\alpha_1$ through $\alpha_k$ are all the free type variables in $\tau$ that do not appear free in $\Gamma$. We define $\texttt{annot}(\nu)$ to add fresh type vars to refs and functions that appear in $\nu$, and add empty constraint sets to the functions.

	\begin{mathpar}
		\relationRule{int}{
			n \in \Z
		}{
			\Gamma, \epsilon \vdash n\ \colon \texttt{Int}, \epsilon, \emptyset, []
		}

		\relationRule{true}{
			\
		}{
			\Gamma, \epsilon \vdash \texttt{True}\ \colon \texttt{Bool}, \epsilon, \emptyset, []
		}

		\relationRule{false}{
			\
		}{
			\Gamma, \epsilon \vdash \texttt{False}\ \colon \texttt{Bool}, \epsilon, \emptyset, []
		}

		\relationRule{Unit}{
			\
		}{
			\Gamma, \epsilon \vdash ()\ \colon \texttt{Unit}, \epsilon, \emptyset, []
		}

		\relationRule{global variable}{
			\
		}{
			\Gamma, \epsilon \vdash g_i\ \colon \texttt{ref}(T_i, i), \epsilon, \emptyset, []
		}
	\end{mathpar}

	Now we can write rules for non-value expressions:

	\begin{mathpar}
		\relationRule{local variable}{
			\Gamma[x] = \sigma
		}{
			\Gamma, \epsilon \vdash x\ \colon \texttt{inst}(\sigma), \epsilon, []
		}

		\relationRule{plus}{
			\Gamma, \epsilon \vdash e_1\ \colon \texttt{Int}, \epsilon_1, cs_1, S_1\\
			S_1\Gamma, \epsilon_1 \vdash e_2\ \colon \texttt{Int}, \epsilon_2, cs_2, S_2
		}{
			\Gamma, \epsilon \vdash e_1 + e_2\ \colon \texttt{Int}, \epsilon_2, S_2cs_1 \cup cs_2, S_2S_1
		}

		\relationRule{pair}{
			\Gamma, \epsilon \vdash e_1\ \colon \tau_1, \epsilon_1, cs_1, S_1\\
			S_1\Gamma, \epsilon_1 \vdash e_2\ \colon \tau_2, \epsilon_2, cs_2, S_2
		}{
			\Gamma, \epsilon \vdash (e_1, e_2)\ \colon S_2\tau_1 * \tau_2, \epsilon_2, S_2cs_1 \cup cs_2, S_2S_1
		}

		\relationRule{fst}{
			\Gamma, \epsilon \vdash e\ \colon \tau_1 * \tau_2, \epsilon_1, cs_1, S_1
		}{
			\Gamma, \epsilon \vdash \texttt{fst } e\ \colon \tau_1, \epsilon_1, cs_1, S_1
		}

		\relationRule{snd}{
			\Gamma, \epsilon \vdash e\ \colon \tau_1 * \tau_2, \epsilon_1, cs_1, S_1\\
		}{
			\Gamma, \epsilon \vdash \texttt{snd } e\ \colon \tau_2, \epsilon_1, cs_1, S_1
		}

		\relationRule{let}{
			\Gamma, \epsilon \vdash e_1\ \colon \tau_1, \epsilon_1, cs_1, S_1\\
			S_1\Gamma[x := \texttt{Gen}(S_1\Gamma, \tau_1)], \epsilon_1 \vdash e_2\ \colon \tau_2, \epsilon_2, cs_2, S_2
		}{
			\Gamma, \epsilon \vdash \texttt{let } x = e_1 \texttt{ in } e_2\ \colon \tau_2, \epsilon_2, S_2cs_1 \cup cs_2, S_2S_1
		}

		\relationRule{if}{
			\Gamma, \epsilon \vdash e_1\ \colon \texttt{Bool}, \epsilon_1, cs_1, S_1\\
			S_1\Gamma, \epsilon_1 \vdash e_2\ \colon \tau_2, \epsilon_2, cs_2, S_2\\
			S_2S_1\Gamma, S_2\epsilon_1 \vdash e_3\ \colon \tau_3, \epsilon_3, cs_3, S_3\\
			S_4 = \texttt{mgu}(S_3\tau_2, \tau_3)\\
			S_5 = \texttt{mgu}(S_4S_3\epsilon_2, S_4\epsilon_3)\\
		}{
			\Gamma, \epsilon \vdash \texttt{if } e_1 \texttt{ then } e_2 \texttt{ else } e_3\ \colon \tau, \epsilon_3, S_5S_4S_3S_2cs_1 \cup S_5S_4S_3cs_2 \cup S_5S_4cs_3, S_5S_4S_3S_2S_1
		}
	\end{mathpar}

	Now let's finally write some rules that actually change $\epsilon$.

	\begin{mathpar}
		\relationRule{deref}{
			\Gamma, \epsilon \vdash e\ \colon \texttt{ref} (T, \epsilon_2), \epsilon_1, cs_1, S_1\\
		}{
			\Gamma, \epsilon \vdash\ !e\ \colon T, \epsilon_2+1, cs_1 \cup \{\epsilon_1 \leq \epsilon_2\}, S_1
		}

		\relationRule{update}{
			\Gamma, \epsilon \vdash e_1\ \colon T, \epsilon_1, cs_1, S_1\\
			S_1\Gamma, \epsilon_1 \vdash e_2\ \colon \texttt{ref}(T, \epsilon_3), \epsilon_2, cs_2, S_2
		}{
			\Gamma, \epsilon \vdash e_2 := e_1\ \colon \texttt{Unit}, \epsilon_3+1, S_2cs_1 \cup cs_2 \cup \{\epsilon_2 \leq \epsilon_3\}, S_2S_1
		}
	\end{mathpar}

	And finally, the function rules:
	\begin{mathpar}
		\relationRule{abs}{
			\tau_x = \texttt{annot}(\nu)\\
			\Gamma[x := \tau_x], \alpha \vdash e\ \colon \tau, \epsilon_1, cs, S\\
			\alpha \mbox{ fresh}\\
			cs \mbox{ is SAT}
		}{
			\Gamma, \epsilon \vdash \texttt{fun } (x : \nu) \rightarrow e\ \colon cs \Rightarrow (S\tau_x, S\alpha) \rightarrow (\tau, \epsilon_1), S\epsilon, cs, S
		}

		\relationRule{app}{
			\Gamma, \epsilon \vdash e_1 \colon cs_f \Rightarrow (\tau_{in}, \epsilon_{in}) \rightarrow (\tau_{out}, \epsilon_{out}), \epsilon_1, cs_1, S_1\\
			S_1\Gamma, \epsilon_1 \vdash e_2\ \colon \tau_{in}', \epsilon_{in}', cs_2, S_2\\
			S_3 = \texttt{mgu}(S_2\tau_{in}, \tau_{in}')\\
			S_4 = \texttt{mgu}(S_3S_2\epsilon_{in}, S_3\epsilon_{in}')\\
			S_4S_3S_2cs_f \mbox{ is SAT}
		}{
			\Gamma, \epsilon \vdash e_1\ e_2\ \colon S_4S_3S_2\tau_{out}, S_4S_3S_2\epsilon_{out}, S_4S_3S_2cs_1 \cup S_4S_3cs_2 \cup S_4S_3S_2cs_f, S_4S_3S_2S_1
		}
	\end{mathpar}

Question: do we need something like an interpolant? It would be very nice to ensure that the constraints on a function only refer to variables that it quantifies. And free variables in the environment when it's defined. I think this happens automatically though.

\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:

notes/global typing small step constraints.tex


%\documentclass[aps,showpacs,prb,floatfix,twocolumn]{revtex4}
\documentclass[aps,prb,floatfix,epsfig,twocolumn,showpacs,preprintnumbers]{revtex4}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsmath,amssymb,graphicx,bm,epsfig}
\usepackage{color}

\newcommand{\eps}{\epsilon}
\newcommand{\vR}{{\mathbf{R}}}
\renewcommand{\vr}{{\mathbf{r}}}
\newcommand{\hr}{{\hat{\textbf{r}}}}
\newcommand{\vk}{{\mathbf{k}}}
\newcommand{\vdelta}{{\mathbf{\delta}}}
\newcommand{\vK}{{\mathbf{K}}}
\newcommand{\vq}{{\mathbf{q}}}
\newcommand{\vQ}{{\mathbf{Q}}}
\newcommand{\vPhi}{{\mathbf{\Phi}}}
\newcommand{\vS}{{\mathbf{S}}}
\newcommand{\cG}{{\cal G}}
\newcommand{\cF}{{\cal F}}
\newcommand{\cT}{{\cal T}}
\newcommand{\cH}{{\cal H}}
\newcommand{\cJ}{{\cal J}}
\newcommand{\cD}{{\cal D}}
\newcommand{\cL}{{\cal L}}
\newcommand{\Tr}{\mathrm{Tr}}
\renewcommand{\a}{\alpha}
\renewcommand{\b}{\beta}
\newcommand{\g}{\gamma}
\renewcommand{\d}{\delta}
\newcommand{\npsi}{\underline{\psi}}
\renewcommand{\Im}{\textrm{Im}}
\renewcommand{\Re}{\textrm{Re}}
\newcommand{\cA}{{\cal A}}

\begin{document}

\title{How to plot magnetic calculation in non-magnetic BZ}
\author{Kristjan Haule}
\affiliation{Department of Physics, Rutgers University, Piscataway, NJ 08854, USA}
\date{\today}

%\begin{abstract}
%\end{abstract}
\pacs{71.27.+a,71.30.+h}
\date{\today}
\maketitle

\section{Derivation 1}

The general expression for the GS is
\begin{eqnarray}
G_{\vk_0}(\omega) = \sum_i\int d\vr d\vr' e^{-i\vk_0 \vr}\psi_{i\vk}(\vr)\frac{1}{\omega-\epsilon_\vk^i}\psi_{i\vk}^*(\vr')e^{i\vk_0\vr'}
\end{eqnarray}
with $k_0$ an arbitrary momentum. Here
\begin{equation}
\psi_{i\vk}(\vr)=\sum_{i\vK} A_{i\vK}^{\vk}\chi_{\vk+\vK}(\vr)
\end{equation}
are Kohn-Sham solutions, and $\chi$ are basis functions.
We hence have
\begin{widetext}
\begin{eqnarray}
G_{\vk_0}(\omega) = \sum_i\sum_{\vK_1,\vK_2} \langle e^{-i\vk_0
  \vr}|\chi_{\vk+\vK_1}(\vr)\rangle
A_{i\vK_1}^\vk\frac{1}{\omega-\epsilon_\vk^i}A_{i\vK_2}^{\vk *}\langle
\chi_{\vk+\vK_2}(\vr')|e^{i\vk_0\vr'}\rangle
\end{eqnarray}
\end{widetext}

For plane wave basis, the matrix elements are
$$\langle e^{-i\vk_0 \vr}|\chi_{\vk+\vK}(\vr)\rangle = \delta_L(\vk+\vK-\vk_0) $$
where $\delta_L$ requires that $\vk+\vK=\vk_0$ up to reciprocal vector
of the non-magnetic unit cell!

In order to avoid computing annoying matrix elements, we will use the
same expression also in the LAPW basis set. We just need to
generalized it for the non-orthogonal basis set.
The generalization is
\begin{widetext}
\begin{eqnarray}
G_{\vk_0}(\omega)=\sum_{\vK_1,\vK_2,i}\delta_L(\vk+\vK_1-\vk_0)A_{i\vK_1}^\vk\frac{1}{\omega-\epsilon_\vk^i}A_{i\vK_2}^{\vk *} \delta_L(\vk+\vK_2-\vk_0)\langle\chi_{\vk+\vK_1}|\chi_{\vk+\vK_2}\rangle
\end{eqnarray}
In order to plot fat-bands (with character), we can express $G$ inside
the muffin thin sphere in the following way
\begin{eqnarray}
G_{\vk_0}^{L_1  L_2}(\omega)=\sum_{\vK_1\vK_2,i}\delta_L(\vk+\vK_1-\vk_0)A_{i\vK_1}^\vk
a_{L_1}^{\kappa_1}(\vk+\vK_1)\frac{1}{\omega-\epsilon_\vk^i}A_{i\vK_2}^{\vk  *} a_{L_2}^{\kappa_2 *}(\vk+\vK_2)\delta_L(\vk+\vK_2-\vk_0)\langle u_{l_1}^{\kappa_1}|u_{l_2}^{\kappa_2}\rangle
\end{eqnarray}
which can also be written as
\begin{eqnarray}
G_{\vk_0}^{L_1  L_2}(\omega)=\sum_{i\kappa_1\kappa_2}
{\cal A}_{i L_1}^{\kappa_1}(\vk)
\frac{1}{\omega-\epsilon_\vk^i}
{\cal A}_{i L_2}^{\kappa_2 *}(\vk)
\langle u_{l_1}^{\kappa_1}|u_{l_2}^{\kappa_2}\rangle
\end{eqnarray}
\end{widetext}
with
\begin{equation}
{\cal A}_{i L}^{\kappa}(\vk)=\sum_{\vK}\delta_L(\vk+\vK-\vk_0)A_{i\vK}^\vk a_{L}^{\kappa}(\vk+\vK)
\end{equation}

This expression is used to compute partial density of states in QTL
and DMFT, except that $\delta_L$-functions then requires that
$\vk=\vk_0$ and $\vK$ can be any reciprocal vector.

For magnetic calculation, we need to perform calculation in bigger
unit cell. Hence we have shorter reciprocal vectors. Out of reciprocal
vectors of the magnetic BZ, we need to find those which are reciprocal
vectors of non-magnetic BZ. Then the sum over $\vK$ above should be
performed only over the non-magnetic reciprocal vectors.

%If $\vk_0$ is
%in first-BZ of the magnetic unit cell, or is outside it, a different
%set of  reciprocal vectors will be summed over.

\section{Alternative derivation}

The green's function of LDA+DMFT in real space, expressed in terms of
the Kohn-Sham states $\psi_{i\vk}(\vr)$, is
\begin{equation}
 G(\vr,\vr') = \sum_{ij\vk}\psi_{i\vk}(\vr)\left(\frac{1}{\omega+\mu-\varepsilon_\vk-P_\vk\Sigma}\right)_{ij}\psi_{j\vk}^*(\vr')
\end{equation}
Below, we will use the notation
\begin{equation}
  \left(\frac{1}{\omega+\mu-\varepsilon_\vk-P_\vk\Sigma}\right)_{ij}\equiv  g_{\vk ij}
\end{equation}

Magnetic unit cell is bigger, and hence we can write Green's function
on sublatice A, on sublatice B, and the off-diagonal Green's function.
If the Green's function is written in the position representation
within the unit cell, it is easy to derive the green's function in the
non-magnetic unit cell. The result is
\begin{eqnarray}
\left(
\begin{array}{cc}
 G_{\vk,AA} & G_{\vk,AB}\\
 G_{\vk,BA} & G_{\vk,BB}
\end{array}
\right)
\rightarrow\\
G_{\vk} = G_{\vk,AA} + G_{\vk,BB} + G_{\vk,AB} e^{i\vk\vdelta} + G_{\vk,BA}e^{-i\vk\vdelta}
\end{eqnarray}
Here $\delta$ is the vector connecting sublatice $A$ and sublatice
$B$. For the checkerboard AFM state, this vector is for example $(1,0,0)$.

We want to write the LAPW Green's function in terms of the four
components of sublattices. We first note that the Kohn-Sham solutions $\psi_{i\vk}(\vr)$
are expanded in terms of LAPW basis set functions
$\chi_{\vk+\vK}(\vr)$ in the following way
\begin{equation}
\psi_{i\vk}(\vr) = \sum A^\vk_{i\vK}\chi_{\vk-\vK}(\vr)
\end{equation}
where $A^\vk_{\vk-\vK}$ are eigenvectors, written in \textit{case.vector}.
Since the LAPW basis functions transform
under shift in the same way as plane waves, we have
\begin{widetext}
\begin{eqnarray}
 G(\vr_1+\vdelta_1,\vr_2+\vdelta_2) =
 \sum_{ij\vk,\vK,\vK'}
 A^\vk_{i\vK} e^{i(\vk-\vK)\vdelta_1}\chi_{\vk-\vK}(\vr_1) g_{\vk ij}
 \chi^*_{\vk-\vK'}(\vr_2)e^{-i(\vk-\vK')\vdelta_2} A^{\vk *}_{j\vK'}
\end{eqnarray}
The generalized expression for $G$ in the non-magnetic unit cell, in terms of the four components of
the Green's function, is
\begin{equation}
G_\vk = \int d\vr \left[ G(\vr,\vr) + G(\vr,\vr+\delta)e^{i\vk\delta}+G(\vr+\delta,\vr)e^{-i\vk\vdelta}+G(\vr+\delta,\vr+\delta)\right]
\end{equation}
Using the above expression for $G(\vr_1+\vdelta1,\vr_2+\vdelta_2)$, we
have
\begin{eqnarray}
 G_\vk =
 \sum_{ij\vK,\vK'}
 A^\vk_{i\vK} O^\vk_{\vK\vK'}A^{\vk *}_{j\vK'} g_{\vk ij}
(1+e^{i\vK'\vdelta}+e^{-i\vK\vdelta}+e^{i(\vK'-\vK)\vdelta})
\end{eqnarray}
\end{widetext}
where overlap is
\begin{equation}
O^\vk_{\vK\vK'} = \langle \chi_{\vk-\vK'}|\chi_{\vk-\vK}\rangle.
\end{equation}
It is clear that $e^{i \vK\vdelta}$ is unity for the reciprocal
vectors of the non-magnetic unit cell, and it is $-1$ for the new
reciprocal vectors, which are not part of the non-magnetic unit
cell. Hence, if one of the $\vK$ in the above expression is the "new"
reciprocal vector, and one is "old" (part of the non-magnetic
reciprocal set), the sum of the exponents in the bracket vanishes. The
same is true when both $\vK$ and $\vK'$ are "new" vectors, because
$\vK'-\vK$ is now the "old" vector, and hence $e^{i(\vK'-vK)\vdelta}=1$.
We see that only the terms which include the original non-magnetic
reciprocal vectors survive in the above expression. Hence the
expression is equivalent to the expression in the previous chapter,
but it is more convenient for implementation.
To compute it, we only
need Kohn-Sham eigenvectors $A^\vk_{i\vK}$, since the overlap can also
be expressed in terms of the overlap. The eigenvalue problem demands
$A O A^\dagger  = 1$, hence
\begin{equation}
\sum_{\vK\vK'} A^\vk_{i\vK} O^\vk_{\vK \vK'} A^\vk_{j\vK'} = \delta_{ij}
\end{equation}
We use SVD decomposition to invert eigenvectors (because they are not
quadratic matrice). The SVD is
\begin{equation}
A = U Z V
\end{equation}
where $U$ and $V$ are unitary matrices, and $Z$ are singular
values. We then have
\begin{eqnarray}
O = V^\dagger \frac{1}{Z} U^\dagger U \frac{1}{Z} V.
\end{eqnarray}

We would like to write the final expression in a more compact way. We
define the "coherence"-like factors
\begin{equation}
 C^\vk_{ji} =
 \sum_{\vK \vK'} A^\vk_{i\vK} O^\vk_{\vK\vK'}A^{\vk *}_{j\vK'}(1+e^{i\vK'\vdelta}+e^{-i\vK\vdelta}+e^{i(\vK'-\vK)\vdelta})
\end{equation}
and note that $G$ is then simply given by
\begin{equation}
 G_\vk =  \sum_{ij} C^\vk_{ji}\; g_{\vk ij}.
\end{equation}

Finally, it is convenient to express the Green's function in terms of
the LDA+DMFT eigenvalues and LDA+DMFT eigenvectors. We note that the
LDA+DMFT green's function expressed in Kohn-Sham basis is
\begin{equation}
g_{\vk ij} = A^{R}_{\vk\omega,i l} \frac{1}{\omega+\mu-\varepsilon_{\vk
    l\omega}} A^{L}_{\vk\omega,l j}
\end{equation}
Hence, we can define the LDA+DMFT frequency dependent "coherence" factors
\begin{eqnarray}
\widetilde{C}^\vk_{l\omega} = \sum_{ij} A^{L}_{\vk\omega,l j} C^\vk_{ji} A^{R}_{\vk\omega,i l}
\end{eqnarray}
In terms of these "coherence" factors we finally have
\begin{equation}
G_\vk = \sum_l
\frac{\widetilde{C}^\vk_{l\omega}}{\omega+\mu-\varepsilon_{\vk\omega l}}
\end{equation}

\end{document}


\section{Preliminaries}

Our solution can be described in terms of the participants,
the  notations used to describe the interactions,
and
the primitives used to achieve the desired security
properties.

\subsection{Participants}
\paragraph{Pollster service}
The poll is run by a \emph{Pollster service} application which
allows users to interact with it using a RESTful
interface.  The pollster service implements the following functions:

\begin{itemize}
\item{ \textsc{Create poll\\}
  Lay users, or \emph{human pollsters}, can define polls.
  Upon poll creation the pollster service accepts ballots
  on a voting URL.  This voting URL can be shared with prospective voters.
}
\item{ \textsc{Accept ballot\\}
  Voters cast ballots using the voting URL RESTful interface exposed
  by the pollster service. Because the ballot needs to have
  a well defined structure with cryptographic contents, an
  accompanying library is supported to make it easy for lay voters to
  cast their votes.
}
\item{ \textsc{Bulletin board\\}
  The pollster service publishes ballots on a bulletin
  board.
  Once a sufficient number of ballots have been collected,
  and any disallowed voters trimmed,
  a tally of valid votes are also published on the bulletin board.
}
\end{itemize}

\paragraph{Voters}
The voters are expected to be unsophisticated internet users who
cast their ballots through a \emph{votster widget}.  The function of this
widget is to faithfully convert the voter choice into a anonymity
preserving ballot and to post it on the \textsc{Accept ballot} interface
of the Pollster service.

\paragraph{Verifiers}
Verifiers may be lay users or sophisticated cryptographers who can
rerun the ballots-to-tally computation being exposed on the
\textsc{Bulletin board} interface of the the pollster service.

\subsection{Notations}

\begin{table}[t]
\caption{Notation}
\begin{center}
\begin{tabular}{|cc|} \hline
$K_A$   &  Public key of the participant $A$\\
$K^{-1}_A$   &  Private key of the participant $A$ \\
$\{x,y,z\}$   &  A message containing $x$, $y$ and $z$ \\
$\{x\}_A$ &  A message signed by $A$ \\ \hline
\end{tabular}
\label{table:notation}
\end{center}
\end{table}

The general notations used in this paper are shown in Table~\ref{table:notation}.
We consider $n$ voters $v_1\ldots v_n$  who want to vote on a
binary poll $\mathcal{B}$ with choices $0$ or $1$.
The pollster service is represented as $\mathbf{P}$.
It has a well known public key $K_P$ which
is used for creating digitally signed messages.

The participants communicate with each other using messages, which are
represented using the security protocol
notation~\footnote{ Even though an abstract
  security protocol notation is used for protocol
  specification and analysis, the implemented messages may be represented
  in a more machine friendly manner, for example as JSON objects.
}.
For example, $A$ sending a message containing
$X$ and $Y$ to $B$ is represented as follows:
\[
A \rightarrow B \hspace{10pt} : \hspace{10pt} \{X,Y\}
\]

\subsection{ElGamal cryptosystem}
The ElGamal cryptosystem is a well known
and established public key
cryptosystem based on the Discrete Logarithms problem~\cite{1057074}.
Its security
comes from the assumption that computing discrete logarithms over
a prime group is hard.
\begin{assumption}
Given a large prime $p$ and a generator $g$,
it is computationally infeasible to find $x$ from $y \equiv g^x \bmod p$.
\end{assumption}

The ElGamal cryptosystem works by all players initially agreeing to a large prime $p$
and a generator $g$.  The receiver chooses a secret key $s < p$ and publishes
the public key $h \equiv g^s \bmod p$, which is assumed to be well-known to
all parties.

In the context of the ElGamal cryptosystem
we will assume all random choices and operations are done
modulo $p$.  Hence one can succintly represent the
public key publication message as
\[
\text{Receiver} \rightarrow \text{Sender} \hspace{10pt} : \hspace{10pt} \{g^s\}
\]

Suppose the sender wants to send a message $m$ to the receiver, then it chooses
a random integer $r$ and sends the following message:
\[
\text{Sender} \rightarrow \text{Receiver} \hspace{10pt} : \hspace{10pt} \{g^r, h^rm\}
\]

Since the receiver does not know about the random choice $r$ made by the sender, we
represent the received message as $\{x, y\}$.  Using its secret $s$, the receiver recovers
the message by computing $\frac{y}{x^s}$, as shown below.
\begin{equation} \label{eq1}
\begin{split}
\frac{y}{x^s} & = \frac{h^rm}{g^{r^s}} \\
              & = \frac{{{(g^s)}^r}m}{g^{r^s}}\\
              & = m
\end{split}
\end{equation}

\subsection{Non-interactive zero knowledge proofs}

Zero knowledge proofs permit a prover to convince a verifier about their knowledge
of a particular information without divulging that information.  The proving
process can either take the form of an interactive session where the verifier
can issue challenges and the prover can respond correctly.  These ineractions can
be converted into an equivalent non-interactive proof,
thereby avoiding the need for participants
to be online.  One such construction is the Schnorr protocol, which
provides universal verifiability.

The objective of the Schnorr protocol is for the prover to convince a
verifier that it knows the discrete logarithm $x$ of a well known
value $y \equiv g^x$ \emph{without} disclosing the value $x$.  The interactive
protocol proceeds by the prover and verifier selecting random numbers,
$e$ and $c$ respectively,
and exchanging the following messages:
\[
\begin{array}{lcccc}
  \text{Prover} \rightarrow \text{Verifier} & & : & & \{ t \equiv g^e  \} \\
  \text{Verifier} \rightarrow \text{Prover} & & : & & \{ c \} \\
  \text{Prover} \rightarrow \text{Verifier} & & : & & \{ d \equiv e - xc \}
\end{array}
\]
The verifier checks if $y^cg^d = t$, which follows from :
\begin{equation} \label{eq2}
\begin{split}
y^cg^d & = g^{xc}g^d \\
       & = g^{(xc + d)}  \\
       & = g^{(xc + e - xc)} \\
       & = g^e \\
       & = t
\end{split}
\end{equation}

A non-interactive proof is generated by constraining the verifier challenge
$c$ to be predictable by the prover yet to resist an adaptive
ciphertext attack.
This can be done by having it depend on a secure hash function $H$ whose
output is sufficiently random and unpredictable.  Then the zero
knowledge interactive protocol with the verifier $v_i$
can be transformed into its non-interactive version with a
transcript as follows:
\[
\{ g^e , H(g^e, v_i) , e - xH(g^e, v_i) \}
\]

% TODO : isnt it true we can have recursively contained nizkp s
% such that $v_i \equiv \star$ is universally verifiable, whereas
% org.* may be a more specific nizkp

Such a transcript can be produced by the prover in advance, without
requiring any action from the verifier.  This Schnorr protocol
construction is used for ensuring universal verifiability of several
properties of the voting protocol.


\chapter{Integration of rare processes}

\label{sec:rare}

When propagating particles, PROPOSAL considers ionization, bremsstrahlung, electron-positron pair production and photonuclear interactions.
These four processes were originally chosen due to their quantitatively relevant contribution to the energy loss of muons, see figure \ref{fig:dEdx}.
However, the polymorphic code structure of PROPOSAL allows for the simple implementation of additional interactions.

The following section describes the implementation of two rare processes, the production of muon pairs and the weak interaction of charged leptons, in PROPOSAL.
While their contribution to the average energy loss is insignificant, they are able to produce qualitatively significant detector signatures for certain analyses as described individually in sections \ref{sec:signatures} and \ref{sec:weak_signature}.

Definitions and numerical values of variables are, unless otherwise specified, listed, if necessary with their corresponding numerical values, in appendix \ref{sec:constants}.

\section{Muon pair production}

The process of muon pair production is a rare process with a negligible contribution to the average energy loss of a propagated particle.
However, the created signatures may be qualitatively relevant for neutrino observatories such as IceCube or underground detectors examining muons, see section \ref{sec:signatures} for a description of these signatures.

\subsection{Theoretical description}

Muon pair production describes the creation of a muon-antimuon pair by a particle in the field of an atomic nucleus $Z$, in case of an initial muon the reaction is
\begin{align*}
    \mu^- + Z \rightarrow \mu^- + \mu^+ + \mu^- + Z.
\end{align*}
A Feynman diagram in leading order for the process is shown in figure \ref{fig:feynman_mupair}.

\begin{figure}
	\centering
	\input{content/feynman/feynman_mupair.tex}
    \caption{One possible Feynman diagram describing the creation of a muon pair by an ingoing muon.}
    \label{fig:feynman_mupair}
\end{figure}

The process has been described in \cite{Kelner2000} where a simplified analytical double differential cross section for muon pair production is given by
\begin{equation}
    \label{eqn:mupair}
    \frac{\mathrm{d}^2\sigma}{\mathrm{d}v \mathrm{d}\rho} = \frac{2}{3\pi} (Z \alpha r_\mu)^2 \frac{1-v}{v} \Phi(v, \rho) \ln \left( X \left(E, v, \rho \right) \right)
\end{equation}
with the relative energy loss $v$ and the asymmetry parameter $\rho$ defined by
\begin{align}
    v &= \frac{E_+ + E_-}{E}, & \rho &= \frac{E_+ - E_-}{E_+ + E_-}
\end{align}
and the energy of the produced (anti)muon $E_\pm$.
The functions $\Phi(v, \rho)$ and $X(E, v, \rho)$ have the form
\begin{align}
    \begin{split}
    \Phi(v, \rho) &= \left[ (2 + \rho^2) (1 + \beta) + \xi (3 + \rho^2) \right] \cdot \ln{ \left( 1 + \frac{1}{\xi} \right) }\\ &\quad+ \left[ (1 + \rho^2) \left( 1 + \frac{3}{2} \beta \right) - \frac{1}{\xi} (1 + 2 \beta) (1 - \rho^2) \right] \cdot \ln{ (1 + \xi) }\\ &\quad- 1 - 3 \rho^2 + \beta (1 - 2 \rho^2)
    \end{split}
\end{align}
where $X$ is given by
\begin{equation}
    X = 1 + U(E, v, \rho) - U(E, v, \rho_\text{max})
\end{equation}
with
\begin{equation}
    U(E, v, \rho) = \frac{\frac{0.65 m_{\mu}}{m_e} A^{-0.27} B Z^{-\sfrac{1}{3}}}{1 + \frac{2 \sqrt{e} m_{\mu}^2 B Z^{-\sfrac{1}{3}} (1 + \xi) (1 + Y) }{m_e E v (1 - \rho^2)} }
\end{equation}
and with
\begin{align}
    \xi &= \frac{v^2 (1 - \rho^2)}{4 (1 - v)}, & \beta &= \frac{v^2}{2 (1 - v)}, & Y &= 12 \sqrt{\frac{m_{\mu}}{E}}, & B &= 183.
\end{align}

The approximative expression \eqref{eqn:mupair} takes into account the finiteness of the nucleus as well as screening effects of the nucleus by atomic electrons.
A more precise formula for the differential cross section is given in \cite{Kelner2000} as well, however it includes multidimensional integrals that are hard to evaluate and is therefore not suited to be used here.
Furthermore, \eqref{eqn:mupair} is chosen to have a discrepancy compared to the precise formula of below $\SI{10}{\percent}$ for all $E > \SI{e4}{\mega\electronvolt}$, the discrepancy of the derived total cross section is even below $\SI{3}{\percent}$ for $E > \SI{3e4}{\mega\electronvolt}$.

The kinematic limits of the process for $v$ and $\rho$
%
\begin{align}
    v_\text{min} &= \frac{2 m_{\mu}}{E}, & v_\text{max} &= 1 - \frac{m_{\mu}}{E}, & \left| \rho \right| \leq \rho_{\text{max}} &= 1 - \frac{2 m_{\mu}}{v E},
\end{align}
%
are easy to retrace by demanding the condition that all particles involved have to fulfill $E > m_{\text{rest}}$ at all times.

\subsection{Implementation in PROPOSAL}
\label{sec:mupair_implementation}

% sloppypar is needed here because otherwise \texttt{...} breaks the layout because it cant use hyphenation here
\begin{sloppypar}
The process of muon pair production is implemented as an optional, additional interaction in PROPOSAL.
It is per default disabled in PROPOSAL and can be enabled by setting the keyword \texttt{mupair} in the configuration file to \texttt{MupairKelnerKokoulinPetrukhin} which is the parametrization that has been described in the previous section.
\end{sloppypar}

\begin{sloppypar}
To obtain the single-differential cross section in $v$ from \eqref{eqn:mupair}, a numerical integration across the entire kinematic range of $\rho$
%
\begin{equation}
    \frac{\symup{d}\sigma}{\symup{d}v} = \int_{\rho_{\text{min}}}^{\rho_{\text{max}}} \frac{\mathrm{d}^2\sigma}{\mathrm{d}v \mathrm{d}\rho} \, \symup{d}\rho
\end{equation}
%
is performed in PROPOSAL.
After sampling the relative energy loss $v$ during propagation according to \eqref{eqn:sample_v}, the asymmetry parameter $\rho$ is also sampled if the parameter \texttt{mupair\_particle\_output} has been set to \texttt{True}.
In this case, \eqref{eqn:mupair} is used with a fixed $v = v^{\ast}$ to solve the integral equation
\begin{equation}
    \left( \frac{\symup{d}\sigma}{\symup{d}v}(v^{\ast}) \right)^{-1} \int_{\rho_\text{min}}^{\rho} \frac{\mathrm{d}^2\sigma}{\mathrm{d}v \mathrm{d}\rho}(v^{\ast}) \, \symup{d}\rho = \xi
\end{equation}
for $\rho$ where $\xi \in \left[0,1\right)$ is a random number.
An additional random number is used to decide on the sign of $\rho$, the muon energies then assigned are $E_{\pm} = v E \cdot(1 \pm \rho)$.
In figure \ref{fig:rho_mupair}, the behavior of $\rho$ for different muon energies and different $v$ is shown.
For high energies, the process tends to have a higher asymmetry $\rho$, especially when a high relative energy loss is involved, while for lower energies, lower asymmetries are favored.
\end{sloppypar}

\begin{figure}
    \centering
    \includegraphics[scale=1]{build/mupair_rho.pdf}
    \caption{Histogram of $\lvert\rho\rvert$ for different $v$ of muons in ice. For each $v$, $\rho$ has been sampled $\num{e6}$ times. The dashed curves correspond to an initial muon energy of $E=\SI{e4}{\mega\electronvolt}$, the solid curves to $E = \SI{e9}{\mega\electronvolt}$.}
    \label{fig:rho_mupair}
\end{figure}

A comparison of the average energy loss in ice due to electron-positron pair production and muon pair production is shown in figure \ref{fig:dEdx_mupair}.
Both functions behave similarly as they both grow linearly with $E$, still, the contribution from muon pair production is by about three orders of magnitudes lower for high energies and even lower for small energies.
This observation shows that the process is negligible for the energy loss for the muon which is especially a result of the difference between the muon mass and the electron mass since
\begin{align*}
	\frac{\sigma_{\mu \text{pair}}}{\sigma_{e \text{pair}}} \propto \frac{r_{\mu}^2}{r_e^2} = \frac{m_e^2}{m_{\mu}^2} \approx \num{2e-5}.
\end{align*}
The average energy loss due to muon pair production compared to the energy loss due to other interactions in PROPOSAL is shown in figure \ref{fig:dEdx_weak}.

\begin{figure}
    \centering
    \includegraphics[scale=1]{build/dEdx_mupair.pdf}
    \caption{Comparison of the average continuous energy losses of muons in ice due to electron-positron pair production \cite{epair_correction, osti_4563918} and muon pair production. No energy cuts are applied in this plot, hence this plot represents the case where all losses are treated continuously.}
    \label{fig:dEdx_mupair}
\end{figure}

Figure \ref{fig:spectrum_mupair} shows a secondary particle spectrum where muon pair production is enabled.
The contribution from muon pair production tends to be distributed among all secondary energies but is, as expected, suppressed compared to contributions from other interactions.
Figure \ref{fig:spectrum_mupair_secondary} illustrates the contribution to the secondary particle spectrum if the muons produced by muon pair production are further propagated.
Here, it can be seen that the influence of muon pair production on the shape of the secondary particle spectrum appears to be negligible.

\begin{figure}
    \centering
    \includegraphics[scale=1]{build/spectrum_mupair.pdf}
    \caption{Secondary particle spectrum for $\num{e5}$ muons with an initial energy of $\SI{e8}{\mega\electronvolt}$, propagated in ice. Muon pair production is enabled. The histogram shows the frequency of the stochastic losses during propagation, classified by the type of energy loss. The energy cuts applied here are $e_\text{cut} = \SI{500}{\mega\electronvolt}$, $v_\text{cut} = 0.05$.}
    \label{fig:spectrum_mupair}
\end{figure}

\begin{figure}
    \centering
    \includegraphics[scale=1]{build/spectrum_mupair_secondary_comparison.pdf}
    \caption{Secondary particle spectrum for $\num{e5}$ muons with an initial energy of $\SI{e8}{\mega\electronvolt}$, propagated in ice. The solid lines in the histogram show the secondary particle spectrum where muon pair production is disabled. The dashed lines show the additional particle spectrum induced by muons that are created if muon pair production is enabled. The energy cuts applied here are $e_\text{cut} = \SI{500}{\mega\electronvolt}$, $v_\text{cut} = 0.05$. The ratio plot in the lower part of the figure shows the difference between the sum of all secondary particles if muon pair production is disabled compared to the sum of all secondary particles if muon pair production is enabled and the produced muons are propagated as well.}
    \label{fig:spectrum_mupair_secondary}
\end{figure}

\subsection{Significant detector signatures}
\label{sec:signatures}

As already described and shown in section \ref{sec:mupair_implementation}, the contribution of muon pair production to the overall energy loss of muons is negligible.
However, for detectors interested in muon events, the effects of muon pair production may portray a source of significant signatures.
In the following, a group of muons moving into almost the same direction with only a small separation is called a muon bundle.
The origin of such a bundle can be muon pair production, in this case, the bundle consists of three muons.

\subsubsection{IceCube event signatures}

Due to resolution effects, the IceCube detector is unable to identify the muons in a bundle as individual muon signatures \cite{Abbasi_2009}.
However, the signature of a single muon traversing the detector is different from a muon bundle originating from muon pair production with the same sum of energy.
The signature of a high-energetic muon in IceCube is often characterized by a dominating high-energetic stochastic energy loss creating a spherical signature.
In a muon bundle, each muon with only a fraction of the total energy produces smaller stochastic losses.
Since the stochastic losses of the individual muons in the bundle are independent of each other, the resulting signature is more homogeneous and the energy loss per distance of a bundle is more uniform compared to the energy loss per distance of a single muon with the same total energy \cite{charmante_myonen}.

\subsubsection{Background for muon bundles in extensive air showers}

Underground detectors observing muons originating from extensive air showers can use the information about muon bundles created in these air showers to learn about the cosmic ray composition and hadronic interaction models.
This is done by comparing the frequency and multiplicity of muon bundles as well as the muon separation measured in experiments with the predictions from Monte Carlo studies.
In \cite{MupairInRock}, the authors describe this procedure in more detail and point out a possible background from muon pair production.

While about $\SI{1}{\percent}$ to $\SI{10}{\percent}$ of the observed muons are part of muon bundles induced in the air shower, these bundles can also be produced due to muon pair production in rock or water above the underground detector.
According to calculations in \cite{MupairInRock}, these bundles induced by muon pair production can portray a background of up to $\SI{10}{\percent}$ compared to the conventional bundles in the showers, although more exact calculations have to be performed individually for each experiment considering its specific geometric properties.
Due to the difference in the distance between the creation and observation point of the muon bundle, both effects can be separated statistically by examining the separation distance in the bundle.
The separation of muon bundles due to muon pair production is mostly below $\SI{1}{\metre}$ while for muon bundles induced in air showers, only a small percentage of the muon bundles have such a small separation \cite{MupairInRock}.

\section{Weak interaction of charged leptons}

The process called weak interaction in PROPOSAL refers to the conversion of a charged lepton to a neutrino under exchange of a W boson, i.e.\ a charged current weak interaction.
This interaction is highly suppressed compared to other processes. However, the produced signature can be of importance, for example as a background for tau neutrino searches as described in section \ref{sec:weak_signature}.

\subsection{Theory and data description}
\label{sec:weak_theory}

The process of interest
%
\begin{equation}
    \label{eqn:weak_lepton}
    l + N \rightarrow \nu_l + X
\end{equation}
%
with a charged lepton $l$, the corresponding neutrino $\nu_l$, the initial nucleon $N$ and the hadronic final state $X$ describes the conversion of a charged lepton to a neutrino under exchange of a W boson.
This specific process is related to the interaction of an anti-neutrino under exchange of a W boson, i.e.\
%
\begin{equation}
    \label{eqn:weak_neutrino}
    \overline{\nu}_l + N \rightarrow \overline{l} + X,
\end{equation}
%
via crossing symmetry\footnote{The argument of crossing symmetry is identical when switching all particles with their corresponding antiparticles, i.e.\ the process $\overline{l} + N \rightarrow \overline{\nu}_l + X$ is related to $\nu_l + N \rightarrow l + X$.} as depicted in figure \ref{fig:feynman_weak} \cite{Griffiths:111880}.
%
\begin{figure}
    \centering
    \input{content/feynman/feynman_weak.tex}
    \caption{Feynman diagrams of lepton interactions under exchange of a W boson and its connection via crossing symmetry.}
    \label{fig:feynman_weak}
\end{figure}
%
Since the kinematics of both processes are identical, the differential cross sections are also identical except for a prefactor of $\sfrac{1}{2}$,
%
\begin{equation}
    \symup{d}\sigma\left( l + N \rightarrow \nu_l + X \right) = \frac{1}{2} \symup{d}\sigma\left( \overline{\nu}_l + N \rightarrow \overline{l} + X \right).
\end{equation}
%
Due to averaging over all possible initial states and summing over all possible final states when evaluating Feynman diagrams, the prefactor $\sfrac{1}{2}$ must be taken into account since the muon can both be left-handed and right-handed while neutrinos are only observed in a left-handed state (and antineutrinos in a right-handed state) \cite{Sandrock:2018hpj}.

Tabulated numerical values for the differential cross section describing the conversion of a neutrino to a charged lepton, i.e.\ the process \eqref{eqn:weak_neutrino}, are available from \cite{Cooper_Sarkar_2011}.
By using crossing symmetry, these data can directly be used to describe the conversion of a charged lepton to a neutrino, i.e.\ \eqref{eqn:weak_lepton}, which is the process of interest in PROPOSAL.

The cross sections for interactions of leptons with hadrons can be derived under the use of parton distribution functions which describe the probability to find a specific parton (quark or gluon) with a given fraction $x$ of the nucleon's momentum when the momentum transfer is given by $Q^2$.
To make predictions for the (anti)neutrino charged current cross sections, the authors of \cite{Cooper_Sarkar_2011} performed next-to-leading order calculations and used the HERAPDF1.5 data set which provides the parton distribution functions based on deep-inelastic scattering measurements performed at the HERA experiment from 2003 to 2007 \cite{am2010proton}.

The values for $\sfrac{\symup{d}\sigma}{\symup{d}v}$ are provided as two-dimensional tables in $E$ and $v$ with $\num{100}$ entries in $E$ and, for each energy, $\num{110}$ entires in $v$.
Here, $v$ describes the fraction of the initial lepton energy $E$ lost to the nucleon.
Tables are available for an ingoing neutrino or an ingoing antineutrino and for a proton or a neutron as a nucleon involved in the interaction.
The ranges of the tabulated values are $\SI{10}{\giga\electronvolt} \leq E \leq \SI{e12}{\giga\electronvolt}$ and $v_\text{min} < v < 1$ in equal, logarithmic intervals.
The lower limit of $v$ has been set to
%
\begin{align}
    v_\text{min} &= \frac{Q^2_{\text{min}}}{s}, & s &= 2 E m + m^2, & Q^2_{\text{min}} &= \SI{1}{\giga\electronvolt^2},
\end{align}
%
with the mass of the involved nucleon $m$ and the center-of-mass energy $\sqrt{s}$.
For values where $Q^2 < Q_\text{min}^2$, the underlying theory of quantum chromodynamics can no longer be treated perturbatively, meaning that the predictions for the cross sections are not reliable in this kinematic range \cite{Cooper_Sarkar_2011}.

\subsection{Implementation in PROPOSAL}
\label{sec:weak_implementation}

% sloppypar is needed here because otherwise \texttt{...} breaks the layout because it cant use hyphenation here
\begin{sloppypar}
The weak interaction process is by default disabled in PROPOSAL and can optionally be enabled by setting the keyword \texttt{weak} in the configuration file to \texttt{CooperSarkarMertsch} which is the parametrization described in the previous section.
\end{sloppypar}
For a component with an atomic number $Z$ and a mass number $A$, the differential cross section is combined from the given tables to be
%
\begin{equation}
	\frac{\symup{d}\sigma}{\symup{d}v} \propto Z \cdot \frac{\symup{d}\sigma_p}{\symup{d}v} + (A - Z) \cdot \frac{\symup{d}\sigma_n}{\symup{d}v}
\end{equation}
%
where the subscript refers to the nucleon involved in the interaction ($p$ for proton and $n$ for neutron).
PROPOSAL then uses a two-dimensional interpolation routine to obtain a continuous differential cross section from the discrete table values.

In contrast to previously described processes, the weak interaction is a catastrophic loss meaning that the initial particle ceases to exist since it is converted to a different type of particle during the interaction.
Therefore, treating a process with this signature continuously as described in section \ref{sec:energy_loss_calculation} would be unphysical, meaning that there is no contribution to the continuous loss in \eqref{eqn:fE} from these interactions.
Additionally, all interactions with catastrophic losses are treated stochastically by neglecting the energy cut in \eqref{eqn:stoch_crosssection} and \eqref{eqn:sample_v}.
Instead, the lower integral limit is set to $v_{\text{min}}$.
After a weak interaction, PROPOSAL returns the produced neutrino as well as the energy transfer to the nucleon and stops the particle propagation.

\begin{figure}
    \centering
    \includegraphics[scale=1]{build/dEdx_weak.pdf}
    \caption{Comparison of the average energy loss of muons in ice due to weak interactions in comparison to other interactions. Note that losses due to weak interactions are always stochastic, the average energy loss is calculated by taking into account that the muon loses all its energy during a weak interaction event.}
    \label{fig:dEdx_weak}
\end{figure}

Figure \ref{fig:dEdx_weak} shows the average energy loss due to weak interactions compared to the average energy loss due to other processes.
For high energies, the average energy loss due to weak interactions is suppressed by three orders of magnitude compared to other default processes in PROPOSAL with an even higher suppression for lower energies.
Therefore, its quantitative contribution to the average energy loss is entirely negligible.

\subsection{Significant detector signatures}
\label{sec:weak_signature}

As described in the previous section, the weak interaction process is highly suppressed and therefore negligible in its contribution to the average energy loss of a charged lepton.
However, under certain conditions, the detector signature of the process could be significant for searches of tau neutrinos, for example in the IceCube neutrino observatory \cite{Sandrock:2018hpj}.

\begin{figure}
    \centering
    \begin{subfigure}{0.46\textwidth}
        \centering
        \input{content/feynman/weak_tau.tex}
        \caption{Lollipop signature triggered by a tau neutrino.}
        \label{fig:lollipop_signature}
    \end{subfigure}%
    \hspace{0.06\textwidth}%
    \begin{subfigure}{0.46\textwidth}
        \centering
        \input{content/feynman/weak_myon.tex}
        \caption{Signature of a muon weakly interacting inside the detector.}
        \label{fig:weak_signature}
    \end{subfigure}
    \caption{Illustrations of two signatures relevant for tau neutrino searches. The detector volume is drawn gray, hadronic cascades are drawn as a red dot, observable tracks are drawn as blue lines and tracks that are not directly observable are drawn as a black, dotted line.}
    \label{fig:test}
\end{figure}

One possible signature hinting at a tau neutrino event called the "lollipop" signature is illustrated in figure \ref{fig:lollipop_signature}.
Here, a tau neutrino moving towards the detector interacts via a charged current and is being converted to a tau lepton \cite{Cowen_2007}.
The tau lepton then enters the detector, leaving behind an observable track of Cherenkov light emerging from the tau itself and the created secondary particles.
%Due to its short lifetime, the created tau can only reach the detector if its energy is high enough, the average tau decay length scales with energy as \SI{5}{\cm\per\tera\electronvolt} \cite{Aartsen_2016} meaning the tau energy has to be $E_{\tau} \gtrapprox \SI{100}{\tera\electronvolt}$.
Due to its short lifetime, the created tau can only reach the detector if its energy is high enough since the average tau decay length scales with energy as \SI{5}{\cm\per\tera\electronvolt} \cite{Aartsen_2016}.
If the tau decays to a hadron inside the detector, a hadronic cascade is generated at the end of the track, giving the signature its characteristic name.

This tau neutrino signature can be imitated by the event shown in figure \ref{fig:weak_signature}.
In this case, a muon, leaving behind a track, enters the detector where it weakly interacts and is therefore converted to a neutrino.
Due to the energy transfer to the involved nucleus in the weak interaction, the process creates a hadronic cascade comparable to the cascade of a hadronic tau decay.
Since the created neutrino is not observable, the overall signature where a track starts outside the detector and ends in a hadronic cascade can be confused with the lollipop signature from figure \ref{fig:lollipop_signature}.
However, the tracks from both signatures behave differently since the energy loss per distance of a muon is higher than the energy loss of a tau.
To have a similar track signature, the tau involved needs to have an energy that is about $\num{6}$ to $\num{11}$ times higher than the energy of a corresponding muon \cite{Sandrock:2018hpj}.

It follows that analyses searching for lollipop signatures have to consider the weak interaction as a possible background.
According to approximative calculations in \cite{Sandrock:2018hpj} based on the properties of the IceCube detector, the expected rate of false lollipop events due to atmospheric muons undergoing weak interactions is about $\SI{2e-2}{\per yr}$.
This, together with further approximative calculations for real lollipop signatures from tau neutrino events, corresponds to a possible background of $\SI{10}{\percent}$.
However, further effects such as event selection efficiency (assumed to be perfect in this calculation) or a detailed detector simulation were not taken into account but need to be evaluated when conducting a detailed analysis.


\documentclass[11pt]{article}
\usepackage{fullpage}
\usepackage{hyperref}
\usepackage{amssymb}
\usepackage{spalign}
\usepackage{amsmath}
\usepackage{framed}

\newcommand{\tb}{\textbf}

\newcommand{\R}{\mathbb{R}}

\hbadness=99999

\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
}
\urlstyle{urlcolor=blue}
\usepackage{graphicx}
\graphicspath{{./figures/}}
\setcounter{tocdepth}{2}

\renewcommand{\contentsname}{Table of Contents}
\title{Linear Algebra Reference}
\author{Sidharth Baskaran}

\begin{document}
\maketitle

\begin{center}
    \includegraphics[scale=0.3]{cover.png}
\end{center}

\tableofcontents
\newpage
% -------------------------------------

\section{Row and Column Picture}
\input{tex/1_row-col.tex}

\section{Matrix Multiplication}
\input{tex/2_multiplication.tex}

\section{Factorization into A=LU}
\input{tex/3_alu.tex}

\section{Linear Transformations}
\input{tex/4_linear-transformations.tex}

\section{Inverse Matrices}
\input{tex/5_inverses.tex}

\section{Linear Transformations and Inverse Matrices}
\input{tex/6_transformation-inverses.tex}

\section{Linear Transformations in Geometry}
\input{tex/7_transformations-geometry.tex}

\section{Inverse of a Linear Transformation}
\input{tex/8_inverse_lin_trans.tex}

\section{The Matrix Product}
\input{tex/9_matrix-product.tex}

\section{Transposes, Permutations, Spaces}
\input{tex/10_transposes-permutations.tex}

\section{Image and Kernel}
\input{tex/11_image-kernel.tex}

\section{Subspaces and Basis}
\input{tex/12_subspaces.tex}

\section{Basis of a Kernel}
\input{tex/13_basis-kernel.tex}

\section{Dimension}
\input{tex/14_dimension.tex}

\section{Coordinates}
\input{tex/15_coordinates.tex}

\section{Determinants}
\input{tex/16_determinants.tex}

\section{Intro to Dynamical Systems}
\input{tex/17_intro-dynamical-systems.tex}

\section{Eigenvalue of a Matrix}
\input{tex/18_matrix-eigenvalues.tex}

\section{Eigenvector of a Matrix}
\input{tex/19_matrix-eigenvector.tex}

\section{Diagonalization}
\input{tex/20_diagonalization.tex}

% -------------------------------------
\end{document}