%!TEX root =  ../main.tex

\subsection{``Undo''}

\objective{Find and graph function inverses and their derivatives.}

We have seen that functions can be redefined as the composition of other, simpler
functions.  For example, $\frac{x^2+1}{2}$ can be seen as 1) squaring, 2) adding 1
, and 3) dividing by 2.  What if we wanted to ``undo'' the effects of this function?
We cannot simply do the opposite of each operation ($\frac{\sqrt{x} -1}{2}$ is not
the inverse) but must do the opposites \emph{backwards}.  This is called the
\textbf{inverse} of the function.

\subsection{Swap $x$ and $y$}
In the example already mentioned, the inverse is $\pm\sqrt{2x-1}$.  What is wrong with
this inverse?  It is not a function.  No even power has an inverse which is a function, because
there are infinitely many places where a particular output is reached from two different inputs.
Another way to think of inverses is reversing $x$ and $y$, making the output the input and
visa versa.  Only \textbf{one-to-one} functions --- where every $x$ has a \emph{unique}
$y$ --- will have inverses which are themselves functions.

Numerically, this shows how easy it is to construct an inverse of data: simply swap the
column labels for input and output!   This can be done algebraically too.  Staying with
the same example, we could follow the procedure of 1) swapping $x$ and $y$, and then
2) solving for $y$ to find the inverse of a function.

\begin{align*}
	y &= (x^2+1)/2 \\
	x &= (y^2+1)/2\\
	2x &= y^2+1\\
	2x - 1 &= y^2 \\
	\pm\sqrt{2x-1} &= y\\
\end{align*}

\subsection{S.I.F.T.}
But such examples fail when there are multiple places where $x$ appears in the equation
of $y$.  How can we find the inverse of $y=\sqrt{\frac{x-1}{2-x}}$  A helpful acronym to
remember is such cases is S.I.F.T., which standard for
\begin{itemize}
\item[\textbf{S}pread] Clear the fractions, exponentiate the roots away, distribute the parentheses, etc.
\item[\textbf{I}solate] Move all the terms with the desired variable onto one side of the equation, and move all the other terms to the opposite side.
\item[\textbf{F}actor] Factor out the desired variable from all the terms on its side
\item[\textbf{T}ransfer] Divide off the term in parentheses, leaving the variable alone.
\end{itemize}
Returning to our hard example:

\begin{align*}
	y  &= \sqrt{\frac{x-1}{2-x}}\\
	x  &= \sqrt{\frac{y-1}{2-y}}\\
	x^2 &= \frac{y-1}{2-y}\\
	x^2(2-y) &= y-1 \\
	2x^2-x^2y &= y-1 &\text{finally spread out}\\
	2x^2 + 1 &= y + x^2y & \text{$y$ is isolated on the right}\\
	2x^2 + 1 &= y(1+x^2) & \text{factored out $y$}\\
	\frac{2x^2+1}{1+x^2} &= y & \text{transferred}
\end{align*}

\subsection{Graphically}
Inverses --- whether they are a function or not --- are a reflection across the line $y=x$.
This leads to some amazing properties of there derivatives.

Consider the function $f(x) = (x-1)^3+4$, a simple cubic function, shift right 1 and up 4.
It's derivative is easy to calculate: $f'(x)=3(x-1)^2$.  It's inverse somewhat more complicated,
but perhaps it is enough to sketch it, swapping $x$ and $y$ at every point, reflecting it over
the line $y=x$.

\begin{figure}[h]
\begin{centering}
\begin{tikzpicture}[scale=0.3]
\draw[help lines] (-10,-10) grid (10,10);
\draw[<->] (-10.2,0) -- (10.2,0) node[anchor=west] {$x$};
\draw[<->] (0,-10.2) -- (0,10.2) node[anchor=south] {$y$};
\draw[dashed] (-10,-10) -- (10,10);
\draw[domain=-1.45:2.85,ultra thick,<->,samples=200,smooth,blue] plot (\x,{(\x-1)^3+4});
\draw[<->,domain=-1.44:2.85,samples=200,smooth,red,ultra thick]plot({(\x-1)*(\x-1)*(\x-1)+4},\x);
\end{tikzpicture}
\caption[Graphical example of inverses]{A function and its inverse, which are clearly reflections of each other across the line $y=x$.}
\end{centering}
\end{figure}

This can be done easily on the TI-8*.   First, enter the original function in $Y_1$ and graph
it.  Be sire you have a window appropriate to the function and it's inverse!  Next, select DRAW
and choose option 8: DrawInv, passing it the argument $Y_1$.  Press ENTER and
you will be able to see the inverse.  Unfortunately, we cannot TRACE along it or any of the
other tools we are used to for functions, but that hardly matters.

Consider the tangent line through (2,5) on the original graph.  Hopefully, it is easy for
you to calculate that it follows the equation $y-5=3(x-2)$.  Enter this as $Y_2$.
Have the TI-8* draw its inverse.  This second line will pass through the point (5,2)
and have a reciprocal slope: $\frac{1}{3}$.

This shows that the derivative of the inverse is equal to the reciprocal of the derivate,
for every point $(x,y)$ which has been mapped onto $(y,x)$.
\index{derivative!of the inverse}


\documentclass[../../main.tex]{subfiles}
\begin{document}
\subsubsection{Update}
The operation $update$ will return a Collection $coll!$ which is the same as the input Collection $coll?$
except for at index $idx?$. The existing member $coll?_{idx?}$ is replaced by the provided Value $v?$ at $idx?$ in $coll!$
such that
$$idx? \mapsto v? \in coll! ~ \land ~ idx? \mapsto coll?_{idx?} \not \in coll!$$
which is equivalent to $remove ~\pipe ~append$
\begin{zed}
  update(coll?, v?, idx?) \equiv append(remove(coll?, idx?), v?, idx?)
\end{zed}
The functionality of $update$ is further explained in the following schema.
\begin{schema}{Update[Collection, V, \nat]}
  idx? : \nat \\
  coll?, coll! : Collection \\
  v? : V \\
  update~\_ : Collection \cross V \cross \nat \bij Collection
  \where
  1 = \#~idx? \\
  coll! = update(coll?, v?, idx?) @ \\
  \t1 let ~ ~ coll' == \{~ i : \nat ~| ~ i \in 0~..~idx?\} \extract coll? \\
  \t1 \ \ \ ~~~ coll'' == head(coll') ~\cat ~ v?\\
  \t1 \ \ \ ~~~ coll''' == \{~ j : \nat ~| ~ j \in idx?+1~..~\#~coll?\} \extract coll? \\
  \t1 =  coll'' ~\cat ~coll'' \implies \\
  \t2 (append(remove(coll', idx?), v?, idx?) \cat  coll'') ~ \land \\
  \t2 (~ v? \mapsto idx? \in coll!) ~\land \\
  \t2 (~\#~ coll! = \#~ coll?) ~\land
\end{schema}
The value which previously existed at $idx? \in coll?$ is replaced with $v?$ to result in $coll!$
\begin{itemize}
\item $coll'$ is the items in $coll?$ up to and including $idx?$
\item $coll''$ is the items in $coll?$ except the item at $idx?$ has been replaced with $v?$
\item $coll'''$ is the items in $coll?$ from $idx?+1$ to $\#~coll? \implies coll?_{idx?} \not \in coll''$
\end{itemize}
The following example illustrates these properties.
\begin{argue}
  X = \langle x_{0}, x_{1}, x_{2} \rangle \\
  \t1 x_{0} = 0 \\
  \t1 x_{1} = foo \\
  \t1 x_{2} = \langle a, b, c \rangle \\
  \t1 v? = bar \\
  update(X, v?, 0) = \langle bar, foo, \langle a, b, c \rangle \rangle \\
  update(X, v?, 1) = \langle 0, bar, \langle a, b, c \rangle \rangle \\
  update(X, v?, 2) = \langle 0, foo, bar \rangle \\
  update(X, v?, 3) = \langle 0, foo, \langle a, b, c \rangle, bar \rangle \\
  update(X, v?, 4) = append(X, v?, 3) = update(X, v?, 3) \iff 3 \not \in \dom X
\end{argue}
\end{document}


\section{Matrix Product States}
MPS closed chain.
\begin{align}
    \ket{\psi} &=
    \sum_{i_1,\ldots,i_N} \Tr\left(
    A_{i_1}\cdots A_{i_N}
    \right)
    \ket{i_1,\ldots,i_N}
\end{align}
where $A_i$ are $D\times D$ matrices, and $i=1,\ldots, d$ where
$d$ is the dimension of the site Hilbert space.
There are $dND^2$ parameters here to describe a quantum state.

Gapped ground states of local Hamiltonians satisfy the area law for entanglement
entropy.

Can approximate gapped ground states to accuracy $1/\poly(N)$
with MPS with $D$ sublinear in $N$.

A MPS is injective if there exists finite $L_0$ such that
\begin{align}
    \tilde{A}_I &=
    A_{i_1} A_{i_2} \cdots A_{i_N}
\end{align}
spans the whole space of $D\times D$ matrices.

The question is if these matrices span the entire space of $D\times D$
matrices.

The reason injectivity is important is that you can show that an injective MPS
has the following properties.
\begin{enumerate}
    \item Finite correlation length.
    \item There are unique gapped ground states of a frustration-free parent
        Hamiltonian.
\end{enumerate}

There is a book by Xiao-Gang Wen, Xie Chen, Bei Zeng and one other author which
has a nice discussion of MPS and in particular the relation between MPS and SPT
phases.

There's another formulation called PEPS,
projected entangled pair states.

Consider a chain of maximally entangled pairs which are then projected.
So you have on each site,
imagine you have two kinds of spins.
And then you put the spins on nearby states into singlets,
and then you do a projection.

So here,
this singlet bond,
what that really means,
you can think of it as a maximally entangled state between the Hilbert space on
the two sides.
\begin{align}
    \frac{1}{\sqrt{D}} \sum_{\alpha=1}^{D} \ket{\alpha}\ket{\alpha}
\end{align}
where $D$ is some internal bond dimension.
The idea is that each of these are some virtual spin,
and $D$ would be the dimension of the virtual spin.

And then the projection projects from two virtual spins to a physical degree of
freedom of dimension $D$.

So this projection,
if you write it in the following way
\begin{align}
    P &= \sum_{i,\alpha,\beta} A_{i,\alpha\beta} \ket{i}\bra{\alpha\beta}
\end{align}
Then this state is actually equivalent to the MPS $\ket{\psi}$.

So the MPS is exactly equivalent to this PEPS when the projection is written
like above.

Something that happened in 2010,
that led to people thinking all 1D phases are classified by $H^2(G, U(1))$,
is that if you take the bond dimension,
and what can be analysed by constant depth circuits,
is the following.

One can show that any MPS with fixed bond dimension can be disentangled
to exponential accuracy by local constant depth circuit.

The fact you can do this is evidence for no bosonic topological order,
meaning no topologically ordered phases of bosons without any symmetry.

Disentangle means toke to the direct product state.

It doesn't prove it of course,
because the bond dimension is assumed to be fixed,
but in general you should consider the bond dimension to grow with system size.

Last time in the paper,
they show the bond dimension is sublinear in $N$,
but not necessarily constant in $N$.
This discovery of disentanglement with fixed bond dimension doesn't prove there
is no topological order in 1D but it does strongly suggest there is no bosonic
topological order in 1D.

Then you could add symmetry in the circuit,
and let the circuit be symmetric,
and then you can show from there that you basically get this PEPS form.
That is,
you can show that any MPS with a fixed bond dimension and symmetry $G$
can be converted into an entangled pair form via a symmetric constant depth
circuit.

Furthermore, each virtual spin is in projective representation of $G$
characterized by this cocycle
$[w] \in H^2(G,U(1))$.

This again,
is evidence that the classification of gapped phases should be
$H^2(G,U(1))$.
The caveat is that we're considering MPS,
and constant depth local circuits that disentangle,
or take any generic MPS to this fixed point form.

I'm not going to go through the exact construction,
but this book has s nice account of it.

I want to describe a different model for thinking about SPT states in terms of
path integrals,
state sums and wave functions that can generalize to every dimension.
This whole discussion about MPS is limited to 1D.
While it's interesting and illuminated,
I'm not going to dwell more on it because it's so specific to 1D.
This is the overview of what happened 10 years ago in 1D that led people to go
further and classify higher dimensions.

\begin{question}
    Experimental tests of AKLT?
\end{question}
The spin-1 Heisenberg chain is gapped phase of matter with dangling gapped edge
modes,
and there are experiments.
The Haldane chain is half the reason why Haldane won the Nobel prize,
even though he didn't realize it's an SPT state at the time.

\begin{question}
    Is it because of ground state degeneracy?
\end{question}
Every 1D bosonic topological phase is a trivial phase,
if you forget about symmetry.
For fermions,
it's not the case because we have Majorana chains.
Even though it has no edge modes on a ring,
it's still topological.

It's not exactly because of ground state degeneracy,
because the Majorana chain does not have ground state degeneracy on a closed
chain either.

\begin{question}
    Why is the second statement evidence?
\end{question}
Every sate,
you can run it through some constant depth symmetric circuit,
and take it not a form like this,
where every one is a projective representation,
with a dangling edge state.
You could run some RG procedure that takes a constant number of steps,
but takes you to this idealized fixed-point form to good accuracy.

\begin{qeustion}
    Is the second statement still true for $d=1$.
\end{qeustion}
You can actually get from PEPS to the trivial product state by disentangling
each of these guys,
but he only way to do that is break the symmetry $G$.
But to fully disentangle,
you need that one extra step to break the symmetry.

I encourage to read the relevant chapter in the book by X.G. Wen.
There's also a book by Ignacio Cirac.

\section{Group Cohomology Model (Dijkgraaf-Witten theory)}
I want to turn to a model for SPT state,
first in 1D,
but this model actually generalized to higher dimensions as well.

The idea is that we're going to construct a TQFT that gives SPT states
by constructing the path integral.
Construct a path integral fora TQFT
\begin{align}
    Z(M^2, A)
\end{align}
We have a symmetry $G$, so there is a gauge field $A$ for that $G$ symmetry.

The first step is to triangulate spacetime.

Then the next step is define a branching structure.
A branching structure is a local ordering of the vertices.
Another way of saying what it is is to make all edges directed in a way such
that there are no closed loops.
That's all a branching structure is.

For example, take some triangle,
with vertices labelled 0, 1, 2.
Then arrows pointing from lower to higher number vertices on edge,
and you see there're no loops.

Then we introduce an orientation.
You can reverse the arrows,
and you notice you can't rotate one to make it look like the other,
because if you follow two of the arrow,
your thumb points down,
but it points up on the other orientation.
You call one the $+$ orientation and you call the other the $-$ orientation.

The next thing to do is to assign group elements to vertices.

It effectively introduces a gauge field into the problem,
because if I draw a triangle with
$g_0$, $g_1$ and $g_2$ on vertices,
the links between them will be $g_0^{-1}g_1$ from $g_0$ to $g_1$,
$g_{0}^{-1}g_2$ from $g_0$ to $g_2$ and
$g_1^{-1}g_2$ from $g_1$ to $g_2$.

[picture]

This defines a special kind of gauge field,
it's a \emph{flat} gauge field.
That is,
there is no net flux through a plaquette.

For example,
the flux through one triangle is
$A_{01}A_{12}A_{20}=1$
and in fact the product of any loop is 1 with
\begin{align}
    \prod_{\textrm{loop}} A = 1
\end{align}
so in fact $A$ is a \emph{trivial} flat gauge.

Then for each 2-simplex (triangle),
we're going to associate a phase factor,
which is an amplitude,
that depends on the group elements.

To each 2-simplex $\Delta^2$, define
\begin{align}
    \left[ \nu_2\left( g_0, g_1, g_2 \right) \right]^{S\left( \Delta^2 \right)}
\end{align}
where $\nu_2 \in U(1)$.
I assume the labels are labelled $g_0,g_1,g_2$.
$S$ is the orientation of $\Delta^2$.

\begin{question}
    Is this an invertible TQFT?
\end{question}
This will be an invertible TQFT,
and the fact that this is just a $U(1)$ phase is important why it's invertible.
You can generalize it,
but it's significantly more complex to make $U(1)$ not just a phase.

The path integral that we're going to define is defined as follows.
\begin{align}
    Z &=
    \frac{1}{|G|^{N_V}}
    \sum_\left\{ {g_i \right\}}
    \prod_{\Delta_2 \ni (i, j, k)}
    \left[
    \nu_2 \left( g_i, g_j, j_k \right)^{S(\Delta_2)}
    \right]
\end{align}
we're taking the product over all 2-simplices $\Delta_2$
each of which have vertices $i,j,k$ in order.
And I'm going to take the product of all these phases $\nu_2$
and I'm going to raise it to the orientation $S\left( \Delta_2 \right)$.
And then I'm going to sum over all possible choices of vertices $\left\{ g_i
\right\}$
and then I'm going to average by dividing by $|G|^{N_V}$
where $N_V$ is the number of vertices and $|G|$ is the number of elements in
$G$.

We'll come to this,
but if you're a mathematician and see this,
you might think we're crazy,
because you'll see the sum is completely useless for defining the path integral,
but the sum is here for physics.
What you find here is that every term is here is the same.
I haven't told you what $\nu_2$ are.
It turns out every term in the term is the same.

We're just summing over all possible labellings.

\begin{question}
    $G$ survives permutations?
\end{question}
We have some crazy triangulation,
and I'm just summing over every possible value of $G$.
Every vertex has a group element attached to it,
and each vertex has a different group element.

\begin{question}
    Are there as many group elements as vertices?
\end{question}
There are $N_V$ group elements,
which is different from $|G|$.
For example $G=\mathbb{Z}_2$,
then there are $2^{N_V}$.

\begin{question}
    How does it connect to the system we're trying to study?
\end{question}
Maybe you should wait.
If you remember in TQFT,
you can define a path integral for spacetime.
If your spacetime has a boundary,
you have a state on the boundary.
This path integral can give a wave function state on the boundary.

Any boundary is going to be a circle,
or a bunch of disconnected circles,
so we can get a wave function on circles that describes SPTs.
And from those circles,
we deduce an exactly solvable Hamiltonian as well.

This gives a topologically invariant path integral,
form which we extract topological invariants.

\begin{question}
    Is branching structure the same as consistent orientation?
\end{question}
No, it's more than that.
It's even more than a specific set of orientations.
It's a specific set of ordering of vertices.

\begin{question}
    Should neighbouring vertices have the same ordering?
\end{question}
Not necessarily.

\begin{question}
    We take all gauge-equivalent into one term?
\end{question}
Yes, this is going to wind up being an average over gauge transformations.

It's gauge equivalent to no $G$,
we haven't defined $\nu_2$ yet.
We'll be able to relax this product of $A=1$ condition,
so we can introduce twists and things wrap around,
and it won't be gauge-equivalent to nothing.

It's also useful to think of $Z$ in the following way,
as a sum over all $g$s normalized
over the exponential of some topological action.
\begin{align}
    Z &=
    \frac{1}{|G|^{N_V}}
    \sum_\left\{ {g_i \right\}}
    e^{i S_{\mathrm{top}}\left( \left\{ g_i \right\} \right)}
\end{align}
I'm being a bit sloppy here,
when I say $A$,
I really mean equivalence classes of $[A]$,
by gauge equivalence.
But if we know $ZA$ is gauge invariant,
I don't really need to write the square brackets.
\begin{align}
    Z = Z\left( M^2 , [A] \right)
\end{align}

This has a global symmetry,
and what I mean is that the amplitude should be the same as if multiplied by
some global $g$.
Every term in the sum is explicitly the same if I change all $g_j$'s at once by
some global $g$.
\begin{align}
    e^{iS\left( \left\{ g_i \right\} \right)}
    =
    e^{iS\left( \left\{ gg_i \right\} \right)}
\end{align}
which also means
\begin{align}
    \nu_2\left( gg_0, gg_1, gg_2 \right) &=
    \nu_2\left( g_0, g_1, g_2 \right)
\end{align}
We're assuming $g$ is unitary,
but if it's anti-unitary,
you just introduce a complex conjugate in the above equation.

What this allows is to do is define a 2-cochain.
The reason it defines a 2-cochain is because I can define the usual 2-cochain,
which I introduced last lecture,
which is
\begin{align}
    \omega_2(g_1, g_2) &=
    \nu_2 (1, g_1, g_1 g_2)
\end{align}
Furthermore,
I can multiply every element by $g_0^{-1}$ so
\begin{align}
    \nu_2 (g_0, g_1, g_2) &=
    \nu_2 \left(
    1, g_0^{-1},g_1, g_{0}^{-1} g_1 g_1^{-1} g_2
    \right)\\
    &= \omega_2\left( g_0^{-1} g_1, g_1^{-1} g_2 \right)
\end{align}
We thought of 2-cochains as something that takes in 2 group elements and splits
out a phase factor.
But here,
we can think of it as taking 3 group elements and spits out a factor,
but it has some symmetry in the inputs.
$\nu_2$ is called a homogeneous 2-cochain,
whereas $\omega_2$ is an inhomogeneous 2-cochain.

\begin{question}
    What's inhomogeneous about it?
\end{question}
If you think about it,

\begin{question}
    What is symmetric?
\end{question}
I want the action to be symmetric.
Usually when you talk about a symmetric system,
I say the path integral is a sum over all field configurations.
But I say my system is symmetric if my action has the symmetry.

\begin{question}
    Can't we have each equality up to a phase
    so the phases cancel instead?
\end{question}
I haven't thought about that too more carefully.
I'm saying that this implies this,
but not the other way around.
You could relax things and consider it more general,
but I'm not sure how to do that in a way that's compatible with locality.
At the very least,
it gives us a way of getting a symmetric path integral.

\begin{question}
    Every group element can be mapped to another group element by another group
    element.
    Why are not all the vertices not connected to each other.
    You can always form a side that connects $g_1$ to $g_3$.
    What is the point of triangulation?
    All group elements are connected to each other.
\end{question}
I don't understand the question.
That's the graph of the group.
You can think if this as defining a gauge field on a manifold.

\begin{question}
    We're assuming $\nu_2$ to have a global $g$ symmetry,
    not a local $g$ symmetry.
\end{question}
We have a global $g$ symmetry,
which means we want every amplitude independent of $g$,
but there's also a gauge symmetry,
in that I can do a gauge transformation $A$ and not change the path integral.
There's something much stronger that's happening here in that there's also a
local gauge symmetry.

\section{Topological invariance of the path integral}
Now we get to the topological invariance of $Z$.
So far,
we had to triangulate spacetime and add a branching structure.
That's just geometry.
But for topological invariance,
we need it to be independent of geometry and choice of branching structure.

The point is,
that we want $Z$ to be independent of triangulation and branching structure.
that's what we want to demand,
but actually we want to demand something even stringer,
that is the action $e^{iS}$ is topological,
meaning independent of triangulation.

And the way that you can require that something be independent of triangulation,
is given any triangulation,
you can always get to another triangulation by a series of moves,
and these moves are called \emph{Pacher moves}.

Suppose I have two triangles like this.
One Pacher move is to have a rhombus with a diagonal,
and change the diagonal to the other diagonal. This is a 2-2 move.

There is a 1-3 move which inserts a vertex on a triangle,
and draws rays from the new vertex.

It's just pasting a simplex of one higher dimension.
In 2D you have a 2-simplex that is a triangle.
But in one-higher dimension,
you have a tetrahedron.
Think of pasting a tetrahedron onto a triangle and flattening it.

So one way of thinking about Pachner moves is pasting $D+1$-simplices onto your
$D$ simplices and flattening it out.

But we actually need branched Pachner moves,
which also deals with the ordering.

I need some extra conditions.
For example,
in the 2-2 Pachner move,
there would be
\begin{align}
    \nu_2 (g_0, g_1, g_2)
    \nu_2 (g_0, g_2, g_3)
    =
    \nu_2 (g_0, g_1, g_3)
    \nu_2 (g_1, g_2, g_3)
\end{align}
[picutre]

To be careful,
you should also check the orientation and make sure you put the right complex
conjugation.
For the 1-3 Pachner move,
you would have
\begin{align}
    \nu_2(g_0, g_1, g_2) =
    \nu_2(g_0, g_1, g_3)
    \nu_2(g_1, g_2, g_3)
    \nu_2(g_0, g_2, g_3)
\end{align}

But secretly,
they are the same equation,
in fact they are just the 2-cocycle equation that
\begin{align}
    d\nu_2 = 1
\end{align}

To make the topological action re-triangulation invariant,
we require that $\nu_2$ to be a 2-cocycle.

And finally,
let's look at the invariant under 2-coboundaries

\subsection{Invariance under coboundaries}
Suppose that we take
\begin{align}
    \nu_2 (g_0, g_1, g_2)
    \to
    \nu_2 \cdot
    b_1 (g_0, g_1)
    b_1 (g_1, g_2)
    \left[ b_1 (g_0, g_2) \right]^*
\end{align}
and I'm going to require
\begin{align}
    b_1 (g_1, g_2) &= b_1 (gg_1, gg_2)
\end{align}
And $e^{iS}$ is invariant because each edge (1-simplex) appears in exactly two
2-simplices with opposite induced orientation.

The reason it's invariant, is every single 1-simplex appears with 2 neighbouring
triangles.
For example, if I have a triangulation,
every 1-simplex has 2 neighbouring triangles.
And every 1-simplex has opposite orientation relative to each triangle.
That means that if one triangle changes by this factor $b_1(g_1,g_2)$,
the neighbour is going to change by a similar factor,
but it's going to appear complex conjugated in the neighbour so they're all
going to cancel out.

In terms of inhomogeneous 2-cocycles,
applying $g_0^{-1}$ to each term,
we get
\begin{align}
    \nu_2(1, g_0^{-1} g_1, g_{0}^{-1} g_2)
    &\to
    \nu_2 \cdot
    \frac{b_1(1, g_{01}) b_1(1, g_{12})}{b_1(1, g_{02})}
\end{align}
and
\begin{align}
    \omega_2(g_{01}, g_{12}) \to
    \omega_2
    \frac{\epsilon_1(g_{01}) \epsilon_1_1\left( g_{12} \right)}{\epsilon_1\left(
    g_{02} \right)}
\end{align}

That means, if we change our 2-coboundary by 2-cocycles,
the topological boundary doesn't change.
That is,
distinct $G$-symmetric path integrals are classified by
\begin{align}
    [\nu_2] \in
    H^2\left( G, U(1) \right)
    = \frac{\mathbb{Z}^2}{B^2}
\end{align}
Actually,
the last step is a bit of a jump.

Let me give more details.

On closed manifolds,
what we defined so far always gives us one with
$Z(M^2)=1$.
That's because what we have is a trivial $G$-bundle,
meaning that
$\prod_{\textrm{loop}}A=1$.

To get non-trivial results we non-trivial flat bundles with
$\prod_{\textrm{loop}}A \ne 1$.
We want it to be flat but we want holomony over non-contractible loops.

One way of doing this is this construction we've defined,
is we can cut our manifold along whatever loop we're interested with having
holomony,
then inserting some $G$-twist when we glue them back together.

Let me draw a picture.
Suppose w have a cylinder,
and we want to put a $h$ branch cut along the cylinder axis.
So then this loop at the end of the cylinder is $\gamma$,
with $\prod_\gamma A = h$.

Then if you roll out the cylinder flat,
you can draw a triangulation like this.

[picture of unrolled cylinder sheet]

The point is that if we have $g_1,g_2,\ldots$ on the bottom edge of the cut,
which we identify with the vertices on the top edge of the cut to get a
cylinder.
To do the twist,
just make the top edge vertices labelled $hg_1, hg_2, \ldots$.

For a closed $M^2$
non-trivial flat bundle,
\begin{align}
    |Z(M^2, A)| = 1
\end{align}
but the phase is going to be non-trivial,
with $Z(M^2, A)$ being a gauge-invariant polynomial in $\omega_2$.
For every element of $H^2$,
we're going to get a path integral that will spit out a $U(1)$ phase and if we
look at al possible closed manifolds and all possible closed bundles,
we find that all elements of $H^2(G, U(1))$ corresponds to a distinct path
integral $Z(M^2, A)$.

So there is a one-to-one correspondence between this group and these TQFTs by
picking appropriate fluxes along non-contractible cycles.
\begin{align}
    H^2(G, U(1)) \leftrightarrow Z(M^2, A)
\end{align}
I didn't prove that $Z(M^2)=1$ if it's flat and trivial,
because I didn't prove that the sum over $G$ is actually invariant yet.

\begin{question}
    What is the definition of $\prod A$?
\end{question}
If you have a torus.
If you take a product of lops on a contractible bundle,
you get 1.
But you get a holomony over a non-contractible loop?

\begin{question}
    What if we generalize to cellulations?
\end{question}
well this $\nu_2(g_0, g_1, g_2)$ only makes sense over triangles because it has
3 inputs,
but you could consider cellulations,
but the framework will be a different,
but ultimately you get the same answer.


\documentclass{lucky}

\title{MAST Diagnostic}
\author{Dennis Chen}
\date{Season 1}

\begin{document}

\maketitle

\section{Instructions}
Take as long as you need on these problems and do as many as you can. For computational problems, provide numerical answers and include a short sketch of your solution. For proof problems, include a full solution. Once done, submit it through the MAST Diagnostic Form.

You may use books as reference/ask me or other people for help. (In particular, if you need reading to learn the material, please contact me.) All of these are my problems so I do think it'll be difficult to google them, but please don't try this all the same.

\section{Problems}

\subsection{Computational}

\begin{enumerate}

\item How many integer values of $1\leq x\leq 100$ makes $x^2+8x+5$ divisible by $10?$

\item In the following diagram, $m\angle BAC=m\angle BFC=40^{\circ}$, $m\angle ABF=80^{\circ}$, and $m\angle FEB=2m\angle DBE=2m\angle FBE$. What is $m\angle ADB$?

    \begin{center}
        \begin{asy}
        import olympiad;
        size(4cm);
    draw((0,0)--(-14,0)--(2,8)--(0,0)--(-9,2.5)--(-5.5,0)--(-6,4)--cycle);
    draw((-5.5,0)--(2,8));
    label("A", (2,8), NE);
    label("B", (0,0), SE);
    label("C", (-5.5,0), S);
    label("D", (-14,0), SW);
    label("E", (-9,2.5), NNW);
    label("F", (-6,4), NNW);
        \end{asy}
    \end{center}

\item Consider parallelogram $ABCD$ with $AB=7,$ $BC=6.$ Let the angle bisector of $\angle DAB$ intersect $BC$ at $X$ and $CD$ at $Y.$ Let the line through $X$ parallel to $BD$ intersect $AD$ at $Q.$ If $QY=6,$ find $\cos\angle DAB.$

\item Consider unit circle $O$ with diameter $AB.$ Let $T$ be on the circle such that $TA<TB.$ Let the tangent line through $T$ intersect $AB$ at $X$ and intersect the tangent line through $B$ at $Y.$ Let $M$ be the midpoint of $YB,$ and let $XM$ intersect circle $O$ at $P$ and $Q.$ If $XP=MQ,$ find $AT.$

\item A secret spy organization needs to spread some secret knowledge to all of its members. In the beginning, only $1$ member is \textit{informed}. Every informed spy will call an uninformed spy such that every informed spy is calling a different uninformed spy. After being called, an uninformed spy becomes informed. The call takes $1$ minute, but since the spies are running low on time, they call the next spy directly afterward. However, to avoid being caught, after the third call an informed spy makes, the spy stops calling. How many minutes will it take for every spy to be informed, provided that the organization has $600$ spies?

\item Andy the unicorn is on a number line from $1$ to $2019.$ He starts on $1.$ Each step, he randomly and uniformly picks an integer greater than the integer he is currently on, and goes to it. He stops when he reaches $2019.$ What is the probability he is ever on $1984?$

\item Find \[\sum\limits_{a=1}^{\infty}\frac{32a}{16a^4+24a^2+25}.\]

\item Find the sum of all odd $n$ such that $\frac{1}{n}$ expressed in base $8$ is a repeating decimal with period $4.$

\item Santa Claus is putting $n$ identical toy trains into a red stocking, a green stocking, and a white stocking such that the amount of trains in the green stocking is divisible by $3$ and the amount of trains in the white stocking is even. Mrs. Claus is putting $n$ identical elves into a red stocking, a green stocking, and a white stocking such that the amount of elves in the green stocking is divisible by $3$ and the amount of elves in the white stocking is odd. Find, in terms of $n,$ the positive difference between the amount of ways Santa Claus can put his trains in the stockings and the amount of ways Mrs. Claus can put her elves in the stockings.

\item Find the maximum value of $k$ such that $(x+1)^4\geq kx^3$ for all $x.$

\end{enumerate}

\subsection{Proof}

\begin{enumerate}
    \item Consider $\triangle ABC,$ and let the feet of the $B$ and $C$ altitudes of the triangle be $X,Y.$ Let $XY$ intersect $BC$ at $P.$ Then prove that the circumcircles of $\triangle PBY$ and $\triangle PCX$ concur with $AP.$

    \item Consider $\triangle ABC$ with $D$ on line $BC.$ Let the circumcenters of $\triangle ABD$ and $\triangle ACD$ be $M,N,$ respectively. Let the circumcircle of $\triangle MND$ intersect the circumcircle of $\triangle ACD$ again at $H\neq D.$ Prove that $A,M,H$ are collinear.

    \item Let $f(x)=x^2-12x+36.$ In terms of $k$, for $k\geq 2,$ find the sum of all real $n$ such that $f^{k-1}(n)=f^k(n).$

    \item Consider scalene $\triangle ABC$ with incenter $I.$ Let the $A$ excircle of $\triangle ABC$ intersect the circumcircle of $\triangle ABC$ at $X,Y.$ Let $XY$ intersect $BC$ at $Z.$ Then choose $M,N$ on the $A$ excircle of $\triangle ABC$ such that $ZM,ZN$ are tangent to the $A$ excircle of $\triangle ABC.$ Prove $I,M,N$ are collinear.
\end{enumerate}

\end{document}


One of the most surprising outcomes of the revolution in computing
technology has been the discovery of diverse uses for randomness
in the analysis of data and in science generally.  Most young people
have little trouble with the idea of a computer generating random data;
they see it in computer games and simulations.  Older people,
raised with the idea that computers do mathematical operations and
that such operations are completely deterministic, sometimes find
computer-generated randomness suspect.  Indeed, conventional algebraic
notation ($+$, $-$, $\sqrt{}$, $\cos$, and so on) has no
notation for ``generate at random.''

\index{C}{resampling}
\index{P}{resample@\texttt{resample}*}
\index{P}{Resampling!resample@\texttt{resample}*}
\index{C}{coin flip!simulation}
\index{P}{Simulations!coin flip}
One of the simplest operators for generating random events is
\code{resample}.  This takes two arguments: the first is a set of
items to choose from at random, the second is how many events
to generate.  Each item is equally likely to be
choosen.  For example, here is a simulation of a coin flip:
\begin{Schunk}
\begin{Sinput}
> coin = c("H","T")
> resample(coin, 5)
\end{Sinput}
\begin{Soutput}
[1] "H" "T" "T" "T" "H"
\end{Soutput}
\begin{Sinput}
> resample(coin, 5)
\end{Sinput}
\begin{Soutput}
[1] "H" "H" "H" "T" "T"
\end{Soutput}
\end{Schunk}
The first command creates an object holding the possible outcome of
each event, called \code{coin}.  The next command generated five
events, each event being a random choice of the outcomes in
\code{coin}.

Another example is rolling dice.  First, construct a set of the
possible outcomes: the numbers 1, 2, 3, 4, 5, 6.
\begin{Schunk}
\begin{Sinput}
> die = seq(1,6)
> die
\end{Sinput}
\begin{Soutput}
[1] 1 2 3 4 5 6
\end{Soutput}
\end{Schunk}
Then generate random events.  Here is a roll of two dice.
\begin{Schunk}
\begin{Sinput}
> resample(die,2)
\end{Sinput}
\begin{Soutput}
[1] 4 5
\end{Soutput}
\end{Schunk}

The \function{resample} function is also useful for selecting cases at
random from a data frame.  This use will be the basis for statistical
methods introduced in later chapters.

\subsection{Random Draws from Probability Models}

Although \function{resample} is useful for random sampling, it can work
only with finite sets of possible outcomes such as H/T or 1/2/3/4/5/6
or the cases in a data frame.  By default in \function{resample}, the
underlying probability model is
\newword{equiprobability} --- each possible outcome is equally likely.
You can specify another probability model by using the \code{prob=} argument
to \function{resample}. For instance, to flip coins that are very likely to come up heads:
\begin{Schunk}
\begin{Sinput}
> resample( coin, 10, prob=c(.9,.1))
\end{Sinput}
\begin{Soutput}
 [1] "H" "H" "H" "H" "H" "H" "H" "H" "H" "T"
\end{Soutput}
\end{Schunk}

R provides other operators that allow
draws to be made from outcome sets that are infinite.

