\ignore{
\documentstyle[11pt]{report}
\textwidth 13.7cm
\textheight 21.5cm
\newcommand{\myimp}{\verb+ :- +}
\newcommand{\ignore}[1]{}
\def\definitionname{Definition}

\makeindex
\begin{document}

}
\chapter{The \texttt{ordset} Module}
An ordered set is represented as a sorted list that does not contain duplicates. The \texttt{ordset} module provides useful utility functions and predicates on ordered sets. This module must be imported before use.

\begin{itemize}
\item \texttt{delete($OSet$,$Elm$) = $OSet_1$}\index{\texttt{delete/2}}: This function returns of a copy of $OSet$ that does not contain the element $Elm$.
\item \texttt{disjoint($OSet_1$,$OSet_2$)}\index{\texttt{disjoint/2}}: This predicate is true when $OSet_1$ and $OSet_2$ have no element in common.
\item \texttt{insert($OSet$,$Elm$) = $OSet_1$}\index{\texttt{insert/2}}: This function returns a copy of $OSet$ with the element $Elm$ inserted.
\item \texttt{intersection($OSet_1$,$OSet_2$)=$OSet_3$}\index{\texttt{intersection/2}}: This function returns an ordered set that contains elements which are in both $OSet_1$ and $OSet_2$.
\item \texttt{new\_ordset($List$) = $OSet$}\index{\texttt{new\_ordset/1}}: This function returns an ordered set that contains the elements of $List$.
\item \texttt{ordset($Term$)}\index{\texttt{ordset/1}}: This predicate is true if $Term$ is an ordered set.
\item \texttt{subset($OSet_1$,$OSet_2$)}\index{\texttt{subset/2}}: This predicate is true if $OSet_1$ is a subset of $OSet_2$.
\item \texttt{subtract($OSet_1$,$OSet_2$)=$OSet_3$}\index{\texttt{subtract/2}}: This function returns an ordered set that contains all of the elements of $OSet_1$ which are not in $OSet_2$.
\item \texttt{union($OSet_1$,$OSet_2$)=$OSet_3$} \index{\texttt{union/2}}: This function returns an ordered set that contains all of the elements which are present in either $OSet_1$ or $OSet_2$.
\end{itemize}

\ignore{
\end{document}
}


\section{Verifying Simple Programs}
We begin by describing how VCC verifies ``simple programs'' ---
sequential programs without loops,  function calls, or concurrency. This
might seem to be a trivial subset of C, but in fact VCC reasons about
more complex programs by reducing them to reasoning about simple programs.

\subsection{Assertions}
\label{sect:assert-assume}

Let's begin with a simple example:

