\chapter{The ALU}

\section{Design}
For a computer to be capable of effective operation, it needs the ability to perform
 actual processing of data.
It has long been known that the ability to compare two items and act upon the result is sufficient for effective computation
---Turing Machines are based around this concept.
It would therefore have been possible to build a basic  comparison unit, and rely
on software  to derive mathematical and logical operations.
This would have been unreasonably  inefficient.
All realistic computers   have hardware dedicated to evaluation of these functions.
These Arithmetic and Logic Units ({\bf ALU}) normally perform at least integer addition, subtraction and the standard boolean functions of two variables.
More powerful units are capable of high speed multiplication, or even manipulate
floating point numbers.

At the start of the project I was offered the possibility of using a
single chip 64-bit floating point ALU from AMD (AM29C327) \cite{amd:uprogramming,amd:29c300}.
This would have produced impressive performance figures, but I
decided that it would have been unworkable, since it was
designed for a triple data bus and needed 31 bits of control
information every cycle. A single bus system would have  been unable to use this
device effectively.

Instead I designed a very simple ALU, since this made
formal specification  possible. The unit was
built from eight bit sliced TTL ICs, each of which  operates on four bits.
 When connected together via a two level
 carry lookahead generator, they  perform   operations on 32-bit words.

This
is sufficient for many purposes, except that the ability to shift
a word  right was needed in iterative multiplication and division algorithms.

 The result of the ALU had to be stored until  re-used in later instructions.
The state of this result,
whether zero or  negative  needed to obtained in a form
 which could be passed to the Skip register.
 Arithmetic overflow and carry flags were also desirable,
   detecting results too large to be represented in 32 bits.

\section{Implementation}

The design of the ALU is shown in figure~\ref{figure:alu}.

An Accumulator stores the output of the ALU between operations.
This can be read as a memory location.
The contents of the Accumulator are also used as one of the inputs to the ALU,
so only one other argument needs to be supplied per operation.
This accumulator is built out of four SSRS, so can be read directly by the host.

A number of bit sliced ALUs were available with built in accumulator registers.
For example,
the AMD AM2901 (\cite{amd:logic}) or the TTL 74F681 ALU bit slices,
 would have provided enhanced performance with less components and wiring.
Using these would have prevented the host examining the Accumulator directly.
Instead I used 74F381 ALU/function generators in my design.
These  only perform basic operations ---addition, subtraction, and, or, exclusive or, preset and clear.
Three control signals  are used to select a function.

Between the outputs of the ALU ICs and the Accumulator is a bank of five PALS.
Normally these pass the result straight through, each PAL checking if the bits passed though it are all zero or not.
They can also be instructed to shift the result ---including the carry flag--- one bit to the right;
this shifting is controlled by a  one bit signal.
This post shifting  allows a normal operation to be combined with a shift, to make unusual functions such as `subtract and divide by two'.

The results of the five
zero tests along with other signals are fed to another PAL, which
produces values for a Condition Code register ({\bf CC}),  constructed from a Shadow Serial Register.
The PAL generates a zero flag  when all five slices of the result are zero.

\begin{figure}
\vspace{20cm}
\caption{The ALU}
\label{figure:alu}
\end{figure}

\subsubsection{Overflow}

An arithmetic overflow is where  a signed number's sign changes due to too large an addition, subtraction or shift.

My design of an ALU does not detect signed overflow, despite the original intent to do so.
I had originally
acquired equations  from my CS3 notes to detect  overflows using a PAL.
While specifying the system  I realised
these equations  only detected overflow on signed addition.
To detect overflow in a multi-function ALU, one must compare the carry between
bit 30 and bit 31 of the result with the most significant bit, an overflow occuring if the two differ.
This can not be done with the 74F381 bit-sliced devices, as this carry is internal.
I have discovered that AMD make a special most-significant-slice version of this bit-sliced ALU which does detect overflows internally.
The result of this check would however become confused if shifting was performed after the operation, so would not always be reliable.

 Note that even if the ALU did produce an overflow flag, the software would still have to check it after every operation. A number of
implementations of languages do not do this because of the overhead this entails;
APM Pascal and Standard ML are two such  implementations.

\subsubsection{Memory Interface}

Seventeen addresses are allocated to the ALU, as shown in table~\ref{table:memory}.
One of these addresses returns the current value of the Accumulator whenever it is read.
The remaining sixteen addresses all apply a different function between the accumulator and the word moved to the selected address.
This is accomplished by wiring  address bus lines directly to the ALU  and the PALS.

It is not be possible to directly load the
accumulator, but a two instruction sequence  clears it and then adds a
number to the now empty accumulator.

Condition code flag manipulation is  supported:
reading any of the sixteen function addresses returns one of the condition code flags in the least significant bit.
These results can be passed directly to the Skip register for conditional branching.
Before performing a subtraction the carry flag has to be set to true, while
for other operations the flag has to be cleared.
An address is provided to enable this; when it is written to, the least significant bit is passed to the carry flag.


% corrected VD 81

\subsubsection{Recurrent Neural Network}~\\

%introduction

Recurrent Neural Networks (RNNs) are a particular architecture of ANNs which can
process sequential data $S = x_{1},\dots,x_{n}$. In traditional ANN the input
and output data are assumed to be independent. However, for sequential data,
this is usually not the case. For example, the prediction of the next word in a
sentence is dependent on the words that appeared before. As opposed to MLP, RNN
feeds back their outputs back to their network and thus gain an overview of past
inputs. To explain how RNNs are implemented, we have to introduce the notion of
computational graphs. A computational graph is a formal structure representing a
set of computations. We obtain a chain of events by unfolding a recurrent
computation into a computational graph with a repetitive structure. \\

Consider a recurrent system,
\begin{equation}
  s_{t} = f(s_{t-1};\theta)
\end{equation}
with $s$ being the state of the system. The graph can be unfolded considering
the time step $t = 3$, we have,
\begin{equation}
  \begin{split}
    s_{3} & = f(s_{2};\theta) \\
          & = f(f(s_{1};\theta);\theta)
  \end{split}
  \label{recurrentsystem}
\end{equation}
This expression can be illustrated by a directed acyclic computational graph, as
shown in Figure~\ref{dag}\\
\input{sections/scientific/fr2/DAG.tex}

Now we consider the recurrent system accepting an external signal $\bm{x}_{t}$,
\begin{equation}
  s^{t} = f(s^{t-1},\bm{x}_{t};\theta)
  \label{eqaccepting}
\end{equation}
where the state $s$ is containing information about the past sequence $S$. The
hidden units can be described with equation~\ref{eqaccepting} using $\bm{h}$ to
denote the state,
\begin{equation}
  \bm{h}_{t} = f(\bm{h}_{t-1},\bm{x}_{t};\theta)
\end{equation}
represented in Figure~\ref{unfoldrnnaccepting}.\\
\input{sections/scientific/fr2/unfoldrnnaccepting.tex}

%math

With graph unfolding, we can now present some common examples of an RNN. Here are
some important designs of RNNs:\\

\begin{itemize}
  \item RNNs which take a single input and produce an output at every time step
    $t$. This is called a one-to-many RNN.\\
  \item RNNs which read an entire data sequence and produce a data sequence.
    This is called a many-to-many RNN.\\
  \item RNNs which are connected recurrently between hidden units, read an
    entire data sequence $S$ and produce only one single output. This is called
    a many-to-one RNN.\\
\end{itemize}

\input{sections/scientific/fr2/noutputrnn.tex}

We pick the RNN represented in Figure~\ref{noutputrnn} to develop forward
propagation equations. This RNN takes in a data sequence $S$ and outputs for
every time step $t$ an output. In this figure, we didn't include an
activation function for the hidden units $h$. However, for the equations, we
assume the activation function $\mathcal{H}$ to be the hyperbolic tangent.\\

Let $h_{0}$ be the initial state. For every time step from $t = 1$ to $t =
n$, we apply the following equations:
\begin{align}
  \bm{a}_{t} & = \bm{b} + \bm{Wh}_{t-1} + \bm{Ux}_{t} \\
  \bm{h}_{t} & = \tanh(\bm{a}_{t}) \\
  \bm{o}_{t} & = \bm c + \bm{Vh}_{t} \\
  \bm{\hat y}_{t} & = softmax(\bm o_{t})
\end{align}
where $\bm b$ and $\bm c$ are the bias vectors and $\bm U$, $\bm V$ and $\bm W$ are
the weight matrices.\\

%problem

\textbf{The Challenge of Long-Term Dependencies.} The challenge of learning
long-term dependencies is that gradients, propagated through a very deep RNN,
can vanish or explode. Gradients can vanish when the gradients are converging to
$0$ and therefore the weights won't be updated while learning. Exploding
gradients happen if the gradients are too large and the loss function will never
reach the optimized minimum. As a solution to the challenges of RNNs, effective
sequence models used in practice are called gated RNNs. These include the long
short-term memory (LSTM) and the gated recurrent unit (GRU) based RNNs. Gated
RNNs are based on the idea of creating paths through time that have gradients
that neither vanish nor explode.\cite{doi:10.1162/neco.1997.9.8.1735}~\\


\documentclass[../PHYS306Notes.tex]{subfiles}

\begin{document}
\section{Lecture 15}
\subsection{Lecture Notes - Rotating Frame Clickers}
Which of the following motion leads to fictituous forces?
\begin{enumerate}[1.]
    \item The frame moves at a constant velocity with respect to an inertial reference frame.
    \item The frame rotates at a constant angular velocity with respect to an inertial reference frame.
    \item The frame moves at a constant acceleration with respect to an inertial reference frame.
    \item The frame rotates at a constant angular acceleration with respect to an inertial reference frame.
\end{enumerate}
\begin{s}
Three of these frames have fictituous forces (1 does not, its inertial). 2. We saw last day, 3/4 lead to fictituous forces as we will see today!
\end{s}
\noindent The coriolis and centrifugal "forces" are
$$
\begin{array}{l}
\mathbf{F}_{\text {coriolis }}=-2 \mathrm{~m} \boldsymbol{\Omega} \times \mathbf{v} \\
\mathbf{F}_{\text {centifitigal }}=-\mathrm{m} \boldsymbol{\Omega} \times(\boldsymbol{\Omega} \times \mathbf{r})
\end{array}
$$
Which force is more important in the limit of slow velocity (in the rotating frame)?
\begin{s}
In the limit of slow velocity, the centrifugal force (independent of velocity) dominates (the Coriolois force is linear in velocity).
\end{s}
A disk drive typically rotates at $3600$rpm, or $360$ radians per second. For a dust particle at radius $r = 5$cm, how fast must the particle be moving (in the rotating frame) for the Coriolis and the centrifugal forces to have approximately equal magnitude?
\begin{s}
Equating the two expressions and solving for $\abs{\v{v}}$, we find that $\abs{\v{v}} = 900$cm/s.
\end{s}
\noindent A hockey puck slides from the center towards the edge of a frictionless, rotating merry-go-round. The merry-go-round has angular velocity $\Omega$ and rotates CCW when viewed from above. In the rotating frame, the initial velocity is in the positive y direction. In the \textbf{inertial} frame, which way does the path of the puck bend?
\begin{center}
    \includegraphics[scale=0.3]{Lecture-15/w15-img3.png}
\end{center}
\begin{s}
The path of the puck does not bend in the inertial frame; it retains a straight trajectory (there is no force acting on it!)
\end{s}
\noindent In the rotating frame, which way does the path of the puck bend?
\begin{s}
Applying the RHR, we see that the path curves to the right when viewed from above (towards positive $x$).
\end{s}
\end{document}


\section{Network Level Performance with Retransmission mechanism}
\label{sec:op_over_infinite_plane_with_retransmission}
In this section, we extend the network level performance analysis by taking into account retransmission mechanism. Let $N_{\text{max}}$ be the maximum allowed number of transmissions. We consider a conventional retransmission mechanism: in case of no reception of acknowledge from BS, a packet is retransmitted after a random interval until its delivery to BS or the reach of maximum allowed trials. For macro diversity, the retransmission mechanism may be different depends whether the BS is designed to acknowledge the received packet. For LPWAN such as LoRaWAN, the employed retransmission mechanism is completely the same as that use in slotted ALOHA cellular systems. For Sigfox, devices always transmit one packet $N_{\text{max}}$ times no matter whether previous packet transmission is successful.

In case of retransmission, $p\lambda_{m}$ is the fresh space-time arrival packet intensity and $L = p\lambda_{m}/\lambda_{b}$ is referred to as the fresh normalized load. We assume that each retransmission takes place at random over long intervals following the collisions that give rise to them, therefore, the aggregate uplink packets stream still follows a Poisson Point Process with aggregate time-space intensity $\lambda_{\text{agg}}$. Let $G = p\lambda_{\text{agg}}/\lambda_{b}$ be the aggregated normalized load.

According to Poisson's splitting property~\cite{meyn2012markov}, the aggregate packet arrival process can be divided into $N_{max}$ mutually independent Poisson arrivals processes. Let $p_{f}$ be the failure probability of one transmission and $P_{f}$ be the network level packet loss rate after $N_{max}$ transmissions, namely $P_{f} =  p_f^{N_{max}} $. The relationship between aggregated normalized load $G$ and fresh normalized load $L$, depends whether the BS acknowledges the received packet, is as follows:
\begin{equation}
\label{eq:relationship_intensity_fresh_agg}
	G=
	\begin{cases}
	\frac{ 1-P_f }{1-P_f^{1/N_{\text{max}}}} L, & \text{ACK available} \\
	N_{\textbf{max}} L , & \text{otherwise}
	\end{cases}
\end{equation}
\subsection{Best BS attach}
Consider a typical device, at the origin, whose modified distance to the best BS is denoted by $r'$. The distribution of $r'$ is given by $(\ref{eq:pdf_modified_r})$. From $\eqref{eq:succ_proba_with_modified_r}$, its packet loss rate $p_{f, b}(r')$ with respect to $r'$ and $\lambda_{\text{agg}}$ is:
\begin{align}
	\label{eq: fail_proba_with_modified_r_retrans}
	p_{f, b}(r') &= \left[ 1 - exp(-p \lambda_{\text{agg}} \pi A \theta_{T}^{\frac{2}{\gamma}} e^{\frac{2\sigma^2}{\gamma^2}}  {r'} ^ 2)\right] ^{N_{\text{max}}}, \nonumber \\
	&= \left[ 1 - exp(-B {r'} ^ 2)\right] ^{N_{\text{max}}},
\end{align}
where $B = p \lambda_{\text{agg}} \pi A \theta_{T}^{\frac{2}{\gamma}} e^{\frac{2\sigma^2}{\gamma^2}} $.

The network-level packet loss rate $P_{f,b}$ is obtained by averaging over the infinite plane:
\begin{align}
	\label{eq:bs_best_att_analytical_retransmission}
	P_{f,b} &= \mathbb{E}_{r}\left[ p_{f, b}(r') \right]  \nonumber\\
	&= \int_{0}^{+\infty}  \left[ 1- \exp(-B {r'}^2 ) \right] ^{N} 2 \pi \lambda_b e^{\frac{2\sigma^2}{\gamma^2}}  \exp( -\lambda_b  e^{\frac{2\sigma^2}{\gamma^2}} \pi {r'}^2 ) r' dr' \nonumber\\
	&\overset{\mathclap{\strut\text{(a)}}} =   \sum_{i=0}^{N}\left[ \binom{N}{i} (-1)^i \int_{0}^{+\infty}  \exp(-i B {r'}^2) 2 \pi \lambda_b e^{\frac{2\sigma^2}{\gamma^2}}  \exp( -\lambda_b  e^{\frac{2\sigma^2}{\gamma^2}} \pi {r'}^2 ) r' dr' \right]  \nonumber\\
	&=   \sum_{i=0}^{N}\left[ \binom{N}{i} (-1)^i \frac{1}{iB + \lambda_b  e^{\frac{2\sigma^2}{\gamma^2}} \pi }  \pi \lambda_b e^{\frac{2\sigma^2}{\gamma^2}} \right]  \nonumber\\
	&=   \sum_{i=0}^{N}\left[ \binom{N}{i} (-1)^i \frac{1}{i A \theta_{T}^{\frac{2}{\gamma}} G + 1 } \right],
\end{align}
where step $(a)$ is obtained by using binomial theorem and changing the order of summation and integration.

With a given $L$, network level packet loss level along side with other performance metrics, can be obtained by fixed point iteration method base on $\eqref{eq:relationship_intensity_fresh_agg}$ and $\eqref{eq:bs_best_att_analytical_retransmission}$.
\subsection{Selective Combining based Macro Diversity}
Let $P_{f, m}$ and $p_{f, m}$ respectively be the network packet loss rate and one transmission failure probability. Similar to $\eqref{eq: fail_proba_with_modified_r_retrans}$,  $p_{f, m}$ is allows:
\begin{align}
\label{eq: fail_proba_with_modified_r_retrans_macro_diversity}
p_{f, m}(r')
&= \left[ 1 - exp(-B {r'} ^ 2)\right] ^{N_{\text{max}}},
\end{align}
where $B = p \lambda_{\text{agg}} \pi A \theta_{T}^{\frac{2}{\gamma}} e^{\frac{2\sigma^2}{\gamma^2}} $.
With macro reception diversity, one packet is failed if and only if none of BS has decoded it after $N_{\text{max}}$ trials. Using similar justification in Sec~$\ref{sec:sc_macro_diversity}$, we have:
\begin{align}
\label{eq:definition_pfm_retransmission}
P_{f,m} &= \mathbb{E}\left[  \prod_{r_i \in \Phi_{b}} (1-p_{s}(r_i))^{N_{\text{max}}} \right], \nonumber\\
& = \mathbb{E}\left[  \prod_{r_i \in \Phi_{b}} ( 1 - \exp(-p \lambda_{m} \pi A e^{\frac{2\sigma^2}{\gamma^2}} \theta_{T}^{\frac{2}{\gamma}} r^2 ) )^{N_{\text{max}}} \right], \text{with } r_i \in \left[0, +\infty\right].
\end{align}
where $r_i$ is the modified distance between the device and BS with label $i$. By using Campbell theorem:
\begin{align}
\label{eq:bs_rx_divers_retransmission_analytical_before_last}
P_{f,m} &= \exp\left\lbrace -2\pi \lambda_{b} e^{\frac{2\sigma^2}{\gamma^2}}\int_{0}^{+\infty} \left[  1 - \left( 1-\exp(-Br^2) \right) ^{N_{\text{max}}} \right]  rdr \right\rbrace.
\end{align}
Applying binomial theorem to $\eqref{eq:bs_rx_divers_retransmission_analytical_before_last}$:
\begin{align}
	\label{eq:plr_bs_div_retransmission}
	P_{f,m} &= \exp\left\lbrace -2\pi \lambda_{b} e^{\frac{2\sigma^2}{\gamma^2}}\int_{0}^{+\infty} \left[ -\sum_{i=1}^{N_{\text{max}}} \binom{N}{i} (-1)^i \exp(-iBr^2) \right] rdr \right\rbrace \nonumber\\
	&= \exp\left\lbrace 2\pi \lambda_{b} e^{\frac{2\sigma^2}{\gamma^2}} \sum_{i=1}^{N_{\text{max}}} \int_{0}^{+\infty} \binom{N}{i} (-1)^i \exp(-iBr^2) rdr \right\rbrace \nonumber\\
	&= \exp(\sum_{i=1}^{N_{\text{max}}} \binom{N}{i} (-1)^{i} \frac{1 }{i A \theta^{2\sigma^2/\gamma^2} G })
\end{align}
Similarly, the combination of $\eqref{eq:relationship_intensity_fresh_agg}$ and $\eqref{eq:plr_bs_div_retransmission}$ allows to using fixed point iteration method to calculate the network level packet loss level with a given $L$.


\documentclass{amsart}

\usepackage{amssymb}
\usepackage{amsmath}

\title{Probability: Quiz 2}
\author{Mark Ditsworth}

\begin{document}
	\maketitle
	\section{Problem 1}
	Indicate True of False for each statment.
	\subsection{Part A}
	$X$ and $Y$ are independent random variables. $X$ is uniformly distributed on $[-2,2]$. $Y$ is uniformly distributed on $[-1,5]$. If $Z=X+Y$, then $f_Z(3) = 1/6$.
	\\\\
	\textbf{True}.\\
	This PDF of the sum of two random variables is found through convolution, where $f_Z(z) = \int_{-\infty}^{\infty}f_X(x)f_Y(z-x)~dx$.\\\\
	$f_Z(3) = \int_{-\infty}^{\infty}f_X(x)f_Y(3-x)~dx$\\
	$f_X(x)$ in non-zero only for $x\in[-2,2]$. $f_Y(y)$ is only non-zero for $y\in [-1,5]$, thus $f_Y(3-x)$ is only non-zero for $x\in [-2,4]$. The limits of integration is the union of these two sets: $[-2,2]$.\\
	$f_Z(3) = \int_{-2}^{2}f_X(x)f_Y(3-x)~dx = \left(\frac{1}{6}\right)\left(\frac{1}{4}\right)\left(2+2\right) = \frac{1}{6}$\\
	\subsection{Part B}
	If $X$ is a Gaussian random variable with mean $0$ and variance $1$, then the density function of of $Z=|X|$ is equal to $2f_X(x),z\geq0$.\\
	\\
	\textbf{True}. Since $X$ is symmetric about $0$, $Z=|X|$ means the probability of $-x$ adds to the probability of $x$, causing the $f_Z(z) = 2f_X(z)$ where $z\geq0$.\\
	\subsection{Part C}
	The sum of a random number ($N$) of independent Gaussian random variables with zero mean and unit variance results in a Gaussian random variable, regardless of the distribution of $N$.\\
	\\
	\textbf{False}\\
	For $Y = X_1 + X_2 + \dots + X_N$, the transform of $Y$ can be found as such.\\
	$M_Y(s) = M_N(s)|_{e^s = M_X(s)}$. Let $N$ be Gaussian.\\
	\\
	$M_N(s) = e^{s^2/2}$ and since $X$ is Gaussian, $M_X(s) = e^{s^2/2}$.\\
	\\
	Thus, $M_Y(s) = \sqrt{(e^s)^s}|_{e^s=M_X(s)} = \sqrt{(e^{s^2/2})^s}$, which is clearly not Gaussian.\\
	\subsection{Part D}
	If $X$ and $Y$ are independent random variables, both exponentially distributed with parameters $\lambda_1$ and $\lambda_2$ respectively, then the random variable $Z = \min\{X,Y\}$ is also exponentially distributed.\\
	\\
	\textbf{True}\\
	The CDF $F_Z(z) = P(Z\leq z) = P(\min\{X,Y\}\leq z)$ is not immediately evident, but $1-F_Z(z)$ is.\\
	\[
		1-F_Z(z) = P(Z > z) = P(\min\{X,Y\} > z)
	\]
	\[
		= P(X>z, Y>z) = P(X>z)~P(Y>z)
	\]
	\[
		= \left(1-F_X(z)\right)\left(1-F_Y(z)\right) = \left(1-1+e^{-\lambda_1z}\right)\left(1-1+e^{-\lambda_2z}\right)
	\]
	\[
		1-F_Z(z) = e^{-(\lambda_1 + \lambda_2)z}
	\]
	\[
		f_Z(z) = (\lambda_1+\lambda_2)e^{-(\lambda_1 + \lambda_2)z}
	\]\\
	\subsection{Part E}
	Let the transform associated with random variable $X$ be $M_X(s) = \left(\frac{e^s}{1-s}\right)^{15}$. $\textbf{E}[X]$ is equal to 30.\\
	\\
	\textbf{True}\\
	\[
		\textbf{E}[X] = \frac{d}{ds}M_X(s)|_{s=0} = 15\left(\frac{e^s}{1-s}\right)^{14}\frac{(1-s)e^s + e^s}{(1-s)^2}|_{s=0}
	\]
	\[
		\textbf{E}[X] = 15\left(\frac{1}{1-0}\right)^{14}\frac{(1)(1)+1}{(1-0)^2} = 15~(2) = 30
	\]\\
	\subsection{Part F}
	$X$ and $Y$ are independent random variables. $Y$ is normal with mean 0 and variance 1, $X$ is uniform on $[0,1]$. $Z=X+Y$. The conditional density of $Z$ given $X$, $f_{Z|X}(z|x)$ is normal with mean $x$ and variance 1.\\
	\\
	\textbf{True}\\
	$Z$ given some $x$ is the normal random variable $Y$ plus $x$, $Z|x = Y + x$. Thus, $\textbf{E}[Z|X] = \textbf{E}[Y] + x$ and $\text{Var}(Z|X) = \text{Var}(Y)$.\\
	\subsection{Part G}
	Var($Z$)=2.\\
	\\
	\textbf{False}\\
	Since $X$ and $Y$ are independent, Var($X+Y$)=Var($X$)+Var($Y$)\\So, Var($Z$) = $\frac{1}{12} + 1 \neq 2$.\\
	\subsection{Part H}
	$\textbf{E}[X|Z=-1]=-1$\\
	\\
	\textbf{False}\\
	$X$ is bounded by $[0,1]$, so it cannot take the value of -1.\\
	\subsection{Part I}
	Cov($X$,$Z$) = Var($X$)\\
	\\
	\textbf{True}\\
	\[
		\text{Cov}(X,Z) = \textbf{E}[XZ] - \textbf{E}[X]\textbf{E}[Z]
	\]
	\[
		= \textbf{E}[X(X+Y)] - \textbf{E}[X]\textbf{E}[X+Y]
	\]
	\[
		= \textbf{E}[X^2] + \textbf{E}[XY] - \textbf{E}[X]^2 - \textbf{E}[X]\textbf{E}[Y]
	\]
	\[
		= \textbf{E}[X^2] - \textbf{E}[X]^2 + \textbf{E}[XY] - \textbf{E}[X]\textbf{E}[Y]
	\]
	\[
		= \text{Var}(X) + \text{Cov}(X,Y)
	\]
	And since $X$ and $Y$ are independent, Cov($X$,$Y$)=0, thus Cov($X$,$Z$) = Var($X$)\\
	\subsection{Part J}
	$Z = \textbf{E}[X|Z] + \textbf{E}[Y|Z]$\\
	\\
	\textbf{True}\\
	$\textbf{E}[Z|Z] = \textbf{E}[X+Y|Z]$ and since conditional expectation is linear, $\textbf{E}[Z|Z] = Z = \textbf{E}[X|Z] + \textbf{E}[Y|Z]$
	\pagebreak
	\section{Problem 2}
	\subsection{Part A}
	Find the least squares estimate of $Y$ given $X=x$, for all possible values of $x$.\\
	\\
	\[
	\mathbf{E}[Y|X] =
	\begin{cases}
	\frac{1}{2} & 0 \leq X < 1\\
	X-\frac{1}{2} & 1 \leq X \leq 2
	\end{cases}
	\]
	\\
	\subsection{Part B}
	Let $g(x)$ be the estimate from Part A. Find $\mathbf{E}[g(X)]$ and Var$(g(X))$.\\
	\\
	\[
	\mathbf{E}[g(X)] = \int_{0}^{2}g(x)f_X(x)~dx =
	\frac{1}{2}\left(
	\int_{0}^{1}\frac{1}{2}~dx + \int_{1}^{2}x-\frac{1}{2}~dx
	\right)
	\]
	\[
	\mathbf{E}[g(X)] = \frac{1}{2}\left(
	\frac{1}{2} + 1 - 0
	\right) = \frac{3}{4}
	\]
	\[
	\mathbf{E}[g(X)^2] = \int_{0}^{2} g(x)^2f_X(x)~dx=
	\frac{1}{2}\left(
	\frac{1}{4} + \int_{1}^{2}(x-\frac{1}{2})^2~dx
	\right) = \frac{1}{2}(\frac{1}{4}+\frac{13}{12}) = \frac{2}{3}
	\]
	\[
	\text{Var}(g(X)) = \mathbf{E}[g(X)^2] - \mathbf{E}[g(X)]^2 = \frac{2}{3} - \frac{9}{16} = \frac{5}{48} \approx 0.1042
	\]
	\subsection{Part C}
	Find the mean squared error $\mathbf{E}[(Y-g(X))^2]$. Is it the same as $\mathbf{E}[\text{var}(Y|X)]$?\\
	\\
	Since $g(X)=\mathbf{E}[Y|X]$,
	\[
	\mathbf{E}[(Y-g(X))^2] = \mathbf{E}[(Y-\mathbf{E}[Y|X])^2]=
	\mathbf{E}[\mathbf{E}[(Y-\mathbf{E}[Y|X])^2|X]]
	\]
	\[
	= \mathbf{E}[\mathbf{E}[(Y|X-\mathbf{E}[Y|X])^2]]=
	\mathbf{E}[\text{Var}(Y|X)]
	\]
	Since $Y$ is uniform for all $X$, $\text{Var}(Y|X) = \frac{1}{12}(Y_1+1-Y_1)^2 = \frac{1}{12}$, $0\leq X\leq2$\\
	$\mathbf{E}[\text{Var}(Y|X)] = \frac{1}{2}\int_{0}^{2} \frac{1}{12}~dx = \frac{1}{12}$
	\pagebreak
	\section{Problem 3}
	Each year, an editor is sent a random number of books for review. The number of books received can be modeled as a Poisson random variable \textit{N} with mean $\mu$. Each book contains a random number of typos, modeled by a Poisson random variable with mean $\lambda$. Let $B_i$ denote the number of typos in book $i$. Assume all random variables are independent. The editor finds typos with probability $p$, independent of all other findings, and other random variables.

	There are two different payment options:

	\textbf{Option 1.} \$1 for each typo found

	\textbf{Option 2.} \$1 for each book where at least 1 typo is found

	Let $X_i$ be the amount of money the editor receives for book $i$ and $T$ the total amount of money the editor receives in a year.
	\subsection{Part A}
	The the PMF of $X_i$ under option 1.\\
	\\
	The PMF of $X_i$ under option 1 is the PMF of the number of typos in book $i$. For each typo is book $i$, the editor has a $p$ probability of catching it. Thus, the PMF is a binomial distribution with the number of trials the random variable of $B_i$.\\
	\[
	\mathbf{P}(X_i=x|B_i=b) = \binom{b}{x}p^x(1-p)^{b-x}
	\]
	Since $X_i$ and $B_i$ are independent,
	\[
	\mathbf{P}(X_i=x) = \sum_{b=x}^{\infty}\mathbf{P}(X_i=x|B_i=b)\mathbf{P}(B_i=b)
	\]
	\[
	\mathbf{P}(X_i=x) = \sum_{b=x}^{\infty}\binom{b}{x}p^x(1-p)^{b-x} \frac{\lambda e^{-\lambda}}{b!}
	\]
	\[
	\mathbf{P}(X_i=x) =
	\frac{(p\lambda)^x}{x!}e^{-\lambda}\sum_{b=0}^{\infty}
	\frac{(\lambda(1-p))^b}{b!} = \frac{(p\lambda)^x}{x!}e^{-p\lambda}
	\]
	This is a Poisson PMF with mean $p\lambda$.
	\\
	\subsection{Part B}
	Find $M_T(s)$ under option 1.\\
	\\
	$T = X_1 + X_2 + \dots X_N$. Thus, $M_T(s) = M_N(s)|_{e^s=M_X(s)}$
	\[
	M_N(s) = e^{\mu(e^s-1)} \qquad M_X(s) = e^{p\lambda(e^s-1)}
	\]
	\[
	M_T(s) = e^{\mu\left(e^{p\lambda(e^s-1)}-1\right)}
	\]
	\\
	\subsection{Part C}
	Find \textbf{P}$(T=2)$ under option 2.\\
	\\
	Since $T$ is a discrete random variable, we can find probabilities through differentiation of $M_T(s)$ as  such:
	\[
	\mathbf{P}(T=t) = \frac{1}{t!}\frac{d^t}{d(e^s)^t}M(s)|_{e^s=0}
	\]
	\[
	\mathbf{P}(T=2) = \frac{1}{2}\frac{d^2}{d(e^s)^2}M_T(s)|_{e^s=0}
	\]
	\[
	= \left[\frac{\mu p\lambda}{2}\exp\{\mu e^{p\lambda(e^s-1)-\mu+p\lambda e^s - p\lambda}\left(\mu p\lambda e^{p\lambda(e^s-1)}+p\lambda\right)
	\right]|_{e^s=0}
	\]
	\[
	\mathbf{P}(T=2) = \frac{1}{2}\mu(p\lambda)^2 e^{-p\lambda}e^{\mu(e^{-p\lambda -1})}\left(\mu e^{-p\lambda}+1\right)
	\]
	\\
	\subsection{Part D}
	Find $\mathbf{E}[T]$.\\
	\\
	\[
	\mathbf{E}[T] = \frac{d}{ds}M_T(s)|_{s=0} = e^{\mu\left(e^{p\lambda(e^s-1)}-1\right)}\mu e^{p\lambda(e^s-1)}p\lambda e^s|_(s=0)
	\]
	\[
	\mathbf{E}[T] = \mu p\lambda
	\]
	\\
	\subsection{Part E}
	Find Var($T$).\\
	\\
	\[
	\text{Var}(T) = \mathbf{E}[T^2]-\mathbf{E}[T]^2
	\]
	\[
	\mathbf{E}[T^2] = \frac{d^2}{ds^2}M_T(s)|_{s=0}
	= (\mu p\lambda)^2 + \mu(p\lambda)^2 + \mu p\lambda
	\]
	\[
	\text{Var}(T) = (\mu p\lambda)^2 + \mu(p\lambda)^2 + \mu p\lambda - (\mu p\lambda)^2 = \mu p\lambda(p\lambda + 1)
	\]
	\\
	\subsection{Part F}
	Find the PMF of $X_i$ under option 2.\\
	\\
	Under option 2, $X_i = 1$ if at least 1 typo is found in book $i$, and 0 otherwise (Binomial distribution). From Part A, we see that the  number of found typos is book $i$ is a Poisson random variable with mean $p \lambda$. Thus, the probability that $X_i=0$ is $e^{-p \lambda}$. The full PMF is:
	\[
	X_i =
	\begin{cases}
		e^{-p\lambda} & x=0\\
		1-e^{-p\lambda} &x=1\\
		0 & \text{otherwise}
	\end{cases}
	\]
	\\
	\subsection{Part G}
	Find $\mathbf{E}[T]$ under option 2.\\
	\\
	Each book viewed by the editor, there is a $\rho$ probability that he or she will get a dollar for the book. There are $N$ number of attempts ate getting dollars. Thus, $T$ has a binomial distribution with the number of trials being a Poisson random variable. Following a similar procedure as Part A:
	\[
		\mathbf{P}(T=t) = \sum_{n=t}^{N}\binom{n}{t}\rho^t(1-\rho)^{n-t}\frac{\mu^n}{n!}e^{-\mu} = \frac{(\mu\rho)^t}{t!}e^{-\mu\rho}
	\]
	This is a Poisson distribution with mean $\mu\rho$. From Part G, we saw that the probability $\rho$ of receiving a dollar for book $i$ is $1-e^{-p\lambda}$. Therefore, we have:
	\[
	\mathbf{E}[T] = \mu\rho = \mu(1-e^{-p\lambda})
	\]
	\\
	\subsection{Part H}
	Which option should the editor choose?\\
	\\
	We will answer this by finding the option with the highest expected value for $T$. Under option 1, $\mathbf{E}[T] = \mu p\lambda$. Under option 2, $\mathbf{E}[T] = \mu(1-e^{-p\lambda})$.

	Both $\mu$ and $\lambda$ are out of the editor's control. But $p$ is determined by the editor's skill in spotting typos. As $p$ increases towards 1, the expected yearly payout under option 1 grows linearly towards $\mu\lambda$. Whereas under option 2 it is bounded above by $\mu(1-e^{-\lambda})$. Note that $1-e^{-\lambda}$ grows sub-linearly, so $\mu\lambda$ will always be greater than $\mu(1-e^{-\lambda})$.

	Therefore, option 1 will result in the highest expected value of $T$.
\end{document}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
%     This file is included from the file   Segmentation.tex
%
%     Section tag and label are placed in this top file.
%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\itkpiccaption[Zero Set Concept]{Concept of zero set in a level set.\label{fig:LevelSetZeroSet}}
\parpic(9cm,6cm)[r]{\includegraphics[width=8cm]{LevelSetZeroSet.eps}}

The paradigm of the level set is that it is a numerical method for tracking
the evolution of contours and surfaces. Instead of manipulating the contour
directly, the contour is embedded as the zero level set of a higher
dimensional function called the level-set function, $\psi(\bf{X},t)$. The
level-set function is then evolved under the control of a differential
equation.  At any time, the evolving contour can be obtained by extracting
the zero level-set $\Gamma(\bf(X),t) =
\{\psi(\bf{X},t) = 0\}$ from the output.  The main advantages of using level
sets is that arbitrarily complex shapes can be modeled and topological
changes such as merging and splitting are handled implicitly.

Level sets can be used for image segmentation by using image-based features
such as mean intensity, gradient and edges in the governing differential
equation.  In a typical approach, a contour is initialized by a user and is
then evolved until it fits the form of an object in the image.
Many different implementations and variants of this basic concept have been
published in the literature. An overview of the field has been made by
Sethian \cite{Sethian1996}.

The following sections introduce practical examples of some
of the level set segmentation methods available in ITK.  The remainder of this
section describes features common to all of these filters except the
\doxygen{itk}{FastMarchingImageFilter}, which is derived from a different code
framework.  Understanding these features will aid in using the filters
more effectively.

Each filter makes use of a generic level-set equation to compute the update to
the solution $\psi$ of the partial differential equation.

\begin{equation}
\label{eqn:LevelSetEquation}
\frac{d}{dt}\psi = -\alpha \mathbf{A}(\mathbf{x})\cdot\nabla\psi - \beta
  P(\mathbf{x})\mid\nabla\psi\mid +
\gamma Z(\mathbf{x})\kappa\mid\nabla\psi\mid
\end{equation}

where $\mathbf{A}$ is an advection term, $P$ is a propagation (expansion) term,
and $Z$ is a spatial modifier term for the mean curvature $\kappa$.  The scalar
constants $\alpha$, $\beta$, and $\gamma$ weight the relative influence of
each of the terms on the movement of the interface.  A segmentation filter may
use all of these terms in its calculations, or it may omit one or more terms.
If a term is left out of the equation, then setting the corresponding scalar
constant weighting will have no effect.

All of the level-set based segmentation filters \emph{must} operate with
floating point precision to produce valid results.  The third, optional
template parameter is the \emph{numerical type} used for calculations and as
the output image pixel type.  The numerical type is \code{float} by default,
but can be changed to \code{double} for extra precision.  A user-defined,
signed floating point type that defines all of the necessary arithmetic
operators and has sufficient precision is also a valid choice.  You should
not use types such as \code{int} or \code{unsigned char} for the numerical
parameter.  If the input image pixel types do not match the numerical type,
those inputs will be cast to an image of appropriate type when the filter is
executed.

Most filters require two images as input, an initial model $\psi(\bf{X},
t=0)$, and a \emph{feature image}, which is either the image you wish to
segment or some preprocessed version.  You must specify the isovalue that
represents the surface $\Gamma$ in your initial model. The single image
output of each filter is the function $\psi$ at the final time step.  It is
important to note that the contour representing the surface $\Gamma$ is the
zero level-set of the output image, and not the isovalue you specified for
the initial model.  To represent $\Gamma$ using the original isovalue, simply
add that value back to the output.

The solution $\Gamma$ is calculated to subpixel precision.  The best discrete
approximation of the surface is therefore the set of grid positions closest to
the zero-crossings in the image, as shown in
Figure~\ref{fig:LevelSetSegmentationFigure1}.  The
\doxygen{itk}{ZeroCrossingImageFilter} operates by finding exactly those grid
positions and can be used to extract the surface.

\begin{figure}
\centering
\includegraphics[width=0.4\textwidth]{LevelSetSegmentationFigure1.eps}
\itkcaption[Grid position of the embedded level-set surface.]{The implicit level
set surface $\Gamma$ is the black line superimposed over the image grid.  The location
of the surface is interpolated by the image pixel values.  The grid pixels
closest to the implicit surface are shown in gray. }
\protect\label{fig:LevelSetSegmentationFigure1}
\end{figure}

There are two important considerations when analyzing the processing time for
any particular level-set segmentation task: the surface area of the evolving
interface and the total distance that the surface must travel.  Because the
level-set equations are usually solved only at pixels near the surface (fast
marching methods are an exception), the time taken at each iteration depends on
the number of points on the surface.  This means that as the surface grows, the
solver will slow down proportionally.  Because the surface must evolve slowly
to prevent numerical instabilities in the solution, the distance the surface
must travel in the image dictates the total number of iterations required.

Some level-set techniques are relatively insensitive to initial conditions
and are therefore suitable for region-growing segmentation. Other techniques,
such as the \doxygen{itk}{LaplacianSegmentationLevelSetImageFilter}, can easily
become ``stuck'' on image features close to their initialization and should
be used only when a reasonable prior segmentation is available as the
initialization.  For best efficiency, your initial model of the surface
should be the best guess possible for the solution.

\subsection{Fast Marching Segmentation}
\label{sec:FastMarchingImageFilter}

\ifitkFullVersion
\input{FastMarchingImageFilter.tex}
\fi

%% \subsection{Shape Detection Segmentation}
%% \label{sec:ShapeDetectionLevelSetFilter}

%% \ifitkFullVersion
%% \input{ShapeDetectionLevelSetFilter.tex}
%% \fi

%% \subsection{Geodesic Active Contours Segmentation}
%% \label{sec:GeodesicActiveContourImageFilter}

%% \ifitkFullVersion
%% \input{GeodesicActiveContourImageFilter.tex}
%% \fi

%% \subsection{Threshold Level Set Segmentation}
%% \label{sec:ThresholdSegmentationLevelSetImageFilter}
%% \ifitkFullVersion
%% \input{ThresholdSegmentationLevelSetImageFilter.tex}
%% \fi

%% \subsection{Canny-Edge Level Set Segmentation}
%% \label{sec:CannySegmentationLevelSetImageFilter}
%% \ifitkFullVersion
%% \input{CannySegmentationLevelSetImageFilter.tex}
%% \fi

%% \subsection{Laplacian Level Set Segmentation}
%% \label{sec:LaplacianSegmentationLevelSetImageFilter}
%% \ifitkFullVersion
%% \input{LaplacianSegmentationLevelSetImageFilter.tex}
%% \fi

%% \subsection{Geodesic Active Contours Segmentation With Shape Guidance}
%% \label{sec:GeodesicActiveContourShapePriorLevelSetImageFilter}
%% \ifitkFullVersion
%% \input{GeodesicActiveContourShapePriorLevelSetImageFilter.tex}
%% \fi


\chapter{Kinematics}\label{CrossSectionApp}

Consider the process
\bel{csProcess}
f_1(\pa, \ra), f_2(\pb, \rb) \rightarrow f'_1(\ppa, \rpa), f'_2(\ppb, \rpb),
\ee
where
$f_{1, 2}$, $f'_{1, 2}$ are some fermions,
$\pa$, $\ra$, $\pb$, $\rb$ denote the momenta and
spin polarization states of the incoming particles
and the "prime" versions are used for the outgoing ones. The particle momenta
satisfy the on-shell conditions,
\be
\pa^2 = \ma^2, \quad  \pb^2 = \mb^2,
\quad
\ppa^2 = \mpa^2, \quad  \ppb^2 = \mpb^2,
\ee

\P
The amplitude is given by
the $S$-matrix element that has the following general structure,
\beml{csSis}
S(f_1, f_2 \rightarrow f'_1, f'_2)
& = &
-i (2\pi)^{4}
\left(\frac{\ma\mb\mpa\mpb}{\Ea\Eb\Epa\Epb}\right)^{\frac{1}{2}}
\delta(\ppa + \ppb - \pa - \pb)

\nel &&{}\times
 M(\pa, \ra, \pb, \rb, \ppa, \rpa, \ppb, \rpb).
\ee

Here $M$ is some smooth Lorentz-invariant function of momenta and spins
(Feynman amplitude) and $E$ is defined through
\be
    E^2 = \absp^2 + m^2.
\ee

The Dirac delta-function in \rf{csSis} reflects the 4-momentum conservation
in the process \rf{csProcess},
\bel{cs-conservation-law}
\pa + \pb \; = \; \ppa +\ppb,
\ee

\P
The center-of-mass unpolarized differential cross section is according
to~\cite{SMTextBook} given by
\bel{cs-cross1}
\left({d\sigma \over d\Omega}\right)_{\rm c.m.}
\; = \;{1 \over 4 \pi^2 (\Ea + \Eb)^2}{\abspp\over \absp}
\ma\mb\mpa\mpb \, X(\pa, \pb, \ppa, \ppb),
\ee

with
\bel{cs1}
X(\pa, \pb, \ppa, \ppb) \; = \; {1 \over 4}\sum_\ra\sum_\rb\sum_\rpa\sum_\rpb
   M^\dagger(\ra, \rb, \rpa, \rpb) M(\ra, \rb, \rpa, \rpb),
\ee

where $E$, $E'$, $\vecp$ and $\vecpp$ are
the energies and 3-momenta of the
incoming and outgoing particles in the center-of-mass frame,

\be
\pa|_{\rm c.m} = (\Ea, \vecp),
\quad
\pb|_{\rm c.m}  = (\Eb, -\vecp),
\quad
\ppa|_{\rm c.m} = (\Epa, \vecpp),
\quad
\ppb|_{\rm c.m} = (\Epb, -\vecpp).
\ee

To rewrite the cross section in an explicitly Lorentz-invariant form
I express it through the total momentum squared $s$ and two other
kinematic invariants $t$ and $u$,
\be
s = (\pa + \pb)^2 =  (\ppa + \ppb)^2,
\ee
\be
t = (\ppa - \pa)^2 =  (\pb - \ppb)^2,
\ee
\be
u = (\ppb - \pa)^2 =  (\pb - \ppa)^2.
\ee

These Lorentz scalars are related by the identity
\bem
s + t + u & = & (\pa + \pb)^2 + (\ppa - \pa)^2 + (\ppb - \pa)^2
\nel
& = & \ma^2 + \mb^2 + \mpa^2 + \ma^2 + \mpb^2 + \ma^2
\nel
&&{}  + 2(\pa \cdot \pb) - 2(\pa \cdot \ppa) - 2(\pa \cdot \ppb)
\nel
& = & 3\ma^2 + \mb^2 + \mpa^2 + \mpb^2
  + 2\pa \cdot(\pb - \ppa -  \ppb)
\nel
& = & 3\ma^2 + \mb^2 + \mpa^2 + \mpb^2
  - 2(\pa \cdot \pa)
\ee
or
\bel{sum-s-t-u}
s + t + u = \ma^2 + \mb^2 + \mpa^2 + \mpb^2 .
\ee

In the c.m. frame $s$ may be written as
\be
s = (\Ea + \Eb)^2 - (\vecp - \vecp)^2 = (\Ea + \Eb)^2
.
\ee

To get an expression for the c.m. momentum $\absp$ I proceed
as following,
\be
(\pa \cdot \pb) = (\pa \cdot \pb)|_{\rm c.m} = \Ea\Eb + \absp^2
= \sqrt{\ma^2 + \absp^2}\sqrt{\mb^2 + \absp^2}
    + \absp^2
    .
\ee

Squaring, I find
\bem
(\ma^2 + \abs{\vec{p}}^2)(\mb^2 + \absp^2)
 & = &
[(\pa \cdot \pb) - \absp^2]^2,
\nel
\absp^2(\ma^2 + \mb^2) + \ma^2\mb^2
& = &
(\pa \cdot \pb)^2 - 2(\pa \cdot \pb)\absp^2,
\nel
(\pa \cdot \pb)^2 - \ma^2\mb^2
&=& \absp^2[\ma^2 + \mb^2 + 2 (\pa \cdot \pb)]
,
\ee
or
\be
(\pa \cdot \pb)^2 - \ma^2\mb^2 \;=\; \absp^2(\pa + \pb)^2 \;=\; s\absp^2
.
\ee

Thus
\be
\absp^2
={1 \over s}[(\pa \cdot \pb)^2 - \ma^2\mb^2]
={1 \over 4s}\{[2(\pa \cdot \pb)]^2 - [2\ma\mb]^2\}.
\ee

Furthermore,

\bem
\lefteqn{
[2(\pa \cdot \pb)]^2 - [2\ma\mb]^2 \; = \; (s - \ma^2 - \mb^2)^2 - [2\ma\mb]^2
}
\nel
&=& (s - \ma^2 - \mb^2 - 2\ma\mb)(s - \ma^2 - \mb^2 + 2\ma\mb)
\nel
&=& [s - (\ma + \mb)^2][s - (\ma - \mb)^2]
.
\ee

So
\bel{cs-abs-p-squared}
\absp^2   =
{1 \over 4s} [s - (\ma + \mb)^2][s - (\ma - \mb)^2]
.
\ee

In the same way I find
\bel{cs-abs-pp-squared}
\abspp^2  =
{1 \over 4s} [s - (\mpa + \mpb)^2][s - (\mpa - \mpb)^2],
\ee
and thus
\bel{cs-pp-over-p}
{\abspp\over \absp}
= \sqrt{[s - (\mpa + \mpb)^2][s - (\mpa - \mpb)^2] \over
        [s - (\ma + \mb)^2][s - (\ma - \mb)^2]}
.
\ee

\P

To be Lorentz-invariant, the quantity $X$ can depend on the particle momenta
only through scalar products of different $p$. With
\beml{cs-t-explicit}
t    & = & (\ppa - \pa)^2 = \mpa^2 + \ma^2 - 2(\ppa \cdot \pa)
\nel & = & (\pb - \ppb)^2 = \mb^2 + \mpb^2 - 2(\pb \cdot \ppb)
,
\ee

\beml{cs-u-explicit}
u    & = & (\ppb - \pa)^2 = \mpb^2 + \ma^2 - 2(\ppb \cdot \pa)
\nel & = & (\pb - \ppa)^2 = \mb^2 + \mpa^2 - 2(\pb \cdot \ppa)
,
\ee

all such products are given by
\begin{eqnarray}\label{cs-scalar-products-1}
(\pa \cdot \pb) & = &{1 \over 2} (s - \ma^2 - \mb^2),
\\
(\ppa \cdot \ppb) & = & {1 \over 2} (s - \mpa^2 - \mpb^2),
\\
(\ppa \cdot \pa) & = & {1 \over 2} (\mpa^2 + \ma^2 - t),
\\
(\ppb \cdot \pa) & =& {1 \over 2} (\mpb^2 + \ma^2 - u)
\nel &=&
{1 \over 2} [\mpb^2 + \ma^2 - (\mpa^2 + \ma^2 + \mpb^2 + \mb^2 - s - t)]
\nel &=&
{1 \over 2} (s + t - \mpa^2 - \mb^2),
\\
(\ppa \cdot \pb) &=& {1 \over 2} (\mpa^2 + \mb^2 - u)
= {1 \over 2} (s + t - \mpb^2 - \ma^2) ,
\\
(\ppb \cdot \pb)
&=& {1 \over 2} (\mpb^2 + \mb^2 - t)
= {1 \over 2} (s + u - \mpa^2 - \ma^2)
.
\label{cs-scalar-products-2}
\end{eqnarray}

Thus $X(\pa,\pb,\ppa,\ppb)$ may be viewed as a function of $s$ and $t$,
\bel{cs-X-of-s-t}
X = X(s, t).
\ee

\P
The variable $t$ can be expressed via the center-of-mass frame
scattering angle $\theta$ defined by
$\vecpa\cdot\vecppa = \vecp\cdot\vecpp = \absp\abspp\cos\theta$,

\be
(\ppa \cdot \pa) = (\ppa \cdot \pa)|_{\rm c.m} = \Epa\Ea -  \vecpa\cdot\vecppa
= \Epa\Ea -  \absp\abspp\cos\theta
.
\ee
Thus
\be
{1 \over 2} (\ma^2 + \mpa^2 - t)
  = \Epa\Ea -  \absp\abspp\cos\theta,
\ee
and
\bel{cs-t-of-theta}
t =   2\absp\abspp\cos\theta - t_0,
\ee
where I defined
\bel{cs-tmp-t0-is}
t_0 = 2\Epa\Ea  - (\ma^2 + \mpa^2)
.
\ee

To calculate $2\Epa\Ea$ in~\rf{cs-tmp-t0-is} I use~\rf{cs-abs-p-squared}
and~\rf{cs-abs-pp-squared}  to express
$\Ea$ and $\Epa$,
\bem
\Ea^2 & = & \absp^2 + \ma^2 =
{1 \over 4s} [s - (\ma + \mb)^2][s - (\ma - \mb)^2]  + \ma^2,
\nel
4s\Ea^2 &=& s^2 + s [4\ma^2 - (\ma + \mb)^2 - (\ma - \mb)^2]
+ (\ma^2 - \mb^2)^2
\nel
& = & s^2 + 2 s (\ma^2 -\mb^2) + (\ma^2 - \mb^2)^2
= (s + \ma^2 -\mb^2)^2
.
\ee
So
\be
\Ea^2 = {1 \over 4s}(s + \ma^2 -\mb^2)^2,
\ee
and similarly
\be
\Epa^2 = {1 \over 4s}(s + \mpa^2 -\mpb^2)^2.
\ee

Taking the square roots I find
\be
2\Epa\Ea = {1 \over 2s}(s + \mpa^2 -\mpb^2)(s + \ma^2 -\mb^2).
\ee

It gives
\beml{cs-t0-is}
t_0 & = &  {1 \over 2s}(s + \mpa^2 -\mpb^2)(s + \ma^2 -\mb^2) - \ma^2 - \mpa^2
\nel
&=& {1 \over 2s}
\{s^2 + s[-2(\ma^2 + \mpa^2) + (\ma^2 - \mb^2) + (\mpa^2 -\mpb^2)]
\nel && \qquad{}
   + (\mpa^2 -\mpb^2)(\ma^2 -\mb^2)\}
\nel &=&
{1 \over 2s}[s^2 - s(\ma^2 + \mpa^2 + \mb^2 + \mpb^2)
   + (\mpa^2 -\mpb^2)(\ma^2 -\mb^2)].
\nel
\ee

Now I may write for the c.m. differential cross-section~\rf{cs-cross1}
\bel{cs-cross2}
\left({d\sigma \over d\Omega}\right)_{\rm c.m.}
\; = \; {d\sigma(s, t(\theta)) \over d\Omega}
\; = \;{1 \over 4 \pi^2 s}{\abspp\over \absp}
\ma\mb\mpa\mpb \, X(s, t).
\ee

Then for the total cross-section for the process \rf{csProcess}, defined by
\be
\sigma_T(s) =
\int {d\sigma \over d\Omega} d\Omega
= \int {d\sigma \over d\Omega} \sin\theta d\theta d\phi
,
\ee

I have
\bel{cs-cross3}
\sigma_T(s) =
\int {d\sigma(s, t(\theta)) \over d\Omega} \sin\theta d\theta d\phi
 = 2\pi \int_{-1}^1 {d\sigma(s, t(\theta)) \over d\Omega} d(\cos\theta) .
\ee

From~\rf{cs-t-of-theta} I find
\be
d(\cos\theta) = {dt \over 2\absp\abspp}
.
\ee

Thus
\bem
\sigma_T(s)
& = & {\pi \over \absp\abspp} \int_{t_-}^{t_+}
\left({d\sigma \over d\Omega}\right)_{\rm c.m.} dt
\nel
& = &
{\ma\mb\mpa\mpb \over 4 \pi^2 s}{\abspp\over \absp}
{\pi \over \absp\abspp} \int_{t_-}^{t_+} X(s, t) dt ,
\nel
& = &{\ma\mb\mpa\mpb \over 4 \pi s \absp^2}
 \int_{t_-}^{t_+} X(s, t) \, dt
 ,
\ee
where $t_{\pm}$ are given by
\be
t_{\pm} = t\left|_{\cos\theta = \pm 1}\right. = \pm 2\absp\abspp - t_0
.
\ee

\P
In the case when
\bel{cs-ultra-approximation}
\mpa = \mpb = m' \gg \ma = \mb = m, \quad s \ge 4m'^2 \gg m^2
\ee

the kinematic relations of this appendix can be simplified.
To write the formulas
in a compact form I introduce the dimension-less quantity $\rho$,
\bel{csRhoIs}
\rho = {m'^2 \over s},
\quad \rho \le {1 \over 4}.
\ee

With this notation I have according
to~\rf{cs-abs-p-squared}--\rf{cs-pp-over-p}
\be
\absp^2 =
{s \over 4} - m^2 \approx {s \over 4},
\qquad
\abspp^2 = {s \over 4}(1 - 4\rho),
\ee
\be
{\abspp \over \absp}
\approx \sqrt{1 - 4\rho},
\qquad
\abspp \absp = {\abspp \over \absp} \absp^2 =
{s \over 4}\sqrt{1 - 4\rho}
.
\ee

So under this approximation $t_\pm$ becomes
\bel{cs-tmp-t-pm-approximation}
t_{\pm} \approx \pm {s \over 2}\sqrt{1 - 4\rho} - t_0
\approx \pm{s \over 2}\sqrt{1 - 4\rho} - {1 \over 2}(s - 2m'^2)
= {s \over 2} (2\rho - 1 \pm \sqrt{1 - 4\rho}).
\ee

The scalar products in~\rf{cs-scalar-products-1}--\rf{cs-scalar-products-2}
now read
\be
(\pa \cdot \pb) \approx {s \over 2},
\qquad
(\ppa \cdot \ppb) = {s \over 2}(1 - 2\rho),
\ee

\beml{csKinApproximation}
(\ppa \cdot \pa) = (\ppb \cdot \pb) & \approx & {m'^2 - t \over 2},
\nel
(\ppb \cdot \pa) = (\ppa \cdot \pb) & \approx & {m'^2 - u \over 2}
\approx {s + t - m'^2 \over 2},
\ee

and the cross sections~\rf{cs-cross2}and~\rf{cs-cross3} are given by

\bel{cs-tmp-dif-approximation}
\left({d\sigma \over d\Omega}\right)_{\mbox{c.m.}}
\approx
{m^2 m'^2  \over 4\pi^2 s} \sqrt{1 - 4\rho}\, X(s, t)
,
\ee

\bel{cs-tmp-total-approximation}
\sigma_T(s)
\approx {m^2 m'^2 \over \pi s^2} \int_{t_-}^{t_+} X(s, t) \, dt
.
\ee

\P
I next present several useful results and find typical integrals
that occur during calculations
of the total cross section under the approximation~\rf{cs-ultra-approximation}:

\bem
\lefteqn{
(\qpb \cdot \qa) (\qpa \cdot \qb) + (\qpb \cdot \qb) (\qpa \cdot \qa)
}
\nel
& \equiv &
{1 \over \ma\mb\mpa\mpb}
[(\ppb \cdot \pa) (\ppa \cdot \pb) + (\ppb \cdot \pb) (\ppa \cdot \pa)]
\nel
& = & {1 \over m^2m'^2}
[(\ppb \cdot \pa)^2 + (\ppa \cdot \pa)^2]
\approx {1 \over 4m^2m'^2}[(s + t - m'^2)^2 + (m'^2 - t)^2]
\nel & = &
{1 \over 4m^2m'^2}[(m'^2 - t)^2 -2s(m'^2 - t) + s^2 + (m'^2 - t)^2],
\ee
or
\bel{cs-4q-sum}
(\qpb \cdot \qa) (\qpa \cdot \qb) + (\qpb \cdot \qb) (\qpa \cdot \qa)
\approx {2(m'^2 - t)^2 + s(s + 2t - 2m'^2) \over 4m^2m'^2}
.
\ee

Through similar steps I have
\beml{cs-4q-sub}
\lefteqn{
(\qpb \cdot \qa) (\qpa \cdot \qb) - (\qpb \cdot \qb) (\qpa \cdot \qa)
}
\nel
& \equiv &
{1 \over \ma\mb\mpa\mpb}
[(\ppb \cdot \pa) (\ppa \cdot \pb) - (\ppb \cdot \pb) (\ppa \cdot \pa)]
\nel
& \approx & {1 \over 4m^2m'^2}[(s + t - m'^2)^2 - (m'^2 - t)^2],
\nel
& \approx & {s \over 4m^2m'^2}(s + 2t - 2m'^2)
.
\ee

The direct consequences of~\rf{cs-tmp-t-pm-approximation} are
\beml{cs-t-pm-pm}
t_+ - t_- & \approx & s\sqrt{1 - 4\rho},
\nel
t_+ + t_- & \approx & s(2\rho - 1),
\nel
t_+ t_- & \approx &
{s^2 \over 4} (2\rho - 1 + \sqrt{1 - 4\rho})(2\rho - 1 - \sqrt{1 - 4\rho})
\nel
&=& {s^2 \over 4} [(2\rho - 1)^2 - (1 - 4\rho)]
= s^2\rho^2
.
\ee

Thus from the definition of $\rho$~\rf{csRhoIs}
\bel{cs-t-pm-mul}
t_+ t_- \approx  m'^4
.
\ee

\P
In the following integrals I assume that
$x$ and $z$ are complex numbers and $r$ is real.

\beml{cs-int-1}
\int_{t_-}^{t_+} (2m'^2 - 2t - s) dt
& = & (t_+ - t_-)(2m'^2 - s) - (t_+^2 - t_-^2)
\nel
& = &
(t_+ - t_-)(2m'^2 - s -t_+ - t_-)
\nel
& = & (t_+ - t_-)[s(2\rho - 1) -t_+ - t_-]
\nel
& \approx & 0,
\ee
where~\rf{cs-t-pm-pm} was used. Next

\bem
\int_{t_-}^{t_+} (m'^2 - t)^2 dt
&=&\int_{t_-}^{t_+} (m'^4 - 2 m'^2t + t^2) dt
\nel
& = &
m'^4(t_+ - t_-) - m'^2(t_+^2 - t_-^2) + {1 \over 3}(t_+^3 - t_-^3)
\nel
& = &
(t_+ - t_-)\{m'^4 - m'^2(t_+ + t_-) + {1 \over 3}[(t_+ + t_-)^2 - t_+t_-]\}.
\ee

At this point, according to~\rf{cs-t-pm-pm}--\rf{cs-t-pm-mul} I can
write the approximation
\beml{cs-int-2}
\int_{t_-}^{t_+} (m'^2 - t)^2 dt
& \approx &
s\sqrt{1 - 4\rho}\{m'^4 - m'^2(2m'^2 - s)
   + {1 \over 3}[(2m'^2 - s)^2 - m'^4]\}
\nel
& = &
s\sqrt{1 - 4\rho}\,[m'^4(1 - 2 + 1) + m'^2s(1 -4/3) + s^2/3]
\nel
& = &
s\sqrt{1 - 4\rho}[s^2/3 - m'^2s/3]
\nel
& = & {s^3 \over 3} (1 - \rho)\sqrt{1 - 4\rho}\,
.
\ee

I shall also need the integral
\be
\int_{t_-}^{t_+} \Re\left({z \over t - x}\right) dt
\ee
for value of $x$ such that no pole is encountered,

\bel{csIntTmp3}
\int_{t_-}^{t_+} \Re\left({z \over t - x}\right) dt
\;=\; \int_{t_- - x}^{t_+ - x} \Re\left({z \over t}\right) dt
\;=\;  \Re\left(z\ln{t_+ - x \over t_- - x}\right)
.
\ee

To simplify the last expression I use,
\begin{eqnarray}
\Re(z_1 z_2) &=& \Re(z_1)\Re(z_2) - \Im(z_1)\Im(z_2),
\\
\label{cs-Im-z1-z2}
\Im(z_1 z_2) &=& \Re(z_1)\Im(z_2) + \Im(z_1)\Re(z_2),
\\
\Re(\ln z_3) &=& \ln\abs{z_3},
\\
\Im(\ln z_3) &=& \arctg{\Im(z_3) \over \Re(z_3)}
%+ \left\{\matrix{0, & \Re(z) \ge 0 \cr \pi, & \Re(z) < 0}\right.
,
\end{eqnarray}
that are valid for any complex $z_1$,$z_2$ and $z_3 \ne 0$. Thus

\bem
\Re\left[z \ln {t_+ - x \over t_- - x}\right]
&=&
\Re(z)\Re\left[ \ln {t_+ - x \over t_- - x}\right]
- \Im(z)\Im\left[ \ln {t_+ - x \over t_- - x}\right]
\nel
&=&
\Re(z)\ln\abs{t_+ - x \over t_- - x}
- \Im(z)\Im\left[ \ln {t_+ - x \over t_- - x}\right],
\ee

where
\bem
\lefteqn{
\Im\left[ \ln {t_+ - x \over t_- - x}\right]
= \Im\left[ \ln {(t_+ - x)(t_- - x^*) \over \abs{t_- - x}^2}\right]
= \Im\left[ \ln (t_+t_- + \abs{x}^2 - x t_- - x^*t_+)\right]
}
&& \fillEqn
\nel
&=& \arctg{\Im(m'^4 + \abs{x}^2 - x t_- - x^*t_+)
         \over \Re(m'^4 + \abs{x}^2 - x t_- - x^*t_+)}
= \arctg{\Im(x)(t_+ - t_-)
         \over m'^4 + \abs{x}^2 - \Re(x)(t_- + t_+)}
,
\ee

or
\bel{cs-tmp-im-log}
\phi(x) \equiv \Im\left[ \ln {t_+ - x \over t_- - x}\right]
=
\arctg{s\sqrt{1 - 4\rho}\,\Im(x)
         \over m'^4 + \abs{x}^2 - s(2\rho - 1)\Re(x)}
.
\ee

It gives for~\rf{csIntTmp3},
\bel{cs-int-3}
\int_{t_-}^{t_+} \Re\left({z \over t - x}\right) dt
\; \approx \;
\Re(z)\ln\abs{t_+ - x \over t_- - x}
- \Im(z) \phi(x).
\ee

Next I consider the integral (where again no pole is encountered)

\bem
\lefteqn{
\int_{t_-}^{t_+} {(t - r)^2 \over t - x} dt
\; = \;
\int_{t_- - x}^{t_+ - x} {(t + x - r)^2 \over t} dt
=
\int_{t_- - x}^{t_+ - x}
\left[{(x - r)^2 \over t} + 2(x - r) + t \right] dt
}
&& \fillEqn
\nel
& = &
(x - r)^2 \ln{t_+ - x \over t_- - x}
+ 2(x - r)(t_+ - t_-) + {1 \over 2}[(t_+ - x)^2 - (t_- - x)^2]
.
\ee

But
\be
(t_+ - x)^2 - (t_- - x)^2 = (t_+ - x + t_- - x)(t_+ - t_-)
= [s(2\rho - 1) - 2x](t_+ - t_-),
\ee

so
\beml{cs-tmp-int1}
\int_{t_-}^{t_+} {(t - r)^2 \over t - x} dt
& = &
(x - r)^2 \ln{t_+ - x \over t_- - x}
+ (t_+ - t_-)[2(x - r) + {s \over 2}(2\rho - 1) - x]
\nel
& = &
(x - r)^2 \ln{t_+ - x \over t_- - x}
+ s\sqrt{1 - 4\rho}(x - 2r + s\rho - s/2)
.
\ee

I use~\rf{cs-tmp-int1} to calculate the following two integrals.
First I consider

\bem
\lefteqn{
\int_{t_-}^{t_+} \Re\left(z{(t - r)^2 \over t - x}\right) dt
}
\nel
& \approx &
\Re\left[z(x - r)^2 \ln{t_+ - x \over t_- - x}\right]
+ s\sqrt{1 - 4\rho}\Re[z(x  - 2r + s\rho - s / 2)]
\nel
& = &
\Re\left[z(x - r)^2 \ln{t_+ - x \over t_- - x}\right]
+ s\sqrt{1 - 4\rho}\Re[zx  - z(2r - s\rho + s / 2)]
\nel
& = &
\Re[z(x - r)^2] \Re\left[\ln{t_+ - x \over t_- - x}\right]
-\Im[z(x - r)^2] \Im\left[\ln{t_+ - x \over t_- - x}\right]
\nel
&& {}
+ s\sqrt{1 - 4\rho}\{\Re(zx) - \Re(z)[2r + s(1 - 2\rho)/2]\}
,
\ee

or
\beml{cs-int-4}
\int_{t_-}^{t_+} \Re\left(z{(t - r)^2 \over t - x}\right) dt
& \approx &
\Re[z(x - r)^2] \ln\abs{t_+ - x \over t_- - x}
-\Im[z(x - r)^2] \phi(x)
\nel
&&{}
+ s\sqrt{1 - 4\rho}\{\Re(zx) - \Re(z)[2r + s(1 - 2\rho)/2]\}
.
\nel
\ee

\P
In the following calculations I use
\be
{1 \over \abs{t - x}^2}
= {1 \over x - x^*} \left({1 \over t - x} - {1 \over t - x^*} \right)
= {1 \over 2i\Im(x)} \left({1 \over t - x} - {1 \over t - x^*} \right)
,
\ee
where it is supposed that $\Im(x) \ne 0$.
Thus ($r$ is real)

\bem
\int_{t_-}^{t_+} {(t - r)^2 \over \abs{t - x}^2} dt
& \equiv &
\Re\left\{
\int_{t_-}^{t_+} {(t - r)^2 \over \abs{t - x}^2} dt
\right\}
\nel
& = &
\Re\left\{
{1 \over 2i\Im(x)}
\int_{t_-}^{t_+} \left[{(t - r)^2 \over t - x}
                       - {(t - r)^2 \over t - x^*}\right] dt
\right\}
\nel
& = &
{1 \over 2\Im(x)}
\Im\left\{
\int_{t_-}^{t_+} \left[{(t - r)^2 \over t - x}
                       - {(t - r)^2 \over t - x^*}\right] dt
\right\}
,
\ee

where I have used the fact that $r$ is real. So

\beml{cs-int-6}
\lefteqn{
\int_{t_-}^{t_+} {(t - r)^2 \over \abs{t - x}^2} dt
}
\nel
& = &
{1 \over 2\Im(x)}
\Im\left[(x - r)^2 \ln {t_+ - x \over t_- - x}
+ s\sqrt{1 - 4\rho}(x - 2r + m'^2 - s / 2)
\right]
\nel&& {}
-{1 \over 2\Im(x)}
\Im\left[
(x^* - r)^2 \ln {t_+ - x^* \over t_- - x^*}
+ s\sqrt{1 - 4\rho}(x^* - 2r + m'^2 - s / 2)
\right]
\nel
& = &
{1 \over 2\Im(x)}
\Im\left[
(x - r)^2 \ln {t_+ - x \over t_- - x}
- (x^* - r)^2 \ln {t_+ - x^* \over t_- - x^*}
+ s\sqrt{1 - 4\rho}(x - x^*)
\right]
\nel
\ee

I simplify the last expression with the help of the identity
\be
\Im(z - z^*) = \Im[2i\Im(z)] = 2\Im(z).
\ee

According to~\rf{cs-Im-z1-z2} I find for the integral~\rf{cs-int-6}
\bem
\int_{t_-}^{t_+} {(t - r)^2 \over \abs{t - x}^2} dt
& = &
{1 \over \Im(x)}
\Im\left[(x - r)^2 \ln {t_+ - x \over t_- - x} + sx\sqrt{1 - 4\rho} \right]
\nel
& = &
{1 \over \Im(x)}
\Re[(x - r)^2] \Im\left[\ln{t_+ - x \over t_- - x}\right]
\nel&&{}
+{1 \over \Im(x)}
\Im[(x - r)^2] \Re\left[\ln {t_+ - x \over t_- - x}\right]
+ s\sqrt{1 - 4\rho}
\,
.
\ee

By taking into account that
\be
\Re[(x - r)^2] = [\Re(x - r)]^2 - [\Im(x - r)]^2 = [\Re(x) - r]^2 - \Im(x)^2,
\ee
\bel{csReImForSub}
\Im[(x - r)^2] = 2\Im(x - r)\Re(x - r) = 2\Im(x)[\Re(x) - r]
,
\ee

I finally find
\beml{cs-int-65}
\int_{t_-}^{t_+} {(t - r)^2 \over \abs{t - x}^2} dt
&\approx&
{[\Re(x) - r]^2 - \Im(x)^2 \over \Im(x)} \phi(x)
+ 2[\Re(x) - r]\ln\abs{t_+ - x \over t_- - x}
\nel
&&{}
+ s\sqrt{1 - 4\rho}\, .
\ee

When $\Im(x) = 0$, i.e when $x$ is real, I may use,
\be
\lim_{\varepsilon \rightarrow 0}
\left({1 \over \varepsilon} \arctg a\varepsilon\right)
= a
\ee
to calculate the first term in~\rf{cs-int-65},
\bem
{ \phi(x)\over \Im(x)} &=&
{ 1 \over \Im(x)}
\arctg{s\sqrt{1 - 4\rho}\Im(x) \over m'^4 + \abs{x}^2 - s(2\rho - 1)\Re(x)}
\nel&\rightarrow &
{s\sqrt{1 - 4\rho}\over m'^4 + \abs{x}^2 - s(2\rho - 1)\Re(x)}
.
\ee

Thus for real $x$ equation~\rf{cs-int-65} becomes
\beml{cs-int-7}
\int_{t_-}^{t_+} {(t - r)^2 \over (t - x)^2} dt
&\approx&
{s\sqrt{1 - 4\rho}[x - r]^2 \over m_\chi^4 + x^2 - sx(2\rho - 1)}
+ 2(x - r)\ln\abs{t_+ - x \over t_- - x}
+ s\sqrt{1 - 4\rho}\,
.
\nel
\ee

\P
For reference purposes I collect here several key formulas.
For the process~\rf{csProcess} when the particle masses satisfy
\bel{csUltraApproximation}
\mpa = \mpb = m' \gg \ma = \mb = m, \quad s \ge 4m'^2 \gg m^2,
\ee

the c.m. differential  and total cross sections are given by
\bel{csDifApproximation}
\left({d\sigma \over d\Omega}\right)_{\rm c.m.}
\approx
{m^2 m'^2  \over 4\pi^2 s} \sqrt{1 - 4\rho}\, X(s, t)
,
\ee

\bel{csTotalApproximation}
\sigma_T(s)
\approx {m^2 m'^2 \over \pi s^2} \int_{t_-}^{t_+} X(s, t) \, dt
,
\ee

where

\begin{eqnarray}
\label{cs-s}
s & = & (\pa + \pb)^2 = (\ppa + \ppb)^2 ,
\\
\label{cs-t-is}
t &=& (\ppa - \pa)^2 = (\pb - \ppb)^2 ,
\\
\label{cs-t-pm-approximation}
t_\pm & \approx & {s \over 2} (2\rho - 1 \pm \sqrt{1 - 4\rho})
,
\\
\label{cs-rho}
\rho &=& {m'^2 \over s} \; \le \; {1 \over 4},
\end{eqnarray}

and $X$ is the spin sum over initial and final particle spin states,
\bel{cs-X-is}
X(s, t) \equiv
X(\pa, \pb, \ppa, \ppb)
=  {1 \over 4}\sum_{\ra, \rb, \rpa, \rpb = +, -}
   M^\dagger(\ra, \rb, \rpa, \rpb) M(\ra, \rb, \rpa, \rpb)
.
\ee

\P
Under the approximation~\rf{csUltraApproximation} the following relations hold,
\beml{cs-q-scalar-products}
(\qpb \cdot \qa) (\qpa \cdot \qb) + (\qpb \cdot \qb) (\qpa \cdot \qa)
& \approx &
{2(m'^2 - t)^2 + s(s + 2t - 2m'^2) \over 4m^2m'^2}
,
\nel
(\qpb \cdot \qa) (\qpa \cdot \qb) - (\qpb \cdot \qb) (\qpa \cdot \qa)
& \approx & {s \over 4m^2m'^2}(s + 2t - 2m'^2)
,
\ee

\beml{cs-t-expressions}
t_+ - t_- & \approx & s\sqrt{1 - 4\rho},
\nel
t_+ + t_- & \approx & s(2\rho - 1),
\nel
t_+ t_- & \approx & m'^4
.
\ee

\P
One may also find the integrals,

\bel{csInt1}
\int_{t_-}^{t_+} (2m'^2 - 2t - s) dt
\; \approx \;
0
,
\ee

\bel{csInt2}
\int_{t_-}^{t_+} (m'^2 - t)^2 dt
\; \approx \;
{s^3 \over 3} (1 - \rho)\sqrt{1 - 4\rho} \,
,
\ee

\bel{csInt3}
\int_{t_-}^{t_+} \Re\left({z \over t - x}\right) dt
\; \approx \;
\Re(z)\ln\abs{t_+ - x \over t_- - x}
- \Im(z) \phi(x),
\ee

where $z$ is an arbitrary complex number,
$x$ is a complex number such that no pole is encountered in~\rf{csInt3}
and
\bel{csImLog}
\phi(x) \; = \;
\arctg{s\sqrt{1 - 4\rho}\,\Im(x)
         \over m'^4 + \abs{x}^2 - s(2\rho - 1)\Re(x)}
.
\ee

Furthermore
\beml{csInt4}
\int_{t_-}^{t_+} \Re\left(z{(t - r)^2 \over t - x}\right) dt
& \approx &
\Re[z(x - r)^2] \ln\abs{t_+ - x \over t_- - x}
-\Im[z(x - r)^2] \phi(x)
\nel
&&{}
+ s\sqrt{1 - 4\rho}\{\Re(zx) - \Re(z)[2r + s(1 - 2\rho)/2]\}
,
\nel
\ee

\beml{csInt65}
\int_{t_-}^{t_+} {(t - r)^2 \over \abs{t - x}^2} dt
&\approx&
{[\Re(x) - r]^2 - \Im(x)^2 \over \Im(x)} \phi(x)
+ 2[\Re(x) - r]\ln\abs{t_+ - x \over t_- - x}
\nel
&&{}
+ s\sqrt{1 - 4\rho}\,
.
\ee

For a real $x$ the integral~\rf{csInt65} reads
\beml{csInt7}
\int_{t_-}^{t_+} {(t - r)^2 \over (t - x)^2} dt
&\approx&
{s\sqrt{1 - 4\rho}[x - r]^2 \over m_\chi^4 + x^2 - sx(2\rho - 1)}
+ 2(x - r)\ln\abs{t_+ - x \over t_- - x}
+ s\sqrt{1 - 4\rho}\,
.
\nel
\ee


\chapter{Conventions and useful relations}
\label{Conventions}

\begin{itemize}

\item
$A^\dag$, $A^T$, $A^*$ denote respectively
the hermitian conjugation, matrix transposition and complex conjugation of $A$.
For a scalar quantity $a$, $a^T = a$ and $a^\dag = a^*$.

\item
Lower-case Greek letters are used for Lorentz indices
and two-component spinor indices. In most cases the letters
$\mu$, $\nu$, $\rho$, $\sigma$ are Lorentz indices, whereas
$\alpha$ and $\beta$ are two-component spinor indices. Lower-case Roman letters
are used to index four-component spinors. The index $r$ is often used
to denote "+" or "-" polarization states.

\item
The Cartesian metric tensor $\eta_{\mu\nu}$ is given by
\bel{convCartesianMetric}
\eta_{\mu\nu} = \left\{ \matrix{1  & \mbox{if} \quad \mu = \nu = 0 \cr
                                -1 & \mbox{if} \quad \mu = \nu \ne 0 \cr
                                0  & \mbox{otherwise} } \right. .
\ee

\item
$g_{\mu\nu}$ stands for an arbitrary symmetric matrix with signature -2, i.e.
the difference between the number of positive and negative eigenvalues of
$g_{\mu\nu}$ should be -2.

\P
These requirements mean
that one can find a non-singular real matrix $L$ such that

\bel{gamma-metric-transformation}
\eta_{\mu\nu} = L_{\mu}{}^\rho L_{\nu}{}^\sigma g_{\rho\sigma}
\quad \mbox{or} \quad
g_{\rho\sigma} = (L^{-1})_\rho{}^\mu (L^{-1})_\sigma{}^\nu \eta^{\mu\nu}
.
\ee

Another useful form of~\rf{gamma-metric-transformation} is
\bel{gamma-metric-transformation2}
\eta^{\mu\nu} = (L^{-1})_\rho{}^\mu (L^{-1})_\sigma{}^\nu g^{\rho\sigma}
\quad \mbox{or} \quad
g^{\rho\sigma}= L_{\mu}{}^\rho L_{\nu}{}^\sigma\eta^{\mu\nu}
.
\ee

In most cases $g$ is used to denote the determinant of $g_{\mu\nu}$,
\be
g = \det g < 0.
\ee

\item
I use $p$ mostly for particle 4-momenta such that
\be
p^2  \equiv p_\mu p^\mu = g_{\mu\nu}p^\mu p^\mu = m^2 > 0
\ee
with some
mass $m$. I also use $q$ to denote the normalized momenta,
\bel{convQPRelation}
q \equiv p/m, \quad q^2 = 1.
\ee

\item
$(a \cdot b)$ and $\slsh{a}$ represent
the index-less notations for scalar products,
\be
(a \cdot b) \equiv a_\mu b^\mu, \quad \slsh{a} = a_\mu \gu\mu.
\ee

\item
$A_{(\mu_1 \dots \mu_k)}$ and $A_{[\mu_1 \dots \mu_k]}$
denote the symmetric and antisymmetric parts of $A_{\mu_1 \dots \mu_k}$,

\beml{convention-symmetry-anti-symmetry}
A_{(\mu_1 \dots \mu_k)} & = &
\frac{1}{k!}\sum_{\sigma}
A_{\mu_{\sigma(1)} \dots \mu_{\sigma(k)}},

\nel
A_{[\mu_1 \dots \mu_k]} & = &
\frac{1}{k!}\sum_{\sigma}
\sign(\sigma) A_{\mu_{\sigma(1)} \dots \mu_{\sigma(k)}},
\ee

where the sum is taken over the permutation group of the set
$\{ 1, \dots, k \}$, $\sigma(n)$ gives the result of
the permutation $\sigma$ for the number $n$ and
$\sign(\sigma)$ is $1$
if $\sigma$ forms an even permutation of $\{ 1, \dots, k \}$
 and $-1$ otherwise. (A permutation
is even if it is obtained by an even number of simple permutations
and the simple permutation is the exchange
of two neighboring indices.)

\P
It is easy to check that
\beml{contractionWithSymAnti}
&
A_{(\mu_1 \dots \mu_k)}B^{(\mu_1 \dots \mu_k)} =
A_{\mu_1 \dots \mu_k}B^{(\mu_1 \dots \mu_k)} =
A_{(\mu_1 \dots \mu_k)}B^{\mu_1 \dots \mu_k} ,

\nel &
A_{[\mu_1 \dots \mu_k]}B^{[\mu_1 \dots \mu_k]} =
A_{\mu_1 \dots \mu_k}B^{[\mu_1 \dots \mu_k]} =
A_{[\mu_1 \dots \mu_k]}B^{\mu_1 \dots \mu_k} ,

\nel &
A_{[\mu_1 \dots \mu_k]}B^{(\mu_1 \dots \mu_k)} = 0 .

\ee

\item

$\varepsilon^{\mu\nu\rho\sigma}$ is the fully
antisymmetric 4-dimensional tensor defined by

\bel{convEpsilonUpIs}
\varepsilon^{\mu\nu\rho\sigma} = \varepsilon^{[\mu\nu\rho\sigma]} =
   \frac{1}{\sqrt{-g}} e^{\mu\nu\rho\sigma},
\quad
e^{\mu\nu\rho\sigma} = e^{[\mu\nu\rho\sigma]},
\quad
e^{0123} = 1,
\ee

The pseudo-tensor $e^{\mu\nu\rho\sigma}$ satisfies for any $A^\mu{}_\nu$
\bel{convDetIs}
A^\mu{}_{\mu'}A^\nu{}_{\nu'}A^\rho{}_{\rho'}A^\sigma{}_{\sigma'}
                        e^{\mu'\nu'\rho'\sigma'}
= \det(A) \, e^{\mu\nu\rho\sigma}
\ee

By the definition $e_{\mu\nu\rho\sigma} = e^{\mu\nu\rho\sigma}$ and
for the covariant version of $\varepsilon^{\mu\nu\rho\sigma}$
one can find

\beml{convEpsilonDownIs}
\varepsilon_{\mu\nu\rho\sigma}
& = & g_{\mu\mu'}g_{\nu\nu'}g_{\sigma\sigma'}g_{\rho\rho'}
        \varepsilon^{\mu'\nu'\sigma'\rho'}

\nel
&  = & \frac{1}{\sqrt{-g}} g_{\mu\mu'}g_{\nu\nu'}g_{\sigma\sigma'}g_{\rho\rho'}
                        e^{\mu'\nu'\sigma'\rho'}
= \frac{1}{\sqrt{-g}} g e_{\mu\nu\rho\sigma},
\nel
\varepsilon_{\mu\nu\rho\sigma} & = & -\sqrt{-g} \, e_{\mu\nu\rho\sigma}
\ee

\P
In the case when $g_{\mu\nu}$ equals the Cartesian
metric~\rf{convCartesianMetric}
, $g = -1$ and $\varepsilon^{\mu\nu\rho\sigma}$ is given by
\be
\varepsilon^{\mu\nu\rho\sigma} = e^{\mu\nu\rho\sigma},
\quad
\varepsilon^{0123} = 1,
\quad
\varepsilon_{0123} = -e_{0123} = -e^{0123} = -1.
\ee

\end{itemize}


%
% IAT 267: Introduction to Technological Systems - A Course Overview
% Section: Electricity and Circuit Design
%
% Author: Jeffrey Leung
%
\section{Electricity and Circuit Design}
	\label{sec:electricity-and-circuit-design}
\subsection{Electricity}
	\label{subsec:electricity-and-circuit-design:electricity}
\begin{easylist}

	& \emph{Voltage:} Relative level of electrical energy between any two given points in a circuit
		&& Denoted by \si{\volt}
		&& SI unit: Volts (\si{\volt})
		&& Totals 0 over the entire circuit
			&&& Power sources add to the voltage; components subtract from the voltage
	& \emph{Current:} Amount of electrical energy passing through any given point in a circuit
		&& Denoted by I
		&& SI unit: Amperes/amps (\si{\ampere})
		&& Constant throughout the circuit
		&& Follows the path of least resistance

	& \emph{Resistance:} Amount of difficulty in moving an electric current through a given component
		&& Denoted by R
		&& SI unit: Ohms (\si{\ohm})
		&& Inherent property of a material
		&& \emph{Conductor:} Material which has a low resistance
		&& \emph{Insulator:} Material which has a high resistance
		&& Calculating resistance:
			&&& \hyperref[subsec:electricity-and-circuit-design:circuits]{Series circuit}: Add the individual resistances

			&&&& Formula:

			\begin{displaymath}
				R_{T}
				= \sum_{i=0}^{n} R_{i}
			\end{displaymath}

			&&&& E.g. For the circuit in figure~\ref{fig:series-circuit-total-resistance-example},

			\begin{figure}[!htb]
				\begin{center}
					\begin{circuitikz}
						\draw (0,0)
						to [battery] (0, 3)
						to [R, l=R1 (820\ \si{\ohm})] (3, 3)
						to [R, l=R2 (1200\ \si{\ohm})] (3, 0)
						to [R, l=R3 (150\ \si{\ohm})] (0, 0);
					\end{circuitikz}
				\end{center}
					\caption{Series circuit with resistors 820 \si{\ohm}, 1200 \si{\ohm}, 150 \si{\ohm}}
					\label{fig:series-circuit-total-resistance-example}
			\end{figure}

			The total resistance is:
			\Deactivate
			\begin{IEEEeqnarray}{ r C l }
				R_{T}
				& = & \sum_{i=0}^{n} R_{i} \\
				& = & R_{1} + R_{2} + R_{3} \\
				& = & 820\ \si{\ohm} + 1200\ \si{\ohm} + 150\ \si{\ohm} \\
				& = & 2170\ \si{\ohm}
			\end{IEEEeqnarray}
			\Activate

			&&& \hyperref[subsec:electricity-and-circuit-design:circuits]{Parallel circuit}: Find the current of each individual path (see \emph{Ohm's Law} below) (voltage is constant throughout the circuit), and divide the voltage by the sum of the resulting currents

				&&&& Formula:

				\begin{displaymath}
					R_{T}
					= \frac{V}{\sum^{n}_{i=0} \frac{V}{R_{i}}}
					= \frac{1}{\sum^{n}_{i=0} \frac{1}{R_{i}}}
				\end{displaymath}

				&&&& E.g. For the circuit in figure~\ref{fig:parallel-circuit-total-resistance-example-1},

				\begin{figure}[!htb]
					\begin{center}
						\begin{circuitikz}
							\draw (0,0)
							to [battery, l=60\ \si{\volt}] (0,3)
							to [short] (9,3)
							to [R, l_=R3 (20 \si{\ohm})] (9,0)
							to [short] (0,0);

							\draw (6,3)
							to [R, l_=R2 (12 \si{\ohm})] (6,0);

							\draw (3,3)
							to [R, l_=R1 (6 \si{\ohm})] (3,0);
						\end{circuitikz}
					\end{center}
					\caption{Parallel circuit with resistors 6 \si{\ohm}, 12 \si{\ohm}, 20 \si{\ohm}}
					\label{fig:parallel-circuit-total-resistance-example-1}
				\end{figure}

				The currents are:

				\begin{displaymath}
					I_{1}
					= \frac{V_{1}}{R_{1}}
					= \frac{60\ \si{\volt}}{6\ \si{\ohm}}
					= 10\ \si{\ampere}
				\end{displaymath}

				\begin{displaymath}
					I_{2}
					= \frac{V_{2}}{R_{2}}
					= \frac{60\ \si{\volt}}{12\ \si{\ohm}}
					= 5\ \si{\ampere}
				\end{displaymath}

				\begin{displaymath}
					I_{3}
					= \frac{V_{3}}{R_{3}}
					= \frac{60\ \si{\volt}}{20\ \si{\ohm}}
					= 3\ \si{\ampere}
				\end{displaymath}

				\begin{displaymath}
					I_{T}
					= \sum_{i=0}^{n} I_{i}
					= I_{1} + I_{2} + I_{3}
					= 10\ \si{\ampere} + 5\ \si{\ampere} + 3\ \si{\ampere}
					= 18\ \si{\ampere}
				\end{displaymath}

				Therefore, the total resistance is:

				\begin{displaymath}
					R_{T}
					= \frac{\si{\volt}_{T}}{I_{T}}
					= \frac{60\ \si{\volt}}{18\ \si{\ampere}}
					= 3.\overline{3}\ \si{\ohm}
				\end{displaymath}

				&&&& E.g. For the circuit in figure~\ref{fig:parallel-circuit-total-resistance-example-2},

				\begin{figure}[!htb]
					\begin{center}
						\begin{circuitikz}
							\draw (0,0)
							to [battery, l=60\ \si{\volt}] (0,3)
							to [short] (9,3)
							to [R, l_=R3 (10 \si{\ohm})] (9,0)
							to [short] (0,0);

							\draw (6,3)
							to [R, l_=R2 (15 \si{\ohm})] (6,0);

							\draw (3,3)
							to [R, l_=R1 (5 \si{\ohm})] (3,0);
						\end{circuitikz}
					\end{center}
					\caption{Parallel circuit with resistors 5 \si{\ohm}, 15 \si{\ohm}, 10 \si{\ohm}}
					\label{fig:parallel-circuit-total-resistance-example-2}
				\end{figure}

				The total resistance is:

				\Deactivate
				\begin{IEEEeqnarray}{ r C l }
					R_{T}
					& = & \frac{1}{ \sum_{i=0}^{n} \frac{1}{R_{i}} } \\
					& = & \frac{1}{ \frac{1}{R_{1}} + \frac{1}{R_{2}} + \frac{1}{R_{3}} } \\
					& = & \frac{1}{ \frac{1}{5} + \frac{1}{15} + \frac{1}{10} } \\
					& = & \frac{1}{ \frac{6}{30} + \frac{2}{30} + \frac{3}{30} } \\
					& = & \frac{1}{ \frac{11}{30} } \\
					& = & \frac{30}{11}\ \si{\ohm}
				\end{IEEEeqnarray}
				\Activate

	& \emph{Ohm's Law:} Formula relating voltage, current, and resistance
		&& Formula:

		\begin{displaymath}
			V = I \cdot R
		\end{displaymath}

		\medskip

		\begin{center}
			\Deactivate
			\begin{tabular}{ l r @{ = } l }
				where
				& $V$ & Voltage \\
				& $I$ & Current \\
				& $R$ & Resistance
			\end{tabular}
			\Activate
		\end{center}

		&& \emph{Short-circuit:} Insufficient resistance which creates too much current (as voltage is constant), damaging the circuit

	\bigskip

	& \emph{Power:} Rate at which electrical energy is transferred
		&& Denoted by P
		&& SI unit: Watt (\si{\watt})
		&& Formula:

		\begin{displaymath}
			P = V \cdot I
		\end{displaymath}

		\begin{center}
			\Deactivate
			\begin{tabular}{ l r @{ = } l }
				where
				& $P$ & Power \\
				& $V$ & Voltage \\
				& $I$ & Current
			\end{tabular}
			\Activate
		\end{center}

	& Electron flow:
		&& From greater electrical energy to lesser electrical energy
		&& From the negative terminal to the positive terminal

\end{easylist}
\subsection{Types of Electricity}
	\label{subsec:electricity-and-circuit-design:types-of-electricity}
\begin{easylist}

	& \emph{Piezoelectricity:} Electrical potential created from pressure energy exerted upon a polarized crystal
		&& Discovered in 1880s by the Curies
		&& Explanation:
			&&& Piezoelectric crystals are permanently electrically polarized, aligning the dipoles and attracting excess surface charge to electrically neutralize the crystal
			&&& Applying force to the piezoelectric crystal disrupts the orientation of electric dipoles which creates temporary excess charge
		&& E.g. Quartz is compressed to create a consistent electrical signal in a watch
		&& For applications, see \hyperref[sec:sensors]{Sensors} and \hyperref[sec:actuators]{Actuators}

\end{easylist}
\subsection{Circuits}
	\label{subsec:electricity-and-circuit-design:circuits}
\subsubsection{Introduction}
	\label{subsubsec:electricity-and-circuit-design:circuits:introduction}
\begin{easylist}

	& \emph{Circuit:} Loop of electronic components with a power source and a load

	& Input pins not grounded or connected to power may exhibit variable capacitance (electrical energy)
		&& Example of proper grounding: See figure~\ref{fig:example-input-pin-grounding}

		\begin{figure}[!htb]
			\begin{center}
				\begin{circuitikz}
					\draw (0, 6)
					to [closing switch] (0, 4)
					to [R, l_=10k\ \si{\ohm}] (0, 2)
					to (0, 2) node[ground]{};

					\draw (0, 4)
					to [short, l=Input\ pin] (2, 4);
				\end{circuitikz}
			\end{center}
				\caption{Example of Input Pin Grounding}
				\label{fig:example-input-pin-grounding}
		\end{figure}

	& \emph{Schematic:} Visual representation of a system using standardized symbols

\end{easylist}
\subsubsection{Components}
	\label{subsubsec:electricity-and-circuit-design:circuits:components}
\begin{easylist}

	& \emph{Power source:} Provider of electrical energy
		&& Denoted by:

			&&& Voltage source (American):
			\begin{center}
				\begin{circuitikz}
					\draw (0,0)
					to [american voltage source] (2,0);
				\end{circuitikz}
			\end{center}

			&&& Battery:
			\begin{center}
				\begin{circuitikz}
					\draw (0,0)
					to [battery] (2,0);
				\end{circuitikz}
			\end{center}

				&&&& Longer line is the positive terminal; shorter line is the negative terminal

		&& E.g. Battery, wall plug

	& \emph{Electrical load:} Component which consumes electrical energy
		&& E.g. Light bulb

	& \emph{Resistor:} Electrical component which limits the current in a circuit
		&& Denoted by:
		\begin{center}
			\begin{circuitikz}
				\draw (0,0)
				to [R] (2,0);
			\end{circuitikz}
		\end{center}

		&& \emph{Potentiometer:} Resistor which has adjustable/variable resistance
			&&& Denoted by:
			\begin{center}
				\begin{circuitikz}
					\draw (0,0)
					to [pR] (2,0);
				\end{circuitikz}
			\end{center}
			&&& Connections:
				&&&& Side prong to positive
				&&&& Middle prong to output
				&&&& (Other) side prong to ground
				&&&& Turning the knob moves the middle prong along a resistor, closer/farther to the side prong, forcing the current to move through greater resistance

	& \emph{Polarization:} Characteristic of an electrical component which only operates when the current flows in a specific direction
		&& Anode (longer prong) is connected to the positive terminal
		&& Cathode (shorter prong) is connected to the negative terminal

		\medskip

		&& \emph{Diode:} Electrical component which limits the flow of electricity to only one direction
			&&& Denoted by:
			\begin{center}
				\begin{circuitikz}
					\draw (0,0)
					to [Do] (2,0);
				\end{circuitikz}
			\end{center}

			&&& \emph{Light Emitting Diode (LED):} Diode which emits light when current flows through with the correct voltage
				&&&& Denoted by:
				\begin{center}
					\begin{circuitikz}
						\draw (0,0)
						to [D*] (2,0);
					\end{circuitikz}

					\medskip
					or
					\medskip

					\begin{circuitikz}
						\draw (0,0)
						to [leDo] (2,0);
					\end{circuitikz}
				\end{center}

	& \emph{Capacitor:} Electrical component which stores then releases electrical energy in intervals
		&& May be polarized
		&& Denoted by:

			&&& Unpolarized:
				\begin{center}
					\begin{circuitikz}
						\draw (0,0)
						to [capacitor] (2,0);
					\end{circuitikz}
				\end{center}

			&&& Polarized:
				\begin{center}
					\begin{circuitikz}
						\draw (0,0)
						to [polar capacitor] (2,0);
					\end{circuitikz}
				\end{center}

	& \emph{Switch:} Electrical component which controls a break in a circuit and therefore electrical energy flow
		&& Denoted by:
		\begin{center}
			\begin{circuitikz}
				\draw (0,0)
				to [closing switch] (2,0);
			\end{circuitikz}
		\end{center}

		&& Closing a switch completes the circuit; opening a switch breaks the circuit

	& \emph{(Solderless) Breadboard:} Base on which circuits can be built
		&& Useful for prototyping or designing a circuit
		&& Components should not be added or removed while the circuit is live to avoid short circuits or shocks

	& \emph{Microcontroller:} Small computer with a processor, memory, and programmable inputs/outputs

	& \emph{Analog-to-digital converter}: Device which converts an analog voltage to a digital value

\end{easylist}
\subsubsection{Types of Circuits}
	\label{subsubsec:electricity-and-circuit-design:circuits:types-of-circuits}
\begin{easylist}

	& \emph{Serial circuit:} Circuit in which all components are connected in-line
		&& I.e. Only one path exists from the positive terminal to the negative terminal for the electrons to flow through
		&& E.g. See figure~\ref{fig:series-circuit-example}.

		\begin{figure}[!htb]
			\begin{center}
				\begin{circuitikz}
					\draw (0,0)
					to [battery] (0,2)
					to [lamp] (4,2)
					to [short] (4,0)
					to [lamp] (0,0);
				\end{circuitikz}
				\caption{Example of a series circuit}
				\label{fig:series-circuit-example}
			\end{center}
		\end{figure}

		&& To find the total resistance, see \hyperref[subsec:electricity-and-circuit-design:electricity]{Calculating resistance}

	& \emph{Parallel circuit:} Circuit in which not all components are placed in-line with each other
		&& I.e. Multiple paths exist from the positive terminal to the negative terminal for the electrons to flow through
		&& E.g. See figure~\ref{fig:parallel-circuit-example}.

		\begin{figure}[!htb]
			\begin{center}
				\begin{circuitikz}
					\draw (0,0)
					to [battery] (0,2)
					to [short] (4,2)
					to [lamp] (4,0)
					to [short] (0,0);

					\draw (2,0)
					to [lamp] (2,2);
				\end{circuitikz}
				\caption{Example of a parallel circuit}
				\label{fig:parallel-circuit-example}
			\end{center}
		\end{figure}

		&& To find the total resistance, see \hyperref[subsec:electricity-and-circuit-design:electricity]{Calculating resistance}

	& \emph{Voltage divider:} Portion of a circuit which connects to the ground, using a variable resisitance from a sensor to manipulate the voltage outputted to a component
		&& For an example schematic, see figure~\ref{fig:example-voltage-divider}

		\begin{figure}[!htb]
			\begin{center}
				\begin{circuitikz}
					\draw (0, 6)
					to [short, l^=$V_{in}$] (2, 6)
					to [R, l_=$R_{1}$] (2, 4)
					to [short, l^=$V_{out}$] (4, 4);

					\draw (2, 4)
					to [R, l_=$R_{2}$] (2, 2)
					to (2, 2) node[ground]{};
				\end{circuitikz}
			\end{center}
				\caption{Example of a Voltage Divider}
				\label{fig:example-voltage-divider}
		\end{figure}

		&& Formula for output voltage:

		\begin{displaymath}
			V_{out} = \frac{R_{2}}{R_{1} + R_{2}} \cdot V_{in}
		\end{displaymath}

			&&& Explanation:

			\Deactivate
			\begin{IEEEeqnarray}{ r C l }
				V_{in}
				& = & I \cdot R \\
				& = & I \cdot (R_{1} + R_{2}) \rule[-1.5em]{0pt}{1em} \\
				I
				& = & \frac{V_{in}}{R_{1} + R_{2}} \rule[-1.5em]{0pt}{1em} \\
				V_{out}
				& = & I \cdot R \\
				& = & I \cdot R_{2} \\
				& = & \frac{V_{in}}{R_{1} + R_{2}} \cdot R_{2} \\
				& = & \frac{R_{2}}{R_{1} + R_{2}} \cdot V_{in}
			\end{IEEEeqnarray}
			\Activate

			Reminders: \\
			Voltage is the potential difference between a component in the circuit and the ground. \\
			Current ($I$) is constant throughout the circuit.

\end{easylist}
\clearpage


\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{graphicx}

\graphicspath{ {images/} }

\newtheorem{theorem}{Theorem}

\theoremstyle{definition}
\newtheorem{definition}{Definition}
\theoremstyle{definition}
\newtheorem{example}{Example}

\begin{document}

\title{Spherical Harmonics: Approximating Functions With Orthogonal Bases}
\author{Justin Meiners}

\maketitle

\section{Introduction}

In this paper I will explain how to use sets of simple functions as a basis for approximating more complicated functions. This is similar to trigonometric fourier series but more general. Along the way I will explain how the theory applies to functions on the unit sphere called spherical harmonics. At the end I will apply this theory to a problem in computer graphics.

\section{Inner Products}

In analysis we generalized the notion of distance by definining a metric, which as an operator with certain properties that ensure it acts like a "distance function". For example, it would not make sense to talk about negative distances, so a metric must always be positive.

We can similarly generalize the idea of a dot product by definining an inner product in terms of its essential properties.

\begin{definition}
    An \textbf{inner product} is binary operation with the following properties:

    Let $x, y, z\in V$ and $a\in R$

    \begin{enumerate}
        \item Positive definite: $\langle x, x\rangle=0$ when $x=0$ otherwise $\langle x, x \rangle>0$
        \item Symmetric: $\langle x, y \rangle=\langle y, x \rangle$.
        \item Linear: $\langle ax, y \rangle= a\langle x, y \rangle$.
        \item Distributive: $\langle x, y + z \rangle = \langle x, y \rangle + \langle x, z \rangle$
    \end{enumerate}
\end{definition}

\begin{example}
    Since we wanted to generalize dot product, we expect the euclidean dot product to satisfy these properties.

    $$\langle x, y \rangle =\sum_{i=1}^{n} x_{i}y_{i}$$
\end{example}

\begin{example}
    The topic of this paper is approximating functions. What might an inner product of functions look like? We can think of it as a continuous dot product. The dot product is the sum of multiples of each vector component. Given two functions $f(x), g(x)$ we can similarly add up multiples of their values at every point. This is of course an integral.

    $$\langle f(x), g(x) \rangle = \int_{a}^{b} f(x)g(y) dx$$
    This is an inner product of integrable functions on the interval $[a, b]$.
\end{example}

\begin{example}
    Later we will be approximating functions on the unit sphere. This requires a more exotic inner product which is a spherical integral.

    $$\langle f(\theta, \phi), g(\theta, \phi) \rangle=\int_{0}^{2\pi}\int_{0}^{\pi}f(\theta, \phi)g(\theta, \phi)\sin\phi\ \partial\phi \partial\theta$$

\end{example}

\subsection{Inner Product Spaces}

The presence of an inner product gives us more structure than a plain vector space.

\begin{definition}
    An \textbf{inner product space} is a vector space with an inner product operation.
\end{definition}

\section{Orthogonal Systems}

As we know from euclidean geometry that vectors $x, y$ are said to be orthogonal when $\langle x, y \rangle$=0. This term also applies to any inner product space.

\begin{example}
    What does this look like for functions? An example of two orthogonal functions is $\cos(\pi x)$ and $\cos(2\pi x)$. The image on the right highlights the inner product which makes it easier to see what is happening.

    \begin{figure}[h]
        \includegraphics[scale=0.3]{ortho}
        \includegraphics[scale=0.3]{ortho-int}
        \centering
    \end{figure}
\end{example}

\begin{definition}
    A set $\{u_{1}, u_{2}, \ldots, u_{n} \}$ is called an \textbf{orthogonal system} iff for each $i,j\in \{ 1 \ldots n \}$  $\langle u_{i}, u_{j} \rangle=0$ whenever $i\neq j$.

\end{definition}
Informally it is a set of vectors in which each vector is orthogonal to every other vector in the set.

\subsection{Linear Independance}

\begin{theorem}
    The vectors in an orthogonal system are linearly independant
\end{theorem}

\begin{proof}
    Suppose $c_{1}u_{1}+c_{2}u_{2}+\ldots+c_{n}u_{n}=0$

    Let $i\in \{ 1...n \}$. Then:
    \begin{equation}
        \begin{split}
            &\langle u_{i}, c_{1}u_{1} + c_{2}u_{2} + \ldots + c_{n}u_{n} \rangle \\
            &= \langle u_{i}, c_{1}u_{1} \rangle + \langle u_{i}, c_{2}u_{2} \rangle + \ldots + \langle u_{i}, c_{i}u_{i} \rangle + \ldots + \langle u_{i}, c_{n}u_{n} \rangle \\
            &= c_{1}\langle u_{i}, u_{1} \rangle + c_{2}\langle u_{i}, u_{2} \rangle + \ldots + c_{i}\langle u_{i}, u_{i} \rangle + \ldots + c_{n}\langle u_{i}, u_{n} \rangle \\
            &= c_{i}\langle u_{i}, u_{i} \rangle=0
        \end{split}
    \end{equation}

    Since $\langle u_{i}, u_{i} \rangle \neq 0$ then $c_{i}=0$.
    Therefore the set is linearly independant.
\end{proof}

\subsection{Completeness}

Linear independance leads us to think about forming a basis for our vector space. Specifically to approximate functions, we want to create a basis for our space of functions. We now know we can create a linearly indepedant set from orthogonal vectors, for a finite set this guarentee's the vectors span, but not for an infinite space.

\begin{definition}
    An orthogonal system $S$ is said to be \textbf{complete} iff the smallest space containing $S$ is the whole inner product space $R$.
\end{definition}

Completeness is always relative to the space. Clearly an orthogonal system is always complete in some space (the span of the vectors).

\begin{definition}
    An orthogonal system which is complete is called an \textbf{orthogonal basis}.
\end{definition}

\begin{example}
    The standard basis vectors are an orthgonal basis for $\mathbb{R}^{n}$ under the dot product.
    \begin{equation}
        \begin{split}
            e_{1}&=( 1, 0, \ldots, 0 ) \\
            e_{2}&=( 0, 1, \ldots, 0 ) \\
            \ldots \\
            e_{n}&=( 0, 0, \ldots, 1 )
        \end{split}
    \end{equation}
\end{example}

\begin{example}
    The powers of x are an orthogonal basis for the space of real polynomials.
     $$S=\{ 1, x, x^{2}, x^{3}, \ldots, x^{n}, \ldots \}$$
\end{example}

\begin{example}
    Laplace's equation states
    $$\nabla\cdot\nabla f=0$$.

    Although the derivation is significant\cite{laplace-equation} 3D spherical coordinates this can be written as:

    $$\frac{\partial^{2}}{\partial r^{2}}+\frac{2}{r}\frac{\partial}{\partial r} + \frac{1}{r^{2}\sin^{2}(\phi)}\frac{\partial^{2}}{\partial \theta^{2}}+\frac{1}{r^{2}}\frac{\partial^{2}}{\partial \phi^{2}}+\frac{\cot(\phi)}{r^{2}}\frac{\partial}{\partial \phi}=0$$

    The \textbf{spherical harmonics} are functions which satisfy this equation. They form an orthogonal basis for the space of integrable functions on the unit sphere, using the spherical inner product introduced earlier.

    $$Y_{\ell}^{m}(\theta, \phi)=\sqrt{\frac{(2\ell +1)(\ell-m)!}{4\pi(\ell+m)!}}P_{\ell}^{m}(\cos\phi)e^{im\theta}$$

    Where $P_{\ell}^{m}$ are the associated legendre polynomials.
\end{example}

\section{Bessel's Inequality}

We will now explore Bessel's inequality which will tell us when an orthogonal system is complete. In this section we will refer to the norm of a vector. We will not explore the definition or properties of vector spac enorms here. For our usage the norm is defined by the following:

\begin{definition}
    $||x||=\sqrt{\langle x, x \rangle}$
\end{definition}

\begin{definition}
    Let $U=\{u_{1}, u_{2}, \ldots \}$ be an orthogonal system and $x\in R$ where $R$ is an inner product space. Define the coordinates $c_{i}$ with respect to $U$ as $c_{i}=\langle u_{i}, x \rangle$.
\end{definition}

\begin{theorem}
    Let $U=\{u_{1}, u_{2}, \ldots \}$ be an orthonormal system and $x\in R$. Then:
    $$||x - \sum_{i=1}^{\infty} a_{i}u_{i}||$$
    Is minimized when $a_{i}=c_{i}$, the coordinates with respect to $U$.
\end{theorem}

In other words linear combinations of the vectors in the orthogonal system get closest to the function when they are scaled by the coordintaes.

\begin{proof}
    \begin{equation}
    \begin{split}
        ||x - \sum_{i=1}^{\infty} a_{i}u_{i}||^{2}&=\langle x - \sum_{i=1}^{\infty} a_{i}u_{i}, x - \sum_{i=1}^{\infty} a_{i}u_{i} \rangle \\
        &= \langle x, x \rangle - 2\langle x, \sum_{i=1}^{\infty} a_{i}u_{i} \rangle + \langle \sum_{i=1}^{\infty} a_{i}u_{i}, \sum_{i=1}^{\infty} a_{i}u_{i} \rangle \\
        &= ||x||^{2} - 2\sum_{i=1}^{\infty} a_{i}c_{i} + \sum_{i=1}^{\infty} a_{i}^{2}||u_{i}||^{2} \\
        &= ||x||^{2} - 2\sum_{i=1}^{\infty} a_{i}c_{i} + \sum_{i=1}^{\infty} a_{i}^{2} + \sum_{i=1}^{\infty} (c_{i}^{2} - c_{i}^{2}) \\
        &= ||x||^{2} + (\sum_{i=1}^{\infty} a_{i}^{2} - 2\sum_{i=1}^{\infty} a_{i}c_{i} + \sum_{i=1}^{\infty} c_{i}^{2}) - \sum_{i=1}^{\infty} c_{i}^{2} \\
        &= ||x||^{2} + \sum_{i=1}^{\infty} (a_{i} - c_{i})^{2} - \sum_{i=1}^{\infty} c_{i}^{2}
    \end{split}
    \end{equation}

    This is smallest when the middle term drops out which is when $a_{i} = c_{i}$.
\end{proof}

\begin{theorem}
    Bessel's Inequality
    $$\sum_{i=1}^{\infty}c_{i}^{2} \leq ||x||^{2}$$
\end{theorem}

\begin{proof}
    \begin{equation}
    \begin{split}
        \langle x - \sum_{i=1}^{\infty} a_{i}u_{i}, x - \sum_{i=1}^{\infty} a_{i}u_{i} \rangle &\geq 0 \\
        ||x||^{2} + \sum_{i=1}^{\infty} (a_{i} - c_{i})^{2} - \sum_{i=1}^{\infty} c_{i}^{2} &\geq 0 \\
        ||x||^{2} - \sum_{i=1}^{\infty} c_{i}^{2} &\geq 0 \\
        ||x||^{2} &\geq \sum_{i=1}^{\infty} c_{i}^{2}
    \end{split}
    \end{equation}
\end{proof}

\begin{theorem}
    An orthogonal system is complete iff Bessel's Inequality is always equal.
\end{theorem}

\begin{proof}
    We want to show that any vector $x$ in $V$ is equal to linear combinations of the basis elements. In other words the basis spans $V$.
    \begin{equation}
    \begin{split}
        ||x - \sum_{i=1}^{\infty} c_{i}u_{i}||^{2}&=||x||^{2} + \sum_{i=1}^{\infty} (c_{i} - c_{i})^{2} - \sum_{i=1}^{\infty} c_{i}^{2} = 0 \\
        x=\sum_{i=1}^{\infty} c_{i}u_{i} \\
    \end{split}
    \end{equation}
\end{proof}

So to prove that an orthogonal system is complete we only need to verify that Bessel's inequality is an equality.

\section{Application}
In computer graphics, each object in the scene must be lit directly from each light source (radiance), as well as by light which is bounced from the surronding scene (irradiance). Since light is incoming from all directions, this effect can be modeled as function on a sphere $f(\theta, \phi)$. The normal vectors on the surface of the model are used to evaluate the function to calculate the color value at each point on the surface.

\begin{figure}[h]
    \includegraphics[scale=0.35]{sphere-function}
    \centering
\end{figure}

Unfortunatly, storing this incoming light function, over the entire sphere is not trivial. A common techniques is to place light probes around the scene. At each probe a set of 6 images is rendered (up, down, left, right, forward, back). Nearby objects then  a cubemap (a set of 6 images in a cube) is rendered of the sorrounding scene and then evalatuted. This provides high quality lighting but requires a significant amount of memory to store each of these images.

\begin{figure}[h]
    \includegraphics[scale=0.30]{cubemap}
    \includegraphics[scale=0.35]{cube-function}
    \centering
\end{figure}

With the theory we have just developed we can do better by approximating the lighting function using the orthgonal basis of the spherical harmonics. For very reflective materials, such as metal, an image is necessary to capture high frequency detail, but most materials need a lower frequency signal. For common materials we need only the first 9 spherical harmonics to get a good approximation. \cite{sh-lighting}

\subsection*{Preprocess Step}
\begin{enumerate}
    \item At each probe in the scene render 6 images of the surrounding enviornment to create a cubemap. We will denote each color channel of the cubemap by the function $g_{\alpha}(\theta, \phi)$ where $\alpha\in \{R, G, B \}$.
    \item For each $\alpha$ calculate the 9 coeffecients $s_{\ell}^{m}$ using the inner product.
        $$s_{\ell}^{m}=\langle Y_{\ell}^{m}(\theta, \phi), g_{\alpha}(\theta, \phi) \rangle=
        \int_{0}^{2\pi}\int_{0}^{\pi} Y_{\ell}^{m}(\theta, \phi) g_{\alpha}(\theta, \phi) \sin\phi\ \partial\phi \partial\theta$$
        For $0\leq\ell\leq2$ and $-\ell\leq m \leq\ell$.
\end{enumerate}

\subsection*{Rendering Step}
\begin{enumerate}
    \item Find the closest probe to this model and get its 9 coeffecients.
    \item For each pixel or vertex
        \begin{enumerate}
            \item Calculate the approximate lighting value using the coeffecients and the spherical harmonic functions.
                $$x_{\alpha}=\sum_{\ell=0}^{2} \sum_{m=-\ell}^{\ell} s_{\ell}^{m}Y_{\ell}^{m}(\theta, \phi)$$

        \end{enumerate}
\end{enumerate}

Additional details can be found in Ramamoorthi \cite{sh-lighting} and Green \cite{sh-gritty}.

\subsection*{Results}

The following images were captured from my implementation of this method. The original cubemap is shown on the left, with the spherical harmonic approximation on the right.

\begin{figure}[h]
    \includegraphics[scale=0.25]{vase2}
    \includegraphics[scale=0.25]{vase2-sh}
    \centering
\end{figure}

\begin{figure}[h]
    \includegraphics[scale=0.25]{vase1}
    \includegraphics[scale=0.25]{vase1-sh}
    \centering
\end{figure}

\pagebreak

\begin{thebibliography}{999}

\bibitem{intro-analysis}
  A.N Kolmogorov \& S.V. Fomin,
  \emph{Introductory Real Analysis}.
  Dover Books,
\bibitem{laplace-equation}
    Justin Meiners,
   \emph{Deriving Laplace's Equation in Spherical Coordinates}
\bibitem{sh-lighting}
    Ravi Ramamoorthi \& Pat Hanrahan,
    \emph{An Efficient Representation for Irradiance Enviornment Maps}
\bibitem{sh-gritty}
    Robin Green
    \emph{Spherical Harmonic Lighting: The Gritty Details},
    Sony Computer Entertainment America
\bibitem{cubemap}
    Cubemap images were taken from: http://www.humus.name/

\end{thebibliography}

\end{document}