\index{C}{probability model!sampling from}

For example, the \function{rnorm} function makes random draws from a
normal probability distribution.  The required argument tells how many
draws to make.  Optional, named arguments let you specify the mean and
standard deviation of the particular normal distribution that you
want.  To illustrate, here is a set of 15 random numbers from a normal
distribution with mean 1000 and standard deviation 75:
\begin{Schunk}
\begin{Sinput}
> samps = rnorm(15, mean=1000, sd=75)
> samps
\end{Sinput}
\begin{Soutput}
 [1]  977  941 1000  996  934 1029  995 1079  969  935 1017
[12]  992 1023 1022 1046
\end{Soutput}
\end{Schunk}
In this example, the output was assigned to an object \code{samps}
to facilitate some additional computations to the
values.  For instance, here is the mean and standard deviation of the
sample:
\begin{Schunk}
\begin{Sinput}
> mean(samps)
\end{Sinput}
\begin{Soutput}
mean
 997
\end{Soutput}
\begin{Sinput}
> sd(samps)
\end{Sinput}
\begin{Soutput}
  sd
41.5
\end{Soutput}
\end{Schunk}
Don't be surprised that the mean and standard deviation of the sample
don't match exactly the parameters that were set with the arguments
\code{mean=1000, sd=75}.  The sample was drawn at random and so the
sample statistics are going to vary from one sample to the next.  Part
of the statistical methodology to be studied in later chapters has to
do with determining how close the statistics calculated from a sample
are likely to be to the parameters of the underlying population.

Often you will generate very large samples.  In these situations you
usually don't want to display all the samples, just do calculations
with them.  The practical limits of ``large'' depend on the computer
you are using and how much time you are willing to spend on a
calculation.   For an operator like \code{rnorm} and the others to be
introduced in this chapter, it's feasible to generate samples of size
10,000 or 100,000 on an ordinary laptop computer.
\begin{Schunk}
\begin{Sinput}
> samps = rnorm(100000, mean=1000, sd=75)
> mean( samps )
\end{Sinput}
\begin{Soutput}
mean
1000
\end{Soutput}
\begin{Sinput}
> sd( samps )
\end{Sinput}
\begin{Soutput}
  sd
75.3
\end{Soutput}
\end{Schunk}
Notice that the sample mean and standard deviation are quite close to
the population parameters in this large sample.  (Remember not to put commas in as punctuation in large numbers: it's \code{100000} not 100,000.)

The simulations that you will do in later chapters
will be much more elaborate than the simple draws here.  Even with
today's computers, you will want to use only a few hundred trials.

\subsection{Standard Probability Models}

R provides a large set of operators like \code{rnorm} for different
probability models.  All of these operators work in the same way:
\begin{itemize}
\item Each has a required first argument that gives the number of
draws to make.

\item Each has an optional set of parameters that specify the
particular probability distribution you want.
\end{itemize}

All the operators start with the letter \code{r} --- standing for
``random'' --- followed by the name of the probability model:

\bigskip
\centerline{\begin{tabular}{llp{2.3in}l}
Family & R name & Parameters & \\\hline
Normal & \texttt{rnorm} & \texttt{mean},\texttt{sd} & continuous\\
Uniform & \texttt{runif} & \texttt{min},\texttt{max} & continuous\\
Binomial & \texttt{rbinom}& \texttt{size},\texttt{prob} & discrete\\
Poisson & \texttt{rpois}& Average rate (written \texttt{lambda})& discrete \\
Exponential & \texttt{rexp}& Same rate as in poisson but the parameter
is called \texttt{rate}.& continuous \\
Lognormal & \texttt{rlnorm}& Mean and sd of the natural
logarithm. \texttt{meanlog}, \texttt{sdlog}& continuous \\
$\chi^2$ & \texttt{rchisq} & Degrees of freedom (\texttt{df})&continuous \\
t & \texttt{rt} & Degrees of freedom (\texttt{df})&continuous\\
F & \texttt{rf} & Degrees of freedom in the numerator and in the
denominator (\texttt{df1}, \texttt{df2})&continuous\\
\end{tabular}}
\bigskip
\index{P}{rnorm@\texttt{rnorm}}
\index{P}{runif@\texttt{runif}}
\index{P}{rpois@\texttt{rpois}}
\index{P}{rexp@\texttt{rexp}}
\index{P}{rlnorm@\texttt{rlnorm}}
\index{P}{rchisq@\texttt{rchisq}}
\index{P}{rf@\texttt{rf}}
\index{P}{rt@\texttt{rt}}
\index{P}{rbinom@\texttt{rbinom}}
\index{P}{Probability!random generators}

To use these operators, you first must choose a particular probability
model based on the setting that applies in your situation.  This
setting will usually indicate what the population parameters should
be.  Some examples:
\begin{itemize}

\item You are in charge of a hiring committee
that is  going to interview three candidates selected from a
population of job applicants that is 63\% female.  How many of the
interviewees will be female?  Modeling this as random selection from
the applicant pool, a binomial model is appropriate.  The \code{size}
of each trial is 3, the probability of being female is 63\%:
\begin{Schunk}
\begin{Sinput}
> samps = rbinom(40, size=3, prob=0.63)
> samps
\end{Sinput}
\begin{Soutput}
 [1] 1 3 2 2 1 2 3 1 1 1 1 2 2 2 2 1 2 1 2 2 2 1 3 1 2 1 2 1
[29] 2 2 1 3 1 3 2 2 2 2 2 2
\end{Soutput}
\end{Schunk}
There are 40 trials here, since the first argument was set to 40.
Remember, each of the trials is a simulation of one hiring event.  In
the first simulated event, two of the interviewees were female; in the
third only one was female.  Typically, you will be summarizing all the
simulations, for example to see how likely each possible outcome is.
\begin{Schunk}
\begin{Sinput}
> table(samps)
\end{Sinput}
\begin{Soutput}
samps
 1  2  3
14 21  5
\end{Soutput}
\end{Schunk}

\item You want to simulate the number of customers who come into a
store over the course of an hour.  The average rate is 15 per hour.
To simulate a situation where customers arrive randomly, the poisson
model is appropriate:
\begin{Schunk}
\begin{Sinput}
> rpois(25, lambda=15)
\end{Sinput}
\begin{Soutput}
 [1] 18 15 13 15 14 15 19 10 17 25 13 13  8 19 14 13  8 19
[19] 13 23 12 16 13 11 19
\end{Soutput}
\end{Schunk}

\item You want to generate a simulation of the interval between
earthquakes as in Example \ref{example:earthquake-intervals}.  To
simulate the random intervals with a typical rate of 0.03 earthquakes
per year, you would use
\begin{Schunk}
\begin{Sinput}
> rexp( 15, rate=0.03 )
\end{Sinput}
\begin{Soutput}
 [1]  16.48  13.43  18.74  44.05 129.50  66.52  39.94   5.31
 [9]  14.65  21.42  72.14  45.95  21.64  14.64  26.51
\end{Soutput}
\end{Schunk}

Notice the huge variation in the intervals, from less than half a year
to almost 90 years between earthquakes.

\end{itemize}

\subsection{Coverage Intervals}

\index{C}{coverage interval!computing}

You will often need to compute coverage intervals in order to describe
the range of likely outcomes from a random process.  R provides a
series of operators for this purpose; a separate operator for each
named probability model.  The operators all begin with \code{q},
standing for \newword{quantiles}.  In all cases, the first argument is
the set of quantiles you want to calculate for the particular
probability model.  The optional named arguments are the parameters.

\index{C}{coverage interval!level}
Remember
that to find a 95\% coverage interval you need the 0.025 and 0.975
quantiles.  For a 99\% interval, you need the 0.005 and 0.995
quantiles.

To illustrate, here are 95\% coverage intervals for a few
probability models.
\begin{itemize}
\item A normal distribution with mean 0 and standard deviation 1:
\begin{Schunk}
\begin{Sinput}
> qnorm( c(0.025, 0.975), mean=0, sd=1)
\end{Sinput}
\begin{Soutput}
[1] -1.96  1.96
\end{Soutput}
\end{Schunk}
>

\item The hiring committee situation modelled by a binomial
distribution with \code{size=3} and \code{prob=0.63}:
\begin{Schunk}
\begin{Sinput}
> qbinom( c(0.025, 0.975), size=3, prob=0.63)
\end{Sinput}
\begin{Soutput}
[1] 0 3
\end{Soutput}
\end{Schunk}

Perhaps you are surprised to see that the coverage interval includes
all the possible outcomes.  That's because the number of cases in each
trial ($n=3$) is quite small.

\item The number of customers entering a store during an hour
as modelled by a poisson
distribution with an average rate of 15 per hour.
\begin{Schunk}
\begin{Sinput}
> qpois( c(0.025, 0.975), lambda=15)
\end{Sinput}
\begin{Soutput}
[1]  8 23
\end{Soutput}
\end{Schunk}

\item The interval between earthquakes modelled by an exponential
distribution with a typical rate of 0.03 earthquakes per year:
\begin{Schunk}
\begin{Sinput}
> qexp( c(.025, .975), rate=0.03)
\end{Sinput}
\begin{Soutput}
[1]   0.844 122.963
\end{Soutput}
\end{Schunk}
\end{itemize}

\index{P}{quantiles!q-functions}
\index{P}{Probability!q operators}
\index{C}{quantiles!computing}

You can also use the \code{q} operators to find the value that would
be at a particular percentile.  For example, the exponential model with \code{rate=0.03}
gives the 25th percentile of
the interval between earthquakes as:
\begin{Schunk}
\begin{Sinput}
> qexp( .25, rate=0.03)
\end{Sinput}
\begin{Soutput}
[1] 9.59
\end{Soutput}
\end{Schunk}
A quarter of the time, the interval between earthquakes will be 9.59
years or less.

It's entirely feasible to calculate percentiles and
coverage intervals by combining
the random-number generators with \code{quantile}.  For example, here
is the 95\% coverage interval from a normal distribution with mean 0
and standard deviation 1:
\begin{Schunk}
\begin{Sinput}
> samps = rnorm(10000, mean=0, sd=1)
> qdata( c(.025, .975), samps )
\end{Sinput}
\begin{Soutput}
 2.5% 97.5%
-1.99  1.95
\end{Soutput}
\end{Schunk}
The disadvantage of this approach is that it is a simulation and the
results will vary randomly.  By making the sample size large enough
--- here it is $n=10000$ --- you can reduce the random variation.
Using the \code{q} operators uses mathematical analysis to give
you what is effectively an
infinite sample size.  For this reason, it's advisable to use the
\code{q} operators when you can.  However, for many of the techniques to
be introduced in later chapters you will have to generate a random
sample and then apply \code{quantile} to approximate the coverage intervals.

\subsection{Percentiles}

\index{P}{percentile!p-functions}
\index{C}{percentile!computing}
\index{P}{Probability!p operators}
\index{P}{Probability!q operators}

A percentile computation applies to situations where you have a
measured value and you want to know where that value ranks relative to
the entire set of possible outcomes.  You have already seen
percentiles computed from samples; they also apply to probability models.

It's easy to confuse percentiles with quantiles because they are so
closely related.
Mathematically, the percentile operators are the inverse of the
quantile operators.
To help you remember which is which, it's helpful to distinguish them
based on the type of argument that you give to the operator:
\begin{description}
\item[Percentile] The input
argument is a measured value, something that could be the
output of a single draw from the probability distribution. The output
is always a number between 0 and 1 --- a percentile.

\item[Quantile] The input is a percentile, a number between 0 and 1.
The output is on the scale of the measured variable.
\end{description}

Example:  You have just gotten your score, 670, on a professional school
admissions test.  According to the information published by the
testing company, the scores are normally distributed with a mean of
600 and a standard deviation of 100.  So, your ranking on the test, as
indicated by a percentile, is:
\begin{Schunk}
\begin{Sinput}
> pnorm(670, mean=600, sd=100)
\end{Sinput}
\begin{Soutput}
[1] 0.758
\end{Soutput}
\end{Schunk}
Your score is at about the 75th percentile.

Example: Unfortunately, the professional school that you want to go to
accepts only students with scores in the top 15 percent.  Your score,
at 75.8\%, isn't good enough.  So, you will study some more and take
practice tests until your score is good enough.
How well will you need to score to reach the 85th percentile?
\begin{Schunk}
\begin{Sinput}
> qnorm(0.85, mean=600, sd=100)
\end{Sinput}
\begin{Soutput}
[1] 704
\end{Soutput}
\end{Schunk}


\documentclass{article}
\usepackage{parskip}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{cancel}
\usepackage{algorithmic}

\setlength{\parindent}{0cm}

\begin{document}

\title{CPSC 413 \\ Assignment 4 - Dynamic Programming}
\author{Andrew Helwer}
\date{March 2011}
\maketitle

\section{Design a Divide and Conquer Algorithm}

Define a function $\omega:v \rightarrow \mathbb{R}$ which returns the real
weight of any vertex $v$.

Define a function $\alpha:S \rightarrow \mathbb{R}$, which for
any set of vertices $S$ has the following action:
\begin{equation*}
\alpha(S) = \sum_{v \in S} \omega(v)
\end{equation*}

Within this document, the term \textit{minimal vertex cover} will be synonymous
with a vertex cover $V \subset T$ such that for any vertex cover $V'
\subset T$, $\alpha(V) < \alpha(V')$.

$\{nil\} \cup S = S$ for any set $S$, where $nil$ is the value of $v.left$ or
$v.right$ if $v$ does not have a left or right child.

\textbf{1) Describe how to solve trivial instances:}

One trivial instance of this problem occurs when $|T| = 0$, that is when
$cover(nil)$ is called. $\emptyset$ should be returned in this instance.

The other trivial instance occurs when $|T| = 1$. $\emptyset$
will be returned, as a graph with a single vertex $v$ has no edges and thus the
vertex cover will either be $v$ or $\emptyset$. Since $\alpha(\{v\}) > 0$ and
$\alpha(\emptyset) = 0$, $\alpha(\emptyset) < \alpha(\{v\})$ and so $\emptyset$
is the vertex cover with minimal $\alpha$.

\textbf{2) Describe how sub-instances should be formed from nontrivial ones:}

Define the function $\pi(v)$ for any $v \in T$, where:
\begin{displaymath}
\pi(v) = \left\{
	\begin{array}{lr}
	\emptyset & : v = nil \\
	\{cover(v.left) \cup cover(v.right)\} & : v \neq nil
	\end{array}
	\right.
\end{displaymath}
Consider the case of a tree $T$ of arbitrary size. Given the root of $T$, $v$,
split the problem as follows:
\begin{equation*}
S_1 := \{v\} \cup \pi(v)
\end{equation*}
\begin{equation*}
S_2 := \{v.left\} \cup \{v.right\} \cup \pi(v.left) \cup \pi(v.right)
\end{equation*}
This will find the minimal vertex cover that includes $v$, $S_1$, and the
minimal vertex cover that does not include $v$, $S_2$.

\textbf{3) Describe how a solution is formed from sub-instance solutions:}

The set of $V$ of all vertex covers for $T$ may be partitioned into two
subsets, where the root of $T$ is $v$:
\begin{itemize}
\item The set $V_1$ of all vertex covers for $T$ that include $v$
\item The set $V_2$ of all vertex covers for $T$ that do not include $v$
\end{itemize}
Since $V_1 \sqcup V_2 = V$, the minimal element of $V$ may be found by taking
the lesser of the minimal element in $V_1$ and the minimal element in $V_2$.
Since the minimal element in $V_1$ is $S_1$ and the minimal element in $V_2$ is
$S_2$, if $\alpha(S_1) \leq \alpha(S_2)$, the minimal element of $V$ will be
$S_1$. Otherwise, it will be $S_2$. So $cover(v)$ should return $S_1$ if
$\alpha(S_1) \leq \alpha(S_2)$ and $S_2$ otherwise.

\textbf{4) Describe a recursive algorithm implementation:}

$cover(v)$
\begin{algorithmic}[1]
\IF {($v.left=nil$ and $v.right=nil$) or $v=nil$}
	\RETURN $\emptyset$
\ELSE
	\STATE $S_1\gets\{v\}\cup\pi(v)$
	\STATE $S_2\gets\{v.left\}\cup\{v.right\}\cup\pi(v.left)\cup\pi(v.right)$
	\IF {$\alpha(S_1) \leq \alpha(S_2)$}
		\RETURN $S_1$
	\ELSE
		\RETURN $S_2$
	\ENDIF
\ENDIF
\end{algorithmic}

\textbf{5) Prove correctness of the algorithm using induction:}

Base Cases: $|S|=1$ and $|S|=0$

In both cases, the If statement in Instruction 1 will evaluate to True, and so
instruction 2 will be executed, returning $\emptyset$ as was shown to be
correct in Part 1. Thus the Base Cases hold.

Inductive Case:

Inductive Hypothesis - assume $cover(v)$ is correct for the root $v$ of all
trees $T$ of size greater than 1 to $n$. Consider the case where $|T|=n+1$, $v$
is the root of $T$, and $cover(v)$ is called:

The If statement in Instruction 1 will evaluate to False, and so Instructions 4
and 5 will be executed. These split the problem into sets $S_1$ and $S_2$ as
was defined in Part 2. Since all recursive calls of $cover(u)$ will have $u$ as
one of $v.left$, $v.right$, $v.left.left$, $v.left.right$, $v.right.left$, or
$v.right.right$, the tree for which $u$ is the root is guaranteed to be of size
less than or equal to $n$. Thus $cover(u)$ will return correct output by the
Inductive Hypothesis, and so the values of $S_1$ and $S_2$ will be the minimal
elements of $V_1$ and $V_2$. As was proved in Part 3, whichever of $S_1$ and
$S_2$ have the smaller value of $\alpha$ will be the minimal vertex cover of
$T$, which will be decided by Instructions 6, 7, and 9. Therefore $cover(v)$
returns correct output.

Thus the correctness of $cover(v)$ has been proved by induction. $\square$

\section{Design a Dynamic Programming Algorithm}

\textbf{6) Identify smaller instances that must be solved in nontrivial cases:}

Using the same procedure as in the Divide and Conquer algorithm, for a tree $T$
with root $v$, in order for $cover(v)$ to be solved we must know the minimal
vertex covers for the subtrees of $T$ for which the following are roots:
\begin{itemize}
\item $v.left$
\item $v.right$
\item $v.left.left$
\item $v.left.right$
\item $v.right.left$
\item $v.right.right$
\end{itemize}

\textbf{7) Identify an ordering on these smaller instances:}

Since we may represent instances of the problem as vertices in $T$ upon which
$cover(v)$ is called, for any $u,w \in T$, $u<w$ if and only if $u$ is visited
before $w$ during a Postorder Traversal of $T$. This traversal is defined using
the following function, with $v$ the root of $T$:

$postorder(v)$
\begin{algorithmic}[1]
\IF {$v.left \neq nil$}
	\STATE $postorder(v.left)$
\ENDIF
\IF {$v.right \neq nil$}
	\STATE $postorder(v.right)$
\ENDIF
\STATE visit $v$ and return
\end{algorithmic}

Claim 7.1: For any $v \in T$, if $postorder(v)$ recursively calls
$postorder(v.left)$ or $postorder(v.right)$, then $v.left$ and $v.right$ will
be visited before $v$.

Proof: This follows from the structure of the algorithm above; if
$postorder(v.left)$ is called from Instruction 2 inside $postorder(v)$, then no
other instructions in $postorder(v)$ may be executed until $postorder(v.left)$
returns in Instruction 7, so $v.left$ will have been visited. So $v.left$ is
visited before $v$. By symmetry, $v.right$ will be visited before $v$ as
well, and so Claim 7.1 is true. $\square$

Claim 7.2: For any vertex $v \in T$, all of the following are less than $v$ (if
they exist):
\begin{itemize}
\item $v.left$
\item $v.right$
\item $v.left.left$
\item $v.left.right$
\item $v.right.left$
\item $v.right.right$
\end{itemize}
Proof: Consider a call to $postorder(v)$. If $v.left$ exists,
$postorder(v.left)$ is immediately called, so $v.left$ is visited before $v$ by
Claim 7.1, and equivalently $v.left < v$. By symmetry, $v.right < v$ as
well. Inside the call to $postorder(v.left)$, if $v.left.left$ exists,
$postorder(v.left.left)$ is called, so $v.left.left$ is visited before $v.left$
by Claim 7.1, and equivalently $v.left.left < v.left$. Therefore by the
transitive property of an order relation, $v.left.left < v$. The proof is
symmetric for $v.left.right$, $v.right.left$, and $v.right.right$. Thus Claim
7.2 is true. $\square$

\textbf{8) Choose a data structure}

The data structure of choice will be a hash table, $H$, so that for any $v \in
T$, $H(v)$ returns the minimal vertex cover for the subtree of $T$ with $v$ as
its root in $O(1)$ time. $H(nil)$ will return $\emptyset$.

\textbf{9) Describe a dynamic programming implementation:}

First redefine the function $\pi(v)$ from above:
\begin{displaymath}
\pi(v) = \left\{
	\begin{array}{lr}
	\emptyset & : v = nil \\
	\{H(v.left) \cup H(v.right)\} & : v \neq nil
	\end{array}
	\right.
\end{displaymath}

$cover(v)$
\begin{algorithmic}[1]
\IF {$v.left \neq nil$}
	\STATE $cover(v.left)$
\ENDIF
\IF {$v.right \neq nil$}
	\STATE $cover(v.right)$
\ENDIF
\IF {$v.left = nil$ and $v.right = nil$}
	\STATE $H(v) \gets \emptyset$
\ELSE
	\STATE $S_1\gets\{v\}\cup\pi(v)$
	\STATE $S_2\gets\{v.left\}\cup\{v.right\}\cup\pi(v.left)\cup\pi(v.right)$
	\IF {$\alpha(S_1) \leq \alpha(S_2)$}
		\STATE $H(v) \gets S_1$
	\ELSE
		\STATE $H(v) \gets S_2$
	\ENDIF
\ENDIF
\RETURN $H(v)$
\end{algorithmic}

\textbf{10) Prove correctness of the algorithm using induction:}

Note that $cover(v)$ is simply a modified version of $postcover(v)$, with the
visit and return instruction replaced by a number of other instructions.

Base Case:

If $cover(v)$ is called where $v$ is the only vertex in its tree, then both
Instructions 1 and 4 will not be satisfied but Instruction 7 will be, so
Instruction 8 will be executed and $H(v)$ set to $\emptyset$, as it should be.
Thus the Base Case holds.

Inductive Step:

Inductive Hypothesis - assume $cover(v)$ is correct for the root $v$ of all
trees $T$ of size greater than 1 to $n$. Consider the case where $|T|=n+1$, $v$
is the root of $T$, and $cover(v)$ is called:

At least one of Instructions 1 and 4 will be satisfied, so $cover(v.left)$
or $cover(v.right)$ will be called, and since the subtree of $T$ for which
$v.left$ or $v.right$ is a root is guaranteed to be of size at most $n$, by the
Inductive Hypothesis $cover(v.left)$ and $cover(v.right)$ will be correct.
Instruction 7 will not be satisfied, so Instructions 10 and 11 will be executed.
By Claim 7.2, all of the vertices
required to form sets $S_1$ and $S_2$ will have been visited, and by the
Inductive Hypothesis their values in the hash table $K$ will be correct, so
the values of $S_1$ and $S_2$ will be the minimal elements of $V_1$ and $V_2$.
As
was proved in Part 3, whichever of $S_1$ and $S_2$ have the smaller value of
$\alpha$ will be the minimal vertex cover of $T$, which will be decided by
Instructions 12, 13, and 15. So $H(v)$ will contain the minimal vertex cover of
$T$, which is returned in Instruction 18. Therefore $cover(v)$ returns correct
output.

Thus the correctness of $cover(v)$ has been proved by induction. $\square$

\textbf{11) Define a bounding recurrence relation}

Analysis of $cover(v)$ will be simplified if we first perform some analysis of
$postorder(v)$. Observe that in the worst case, five instructions will be
executed on a single level of recursion in $postcover(v)$, two of which are
recursive calls. As this is a traversal, each vertex will be visited exactly
once, so Instruction 7 will be executed exactly $|V|$ times on different levels
of recursion. We may therefore bound the number of instructions executed by
$postorder(v)$ on a tree of size $n$ as follows:
\begin{equation*}
T(n) \leq 5n
\end{equation*}
In order to convert this equation into a form useful for analysis of
$cover(v)$, define the number of instructions necessary to visit a vertex as
the variable $c$. So:
\begin{equation*}
T(n) \leq 4n + cn
\end{equation*}
As was noted in the proof of correctness, $cover(v)$ is simply a modified
version of $postorder(v)$ whereby the visit instruction is replaced with a
number of operations. Looking at $cover(v)$, we see in the worst case there will
be six instructions executed when visiting a vertex, for example Instructions
7, 10, 11, 12, 15, and 18. So, we can set $c=6$ in the above equation to bound
the number of instructions executed by $cover(v)$ on a tree of size $n$:
\begin{equation*}
T(n) \leq 4n + 6n
\end{equation*}
\begin{equation*}
T(n) \leq 10n
\end{equation*}
Thus $T(n)$ is of order $n$, and so $cover(v)$ runs in $O(n)$ time.

\end{document}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BASED ON Hodge-King's
%   IBL Week 4 Day 1 "Derivative Matching Revised"
% DIRECTIONS: typeset twice to get positioning right
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass[letterpaper,10pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\thispagestyle{empty}
\pagestyle{empty}

\newcounter{card}
\newcommand\content[4]{
\begin{tikzpicture}[remember picture, overlay]
\draw (current page.north west)
++({(floor(\arabic{card}/5)+1/2)*1/3*8.5in},{(mod(\arabic{card},5)+1/2)*-1/5*11in}) coordinate (center);
\draw (center) node {
	\begin{tikzpicture}
	\begin{axis}[
		axis equal image=false,
		width=3in, height=2.4in,
		grid=major, axis lines=center,
		xmin=-3.1, xmax=3.1, xtick={-3,...,3},
		ymin=-2.5, ymax=2.5, ytick={-2,...,2},
		major tick length={0},
		samples=299,
		domain=-3:3,
		% #4 = options for this particular graph, eg, xmax, ytick
		#4
		]
		% #2 = list of functions/options to plot = {fn1/op1, fn2/op2, etc}
		% global var \fncolor = color of plot & title
		\foreach \function/\options in {#2}{
			\edef\temp{\noexpand
				\addplot[ultra thick, smooth, \fncolor, \options]{\function};
				}
			\temp
			}
		% #3 = coordinates of open circles = {(x1,y1) (x2,y2), etc}, note no comma btw pts
		\addplot [\fncolor, only marks, very thick, mark=*, mark options={scale=1, fill=white}]
			coordinates{#3};
		% global var \titlef = title = f or f'
		% global var \titlex = relative x position for title = number btw 0, 1
		\node[\fncolor] at (axis description cs: \titlex,0.8) {\huge$\titlef$};
		% #1 = card ID number/letter
		\node at (axis description cs: 0.95,0.05) {\footnotesize#1};
		\end{axis}
		\end{tikzpicture}
		};
	% cut guides
	\foreach \x/\y in {1/1, 1/-1, -1/1, -1/-1}
	\draw[gray] (center) ++(\x*1/2*1/3*8.5in, \y*1/2*1/5*11in)
		edge[-] ++(left:5mm)
		edge[-] ++(right:5mm)
		edge[-] ++(up:5mm)
		edge[-] ++(down:5mm)
		;
	\end{tikzpicture}
	\stepcounter{card}
	}
\newcommand\contentb[2]{\content{#1}{{#2}/{}}{}{restrict y to domain=-2.5:2.5,}}
\newcommand\contentc[2]{\content{#1}{{#2}/{}}{}{
	xmin=-6.3, xmax=6.3, xtick={-6.28319,-3.14159,3.14159, 6.28319},
	xticklabels={$-2\pi$,$-\pi$,$\pi$, $2\pi$},
	ymin=-1.25, ymax=1.25, ytick={-1,-0.5,0.5,1},
	domain=-6.2:6.2
	}}

\begin{document}
% FUNCTION CARDS
\def\fncolor{black}
\def\titlef{f}
\def\titlex{0.2}
\contentb 1{2*x-1}
\contentb 2{-2*x+1}
\contentb 3{abs(x)}
\contentb 4{x^2+2*x}
%\contentc 5{sin(deg(x)}
\contentb 5{-x^3/3+0.5}
\contentb 6{x^3-x}
\contentb 7{(x+1)^4-1}
\content 8{ln(x)/domain=0.01:3}{}{samples=300}
\contentb 9{x^3/3+1}
\contentb {10}{x^(-1)}
\contentb {11}{2/(1+2.7182818^(-4*x+4))}
\contentb {12}{(x+1)/abs(x+1)*abs(x+1)^(1/3)}
\contentb {13}{2.7182818^(-x^2)}
\content {14}{0.333*x^3+1/domain=-3:1, x+0.333/{samples=99, domain=1:3}}{}{}
\content {15}{-x^4+4*x^2/{}}{}
	{ymin=-7.5, ymax=7.5, restrict y to domain=-7.5:7.5, ytick={-6,-3,...,6}}

% DERIVATIVE CARDS
\newpage
\def\fncolor{red}
\def\titlef{f'}
\def\titlex{0.8}
\setcounter{card}0
\contentb I2
\contentb E{-2}
\content O{-1/domain=-3:0, 1/domain=0:3}{(0,1) (0,-1)}{samples=2}
\contentb D{2*x+2}
%\contentc F{cos(deg(x))}
\contentb F{-x^2}
\contentb A{3*x^2-1}
\contentb M{4*(x+1)^3}
\content N{{1/x}/domain=0.1:3}{}{samples=30}
\contentb J{x^2}
\contentb K{-1*x^(-2)}
\contentb C{8*2.7182818^(-4*x+4)/(1+2.7182818^(-4*x+4))^2}
\content H{
	{(1/3)*1/(x+1)^2^(1/3)}/domain=-3:-1.01,
	{(1/3)*1/(x+1)^2^(1/3)}/domain=-0.99:3
	}{}{}
\contentb B{-2*x*2.7182818^(-x^2)}
\content G{x^2/domain=-3:1, 1/domain=1:3}{}{}
\content L{-4*x^3+8*x/{}}{}
	{ymin=-7.5, ymax=7.5, restrict y to domain=-7.5:7.5, ytick={-6,-3,...,6}}

% SOLUTIONS
\newpage
\section*{Solutions}
\begin{tabular}{rl}
1 & I %& $\div$
\\ 2 & E %& $\star$
\\ 3 & O %& =
\\ 4 & D %& $\triangle$
\\ 5 & F %& $\infty$
\\ 6 & A %& \&
\\ 7 & M %& @
\\ 8 & N %& $\square$
\\ 9 & J %& \#
\\ 10 & K %& \%
\\ 11 & C %& ?
\\ 12 & H %& !
\\ 13 & B %& $+$
\\ 14 & G %& $\heartsuit$
\\ 15 & L %& $\Rightarrow$
\end{tabular}
\end{document}


\subsection{Motion of a Point that moves relative to a Rigid Body}
\begin{frame}{Introduction}\vskip -8mm
	\begin{figure}[ht]
		\centering
		\includegraphics[width=80mm]{images/v_a_2.png}
	\end{figure}\vskip-4mm
	Position of point $N$ in rigid body $(R_2)$:
	\[\vb{r}{N}=\vb{r}{O}+\vb{r}{NO}=\vb{r}{O}+x\ih+y\jh+z\kh\]
\end{frame}
\begin{frame}
	Velocity vector $\vb{v}{N}$ of point $N$:\vskip1.25mm
	$\displaystyle\vb{v}{N}=\vb{v}{O}+[\dot{x}\ih+\dot{y}\jh+\dot{z}\kh]+[x\frac{d\ih}{dt}+y\frac{d\jh}{dt}+z\frac{d\kh}{dt}]$\\
	$\hskip 6.5mm\displaystyle=\vb{v}{O}+\vb{v}{N(xyz)}^{\bm r}+\vb{\omega}{}\times\vb{r}{}$\vskip2.5mm
	where $\vb{v}{N(xyz)}^{\bm r}$ is the relative velocity of point $N$ with respect to the reference frame of rigid body $(R_1)$.\vskip 5mm
	Acceleration vector $\vb{a}{N}$ of point $N$:\vskip1.25mm
	$\displaystyle\vb{a}{N}=\vb{a}{O}+[\ddot{x}\ih+\ddot{y}\jh+\ddot{z}\kh]+2\vb{\omega}{}\times\vb{v}{N(xyz)}^{\bm n}+\vb{\alpha}{}\times\vb{r}{}+\vb{\omega}{}\times(\vb{\omega}{}\times\vb{r}{})$\\
	$\hskip6.25mm\displaystyle= \vb{a}{O}+\vb{a}{N(xyz)}^{\bm r}+\vb{a}{N(xyz)}^{\bm c}+\vb{\alpha}{}\times\vb{r}{}+\vb{\omega}{}\times(\vb{\omega}{}\times\vb{r}{})$\\
	where:\\
	$\vb{a}{N(xyz)}^{\bm r}$ is the relative acceleration of point $N$ with respect to the reference frame of rigid body $(R_1)$.\\
	$\vb{a}{N(xyz)}^{\bm c}$ is referred to as \textit{Coriolis acceleration}.\vskip2.5mm
	For planar motions: $\displaystyle \vb{a}{O}= \vb{a}{O}+\vb{a}{N(xyz)}^{\bm r}+\vb{a}{N(xyz)}^{\bm c}+\vb{\alpha}{}\times\vb{r}{}-\vb{\omega}{}^2\vb{r}{}$
\end{frame}
\begin{frame}
	\begin{block}{Formulas}
		For any point $N$, its velocity and acceleration relative to a reference frame $O$ of a rigid body are:
		\[\begin{cases}
		\vb{v}{N}=\vb{v}{O}+\vb{v}{NO}^{\bm r}+\vb{\omega}{}\times\vb{r}{{NO}}\\
		\vb{a}{N}=\vb{a}{O}+\vb{a}{NO}^{\bm r}+2\vb{\omega}{}\times\vb{v}{NO}^{\bm r}+\vb{\alpha}{}\times\vb{r}{{NO}}+\vb{\omega}{}\times(\vb{\omega}{}\times\vb{r}{NO})
		\end{cases}\]
	\end{block}
\end{frame}


\section*{Web Appendix B}

\begin{proof}[Rest of the proof of Proposition 1]
For the random effects model, let us start from
\[
f(x_{i}\mid\theta_{0},\tau,\sigma_{i})\propto\sum_{j=1}^{J}\rho_{j}\int1_{[\alpha_{j-1},\alpha_{j})}(u_{i})\phi(x_{i}\mid\theta_{i},\sigma_{i}^2)\phi(\theta_{i}\mid\theta_{0},\tau^2)d\theta_{i}.
\]
To calculate the normalizing constant, substitute $1_{[\alpha_{j-1},\alpha_{j})}(u_{i})=1_{[c_{j-1},c_{j})}(x_{i})$
first. This is done since the \emph{p}-value is calculated with respect
to $\sigma_{i}$, not the unknown ${\tau^{2}+\sigma_{i}^{2}}$.
Then the normalizing constant is
\begin{eqnarray*}
\sum_{j=1}^{J}\rho_{j}\int1_{[c_{j-1},c_{j})}(x_{i})\phi(x_{i}\mid\theta_{i},\sigma_{i}^2)\phi(\theta_{i}\mid\theta_{0},\tau)d\theta_{i}dx_{i} & =\\
\sum_{j=1}^{J}\rho_{j}\int1_{[c_{j-1},c_{j})}(x_{i})\phi(x_{i}\mid\theta_{0},{\tau^{2}+\sigma_{i}^{2}})dx_{i} & =\\
\sum_{j=1}^{J}\rho_{j}\left[\Phi(c_{j-1}\mid\theta_{0},{\tau^{2}+\sigma_{i}^{2}})-\Phi(c_{j}\mid\theta_{0},{\tau^{2}+\sigma_{i}^{2}})\right]
\end{eqnarray*}
Use that,
\[
\frac{\phi(x_{i}\mid\theta_{0},{\tau^{2}+\sigma_{i}^{2}})1_{[\alpha_{j-1},\alpha_{j})}(u_{i})}{\Phi(c_{j-1}\mid\theta,{\tau^{2}+\sigma_{i}^{2}})-\Phi(c_{j}\mid\theta,{\tau^{2}+\sigma_{i}^{2}})}=\phi_{[c_{j},c_{j-1})}(x_{i}\mid\theta,{\tau^{2}+\sigma_{i}^{2}}),
\]
and we are done.
%\[
%\sum_{j=1}^{J}\rho_{j}\left[\Phi(c_{j-1}\mid\theta_{0},{\tau^{2}+\sigma_{i}^{2}})-\Phi(c_{j}\mid\theta_{0},{\tau^{2}+\sigma_{i}^{2}})\right].
%\]
\end{proof}