\vccInputSC[linerange={begin-}]{c/2.1.minInline.c}
This program sets \vcc{z} to the minimum of \vcc{x} and
\vcc{y}. In addition to the ordinary C code, this program includes an
\Def{annotation}, starting with \vcc{_(}, terminating with a closing
parenthesis, with balanced parentheses inside. The first identifier
after the opening parenthesis (in the program above it's \vcc{assert})
is called an \Def{annotation tag} and
identifies the type of annotation provided (and hence its function).
(The tag plays this role only
at the beginning of an annotation; elsewhere, it is treated as
an ordinary program identifier.)
Annotations are used only by VCC, and are not seen by the C compiler.
When using the regular C compiler the \vcc{<vcc.h>} header file defines:
\begin{VCC}
#define _(...) /* nothing */
\end{VCC}
VCC does not use this definition, and instead parses the inside of \vcc{_( ... )}
annotations.

An annotation of the form \vcc{_(assert E)}, called an \Def{assertion}, asks VCC to prove that
\vcc{E} is guaranteed to hold (\ie evaluate to a value other than \vcc{0})
whenever control reaches the assertion.%
\footnote{
  This interpretation changes slightly if \vcc{E} refers to
  memory locations that might be concurrently modified by other
  threads; see \secref{concurrency}}
Thus, the line \vcc|_(assert z <= x)| says
that when control reaches the assertion, \vcc{z} is no larger than \vcc{x}.
If VCC successfully verifies a program, it promises that this will hold throughout
every possible execution of the program, regardless of inputs, how concurrent
threads are scheduled, etc. More generally, VCC might verify some, but not all of your assertions;
in this case, VCC promises that the first assertion to be violated will not be one of the verified ones.

\begin{note}
It is instructive to compare \vcc{_(assert E)} with the macro
\lstinline|assert(E)| (defined in \lstinline|<assert.h>|), which
evaluates \vcc{E}  at runtime and aborts execution if \vcc{E}
doesn't hold. First, \lstinline|assert(E)| requires runtime overhead (at least
in builds where the check is made), whereas \vcc{_(assert E)} does
not. Second, \lstinline|assert(E)| will catch failure of the
assertion only when it actually fails in an execution, whereas
\vcc{_(assert E)} is guaranteed to catch the failure if it is
possible in \emph{any} execution. Third, because
\vcc{_(assert E)} is not actually executed, \vcc{E} can include
unimplementable mathematical operations, such as
quantification over infinite domains.
\end{note}

To verify the function using VCC from the command line, save the
source in a file called (say) \lstinline|minimum.c| and run VCC as follows:

\begin{VCC}
/*`C:\Somewhere\VCC Tutorial> vcc.exe minimum.c
Verification of main succeeded.
C:\Somewhere\VCC Tutorial>`*/
\end{VCC}

If instead you wish to use VCC Visual Studio plugin, load the solution
\lstinline|tutorial.sln| in
\lstinline|<vcc source dir>\vcc\vcc\Docs\Tutorial|,
locate the file with the example, and
right-click on the program text.  You should get options to verify the
file or just this function (either will work). The solution has the
examples from this tutorial arrange by section, named so that they
will appear within the project in textual order.

If you right-click within a C source file,
several VCC commands are made available, depending on what kind of
construction IntelliSense thinks you are in the middle of. The choice
of verifying the entire file is always available. If you click within
the definition of a struct type, VCC will offer you the choice of
checking admissibility for that type (a concept explained in \secref{admissibility0}).
If you click within the body of a function, VCC should offer
you the opportunity to verify just that function. However,
IntelliSense often gets confused about the syntactic structure of
VCC code, so it might not always present these context-dependent
options. However, if you select the name of a function and then right
click, it will allow you to verify just that function.

VCC verifies this function successfully, which means that its
assertions are indeed guaranteed to hold and that the program cannot
crash.%
\footnote{
  VCC will not check that this program terminates, because the program
  hasn't been specified as having to terminate; we will see later how
  to provide such specifications. VCC also doesn't check that the
  program doesn't run out of stack space, but this feature may be
  provided in some future version.
}
If VCC is unable
to prove an assertion, it reports an error.  Try changing the
assertion in this program to something that isn't true and see what
happens. (You might also want to try coming up with some complex
assertion that is true, just to see whether VCC is smart enough to
prove it.)

To understand how VCC works, and to use it successfully, it is useful to
think in terms of what VCC ``knows'' at each control point
of your program. In the current example, just before the first conditional,
VCC  knows nothing about the local variables,
since they can initially hold any value.
Just before the first assignment, VCC knows that
\vcc{x <= y} (because execution followed that branch of the conditional), and
after the assignment, VCC also knows that \vcc{z == x},
so it knows that \vcc{z <= x}. Similarly, in the \vcc{else} branch,
VCC knows that \vcc{y < x} (because execution didn't follow the
\vcc{if} branch), and after the assignment to \vcc{z}, it also knows
that \vcc{z == y}, so it also knows \vcc{z <= x}. Since
\vcc{z <= x} is known to hold at the end of each branch of the
conditional, it is known to hold at the end of the conditional, so the
assertion is known to hold when control reaches it.
In general,
VCC doesn't lose any information when reasoning about assignments and
conditionals. However, we will see that VCC may lose
some information when reasoning about loops; you will then need to
provide annotations to make sure that it doesn't lose ``too much''.

When we talk about what VCC knows, we mean what it knows in an ideal
sense, where if it knows \vcc{E}, it also knows any logical
consequence of \vcc{E}. In such a world, adding an assertion that
succeeds would have no effect on whether later assertions succeed.
VCC's ability to deduce consequences is indeed complete for many types
of formulas (e.g. formulas that use only equalities, inequalities,
addition, subtraction, multiplication by constants, and boolean
connectives), but not for all formulas, so VCC will sometimes fail to
prove an assertion, even though it ``knows'' enough to prove it.
Conversely, an assertion that succeeds can sometimes cause later
assertions that would otherwise fail to succeed, by drawing VCC's
attention to a crucial fact it needs to prove the later assertion.
This is relatively rare, and typically involves ``nonlinear
arithmetic'' (e.g. where variables are multiplied together), bitvector
reasoning (\secref{bv}) or quantifiers.

When VCC surprises you by failing to verify something that you think
it should be able to verify, it is usually because it doesn't know
something you think it should know. An assertion provides one way to
check whether VCC knows what you think it knows.

\subsection*{Exercises}
\begin{enumerate}
\item Can the assertion at the end of the example function be made
  stronger? What is the strongest valid assertion one could write? Try
  verifying the program with your stronger assertion.
\item Write an assertion that says that the \vcc{int} \vcc{x} is the average of
  the \vcc{int}s \vcc{y} and \vcc{z}.
\item Modify the example program so that it sets \vcc{x} and \vcc{y} to values
that differ by at most \vcc{1} and sum to \vcc{z}. Prove that your program
does this correctly.
\end{enumerate}

\subsection*{Solutions}
\begin{enumerate}
\item The strongest postcondition is
\vcc{_(assert z<=x && z<=y && (z == x || z == y))}.
\item
\vcc{_(assert 2 * x == y + z)}. (Note that \vcc{_(x == (y + z)/2)}
doesn't quite do the job; you might get a false positive because
division rounds down.)
\item
\begin{VCC}
int main() {
  int x,y,z;
  x = z/2;
  y = z-x;
  _(assert y-x <= 1 && x-y <= 1 && x+y == z)
  return 0;
}
\end{VCC}
\end{enumerate}

\subsection{Logical Operators and Quantifiers}

VCC provides a number of C extensions that can be used within VCC
annotations (such as assertions):
\begin{itemize}
\item
The Boolean operator \vcc{==>} denotes logical implication; formally,
\vcc{P ==> Q} means \vcc{((!P) || (Q))}, and is usually
read as ``\vcc{P} implies \vcc{Q}''. Because \vcc{==>} has lower
precedence than the C operators, it is typically not necessary to
parenthesize \vcc{P} or \vcc{Q}.
\item
The expression \vcc{\forall T v; E} evaluates to \vcc{1} if the
expression \vcc{E} evaluates to a nonzero value for every value
\vcc{v} of type \vcc{T}. For example, the assertion
\begin{VCC}
_(assert x > 1 &&
  \forall int i; 1 < i && i < x ==> x % i != 0)
\end{VCC}
\noindent checks that (\vcc{int}) \vcc{x} is a prime number. If \vcc{b}
is an \vcc{int} array of size \vcc{N}, then
\begin{VCC}
_(assert \forall int i; \forall int j;
  0 <= i && i <= j && j < N ==> b[i] <= b[j])
\end{VCC}
checks that \vcc{b} is sorted.

\item
Similarly, the expression \vcc{\exists T v; E} evaluates to \vcc{1} if there
is some value of \vcc{v} of type \vcc{T} for which \vcc{E} evaluates
to a nonzero value. For example, if \vcc{b} is an \vcc{int} array of
size \vcc{N}, the assertion
\begin{VCC}
_(assert \exists int i; 0 <= i && i < N && b[i] == 0)
\end{VCC}
asserts that  \vcc{b} contains a zero element.
\vcc{\forall} and \vcc{\exists} are jointly referred to as
\Def{quantifiers}.
\item
The type \vcc{\integer} represents the type of mathematical integers;
the type \vcc{\natural} denotes the type of natural numbers.

\item
VCC provides map types; they are declared and used like arrays, but with a type
instead of a size. For example, \vcc{\integer x[int]} declares \vcc{x}
to be a map from C \vcc{int}s to \vcc{\integer}s, and \vcc{x[-5]} is
the \vcc{\integer} to which \vcc{x} maps \vcc{-5}. We'll see map types
used in \secref{ghosts}.

\item
Expressions within VCC annotations are restricted in their use of
functions: you can only use functions that are proved to be
\Def{pure}, \ie free from side effects (\secref{pureFunctions}).
\end{itemize}

\subsection*{Exercises}
\begin{enumerate}
\item Write an assertion that says that the \vcc{int} \vcc{x} is a
  perfect square (\ie a number being a square of an integer).
\item Write an assertion that says that the \vcc{int} \vcc{x} occurs
  in the \vcc{int} array \vcc{b[10]}.
\item Write an assertion that says that the \vcc{int} array \vcc{b},
  of length \vcc{N}, contains no duplicates.
\item Write an assertion that says that all pairs of adjacent elements
  of the \vcc{int} array \vcc{b} of length \vcc{N} differ by at most
  \vcc{1}.
\item Write an assertion that says that an array \vcc{b} of length
  \vcc{N} contains only perfect squares.
\end{enumerate}

\subsection*{Solutions}
\begin{enumerate}
\item \vcc{_(assert \exists unsigned y; x == y*y)}
\item \vcc{_(assert \exists unsigned i; i < 10 && b[i] == x)}
\item
\vcc{_(assert \forall unsigned i,j; i < j && j < N ==> b[i] != b[j])}
\item
\begin{VCC}
_(assert \forall unsigned i,j; 0 <= i && i+1 < N
        ==> -1 <= b[i] - b[i+1] && b[i] - b[i+1] <= 1)
\end{VCC}
\item
\vcc{_(assert \forall unsigned i; i < N ==> \exists unsigned j;  b[i] == j * j)}
\end{enumerate}

\subsection{Assumptions}

You can add to what VCC knows at a particular point with a second
type of annotation, called an \Def{assumption}.
The assumption \vcc{_(assume E)} tells VCC to ignore
the rest of an execution if \vcc{E} fails to hold (\ie if
\vcc{E} evaluates to \vcc{0}).
Reasoning-wise, the assumption simply adds \vcc{E} to what VCC
knows for subsequent reasoning. For example:
\begin{VCC}
int x, y;
_(assume x != 0)
y = 100 / x;
\end{VCC}
Without the assumption, VCC would complain about possible division by
zero. (VCC checks for division by zero because it would cause the
program to crash.)  Assuming the assumption, this error cannot happen.
Since assumptions (like all annotations) are not seen by the compiler,
assumption failure won't cause the program to stop, and subsequent assertions
might be violated. To put it another way, if VCC verifies a program,
it guarantees that in any prefix of an execution
where all (user-provided) assumptions hold, all assertions will also
hold. Thus, your verification goal should be to eliminate as many assumptions as
possible (preferably all of them).

\begin{note}
Although assumptions are generally to be avoided, they are nevertheless
sometimes useful:
\begin{inparaenum}
\item In an incomplete verification, assumptions can be used to mark
  the knowledge that VCC is missing, and to coordinate further
  verification work (possibly performed by other people). If you
  follow a discipline of keeping your code in a state where the whole
  program verifies, the verification state can be judged by browsing
  the code (without having to run the verifier).

\item When debugging a failed verification, you can use assumptions to
  narrow down the failed verification to a more specific failure
  scenario, perhaps even to a complete counterexample.

\item Sometimes you want to assume something even though VCC can
  verify it, just to stop VCC from spending time proving it. For
  example, assuming \vcc{\false} allows VCC to
  easily prove subsequent assertions, thereby focussing its
  attention on other parts of the code. Temporarily adding assumptions
  is a common tactic when developing annotations for complex functions.

\item Sometimes you want to make assumptions about the operating
  environment of a program. For example, you might want to assume that
  a 64-bit counter doesn't overflow, but don't want to justify it
  formally because it depends on extra-logical assumptions (like the
  speed of the hardware or the lifetime of the software).

\item Assumptions provide a useful tool in explaining how VCC
  reasons about your program. We'll see examples of this throughout
  this tutorial.
\end{inparaenum}
\end{note}

An assertion can also change what VCC knows after the assertion, if
the assertion fails to verify: although VCC will report the failure as an error,
it will assume the asserted fact holds afterward. For example, in the following
VCC will report an error for the first assumption, but not for the second:
\begin{VCC}
int x;
_(assert x == 1)
_(assert x > 0)
\end{VCC}

\subsection*{Exercises}
\begin{enumerate}
\item
In the following program fragment, which assertions will fail?
\begin{VCC}
int x,y;
_(assert x > 5)
_(assert x > 3)
_(assert x < 2)
_(assert y < 3)
\end{VCC}
\item
Is there any difference between
\begin{VCC}
_(assume p)
_(assume q)
\end{VCC}
and
\begin{VCC}
_(assume q)
_(assume p)
\end{VCC}
? What if the assumptions are replaced by assertions?
\item
Is there any difference between
\begin{VCC}
_(assume p)
_(assert q)
\end{VCC}
and
\begin{VCC}
_(assert (!p) || (q))
\end{VCC}
?

\end{enumerate}

\subsection*{Solutions}
\begin{enumerate}
\item
\begin{VCC}
int x,y;
_(assert x > 5) // fails
_(assert x > 3) // succeeds
_(assert x < 2) // fails
_(assert y < 3) // fails
\end{VCC}
\item
No difference for assumptions. For assertions, the order does matter,
because the first assertion might allow the second to succeed.
\item
If one of the assertions succeeds, the other will also. However,
assuming and then asserting leaves the assumption in effect for the
code that follows, whereas asserting the conditional does not.
\end{enumerate}


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

% import packages and commands
\input{../header2.tex}

\title{Math 217 -- Geometry and Physics -- Lec09}
\author{UCLA, Fall 2014}
\date{\formatdate{22}{10}{2014}} % Activate to display a given date or no date (if empty),
         % otherwise the current date is printed

\begin{document}
\maketitle

\section{More stuff}

We are considering a bundle $E \rightarrow M$ with inner product $\inner{\cdot}{\cdot}$ with associated metric connection $\nabla$. Last time we found $^t \bar{\Omega} = -\Omega$ and $c_j(E) = \bar{c_j(E)}$, where $c_j(E) \in H^{2j}(M, \reals)$. We will see that $c_j(E) \in H^{2j} (M, \ints)$.

\begin{exercise}
Given $\omega = \omega(t)$ a family of connections, we have the curvature $\Omega = \Omega(t) = \dif \omega - \omega \wedge \omega$. Prove that
\begin{enumerate}
\item \begin{align}
\od{}{t} \log \det (1 + q\Omega) &= q \tr \left[ (1+q\Omega)^{-1} \dot{\Omega} \right] \\
	&= \sum_{\ell = 0}^\infty (-1)^\ell q^{\ell +1} \tr \left( \Omega^\ell (\dif \dot \omega - \omega \dot \omega - \dot \omega \omega) \right).
\end{align}
\item Use the Bianchi identity $\dif \Omega = \Omega \omega - \omega \Omega$ to show that
\begin{align}
\tr \left( \Omega^\ell (\omega \dot \omega + \dot \omega \omega ) \right) &= \tr ( \Omega^\ell \omega \dot \omega - \omega \Omega^\ell \dot \omega) \\
	&= \tr \left( (\dif \Omega^\ell) \dot \omega \right).
\end{align}
\item \begin{eqn}
\od{}{t} \log \det (1 + q\Omega) = \dif \left\{ \sum_{\ell=0}^\infty (-1)^\ell q^{\ell+1} \tr (\Omega^\ell \dot \omega) \right\}.
\end{eqn}
This implies Chern-Weil theory.
\end{enumerate}
\end{exercise}

Since $\Omega$ is skew-Hermitian, i.e. [LHS is typeset wrong, see TeX]
\begin{eqn}
\det {^t \bar{ tI + (i / 2\pi) \Omega }} = \det (tI + \frac{i}{2\pi} \Omega)
\end{eqn}
so $\bar{c_j(E)} = c_j(E)$, we can formally diagonalize $\Omega$
\begin{eqn}
\frac{i}{2\pi} \Omega = \opname{diag} (x_1, \dots, x_r) \quad \implies \quad c_j(E) = \sigma_j (x_1, \dots, x_r)
\end{eqn}
where $\sigma_j$ are the elementary symmetric functions. We will call the $x_i$ the Chern roots and see that they are some form of line bundle. Formally, we have
\begin{eqn}
\frac{i}{2\pi} \Omega = \opname{diag} \left[ \pmat{0 & x_1 \\ -x_1 & 0}, \dots, \pmat{0 & x_r \\ -x_r & 0} \right]
\end{eqn}
and
\begin{eqn}
P_j(E) = \sigma_j (x_1^2, \dots, x_r^2),
\end{eqn}
where the Euler class is
\begin{eqn}
e(E) = \prod_{j=1}^r x_j = \opname{Pf} \frac{i}{2\pi} \Omega.
\end{eqn}

\begin{example}
Some examples:
\begin{enumerate}
\item The trivial bundle, $\nabla = \dif$, $\Omega = \dif^2 = 0$, implies that $c_j = 0$, $p_j = 0$ for $j \geq 1$ and $c_0 = p_0 = 1$.
\item The $n$-sphere, $TS^n \rightarrow S^n$, where
\begin{eqn}
TS^n \oplus N \cong \eval[1]{T\reals^{n+1}}_{S^n}
\end{eqn}
with $N$ the trivial line bundle. Then for the total Chern and Pontryagin numbers
\begin{align}
c(E) &= 1 + c_1(E) + \dots + c_r(E) \\
p(E) &= 1 + p_1(E) + \dots + p_r(E),
\end{align}
we have
\begin{eqn}
P(TS^n \oplus N) = P(\eval[1]{T\reals^{n+1}}_{S^n}) = 1
\end{eqn}
and $P(N) = 1$ so we find $P(TS^n) = 1$.
\end{enumerate}
\end{example}

It's a basic property of Chern classes that
\begin{enumerate}
\item $c(E \oplus E') = c(E) c(E')$,
\item Given $f : M \rightarrow N$, we have $c(f^* E) = f^*(c_1(E))$.
\end{enumerate}
Proof: 1. On $E \oplus E'$, we have
\begin{eqn}
\nabla = \pmat{\nabla^E & 0 \\ 0 & \nabla^{E'}} \quad \implies \quad \Omega = \pmat{\Omega^E & 0 \\ 0 & \Omega^{E'}}.
\end{eqn}
2. Due to the induced connection on $f^* E$, $f^* \nabla^E$
\newline

[Missed an example on projective spaces here]

\begin{theorem}
(Grothendieck) For any complex vector bundle on a closed manifold $M$, there exist unique Chern classes $c_j(E) \in H^{2j}(X, \ints)$ such that
\begin{enumerate}
\item $c_0(E) = 1$ and $c_j(E) = 0$ for $j > r = \opname{rank} E$
\item Given smooth map $f : M \rightarrow N$, we have $c_j(f^* E) = f^* c_j(E)$ (`Naturality')
\item $c(E \oplus E') = c(E) c(E')$
\item For $\bigo(-1) = L \rightarrow \mathbb{P}^1$, we have
\begin{eqn}
c_1(L^*) = c_1(\bigo(1)) = g \quad \text{where} \quad \int_{\mathbb{P}^1} g = 1.
\end{eqn}
\end{enumerate}
\end{theorem}

\subsection{Splitting principle}

Given complex vector bundle $E \overset{\pi}{\longrightarrow} M$, there exists a flag bundle $F(E)$ on $M$ such that
\begin{enumerate}
\item $\pi : F(E) \rightarrow M$, $\pi^* E \cong L_1 \oplus \cdots \oplus L_r \rightarrow F(E)$
\item $\pi^* : H^*(M) \rightarrow H^*(F(E))$ is injective.
\end{enumerate}
Then there are maps $\pi_i$ such that
\begin{eqn}
\begin{matrix}
E & & \pi_1^* E = S_1 \oplus Q_1 & & \pi_2^* Q_1 = S_2 \oplus Q_2 \\
\downarrow & & \downarrow & & \downarrow \\
M & \overset{\pi_1}{\longleftarrow} & P(E) & \overset{\pi_2}{\longleftarrow} & P(Q_1) & \overset{\pi_3}{\longleftarrow} \cdots \longleftarrow P(Q_{r-2}) = F(E)
\end{matrix}
\end{eqn}

We have $\pi^* c_j(E) = \sigma_j (x_1, \dots, x_r) $ where $x_k = c_1(L_k)$

\begin{remark}
To prove identities of Chern classes, can prove using Chern roots.
\end{remark}

\end{document}


\chapter{Introduction}

Although at the present time the Standard Model (SM) shows good agreement
with all available experimental data, there are several reasons
to expect the existence of new physics beyond the SM.

\P
First, to calculate measurable quantities the theory should be
renormalized. Such procedure inevitably introduces some energy scale
at which the theory can not be applied any more. Although this scale can be
set to an arbitrary high value, it means that the SM can be viewed
only as a low energy approximation of some other theory.

\P
The second problem comes from the fact that the SM does not describe
gravitation. At the energy scale of $10^{19}$ GeV the gravitational
interaction between particles becomes as strong as any other interaction.
It is expected that at this energy the effects of quantum gravity will play
an important role.

\P
During the last years several approaches were developed to overcome
these problems. Most of them contain a new symmetry between fermions and
bosons called {\it supersymmetry}~\cite{supersymmetry-appearance}.
Moreover, it seems that only supersymmetric
theories can be used to unify gravity with other fundamental
forces. Still such theories require a renormalization to be carried out.

\P
Among other features the supersymmetric models predict the existence
of new particles that are the superpartners of the ordinary particles
of the SM. It is expected that such particles can be detected at future
colliders. For this reason it is very important to study the properties
of the new particles and processes that can be used to detect them.

\P
For example, the simplest supersymmetric generalization of the SM
called the {\it Minimal Supersymmetric Standard Model}
(MSSM)~\cite{howCharginosCome} contains new
fermions called charginos and neutralinos
that are Dirac and Majorana particles. They are of particular interest due
to their coupling with leptons and gauge bosons that makes it
possible to detect them in $e^+e^-$ collisions.

\P
In this thesis I consider some properties of Majorana fields and calculate
the production cross-section for the lightest charginos.

\P
In chapter 2, I consider various properties of the Dirac algebra
and massive fermion fields in a quite general way.
I prove that electric and magnetic dipole moments
of Majorana particles are zero. The proof uses only basic properties of
the Dirac matrices and does not refer for example to the CPT theorem.

\P Chapter 3 deals mostly with the quadratic and cubic terms
in the MSSM Lagrangian that give masses to the charginos and scalar neutrinos
and describes the coupling between these particles and the electromagnetic and
$Z^0$ fields.

\P The calculation of the lightest chargino production cross section is the
topic of Chapter 4. I perform the calculation in the general case of
CP violation in the chargino sector.

\P
In chapter 5 I present numerical results for the chargino production
cross section.


\documentclass{amsart}

\newcommand{\br}{{\mathbf r}}
\newcommand{\e}{{\mathbf e}}
\newcommand{\brho}{{\boldsymbol \rho}}
\newcommand{\bnabla}{{\boldsymbol \nabla}}

\title{Using the Spherical Software}

\begin{document}

\maketitle

\noindent
The {\tt spherical} software is invoked by the command
\begin{center}
{\tt spherical -p parameter-file.txt}
\end{center}
where {\tt parameter-file.txt} is a text file that sets various parameters, described below.  The command can be invoked with two other command line options, for example:
\begin{center}
{\tt spherical -p parameter-file.txt -o output-file -v10}
\end{center}
where {\tt output-file} is the output file, which will default to {\tt s.out} if not specified, and {\tt -v} denotes verbose output, and if followed by a number $n$, will write out to the console every $n$th time it writes data to the output file.

The program {\tt spherical} uses spherical harmonics to solve Jeffery's equation \cite{jeffery} for $\psi=\psi(\br)$:
$$ \frac\partial{\partial t}\psi = \bnabla\cdot\bigl(-\dot\br \psi + \bnabla(D_r \psi)\bigr) ,$$
where
$$ \dot\br = \tfrac12(\mathbf w \times\br) + \lambda \dot{\tilde\br} ,\quad \dot{\tilde\br} = \tfrac12(\Gamma \cdot\br - \Gamma:\br\br\br) , $$
where $\Gamma$ is the rate of strain tensor, and $\mathbf w$ is the vorticity.  Note that $\bnabla$ here denotes the gradient projected tangentially to the sphere, namely $\bnabla f = (I-\br\br)\cdot(\tfrac{\partial f}{\partial x},\tfrac{\partial f}{\partial y},\tfrac{\partial f}{\partial z})$.

\section*{Basic Parameters}

\noindent
The parameter file consists of a number of lines, each of the form
\begin{center}
{\tt parameter=value}
\end{center}
The order in which they are written in the parameter file is unimportant.

\begin{itemize}
\item Step size of time is set by the parameter {\tt h}.  By default, the program uses the order two Adams-Bashforth multistep method.
\item The parameter set as {\tt ode\_adams\_bash\_4=1} will cause the program will use the order four Adams-Bashforth multistep method.
\item The parameter set as {\tt ode\_rk\_4=1} will cause the program will use the order four Runge-Kutta method.
\item Data will be printed to the output file every {\tt print\_every} time steps.
\item The number of threads used by the program is set by {\tt nr\_threads}.  This can be overridden by the environment variable {\tt NR\_THREADS} (using,for example, the {\tt SET} command in the windows command shell, or the {\tt export} or {\tt env} commands in the unix {\tt sh} or {\tt bash} shells.)
\item The parameter {\tt max\_order} sets the order of spherical harmonics used.
\item The start time and stop time are set by parameters {\tt tstart} and {\tt tend}.
\item The rate of strain tensor is set by parameters {\tt gamma11}, {\tt gamma12}, {\tt gamma13}, {\tt gamma22}, {\tt gamma23}, {\tt gamma33}.
\item The vorticity is set by parameters {\tt w1}, {\tt w2}, {\tt w3}.
\item By default, the initial state is $\psi = 1/4\pi$.  The parameter set as {\tt enter\_aij\_init=1} will cause the initial state to be quadratic with second order moments defined by parameters {\tt a11\_init}, {\tt a12\_init}, {\tt a13\_init}, {\tt a22\_init}, {\tt a23\_init}, {\tt a33\_init}.  (Note that if any of the eigenvalues of the initial state matrix are less than $1/5$, then $\psi$ will be negative on parts of the sphere, and as such $\psi$ will not represent a probability distribution.)
\end{itemize}

\section*{Output}

\noindent
The program, by default, will write to the output file a series of lines containing
\begin{center}$t$ $a_{11}$ $a_{22}$ $a_{33}$ $a_{12}$\end{center}
This same information is output to the console if the command line option {\tt -v} with a number is specified.  Here $a_{ij}$ are the coefficients of the second moments tensor.  Similarly $a_{ijkl}$ are the coefficients of the fourth moments tensor, and $a_{ijklmn}$ are the coefficients of the sixth moments tensor.
\begin{itemize}
\item The parameter set as {\tt print\_aij=1} will cause the lines written to the output file to change to
\begin{center}$t$ $a_{11}$ $a_{12}$ $a_{13}$ $a_{22}$ $a_{23}$ $a_{33}$\end{center}
(but the output to the console will remain as before).
\item The parameter set as {\tt print\_aijkl=1} will add to the end of each line of output the values\\
$a_{1111}$ $a_{1112}$ $a_{1113}$ $a_{1122}$ $a_{1123}$ $a_{1133}$ $a_{1222}$ $a_{1223}$ $a_{1233}$ $a_{1333}$ $a_{2222}$ $a_{2223}$ $a_{2233}$ $a_{2333}$ $a_{3333}$
\item The parameter set as {\tt print\_aijklmn=1} will add to the end of each line of output the values\\
$a_{111111}$ $a_{111112}$ $a_{111113}$ $a_{111122}$ $a_{111123}$ $a_{111133}$ $a_{111222}$ $a_{111223}$ $a_{111233}$ $a_{111333}$ $a_{112222}$ $a_{112223}$ $a_{112233}$ $a_{112333}$ $a_{113333}$ $a_{122222}$ $a_{122223}$ $a_{122233}$ $a_{122333}$ $a_{123333}$ $a_{133333}$ $a_{222222}$ $a_{222223}$ $a_{222233}$ $a_{222333}$ $a_{223333}$ $a_{233333}$ $a_{333333}$
\end{itemize}

\section*{Folgar-Tucker model}

\noindent
The program will default to solving Jeffery's equation with the Folgar-Tucker diffusion term \cite{folgar}.  This sets the diffusion term to $ D_r = C_I \gamma $.
Here, and elsewhere, $\gamma = \left(\frac12\Gamma:\Gamma\right)^{1/2}$.
\begin{itemize}
\item The parameter {\tt lambda} is the Jeffery's parameter $\lambda$.
\item The parameter {\tt CI} sets the parameter $C_I$.
\end{itemize}

\section*{Modified Koch model}

\noindent
This provides an anisotropic diffusion model:
\begin{align*}
\frac\partial{\partial t}\psi &= - \bnabla\cdot(\dot\br \psi) + \bnabla\cdot(I-\br\br)\cdot D_r\cdot\bnabla\psi \\
&\qquad - \mathbf L\cdot(I-\br\br)\cdot E_r\cdot\mathbf L \psi \\
& = - \bnabla\cdot(\dot\br \psi) + (\bnabla-2\br)\cdot D_r\cdot\bnabla\psi - \mathbf L \cdot E_r \cdot \mathbf L \psi .
\end{align*}
Here $(I-\br\br)$ is the matrix of the projection onto the tangent space of the sphere, and $\mathbf L = -i \br \times \bnabla$ is the so called angular momentum operator.  (Note that the Laplacian operator can be expressed two different ways as $\bnabla\cdot\bnabla = -\mathbf L \cdot \mathbf L$.)

Koch \cite{koch} defines $D_r$ as the matrix
$$ D_r = C_1 \gamma^{-1} (\Gamma: \mathbb A:\Gamma) I + C_2 \gamma^{-1} \Gamma: \mathcal A:\Gamma .$$
Here $A$, $\mathbb A$, and $\mathcal A$ are the tensors of $2$nd, $4$th and $6$th moments, respectively, of $\psi$.  This software has an additional modification in the form of $E_r$:
$$ E_r = C_3 \gamma^{-1} \Gamma: \mathcal A:\Gamma .$$
\begin{itemize}
\item The parameter set as {\tt do\_koch=1} will cause the modified Koch diffusion model to be used.
\item The parameter {\tt lambda} is the Jeffery's parameter $\lambda$.
\item The parameters {\tt C1}, {\tt C2} and {\tt C3} are the modified Koch parameters $C_1$, $C_2$ and $C_3$.
\end{itemize}

\section*{Directional diffusion models}

\noindent
These give values for $D_r=D_r(\br)$ that depend upon $\br$, in the diffusion term of Jeffery's equation.  The first directional diffusion model is described in the Ph.D.\ thesis of David Jack \cite{jack}:
$$ D_r = C_1 \gamma^{-1} \int_{\brho \in S^2} \bigl(|\brho\cdot(\br\times\dot{\tilde\brho})|^2 + |\brho\cdot(\br\times\dot{\tilde\br})|^2\bigr) \psi(\brho) \, d\brho +
C_2 \gamma ,$$
and the second directional diffusion model is
$$ D_r = C_1 \gamma^{-1} \int_{\brho \in S^2} |\brho\cdot(\br\times(\dot{\tilde\brho}-\dot{\tilde \br}))|^2 \psi(\brho) \, d\brho +
C_2 \gamma .$$
\begin{itemize}
\item The parameter set as {\tt do\_dd=1} will cause the first directional diffusion model to be used.
\item The parameter set as {\tt do\_dd\_2=1} will cause the second directional diffusion model to be used.
\item The parameter {\tt lambda} is the Jeffery's parameter $\lambda$.
\item The parameters {\tt C1} and {\tt C2} are the directional diffusion parameters $C_1$ and $C_2$.
\end{itemize}

\section*{Variable diffusion models}

\noindent
Define $s_\nu$ for $\nu=1,2$:
$$ s_1 = \left|\int_{S^2} \Gamma:\brho\brho \psi(\brho) \, d\brho\right|
   = |A :\Gamma| ,$$
$$ s_2 = \left(\int_{S^2} \left|\Gamma:\brho\brho\right|^2 \psi(\brho) \, d\brho\right)^{1/2} = \left(\Gamma: \mathbb A:\Gamma\right)^{1/2} . $$
The variable diffusion model sets the diffusion term in Jeffery's equation to $D_r = C_1 s_\nu$.
\begin{itemize}
\item The parameter {\tt do\_vd} can take the values {\tt 1} or {\tt 2}, and will cause the variable diffusion model to be used with the appropriate value of $\nu$.
\item The parameter {\tt lambda} is the Jeffery's parameter $\lambda$.
\item The parameter {\tt C1} is the parameter $C_1$.
\end{itemize}

\section*{Variable lambda models}

\noindent
The Jeffery's parameter is allowed to vary as $\lambda = \lambda_1 - \lambda_2 \gamma^{-1} s_\nu $.
This can be used in conjunction with any of the diffusion models.
\begin{itemize}
\item The parameter {\tt do\_vl} can take the values {\tt 1} or {\tt 2}, and will cause the variable lambda model to be used with the appropriate value of $\nu$.
\item The parameters {\tt lambda1} and {\tt lambda2} replace the parameter {\tt lambda}.
\end{itemize}

\section*{The RSC model of Wang, O'Gara and Tucker}

\noindent
This causes an artificial scaled reduction of the evolution of $\psi$, the ``Reduced-Strain Closure" model.  This can be used in conjunction with any of the other models.  It is described in \cite{rsc}, and the file {\tt rsc.pdf}.  It causes the P.D.E.\
$$ \frac{\partial}{\partial t}\psi(\br) = F(\br),$$
to be replaced by
$$ \frac{\partial}{\partial t}\psi(\br) = F(\br) - \tfrac{15}{8\pi}(1-\kappa)(\br\br-\tfrac15 I):\mathbb M:\int_{S^2} F(\brho) \brho\brho \, d\brho,$$
where $\mathbb M = \sum_{i=1}^3 \e_i\e_i\e_i\e_i$, with $\e_1$, $\e_2$, $\e_3$ being the orthonormal eigenvectors of $A$.

This method has intellectual property restrictions \cite{rsc-pat}.  If you use {\tt do\_rsc=1}, the program will interrogate you to see if you comply with this patent.  You may switch off the interrogation by setting the environment variable {\tt MAY\_USE\_PATENT\_7266469}.

\begin{itemize}
\item The parameter set as {\tt do\_rsc=1} causes RSC to take place.
\item The parameter {\tt kappa} sets the scale reduction factor $\kappa$.
\end{itemize}

\section*{The ARD model of Phelps and Tucker}

\noindent
This ``Anisotropic Rotary Diffusion'' model is described in \cite{ard}.  This is the same form as the Koch model, with
$$ D_r = b_1 \gamma I + b_2 \gamma A + b_3 \gamma A^2 + \tfrac12{b_4} \Gamma + \tfrac14{b_5}\gamma^{-1} \Gamma^2 .$$

\begin{itemize}
\item The parameter set as {\tt do\_ard=1} causes ARD to be used.
\item The parameters {\tt b1}, {\tt b2}, {\tt b3}, {\tt b4} and {\tt b5} set $b_1$, $b_2$, $b_3$, $b_4$ and $b_5$.
\end{itemize}

\section*{Acknowledgments}

\noindent
This work was supported by the National Science Foundation, Division of Civil, Mechanical and Manufacturing Innovation, award number 0727399 (NSF CMMI 0727399).

\begin{thebibliography}{99}
\bibitem{jeffery}
G.B. Jeffery, The Motion of Ellipsoidal Particles Immersed in a Viscous Fluid, Proceedings of the Royal Society of London A {\bf 102}, 161-179, (1923).
\bibitem{folgar}
F.P. Folgar and C.L. Tucker, Orientation Behavior of Fibers in Concentrated Suspensions, Jn. of Reinforced Plastics and Composites {\bf 3}, 98-119 (1984).
\bibitem{koch}
D.L. Koch, A Model for Orientational Diffusion in Fiber Suspensions, Physics of Fluids {\bf 7}, 2086-2088 (1995).
\bibitem{jack}
D.A. Jack, Advanced analysis of short-fiber polymer composite material behavior, Ph.D.\ thesis, University of Missouri (2006).
\bibitem{rsc-pat}
C.L. Tucker III, J. Wang, and J.F. O'Gara, Method and article of manufacture for determining a rate of change of orientation of a plurality of fibers disposed in a fluid. U.S. Patent No. 7,266,469 (2007).
\bibitem{rsc}
Jin Wang, John F. O'Gara, and Charles L. Tucker, III, An objective model for slow orientation kinetics in concentrated fiber suspensions: Theory and rheological evidence, J. Rheology {\bf 52}, 1179-1200 (2008).
\bibitem{ard}
Jay H. Phelps and Charles L. Tucker III, An anisotropic rotary diffusion model for fiber orientation in short- and long-fiber thermoplastics, Journal of Non-Newtonian Fluid Mechanics, to appear (2008).
\end{thebibliography}

\end{document}


\label{sec:model}
This section builds a simple toy model to understand how copyright might affect the reuse of digitized information.

\subsection*{Setup}

Consider a wikipedia page $W_{q,k}$ for an item of quality $q$ and knowledge level $k$. The quality is a parameter that captures how inherently interesting a topic is, for example a famous, well-known baseball player will have higher $q$ than a less well-known player. Knowledge level $k$ captures how much information exists on a given page. Let $q \in \{0,\infty\}$ and $k \in \{{1}/{4},\infty\}$.

Now define value, $V(W_{q,k})=\sqrt{q}+\sqrt{k}-\frac{k}{4}$ to be the value that the Wikipedia community delivers from a page $W_{q,k}$.  In a context like Wikipedia, $V$ could be the traffic that a page receives for example. Note that while $\frac{dV}{dq}>0$ and $\frac{dV}{dk}>0$, $\frac{d^2V}{dq^2}<0$ and $\frac{d^2V}{dk^2}<0$. This simply implies diminishing but positive marginal returns from increased information and increased player quality to $V$.

Define $C(W_{q,k})=\frac{k}{q}$ to be the cost of adding $k$ units of information to a page with quality level $q$. Here, $\frac{dC}{dk}>0$ implying higher costs of information acquistion for higher levels of knowledge, but $\frac{dC}{dq}<0$ , implying that it is easier to source information for higher quality topics, presumably because such information is more easily available.

Under this setup, the Wikipedia community solves the following, simple maximization problem to determine optimal levels of $k$, i.e. $k^*$

$$k^* = \max_k \Big[ V(W_{q,k}) - C(W_{q,k}) \Big]$$

$$k^* = \max_k \Big[\sqrt{q}+\sqrt{k}-\frac{k}{4} - k/q\Big]$$

$$k^* = \frac{4q^2}{(q+4)^2}$$

\subsection*{Digitization and Copyright}

Now consider that a digitization project makes it easier to access information to a certain topic, but that these reduction in costs depend on the copyright status of the underlying material. For topics that can benefit from out-of-copyright material, this reduction in cost is greater than it is for in-copyright material. A general way to parameterize this change is to assume that costs of adding information are reduced differentially for different copyright status groups.

\newpage

Accordingly, let $$C_{in-copy}(W_{q,k})=\frac{C(W_{q,k})}{2}=\frac{k}{2q}$$ $$C_{out-of-copy}(W_{q,k})=\frac{C(W_{q,k})}{4}=\frac{k}{4q}$$

Solving a similar maximization problem as before, we now obtain:

$$k^*_{in-copy}= \frac{4q^2}{(q+2)^2}$$

$$k^*_{out-of-copy}= \frac{4q^2}{(q+1)^2}$$

Therefore, $k^*_{out-of-copy}>k^*_{in-copy}>k^*$. This setup delivers the first two results that we obtained in the main part of the paper, i.e. digitization increased amount of information for both in-copyright and out-of-copyright pages, but this increase is significantly greater for out-of-copyright pages.

\subsection*{Differential Effects for Images vs. Text}

While the previous section modeled the idea that copyright restrictions create differential cost reductions for digital information, the differential impact of copyright by media type were not discussed. However, while it is possible to paraphrase textual material without violating copyright, reusing copyrighted images without violating copyright is harder.

Accordingly, let

$$C^{images}_{in-copy}(W_{q,k})=C^{text}_{in-copy}(W_{q,k})=\frac{C(W_{q,k})}{2}=\frac{k}{2q}$$

$$C^{images}_{out-of-copy}(W_{q,k})=\frac{C(W_{q,k})}{4}=\frac{k}{4q}$$
$$C^{text}_{out-of-copy}(W_{q,k})=\frac{C(W_{q,k})}{2}=\frac{k}{2q}$$

Solving the maximization problem, we obtain:

$$k^{*text}_{out-of-copy}=k^{*text}_{in-copy}= \frac{4q^2}{(q+2)^2}$$

$$k^{*images}_{out-of-copy}= \frac{4q^2}{(q+1)^2} \hspace{5mm} \Big >  \hspace{5mm} k^{*images}_{in-copy}= \frac{4q^2}{(q+2)^2}$$

Therefore, as is clear from this simple example, the differential cost reductions for images and text provides a direct prediction: the impact of copyright on reducing information reuse is driven primarily by a difference in the reuse of images rather than the reuse of textual information.

\subsection*{Differential Effects by Quality Levels}

Now consider the impact of the copyright law on affecting increase in knowledge for topics of different quality types.

For in-copyright topics, percent increase in knowledge $\Delta k_{in-copy}=\frac{k^*_{in-copy}-k^*}{k^*}$ and similarly, for out-of-copyright topics, $\Delta k_{out-of-copy}=\frac{k^*_{out-of-copy}-k^*}{k^*}$. Solving we get:

$$ \Delta k_{in-copy} = \frac{4q^2}{(q+4)^2} \Big[ \frac{4(q+3)}{(q+2)^2} \Big] $$

$$ \Delta k_{out-of-copy} = \frac{4q^2}{(q+4)^2} \Big[ \frac{3(2q+5)}{(q+1)^2} \Big] $$

$$ \therefore \Delta = \Delta k_{out-of-copy} - \Delta k_{in-of-copy} = \frac{4q^2 (2q+3)}{(q+1)^2(q+2)^2} $$

%%\Big[\frac{(q+4)^2(2q+3)}{(q+1)^2(q+2)^2} \Big]$$

$$ \therefore \frac{d\Delta}{dk} = - \Big[ \frac{8q(q^3-6q-6)}{(q+1)^3(q+2)^3} \Big] $$

%%  \frac{2(q+4)(q^3+12q^2+30q+22)}{(q+1)^3(q+2)^3}   $$
%% \implies \boxed{\Delta > 0} \hspace{5mm} and

$$ \implies \hspace{5mm} \boxed{\frac{d\Delta}{dq} > 0 \hspace{5mm} \forall q \in (0, \approx 2.84)}  \hspace{5mm} and \hspace{5mm} \boxed{\frac{d\Delta}{dq} < 0 \hspace{5mm} \forall q \in (\approx 2.84,\infty)}$$

Therefore, under this simple model, while the increase in information reuse is greater for out-of-copyright topics than for in-copyright topics at the same quality level, this magnitude of this positive effect depends significantly on the quality level $q$ of the topic. For low $q$ (i.e. $0<q<\approx2.84$), higher quality topics experience a greater increase in information reuse as compared to lower quality topics. The intuition for this effect is simple, returns to information are higher for higher quality topics, and therefore a greater reduction in cost of adding information due to a lack of copyright is most beneficial for these topics. However, after a certain threshold, this logic no longer applies, and an increase in topic quality reduces the benefit from out-of-copyright status. The intuition for this effect is the following: higher quality topics had higher levels of initial information, and returns to adding more information are decreasing. Therefore, it becomes more valuable to add information to lower quality topics because these have a lower starting starting point, as compared to adding information to topics that already have higher levels of information to begin with.

In this way -- the model builds intuition for the key results of the paper, (i) digitization improves the quality of Wikipedia information, (ii) Copyright law reduces the potential benefits from digitiziation (iii) copyright mainly operates through the reuse of images rather than text and (iv) Potential benefits from a lack of copyright on digital material are greatest for topics of ``intermediate'' quality.

\begin{center}
\textbf{Fig: A plot of how $\Delta$ varies with $q$}
\includegraphics[scale = 0.3]{../tables/model.png}
\end{center}

%Now, for all $q \in \{0,\infy \}$, we have $\Delta k_{out-of-copy}>\Delta k_{in-copy}$


\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{bm}
\usepackage[margin=1in]{geometry}
\usepackage{mathtools}
\usepackage{relsize}

\newcommand{\bmmp}{\bm{\mathcal{P}}} % curve
\newcommand{\splinept}{\sum_j{Q_j(t)\bm{P}_j}}
\newcommand{\half}{\frac{1}{2}}
\newcommand{\vP}{\bm{\mathrm{P}}} % control point vector
\newcommand{\vPT}{\bm{\mathrm{P}}^{\intercal}}
\newcommand{\vQ}{\bm{\mathrm{Q}}} % cardinal basis vector
\newcommand{\vQT}{\bm{\mathrm{Q}}^{\intercal}} % cardinal basis vector
\newcommand{\mM}{\mathbf{M}} % matrix
\newcommand{\mMT}{\mathbf{M}^{\intercal}} % matrix

%% open derivative matrix left
\newcommand{\odml}{\begin{pmatrix}\bm{I_m},\bm{0}\end{pmatrix}}
%% open derivative matrix right
\newcommand{\odmr}{\begin{pmatrix}\bm{0},\bm{I_m}\end{pmatrix}}
%% closed derivative matrix left
\newcommand{\cdml}{\begin{pmatrix}\bm{I_m},\bm{e_1},\dots,\bm{e_{k-1}}\end{pmatrix}}
%% closed derivative matrix right
\newcommand{\cdmr}{\begin{pmatrix}\bm{e_m},\bm{I_m},\bm{e_1},\dots,\bm{e_{k-2}}\end{pmatrix}}

%% open derivative derivative matrix left
\newcommand{\oddml}{\begin{pmatrix}\bm{I_m},\bm{0},\bm{0}\end{pmatrix}}
%% open derivative derivative matrix middle
\newcommand{\oddmm}{\begin{pmatrix}\bm{0},\bm{I_m},\bm{0}\end{pmatrix}}
%% open derivative derivative matrix right
\newcommand{\oddmr}{\begin{pmatrix}\bm{0},\bm{0},\bm{I_m}\end{pmatrix}}

%% closed derivative derivative matrix left
\newcommand{\cddml}{\begin{pmatrix}\bm{I_m},\bm{e_1},\dots,\bm{e_{k-1}}\end{pmatrix}}
%% closed derivative derivative matrix middle
\newcommand{\cddmm}{\begin{pmatrix}\bm{e_m},\bm{I_m},\bm{e_1},\dots,\bm{e_{k-2}}\end{pmatrix}}
%% closed derivative derivative matrix right
\newcommand{\cddmr}{\begin{pmatrix}\bm{e_{m-1}},\bm{e_m},\bm{I_m},\bm{e_1},\dots,\bm{e_{k-3}}\end{pmatrix}}

\begin{document}

\title{Regularization of Cardinal B-Spline Curves}
\author{jerviedog}
\maketitle

\section{Introduction}
This note is about the calculation of the regularization of cardinal b-spline curves involved in the curve fitting problems. It seems convenient to use the vector/matrix representation other than the summation representation. The vector/matrix representation is also more clear, especially when wrap-around operation is needed. Alas, I have made a mistake when using summation representation.

\section{The regularization terms}
The curve is represented by cardinal b-spline of order $k$:
\[
\bmmp=\splinept.
\]
where $\bm{P}_j$ are the control points, and $Q^k_j$ are the cardinal spline basis of order k. The support of $Q^k_j$ is $\left[j-1,j-1+k\right)$.

For the simplicity, I consider the 1-dimensional case so I can use vector/matrix representation in a more clear way, and the order superscript $k$ is dropped (order $k$ is assumed unless specified):
\[
\bmmp=\vPT\vQ,
\]
where
$\vP = [P_1,P_2,...,P_m]^\intercal$ are control point vector, and $\vQ = [Q_1(t),Q_2(t),...,Q_m(t)]^\intercal$ are the cardinal basis vector. The vector/matrix expression for the curve, its first and second derivatives can be found in \ref{subsec:diff_card}.

The regularization terms are $F_1$ and $F_2$:
\[
\begin{split}
F_1 &= \half \int {\|\bmmp^\prime(t)\|^2 }dt \\
&= \half \int {\| \vPT \mM_1 \vQ^{k-1} \|^2} dt \\
& = \half \vPT \mM_1 \Bigl(\int{\vQ\vQT}dt\Bigr) \mMT_1 \vP,
\end{split}
\]
and
\[
\begin{split}
F_2 &= \half \int{\|\bmmp^{\prime\prime}(t)\|^2}dt \\
&= \half \int {\| \vPT \mM_2 \vQ^{k-2} \|^2} dt \\
& = \half \vPT \mM_2 \Bigl(\int{\vQ\vQT}dt\Bigr) \mMT_2 \vP.
\end{split}
\]

Now the derivatives of $F_1$ and $F_2$ with respect to the control points $\vP$ can be obtained easily. The extension to 2-dimensional control points and further discussion of the usage of B-spline in image processing can be found in chapter 3 of Blake and Isard's book ``Active Contours''.

\section{Appendix}
Here are some relations that would be used in the text.
\subsection{Cardinal splines up to order 4}
\[
\begin{split}
Q_1 &=
\begin{cases}
1 & 0 \leq x < 1\\
0 & otherwise
\end{cases}, \\
Q_2 &=
\begin{cases}
x & 0 \leq x < 1 \\
-(x-1)+1 & 1 \leq x < 2\\
0 & otherwise
\end{cases}, \\
Q_3 &=
\begin{cases}
\frac{1}{2}x^2 & 0 \leq x < 1 \\
-(x-1)^2+(x-1)+\frac{1}{2} & 1 \leq x < 2\\
\frac{1}{2}(x-2)^2-(x-2)+\frac{1}{2} & 2 \leq x < 3\\
0 & otherwise
\end{cases}, \\
Q_4 &=
\begin{cases}
\frac{1}{6}x^3 & 0 \leq x < 1 \\
-\frac{1}{2}(x-1)^3+\frac{1}{2}(x-1)^2+\frac{1}{2}(x-1)+\frac{1}{6} & 1 \leq x < 2\\
\frac{1}{2}(x-2)^3-(x-2)^2+\frac{2}{3} & 2 \leq x < 3\\
-\frac{1}{6}(x-3)^3+\frac{1}{2}(x-3)^2-\frac{1}{2}(x-3)+\frac{1}{6} & 3 \leq x < 4\\
0 & otherwise
\end{cases}.
\end{split}
\]

\subsection{Differentiation of cardinal spline basis}
\[
Q^{\prime}_{i,k} = Q_{i,k-1} - Q_{i+1,k-1}.
\]

\subsection{Hodograph}
The general way to construct the hodograph of a curve is to use the general differentiation method of the b-spline, c.f., page 115 of de Boor's book. Note that the evaluation range of the hodograph is the same as the original curve, e.g., $[t_k,\dots,t_{m+1}]$, which is different from the range of the hodograph constructed by the method below.
We can also make use of the properties of the cardinal splines: We compute the control points of the corresponding hodograph and construct the hodograph with cardinal spline of order $k-1$.
\begin{itemize}
\item open curve:
Suppose that the curve is represented by $k$-order cardinal b-spline curve with $m$ control points. The knot sequence is $1, \dots, m+k$. The evaluation span is $[k,m+1]$. The curve is
\[
\begin{split}
\bmmp&=\vPT\vQ^k_m \\
&=
\begin{pmatrix}
P_1 \\
P_2 \\
\vdots \\
P_m
\end{pmatrix}
\begin{pmatrix}
Q^k_1,\dots,Q^k_m
\end{pmatrix}.
\end{split}
\]

The hodograph is a curve represented by cardinal splines of order $k-1$:
\[
\bmmp^{\prime}=\vP^{\prime\intercal}\vQ^{k-1}_{m+1},
\]
where
\[
\vP^{\prime}=[P_1-0,P_2-P_1,\dots,P_m-P_{m-1},-P_m]^\intercal
\]
and
\[
\vQ^{k-1}_{m+1}=[Q^{k-1}_1,\dots,Q^{k-1}_{m+1}]^\intercal.
\]
Or in a more succint form:
\[
\bmmp^{\prime} = \vPT \Bigl[\odml - \odmr\Bigr] \vQ^{k-1}_{m+1}.
\]
The evaluation span is $[k-1,m+2]$.
\item closed curve:
The scenario is similar to that of open curve. Suppose that the curve is represented by $k$-order cardinal b-spline curve with $m$ control points. Besides these $m$ independent control points, there are $k-1$ wrapped-around control points. As a result, there are $m+k-1$ control points. The knot sequence is thus $1, \dots, (m+k-1)+k$. The evaluation span is $[k,(m+k-1)+1]$. The curve is
\[
\begin{split}
\bmmp&=\vPT\vQ^k_{m+k-1} \\
&=
\begin{pmatrix}
P_1 \\
P_2 \\
\vdots \\
P_m \\
P_1 \\
\vdots \\
P_{k-1}
\end{pmatrix}
\begin{pmatrix}
Q^k_1,\dots,Q^k_{m+k-1}
\end{pmatrix} \\
&= \vPT
\cdml
\vQ^k_{m+k-1}
\end{split}
\]
The corresponding hodograph is:
\[
\bmmp^{\prime}=\vP^{\prime\intercal}\vQ^{k-1}_{m+k-1},
\]
where
\[
\vP^\prime=[P_1-P_m,P_2-P_1,\dots,P_m-P_{m-1},P_1-P_m,P_2-P_1,\dots,P_{k-1}-P_{k-2}]^\intercal
\]
and
\[
\vQ^{k-1}_{m+k-1}=[Q^{k-1}_1,\dots,Q^{k-1}_{m+k+1}]^\intercal.
\]
Or in a more succint form:
\[
\bmmp^\prime = \vPT \biggl[ \cdml - \cdmr \biggr] \vQ^{k-1}_{m+k-1}.
\]
The evaluation span is $[k-1,(m+k-1)+1]$.
\end{itemize}

\subsection{Differentiation of cardinal spline curves}\label{subsec:diff_card}
The above discussion can be put in this summary:
\[
\vP =
\begin{pmatrix}
P_1,\\
P_2,\\
\vdots,\\
P_m
\end{pmatrix}.
\]
The curve itself:
\[
\begin{split}
\bmmp_{open} = \bmmp_o &= \vPT\vQ^k_m ,\\
\bmmp_{closed} = \bmmp_c &= \vPT \cdml \vQ^k_{m+k-1} \\
&= \vPT \mM_{0c} \vQ^k_{m+k-1}.
\end{split}
\]

First derivative:
\[
\begin{split}
\bmmp_o^\prime &= \vPT \biggl[ \odml - \odmr \biggr] \vQ^{k-1}_{m+1} \\
&= \vPT \mM_{1o} \vQ^{k-1}_{m+1}, \\
\bmmp_c^\prime &= \vPT \biggl[ \cdml - \cdmr \biggr] \vQ^{k-1}_{m+k-1} \\
&= \vPT \mM_{1c} \vQ^{k-1}_{m+k-1}.
\end{split}
\]

Second derivative \label{second_derivative}:
\[
\begin{split}
\bmmp_o^{\prime\prime} &= \vPT \biggl\{
\biggl[ \oddml - \oddmm \biggr]
-
\biggl[ \oddmm - \oddmr \biggr]
\biggr\}
\vQ^{k-2}_{m+2} \\
&= \vPT \mM_{2o}
\vQ^{k-2}_{m+2},
\\
\bmmp_c^{\prime\prime} &= \vPT \biggl\{
\biggl[ \cddml - \cddmm \biggr] \\
&\mathrel{\phantom{=}}\quad\, -
\biggl[ \cddmm - \cddmr \biggr] \\
&\mathrel{\phantom{=}}\quad\quad \biggr\} \vQ^{k-2}_{m+k-1} \\
&= \vPT \mM_{2c} \vQ^{k-2}_{m+k-1}.
\end{split}
\]
The evaluation range can be inferred by the superscript and subscript of $\vQ^k_m$: $[k,m+k-k+1]$, where $m$ is the number of control points, $m+k$ is the number of knots in the knot sequence, and $k$ is order.

\subsection{Others}
Reorganization of vector of this form $[P_1, \dots, P_m, 0]$ :
\[
\begin{pmatrix}
P_1 \\
\vdots \\
P_m \\
0
\end{pmatrix}
=
\begin{pmatrix}
1, 0, \dots, 0 \\
0, 1, \dots, 0 \\
\vdots, \vdots, \ddots, \vdots \\
0, 0, \dots, 1 \\
0, 0, \dots, 0
\end{pmatrix}
\begin{pmatrix}
P_1 \\
\vdots \\
P_m
\end{pmatrix}
=
\begin{pmatrix}
\bm{I_m} \\
\bm{0}
\end{pmatrix}
\vP,
\]
and
\[
\begin{pmatrix}
P_1 \\
\vdots \\
P_m \\
P_1
\end{pmatrix}
=
\begin{pmatrix}
1, 0, \dots, 0 \\
0, 1, \dots, 0 \\
\vdots, \vdots, \ddots, \vdots \\
0, 0, \dots, 1 \\
1, 0, \dots, 0
\end{pmatrix}
\begin{pmatrix}
P_1 \\
\vdots \\
P_m
\end{pmatrix}
=
\begin{pmatrix}
\bm{I_m} \\
\bm{e_1^{\intercal}}
\end{pmatrix}
\vP.
\]

\end{document}


\documentclass{article}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\title{Evaluation Criteria}
\author{Louis Schlessinger}
\date{February 2019}

\begin{document}

\maketitle

\section{Introduction}\label{sec:introduction}

The following are the evaluation criteria used to assess the performance of the automated kernel search process.
They include three broad areas: model score, model complexity, and population diversity.
Each one is tracked over time and presented as a time-series.

\section{Model Score}\label{sec:model-score}
These evaluation criteria measure the performance of a single model.
E.g.\ negative log marginal likelihood, Bayesian information criterion, etc.
\subsection{Best-so-far}\label{subsec:best-so-far}
The maximum model score for each generation.
\subsection{Average Score}\label{subsec:average-score}
The mean model score for each generation.
\subsection{Score Confidence}\label{subsec:score-confidence}
The sample standard deviation of model scores for each generation.
\section{Model Complexity}\label{sec:model-complexity}
The model complexity over time shows how the model space is explored and which models in that space perform the best.
The mean and standard deviation of each is recorded at each time step.
\subsection{Number of Hyperparameters}\label{subsec:number-of-hyperparameters}
The number of kernel hyperparameters used.
E.g.\  the squared-exponential covariance function in one dimension, $k_y(x_p, x_q)=\sigma_{f}^{2}\left(-\frac{1}{2\ell^2}(x_p - x_q)^2\right)+\sigma_{n}^{2}\delta_{pq}$, has 3 hyperparameters ($\sigma_{f}, \ell,\sigma_{n}$).
This includes parameters such as length scale, period and variance.
This shows the evolution of the types of kernels explored over time and which types of kernels performed the best.
It can be thought of as a model complexity score of the kernel structure.
\subsection{Number of Operands}\label{subsec:number-of-operands}
The number of 1-D sub-kernels used in the full kernel.
E.g. $SE_0 + RQ_1 \cdot SE_1$ has 3 operands.
This is strongly correlated with the number of model hyperparameters and can also be thought of as a model complexity score.
\section{Population Diversity}\label{sec:population-diversity}
These heterogeneity scores measure distance between pairs of kernels.
The mean and standard deviation of each is recorded at each time step.
\subsection{Kernel Expression Distance}\label{subsec:kernel-expression-distance}
The distance between kernels in algebraic form.
The kernel expression distance measures the similarity based on the algebraic expression of the kernel in additive form.
To compute this population diversity score, we first take the mean distance between all pairs of kernels (for each generation).
To compute the distance between a pair of kernels $k_i$ and $k_j$, we first convert each on to additive form.
Then, we vectorize each product within each additive kernel using a simple label encoding.
Lastly, the mean Euclidean distance between the two additive kernels' parts are calculated for all possible pairs of products.

Example:
\begin{gather*}
    k_i = SE_0 + RQ_1(RQ_1 + SE1)\\
    k_j = SE_1 SE_1 + SE_1 RQ_1(RQ_0 + RQ_1)+RQ_0\\
\end{gather*}
\begin{enumerate}
\item Convert to additive form
\begin{gather*}
    k_i = SE_0 + RQ_1 RQ_1 + RQ_1 SE_1\\
    k_j = SE_1 SE_1 + SE_1 RQ_1 RQ_0 + SE_1 RQ_1 RQ_1 + RQ_0\\
\end{gather*}

\item Encode additive kernels (assume $d=2, \mathcal{B} = \{SE, RQ\}$)

\[k_i \implies  L_i = \{
\begin{bmatrix} 0 \\0 \\ 1 \\ 0 \end{bmatrix},
\begin{bmatrix} 0 \\ 2 \\ 0 \\ 0 \end{bmatrix},
\begin{bmatrix} 0 \\ 1 \\ 0 \\ 1 \end{bmatrix}
\}\]

\[k_j \implies  L_j = \{
\begin{bmatrix} 0 \\ 0 \\ 0 \\ 2 \end{bmatrix},
\begin{bmatrix} 1 \\ 1 \\ 0 \\ 1 \end{bmatrix},
\begin{bmatrix} 0 \\ 2 \\ 0 \\ 1 \end{bmatrix},
\begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix}
\}\]

\item Take Cartesian product of all pairs of additive kernels

\[C_{ij} = L_i\times L_j = \{(\ell_i, \ell_j) \mid \ell_i \in L_i,  \ell_j \in L_j\}\]

\item Compute mean Euclidean distance of all Cartesian products

\begin{gather*}
    d_{ij} = \left\Vert \ell_i - \ell_j \right\Vert_2\\
    D_{ij} = \frac{1}{\left\vert C_{ij} \right\vert}\sum_{k=1}^{\left\vert C_{ij} \right\vert}d_{ij}\\
\end{gather*}

\item Compute mean $\bar{D}$ and standard deviation $\sigma_D$ of D

\end{enumerate}

\subsection{Covariate Distance}\label{subsec:covariate-distance}
The $\ell$-2 (Euclidean) distance between a pair of kernel matrices.
It can be thought of as a naïve similarity score between different explanations of the data offered by each kernel.
The distribution of Euclidean distances at each generation can be thought of as population heterogeneity score.
For example, suppose we wish to compute the distance matrix $D \in \mathbb{R}^{n \times n}$:

\begin{gather*}
    D_{ij} = \left\Vert k_i(X, X) - k_j(X, X) \right\Vert_2\\
    D = \frac{D + D^\top}{2}\\
\end{gather*}
We can then compute the mean and standard deviation of $D$.
\begin{gather*}
    \bar{D} = \frac{1}{n^2} \sum_{i=1}^{n}\sum_{j=1}^{n} D_{ij}\\
    \sigma_D = \sqrt{\frac{\frac{1}{n^2} \sum_{i=1}^{n}\sum_{j=1}^{n} (D_{ij} - \bar{D})^2}{n^2 - 1}}\\
\end{gather*}
Equivalently, we can vectorize $D$:
let $\vec{v} = vec(D)\in \mathbb{R^{n^2}}$
Then,
\begin{gather*}
    \bar{v} = \bar{D} = \frac{1}{n^2}\sum_{i=1}^{n^2} v_{i} = \frac{1}{N}\sum_{i=1}^{N} v_{i}\\
    \sigma_v = \sigma_D = \sqrt{\frac{\sum_{i=1}^{n^2} (v_i - \bar{D})^2}{n^2 - 1}} = \sqrt{\frac{\sum_{i=1}^{N} (v_i - \bar{v})^2}{N - 1}}\\
\end{gather*}
where $N = n^2$

\end{document}


\chapter{Theory}

%
% IMAGE PROCESSING
%
\section{Image processing}
\subsection{Representation}
All images in this report are two dimensional arrays of integer values. The image is denoted $f(x,y)$, where $f(0,0)$ is the intensity value of the top left pixel. Positive direction for x and y-axis is respectively right and down as seen in figure \ref{fig:equalized} (a). Pixel axis will be omitted unless useful for description of image.

\begin{figure}
\centering
\includegraphics[width=14cm]{equalized}
\caption{(a) Original image from microscope. (b) Histrogram of intensity values in image (a). (c) Adaptive histogram equalization of image (a). (d) Histogram of intensity values in image (c). Note that the scale of the y-axis in the histograms are logarithmic. }
\label{fig:equalized}
\end{figure}

An image intensity value of zero equals no signal and representation is dependt on colormap chosen. As microscope images in this report tend to have a lot of near zero pixel values, an inverted colormap is used for better visibility. In other words zero are represented as white, in contrast to black that one might assume. As long as possible, the same colormap is used on same type of images. It is suggested that the reader note the colorbar beside the image which indicate correspondence between numerical value and color.

\subsection{Contrast enhancement}
Images where structures are more important than the numerical values, \textit{histogram equalization} is used to enhance contrast. Histogram equalization tries to make each intesity likely probable, which often result to a higher contrast and therefor better visibility. An example is shown in figure \ref{fig:equalized}, where (a) is the original image and (c) is the equalized image. The algorithm used to equalize figure \ref{fig:equalized} (c) is called \textit{adaptive histogram equalization} and are found in the python library scikit-image. As this are just for visibility in the report, it’s suggested to read scikit-image documentation or source code if more detail is needed. Figure caption will always note if images has been processed with any kind of contrast enhancement method.

%
% SCANNING MICROSCOPE
%
\section{Scanning microscope}
The microscope in use is a scanning microscope. It’s called scanning due to the moving mirror which directs the laser to different spatial coordinates on the sample. The laser will move in a raster pattern and a sensor detect light in samples. Each sample represent one pixel and computer software assign the sensed values to a digital image. By scanning speed, we mean the count of lines scanned per second. In example a scanning speed of 600 Hz will use 853 milliseconds to scan a whole image of 512x512 pixels.

As it’s possible to control the amplitude of the mirror oscillation, choosing a smaller amplitude of the oscillation will effectively zoom. This gives the user of a scanning microscope control over spatial resolution without changing objective. Though the zooming is not without limitation, as too high oscillation frequency could damage the mirror. In example, a high mirror oscillation frequency would limit the possible amplitude which effectively limits how low zoom one can use.

Even if it's possible in software to select resolution below the theoretical resolution defined by the Rayleigh criterion, we are still limited by the diffraction limit. Resolution is therefor given by

\begin{equation}
d = 0.61 \cdot \frac{\lambda}{NA}
\end{equation}

where $\lambda$ is wavelenght of light and $NA$ is numerical aperture of objective.

%
% NONLINEAR LIGHT INTERACTION
%
\section{Nonlinear light interaction}
%Signal, noise, sampling, instrumentation
Second harmonic generation (SHG) is a interaction between photons and material which generate light of twice the frequency as the incomming light. The generation is due to the material's nonlinear susceptibility, which can be explained by the polarized density

\begin{equation}
\vec{P} = \chi_1 \vec{E} + \chi_2 \vec{E} \cdot \vec{E} + \chi_3\vec{E} \cdot \vec{E} \cdot \vec{E} + ...
\end{equation}

When a material have $\chi_2 \neq 0$, two photons may interact with the material to create a polarized field. The polarized field then again generates an $\vec{E}$-field with twice the frequency as the incoming light (two photons interact with the material, creating a single photon with twice the energy). The interaction only happens upon a high intensity beam where two photons are at the same place at the same time. Practically this is achieved by using a pulsed laser and focusing the beam with an objective, as a steady beam of this intensity magnitude would damage the sample. Also since the probability for interaction is proportional to intensity squared, one get the convenient benefit of essentially no SHG outside the focal point.

$\chi_2$ is also dependent on wavelength of incoming light and properties of the material, which results in material needs to be non-centrocymetric. This happens to be the case for collagen fibers as some of few biological materials, making it simple to take images of the collagen fibers only with little sample preparation.

The pulsed laser is normally scanned over the sample, generating SHG-signal and detected by sensors. As compared to a confocal microscope, descanning of the light is not necessary to take away background signal.

%
% FOURIER TRANSFORM
%
\section{Forier transform}
A common way to view data is in it's frequency domain. To achieve this, one does a Fourier transform defined by

\begin{equation}
F\{f(t)\} = \int \limits_{-\infty}^{\infty} f(t) e^{-i2\pi \mu t} dt.
\end{equation}

The transform has the property that it "picks out" amplitude and phase of oscillating signals in $f(t)$. This is based on the Fourier series which states that any periodic function can be represented by a sum of finite or infinite set of sines and cosines.

As we are working with images in the discrete domain, one defines $f(t)$ to be a sampled function using the Dirac delta function and gets the discrete Fourier transform

\begin{equation}
F(u) = \sum \limits_{x=0}^{M-1} f(x)e^{-i2 \pi ux/M}.
\end{equation}

Where $u$ and $x$ are discrete values for frequency and position, and M is number of samples in the function $f(x)$. Adding a dimension yields the 2D discrete Fourier transform given by

\begin{equation}
F(u,v) = \sum \limits_{x=0}^{M-1} \sum \limits_{y=0}^{N-1} f(x,y) e^{-i2 \pi \left( \frac{ux}{M} + \frac{vy}{N} \right)}.
\end{equation}

Here $u$ and $v$ are frequencies for accordingly $x$ and $y$ dimensions in the real image $f(x,y)$. $M$ and $N$ are the size of the image. The transform yields an image with same dimensions as the real image, where $F(u,v)$ gives amplitude and phase of given frequencies $u$ and $v$. All Fourier images in this report are logarithms of power spectrum which are shifted. The power spectrum of the Fourier transform is given by

\begin{equation}
|F(u,v)| = \sqrt{F(u,v) \cdot \overline{F(u,v)}},
\end{equation}

where $\overline{F(u,v)}$ is the complex conjugate of $F(u,v)$. Values below 1 are set to 1, to avoid division by zero and $-\infty$ values. Because the domain of values may range $10^6$ in the power spectrum, logarithmic scaling is done. In example the Fourier spectrum to figure \ref{fig:ft_demo} (a), have a maximum value of $8 \cdot 10^6$. Shifting means that $u=0$ and $v=0$ are set to the center of the image, as it's easier to grasp what frequencies are involved and direction of features in the image.

\begin{figure}[h]
\centering
\includegraphics[width=11cm]{ft_demo.png}
\caption{(a) An 8 bit grayscale image with sine wave running in x-direction. (b) The logmarithmic scaled power spectrum of the Fourier transform. The Fourier transform has been shifted for better visibility, as we have no repeating signal in y-direction and the line actually lays on the border of the image ($v$ = 0).}
\label{fig:ft_demo}
\end{figure}

As mentioned, the transform picks out amplitude, phase and frequency, which are properties we can exploit to find orientation of fibers. Figure \ref{fig:ft_demo} shows this concept.

%
% CLASSIFICATION
%
%\section{Classification}
%Magnus: Mulig jeg må droppe dette, ser ikke ut som jeg kommer i mål.

%As the goal for automated analysis is making decisions, quantitative data is used to separate samples into classes. In best case scenario a few quantitative measurement clearly discriminates the samples. Figure \ref{fig:iris} of the classical iris data-set from R.A. Fisher illustrates this concept.

%\begin{figure}
%\centering
%\includegraphics[width=5cm]{iris.png}
%\caption{Three different species of iris flowers, discriminated by their pedal and sepal width. Data from http://archive.ics.uci.edu/ml/datasets/Iris. TODO fix ref}
%\label{fig:iris}
%\end{figure}

%As the figure show, grouping classes based on their quantitative measurements is a simple concept, but it gets complicated when the data span more dimensions that the human mind can easily visualize. To improve our ability to find good classifiers one technique is to use machine learning. The concept is the same, but one lets a computer find which measurements gives good separation of classes. This is done by iteratively computing distance to the mean position of predefined classes. Mean distance is defined as

%\begin{equation}
%\mathbf m_j = \frac{1}{N_j} \sum\limits_{\mathbf x \in \omega_j} \mathbf x_j
%\end{equation}

%where $N_j$ is the number of vectors in class $\omega_j$.

%A simple but effective implementation of this is clustering measurements
%find quantitative measures that disciminates the samples to classes


\subsection{Android Application}
\label{sec:android-application}

The main role of the Android application in this system is to receive ultrasonic waves using microphones on the smartphones. Therefore, the ultrasonic signal range is required to satisfy two conditions. The signal should not be heard by humans, at the same time it should be heard by microphones. The audible range of frequency for humans is between 20Hz and 20kHz, while most microphones on smartphones support sampling rate of 44.1kHz, which is greater than Nyquist rate relative to the highest human audible frequency, 40kHz, to avoid aliasing of the signal. However, as 44.1 kHz is still higher than the Nyquist rate, we can easily speculate that the smartphones are theoretically capable of recording the frequency range between 0 Hz to 22.05 kHz without aliasing, although it will become more difficult to differentiate signals when the frequency gets closer to either of two extremes. The frequency band ranging from 20 kHz to 22.05 kHz satisfies the two conditions mentioned above; this band is not hearable for humans but still hearable for smartphones. However, according to our experiments, the received signal strength becomes too weak to be feasible around the frequency of 21.0 kHz when the frequency goes higher.

The amount of computation gets overly intensive when the number of points in fast Fourier transform (FFT) exceeds 2048. Although the more number of points in FFT gives us the finer granularity to represent data using ultrasound signals, increasing the number of points in FFT requires more computations, which can be a burden for embedded systems such as smartphones. After carrying out experiments related to the proper number of points in FFT, we concluded that 2048 points would be a limit for current smartphones since 4096 point FFT slightly slowed down the response time of recent Android devices like Samsung GalaxyS 3 and Google Nexus 7. 2048 point FFT gives us a feasible resolution of approximately 10.76 Hz per each point so we have about 94 points from 20.0 kHz to 21.0 kHz. It is not possible to fully utilize these points as bits because there is noise in FFT results around the target frequencies due to limitation of precision in sound generation and FFT. Considering the interference caused by neighboring signals, leaving space in frequencies between signals would be proper to obtain clear data from decoding. Therefore, we divided this range of frequency between 20.0 kHz and 21.0 kHz into eight intervals removing 21.0 kHz frequency from the range in order to increase correctness in decoding, assigning 8 bits at between 20.0 kHz and 20.875 kHz as demonstrated in Fig.\,\ref{fig:data_representation}.

To decode room ID from FFT results, differentiating the actual signal value from noise and interference caused by ultrasound generators, environments and neighboring signals. Before taking interference by neighboring signals into consideration, the noise by the generator should be eliminated. Even though the created wav signal by Matlab is quite clear, it might involve some noise from speakers and circuits. If the application always try to choose the FFT result at the exact target frequency it will still have chances to select a signal weaker than what is actually necessary for decoding as shown in Fig.\,\ref{fig:fft_results} box (a). Selecting maximum value among the results which are right beside to the target frequency rather than just picking up the value at the exact frequency can remove this possibility, and we call this value as a “signal value”. The easiest way to detect a signal is to compare the signal value with an absolute value and determine that there is a signal if the signal value is greater than absolute value. However, this method does not work because the signal at neighboring frequencies will affect the FFT result of the target frequency making it hard to differentiate the real signal and the fake signals caused by noise of neighboring signals such as in Fig.\,\ref{fig:fft_results} box (b). To differentiate actual signals from noise and interference of neighboring signals, just comparing the signal value with an absolute value is not sufficient. This tricky problem can be solve by setting “reference values” to be compared with the signal value. Even though there is noise by the signals around the signal value, they tend to be diminished as they get further from its target frequency. Hence, if the signal value is greater than FFT results around the signal value, then we can conclude that there is a signal. The reference values are set as the sum of the FFT results apart from the target frequency by three points scaled by a predefined factor and a base noise, which is a threshold or an absolute value that is set according the target frequency. Since the received signal strength becomes weaker as the frequency increases, the threshold is set to decrease as the target frequency increases.

The Android application is able to determine whether there is a signal by comparing the signal value to the reference values as explained above. But there is one more problem left that needs a solution, the decoded value using this method is still unstable changing frequently as time passes. This can lead to wrong reading or too frequent fluctuation of room ID that makes it difficult to localize the target.  The problem can happen especially when the target person with a phone enters a room with an ultrasound generator. The application employs an exponential moving average denoted in \ref{eqn:1} to stabilize the decoded result and wait until the decoded value after the exponential moving average becomes constant to avoid frequent fluctuation when the localization process begins right after the target enters a room with an ultrasound generator.

\begin{equation}
t>1, s_t=\alpha \cdot y_t+(1-\alpha)\cdot s_{t-1}
\label{eqn:1}
\end{equation}
By using this two-level filtering method, we could obtain almost perfectly clear room ID results.
\ref{eqn:1}

This application also provides additional features to show the target's location depending on the user's selection. Users can choose to share their position on a map through the sMAP server using HTTP POST by sending the localization result to a dedicated server. By setting the user's name on the application interface, the users can publish their positions on the map provide by the server so that other people can identify where they are. The users may keep their location information secret without publishing their position to the public for their privacy. In this case, the application uses a map embedded to the application to show the location of the target without specifying the user's name. The user interface of Android application is also illustrated in Fig.\,\ref{fig:app_interface}. The space between check boxes and a start/stop button can be used to show either the private map or FFT results in graph as shown in leftbottom of the Fig.\,\ref{fig:app_interface}.

\begin{figure}
  \centering
  \includegraphics[width=0.8\columnwidth]{data_representation.png}
  \caption{Data representation on frequency band ranging from 20.0 kHz to 20.875 kHz}
  \label{fig:data_representation}
\end{figure}

\begin{figure}
  \centering
  \includegraphics[width=0.7\columnwidth]{fft_results.png}
  \caption{Results of 2048 point FFT on Android application}
  \label{fig:fft_results}
\end{figure}

\begin{figure}
  \centering
  \includegraphics[width=\columnwidth]{app_interface.png}
  \caption{User interface of Anrdoid application}
  \label{fig:app_interface}
\end{figure}

%% Master
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "ee149"
%%% End: