\subsection{Group actions}\label{subsec:group_actions}

\begin{definition}\label{def:endomorphism_monoid}
  For every object \( X \) in an arbitrary \hyperref[def:category]{category} \( \cat{C} \), the set \( \cat{C}(X) \) is a \hyperref[def:monoid]{monoid} with morphism composition as the monoid operation and \( \id_X \) as the monoid identity.

  Outside of \hyperref[sec:category_theory]{category theory}, whenever the category \( \cat{C} \) is clear from the context, we call \( \cat{C}(X) \) the \term{endomorphism monoid} over \( X \) and denote it by \( \End(X) \).
\end{definition}

\begin{definition}\label{def:monoid_action}
  Let \( M \) be a \hyperref[def:monoid]{monoid} and let \( X \) be an object in some \hyperref[def:category]{category} \( \cat{C} \).

  We will define monoid actions of \( M \) on \( X \), which we will sometimes call \term{left monoid actions}. There are also \term{right monoid actions}, which are only briefly mentioned in \fullref{def:monoid_action/functor}.

  A \term{monoid action} can be defined equivalently as:
  \begin{thmenum}
    \thmitem{def:monoid_action/homomorphism} A \hyperref[def:monoid/homomorphism]{homomorphism} from \( M \) to the \hyperref[def:endomorphism_monoid]{endomorphism monoid} \( \End(X) \).

    \thmitem{def:monoid_action/functor} A \hyperref[def:functor]{functor} from the \hyperref[def:monoid_delooping]{delooping} \( \cat{B}_M \) to \( \cat{C} \).

    Right actions are \hyperref[rem:contravariant_functor]{contravariant functors}.

    \thmitem{def:monoid_action/family} An \hyperref[def:cartesian_product/indexed_family]{indexed family} \( \seq{ \Phi_m }_{m \in M} \) of \hyperref[def:morphism_invertibility/endomorphism]{endomorphisms} of \( X \) such that
    \begin{align}
      &\Phi_e = \id_X, \label{eq:def:monoid_action/family/identity}\tag{\logic{MA1}} \\
      &\Phi_{mn} = \Phi_m \bincirc \Phi_n. \label{eq:def:monoid_action/family/compatibility}\tag{\logic{MA2}}
    \end{align}

    This defines a function \( \Phi: M \times A \to A \).
  \end{thmenum}
\end{definition}
\begin{proof}
  \ImplicationSubProof{def:monoid_action/homomorphism}{def:monoid_action/functor} Suppose that we have a monoid homomorphism \( \Phi: M \to \End(X) \). Define the functor
  \begin{equation*}
    \begin{aligned}
      &F: \cat{B}_M \to \cat{C} \\
      &F(\anon) \coloneqq X \\
      &F(m) \coloneqq \Phi(m).
    \end{aligned}
  \end{equation*}

  This is indeed a functor because \eqref{eq:def:functor/CF1} follows from \eqref{eq:def:pointed_set/homomorphism} and \eqref{eq:def:functor/CF2} follows from \eqref{eq:def:magma/homomorphism}.

  \ImplicationSubProof{def:monoid_action/functor}{def:monoid_action/family} Suppose that we have a functor \( F: \cat{B}_M \to \cat{C} \). Let \( X \coloneqq F(\anon) \) and define the \( M \)-indexed family
  \begin{equation*}
    \begin{aligned}
      &\Phi_m: X \to X \\
      &\Phi_m \coloneqq F(m).
    \end{aligned}
  \end{equation*}

  It satisfies the necessary axioms:
  \begin{itemize}
    \item \ref{eq:def:monoid_action/family/identity} holds:
    \begin{equation*}
      \Phi_e
      =
      F(e)
      \reloset {\eqref{eq:def:functor/CF1}} =
      \id_A.
    \end{equation*}

    \item \ref{eq:def:monoid_action/family/compatibility} holds: for every pair \( m, n \in M \), we have
    \begin{equation*}
      \Phi_{mn}
      =
      F(mn)
      \reloset {\eqref{eq:def:functor/CF2}} =
      F(m) \bincirc F(n)
      =
      \Phi_m \bincirc \Phi_n
    \end{equation*}
  \end{itemize}

  \ImplicationSubProof{def:monoid_action/family}{def:monoid_action/homomorphism} Suppose that we have an indexed family \( \seq{ \Phi_m }_{m \in M} \) of endomorphisms of \( A \) that satisfies the axioms for left action. Regard this indexed family as a function \( \Phi: M \to \End(X) \).

  Then \( \Phi \) is a monoid homomorphism because \ref{eq:def:monoid_action/family/identity} implies \( \Phi(e) = \id_X \) and \eqref{eq:def:monoid_action/family/compatibility} implies
  \begin{equation*}
    \Phi(mn) = \Phi(m) \bincirc \Phi(n).
  \end{equation*}
\end{proof}

\begin{proposition}\label{thm:monoid_is_action}
  Every \hyperref[def:monoid]{monoid} \hyperref[def:monoid_action]{acts} on itself via the family of functions \( h \mapsto g \cdot h \) indexed by \( g \). These functions are not monoid homomorphisms in general.

  Compare this result to \fullref{thm:cayleys_theorem}.
\end{proposition}
\begin{proof}
  The family satisfies \fullref{def:monoid_action/family}:
  \begin{itemize}
    \item \ref{eq:def:monoid_action/family/identity} follows from \eqref{eq:def:monoid/theory/identity}.

    \item \ref{eq:def:monoid_action/family/compatibility} follows from associativity:
    \begin{equation*}
      [h \mapsto g_1 \cdot h] \bincirc [h \mapsto g_2 \cdot h] = [h \mapsto g_1 \cdot (g_2 \cdot h)] = [h \mapsto (g_1 \cdot g_2) \cdot h].
    \end{equation*}
  \end{itemize}
\end{proof}

\begin{proposition}\label{thm:exponentiation_monoid_action}
  The \hyperref[def:set_of_natural_numbers]{natural numbers} \( \BbbN \) (\hyperref[rem:peano_arithmetic_zero]{with zero}) act on any \hyperref[def:monoid]{monoid} by \hyperref[def:monoid/exponentiation]{exponentiation} via the family of function \( g \mapsto g^n \) indexed by \( n \in \BbbN \).

  Compare this result to \fullref{thm:exponentiation_group_action}.
\end{proposition}
\begin{proof}
  This family satisfies \fullref{def:monoid_action/family}:
  \begin{itemize}
    \item \ref{eq:def:monoid_action/family/identity} is obvious.
    \item \ref{eq:def:monoid_action/family/compatibility} follows from \fullref{thm:magma_exponentiation_properties/repeated}.
  \end{itemize}
\end{proof}

\begin{definition}\label{def:automorphism_group}
  For every object \( X \) in a \hyperref[def:groupoid]{groupoid} \( \cat{G} \), the set \( \cat{G}(X) \) is a \hyperref[def:group]{group} with morphism composition as the group operation.

  Similarly to \hyperref[def:endomorphism_monoid]{endomorphism monoids}, whenever the groupoid \( \cat{G} \) is clear from the context, we call \( \cat{G}(X) \) the \term{automorphism group} over \( X \) and denote it by \( \aut(X) \).
\end{definition}

\begin{definition}\label{def:symmetric_group}
  We call the \hyperref[def:automorphism_group]{automorphism group} of a set \( A \) the \term{symmetric group}\footnote{The term possibly comes from symmetric functions defined in \fullref{def:symmetric_function}} on \( A \) and denote it by \( S(A) \). The group \( S(A) \) consists of bijective functions, which we call \term{permutations}.

  Rather than for arbitrary sets, we often consider symmetric group
  \begin{equation*}
    S_n \coloneqq S(\set{ 1, 2, \ldots, n }).
  \end{equation*}

  It is conventional to call \( S_n \) the \enquote{symmetric group on \( n \) letters}.

  \begin{thmenum}
    \thmitem{def:symmetric_group/permutation} It is common to write a permutation \( \sigma \) in \( S_n \) as
    \begin{equation*}
      \begin{pmatrix}
        1         & \cdots & n \\
        \sigma(1) & \cdots & \sigma(n)
      \end{pmatrix}
    \end{equation*}

    \thmitem{def:symmetric_group/cycle} If there exists a finite sequence \( k_1, \ldots, k_m \) of distinct numbers such that \( \sigma(k_m) = k_1 \) and \( \sigma(k_{i+1}) = \sigma(k_i) \) for each \( i < m \), we say that the permutation is \term{cyclic} or a \term{cycle} of \term{length} \( m \). For brevity, we denote this cycle by \( \cycle{k_1, \cdots, k_m} \).

    We call cycles of length \( 1 \) \term{trivial cycles} or \term{loops} and cycles of length \( 2 \) --- \term{transpositions}. Every \hyperref[def:symmetric_group/cycle]{transposition} is an \hyperref[def:set_with_involution]{involution}, and thus a transposition is equal to its inverse permutation.

    \thmitem{def:symmetric_group/disjoint_cycle} If \( \cycle{k_1, \cdots, k_m} \) and \( \cycle{s_1, \cdots, s_l} \) are two cycles and if the sets \( \set{ k_1, \ldots, k_m } \) and \( \set{ s_1, \ldots, s_l } \) are disjoint, we say that the cycles themselves are \term{disjoint}.

    Two disjoint cycles commute. That is,
    \begin{equation*}
      \cycle{k_1, \cdots, k_m} \bincirc \cycle{s_1, \cdots, s_l} = \cycle{s_1, \cdots, s_l} \bincirc \cycle{k_1, \cdots, k_m}.
    \end{equation*}
  \end{thmenum}
\end{definition}

\begin{proposition}\label{thm:cycle_transposition_decomposition}
  Every nontrivial cycle \( \cycle{ k_1, \cdots, k_m } \) can be decomposed into the product of transpositions
  \begin{equation*}
    \cycle{ k_1, \cdots, k_m } = \cycle{ k_1, k_m } \bincirc \cycle{ k_1, k_{m-1} } \bincirc \cdots \bincirc \cycle{ k_1, k_2 }.
  \end{equation*}
\end{proposition}
\begin{proof}
  Trivial.
\end{proof}

\begin{proposition}\label{thm:symmetric_group_cardinality}
  The \hyperref[def:symmetric_group]{symmetric group} \( S_n \) has \( n! \) elements.
\end{proposition}
\begin{proof}
  We use induction on \( n \). The case \( n = 1 \) is trivial. Suppose that \( S_{n-1} \) has \( (n-1)! \) elements. Then \( S_n \) is obtained by permuting \( n \) with each element of \( S_{n-1} \). That is,
  \begin{equation*}
    S_n = \set{ \cycle{ k, n } \bincirc \sigma \given \sigma \in S_{n-1} \T{and} 1 \leq k \leq n }.
  \end{equation*}

  It follows that
  \begin{equation*}
    \card(S_n) = n \cdot \card(S_{n-1}) = n (n-1)! = n!.
  \end{equation*}
\end{proof}

\begin{definition}\label{def:group_action}
  Let \( G \) be a \hyperref[def:group]{group} and let \( X \) be an object in some \hyperref[def:concrete_category]{concrete category} \( \cat{C} \).

  We will define group actions as a special case of \hyperref[def:monoid_action]{monoid actions}, with the same remarks regarding left and right group actions.

  A \term{group action} can be defined equivalently as:
  \begin{thmenum}
    \thmitem{def:group_action/homomorphism} A \hyperref[def:group/homomorphism]{homomorphism} from \( G \) to the \hyperref[def:automorphism_group]{automorphism group} \( \aut(X) \).

    Right actions are homomorphisms from the \hyperref[def:monoid/opposite]{opposite} group \( G^{\opcat} \) to \( \aut(X) \).

    \thmitem{def:group_action/functor} A \hyperref[def:functor]{functor} from the \hyperref[def:monoid_delooping]{delooping} \( \cat{B}_G \) to \( \cat{C} \).

    Right actions are \hyperref[rem:contravariant_functor]{contravariant functors}.

    \thmitem{def:group_action/family} An \hyperref[def:cartesian_product/indexed_family]{indexed family} \( \seq{ \Phi_x }_{x \in G} \) of \hyperref[def:morphism_invertibility/isomorphism]{isomorphisms} of \( X \) such that, for every pair \( g, h \in G \),
    \begin{equation}\label{eq:def:group_action/family/compatibility}\tag{\logic{GA}}
      \Phi_{gh} = \Phi_g \bincirc \Phi_h.
    \end{equation}

    This defines a function \( \Phi: G \times A \to A \).
  \end{thmenum}
\end{definition}
\begin{proof}
  The proof of equivalence is simple; it is similar to \fullref{def:monoid_action}.
\end{proof}

\begin{theorem}[Cayley's theorem]\label{thm:cayleys_theorem}
  Every \hyperref[def:group]{group} \hyperref[def:group_action]{acts} on itself via the family of functions \( y \mapsto x \cdot y \) indexed by \( x \). These functions are not group homomorphisms in general.

  Compare this result to \fullref{thm:monoid_is_action}.
\end{theorem}
\begin{proof}
  Follows directly from \fullref{thm:monoid_is_action} and \fullref{thm:group_operation_induces_bijections}.
\end{proof}

\begin{proposition}\label{thm:exponentiation_group_action}
  The \hyperref[def:set_of_integers]{integers} \( \BbbZ \) act on any \hyperref[def:group]{group} by \hyperref[def:monoid/exponentiation]{exponentiation} via the family of function \( g \mapsto g^n \) indexed by \( n \in \BbbZ \).

  Compare this result to \fullref{thm:exponentiation_monoid_action}.
\end{proposition}
\begin{proof}
  Follows from \fullref{thm:exponentiation_monoid_action}.
\end{proof}

\begin{definition}\label{def:group_action_orbit}\mcite[163]{Knapp2016BasicAlgebra}
  The \term{orbit} of \( x \) under the \hyperref[def:group_action]{group action} \( \Phi: G \to \End(X) \) is the set
  \begin{equation*}
    \set{ \Phi_g(x) \given g \in G }.
  \end{equation*}

  This is the set of all members of \( X \) \enquote{reachable} from \( x \) via the action.

  The relation \( g \sim h \) on \( G \), defined to hold if \( g \) and \( h \) have the same \hyperref[def:group_action_orbit]{orbit}, is an \hyperref[def:equivalence_relation]{equivalence relation}. The quotient set \( G / {\sim} \) is a partition of \( G \) into sets called \term{orbits}.
\end{definition}

\begin{example}\label{ex:plane_rotation_action_orbits}
  Consider the action of the additive group of \( \BbbR \) on \( \BbbR^2 \) given by the \hyperref[def:euclidean_transformation/rotation]{rotation} \hyperref[def:array/matrix]{matrices}
  \begin{equation*}
    \Phi_r \coloneqq \begin{pmatrix}
      \cos(r)  & \sin(r) \\
      -\sin(r) & \cos(r) \\
    \end{pmatrix}
  \end{equation*}

  Fix a nonzero vector \( (x, y)^T \) in \( \BbbR^2 \) with norm \( l \). Since rotation matrices are orthogonal, they preserve norms. Furthermore, given a vector of norm \( l \), with the angle \( r \) defined via \eqref{eq:def:angle/measure}, \( \Phi_r^{-1} \) sends the vector to \( (x, y)^T \).

  The \hyperref[def:group_action_orbit]{orbit} of \( (x, y)^T \) is thus a \hyperref[def:quadratic_plane_curve/ellipse]{circle} at the origin with radius \( l \).
\end{example}

\begin{proposition}\label{thm:group_conjugation_action}\mcite[165]{Knapp2016BasicAlgebra}
  Every \hyperref[def:group]{group} \hyperref[def:group_action]{acts} on itself via the \term{conjugation automorphisms} defined as
  \begin{equation*}
    \begin{aligned}
      &\Phi_g: G \to G, \\
      &\Phi_g(h) \coloneqq g h g^{-1}.
    \end{aligned}
  \end{equation*}
\end{proposition}
\begin{proof}
  Trivial.
\end{proof}

\begin{definition}\label{def:inner_and_outer_automorphisms}\mcite[exer. 6.12.15]{Knapp2016BasicAlgebra}
  Denote by \( \Phi: G \to \aut(G) \) the \hyperref[thm:group_conjugation_action]{conjugation action} on the group \( G \).

  The \term{inner automorphisms group} of \( G \) is
  \begin{equation*}
    \op{inn}(G) \coloneqq \set{ \Phi_g \given g \in G }.
  \end{equation*}

  The \term{outer automorphism group} is the \hyperref[def:group/quotient]{quotient group}
  \begin{equation*}
    \op{out}(G) \coloneqq \aut(G) / \op{inn}(G).
  \end{equation*}
\end{definition}
\begin{defproof}
  We will show that \( \op{inn}(G) \) is a \hyperref[thm:normal_subgroup_equivalences]{normal subgroup} of \( \aut(G) \).

  Fix a member \( g \) of \( G \) and define the inner automorphism
  \begin{equation*}
    \varphi(h) \coloneqq gh^{-1}g.
  \end{equation*}

  Let \( \psi \) be an arbitrary automorphism of \( G \). Then
  \begin{equation*}
    [\varphi \bincirc \psi \bincirc \varphi^{-1}](h)
    =
    \varphi(g \varphi^{-1}(h) g^{-1})
    =
    \varphi(g) h \varphi(g^{-1}),
  \end{equation*}
  and thus \( \varphi \bincirc \psi \bincirc \varphi^{-1} \) is again an inner automorphism.
\end{defproof}

\begin{proposition}\label{thm:permutation_decomposition_existence}
  Let \( S_n \) be a \hyperref[def:symmetric_group]{symmetric group} and let \( \sigma \) be a permutation in \( S_n \). Then there exists a finite sequence \( c_1, \ldots, c_m \) of nontrivial \hyperref[def:symmetric_group/disjoint_cycle]{disjoint cycles} such that
  \begin{equation*}
    \sigma = c_1 \bincirc \cdots \bincirc c_m.
  \end{equation*}

  The case where \( \sigma \) is the identity permutation corresponds to \( m = 0 \).

  We call this a \term{cycle decomposition} of \( \sigma \). Via \fullref{thm:cycle_transposition_decomposition}, this permutation can further be decomposed into a composition of individual transpositions. We call the latter a \term{transposition decomposition} of \( \sigma \).

  Neither decomposition is unique. Nonetheless, existence is sufficient for most practical purposes, including permutation parity defined in \fullref{def:permutation_parity}.
\end{proposition}
\begin{proof}
  Suppose that \( \sigma \) is not the identity.

  Consider the \hyperref[def:group_action]{group action}
  \begin{equation*}
    \begin{aligned}
      &\Phi^{(\sigma)}: \braket{ \sigma } \times \set{ 1, \ldots, n } \to \set{ 1, \ldots, n } \\
      &\Phi^{(\sigma)}_\sigma(k) \coloneqq \sigma(k)
    \end{aligned}
  \end{equation*}
  of the \hyperref[def:first_order_generated_substructure]{generated subgroup} \( \braket{ \sigma } \).

  The \hyperref[def:group_action_orbit]{orbit} of \( k \) under \( \Phi^{(\sigma)} \) is the set
  \begin{equation*}
    O_\sigma(k) \coloneqq \set{ \sigma^m(k) \given m \in \BbbZ }
  \end{equation*}
  of all numbers reachable from \( k \) via iterated application of \( \sigma \) or \( \sigma^{-1} \). The family
  \begin{equation*}
    \set{ O_\sigma(k) \given k = 1, \ldots, n }
  \end{equation*}
  of orbits partitions \( 1, \ldots, n \) into disjoint subsets.

  Each orbit \( O \) has a smallest element \( o \); and \( O_\sigma(o) = O \). This smallest element uniquely identifies a cycle
  \begin{equation*}
    \cycle{o, \sigma(o), \sigma^2(o), \ldots, \sigma^{c-1}(o)},
  \end{equation*}
  where \( c \) is the cardinality of \( O_\sigma(o) \).

  Ignoring the trivial cycles, we obtain a unique set of disjoint nontrivial cycles for every permutation \( \sigma \) in \( S_n \), which we call the \term{cycle decomposition} of \( \sigma \). Denote this set by \( C_\sigma \).

  We must prove that \( C_\sigma \) is family of disjoint sets. Let \( O_\sigma(k_1) \) and \( O_\sigma(k_2) \) be two orbits.

  Suppose that there exists a number \( k \in O_\sigma(k_2) \cap O_\sigma(k_1) \). Then there exist \( m_1, m_2 \leq n \) such that \( k = \sigma^{m_1}(k_1) \) and \( k = \sigma^{m_2}(k_2) \). Then
  \begin{equation*}
    k_1 = \sigma^{-m_1}(k) = \sigma^{-m_1}(\sigma^{m_2}(k_2)) = \sigma^{m_2 - m_1}(k_2),
  \end{equation*}
  and thus \( O_\sigma(k_2) \subseteq O_\sigma(k_1) \). We can analogously obtain the converse inclusion.

  Therefore, if two orbits have a nonempty intersection, they are equal.

  Finally, we will use induction on \( m \) to show that these cycles give us \( \sigma \). The case \( m = 0 \) is trivial. For the inductive hypothesis, note that \( c_1^{-1} \sigma \) has as cycles \( c_2, \ldots, c_m \) because all the numbers in \( c_1 \) are fixed points of \( c_1^{-1} \sigma \). Thus, the inductive hypothesis holds for \( c_1^{-1} \sigma \).

  From
  \begin{equation*}
    c_1^{-1} \sigma = c_2 \bincirc \cdots \bincirc c_m
  \end{equation*}
  it follows that
  \begin{equation*}
    \sigma = c_1 \bincirc \cdots \bincirc c_m.
  \end{equation*}
\end{proof}

\begin{lemma}\label{thm:permutation_parity_correctness}
  If a \hyperref[def:symmetric_group/permutation]{permutation} \( \sigma \in S_n \) can be decomposed into \hyperref[def:symmetric_group/cycle]{transpositions} as both
  \begin{equation}\label{eq:thm:permutation_parity_correctness/k}
    \sigma = \underbrace{\cycle{ k_1, k_2 } \bincirc \cycle{ k_3, k_4 } \bincirc \cdots \bincirc \cycle{ k_{2n-1}, k_{2n} }}_{n \T*{transpositions}}
  \end{equation}
  and
  \begin{equation}\label{eq:thm:permutation_parity_correctness/l}
    \sigma = \underbrace{\cycle{ l_1, l_2 } \bincirc \cycle{ l_3, l_4 } \bincirc \cdots \bincirc \cycle{ l_{2m-1}, l_{2m} }}_{m \T*{transpositions}},
  \end{equation}
  then \( n - m \) is an even number.
\end{lemma}
\begin{proof}
  We will use induction on \( n \). First consider the base case \( n = 0 \). Then \( \sigma \) is the identity. Hence, every transposition in \eqref{eq:thm:permutation_parity_correctness/l} should be present twice so that its action cancels out. Therefore, \( m \) is an even number.

  Now suppose that the statement holds for \( n - 1 \). Add (compose on the right) the last transposition \( \cycle{ k_{2n-1}, k_{2n} } \) of \eqref{eq:thm:permutation_parity_correctness/k} to both \eqref{eq:thm:permutation_parity_correctness/k} and \eqref{eq:thm:permutation_parity_correctness/l}. The obtained permutations are obviously equal. Furthermore, since \( \cycle{ k_{2n-1}, k_{2n} } \) is its own inverse, we can just as well remove \( \cycle{ k_{2n-1}, k_{2n} } \) from \eqref{eq:thm:permutation_parity_correctness/k} to obtain a decomposition into \( n - 1 \) (rather than \( n + 1 \)) transpositions.

  By the inductive hypothesis, \( (n - 1) - (m + 1) = n - m - 2 \) is an even number. Therefore, \( n - m \) is also an even number.
\end{proof}

\begin{definition}\label{def:permutation_parity}
  We say that a \hyperref[def:symmetric_group/permutation]{permutation} \( \sigma \in S_n \) is \term{even} (resp. \term{odd}) if a decomposition of \( \sigma \) into \hyperref[def:symmetric_group/cycle]{transpositions} has an even (resp. odd) number of transpositions.

  By \fullref{thm:permutation_decomposition_existence}, such a decomposition exists. By \fullref{thm:permutation_parity_correctness}, all such decompositions yield the same parity even if they decompose into a differing number of transpositions.

  We correspondingly define the \term{sign} of a permutation as
  \begin{equation*}
    \begin{aligned}
       &\sgn: S_n \to \BbbZ, \\
       &\sgn(\sigma) \coloneqq \begin{cases}
        1,  &\sigma \T{is even} \\
        -1, &\sigma \T{is odd}
      \end{cases}
    \end{aligned}
  \end{equation*}
\end{definition}

\begin{definition}\label{def:alternating_group}
  The \term{alternating group} \( A_n \) on \( n \) letters is the subgroup of all \hyperref[def:permutation_parity]{even permutation} in the \hyperref[def:symmetric_group]{symmetric group} \( S_n \).
\end{definition}

\begin{proposition}\label{thm:alternating_group_cardinality}
  The \hyperref[def:alternating_group]{alternating group} \( A_n \) has \( \ifrac {n!} 2 \) elements.
\end{proposition}
\begin{proof}
  The proof is similar to that of \fullref{thm:symmetric_group_cardinality}, but is a little different.

  We use induction on \( n \). The case \( n = 1 \) is trivial. Suppose that \( A_{n-1} \) has \( \ifrac {(n-1)!} 2 \) elements. Then
  \begin{equation*}
    A_n = \set{ \cycle{ k, n } \bincirc \sigma \given \sigma \in S_{n-1} \setminus A_{n-1} \T{and} 1 \leq k \leq n }.
  \end{equation*}

  We obtain \( A_n \) by taking all the odd permutations in \( S_{n-1} \) and composing them with one new transposition. It follows that
  \begin{equation*}
    \card(A_n) = n \cdot \card(S_{n-1} \setminus A_{n-1}) = n \frac {(n-1)!} 2 = \frac {n!} 2.
  \end{equation*}
\end{proof}

\begin{example}\label{ex:s3_and_a3}
  The \hyperref[def:symmetric_group]{symmetric group} \( S_3 \) contains the following \hyperref[def:symmetric_group/permutation]{permutations}:
  \begin{equation*}
    S_3
    \coloneqq
    \set[\vast]
    {
      \begin{pmatrix}
        1 & 2 & 3 \\
        1 & 2 & 3
      \end{pmatrix},
      \underbrace
        {
          \begin{pmatrix}
            1 & 2 & 3 \\
            2 & 1 & 3
          \end{pmatrix}
        }_{
          \cycle{ 1, 2 }
        },
      \underbrace
        {
          \begin{pmatrix}
            1 & 2 & 3 \\
            2 & 3 & 1
          \end{pmatrix}
        }_{
          \cycle{ 1, 2, 3 }
        },
      \underbrace
        {
          \begin{pmatrix}
            1 & 2 & 3 \\
            3 & 2 & 1
          \end{pmatrix}
        }_{
          \cycle{ 1, 3 }
        },
      \underbrace
        {
          \begin{pmatrix}
            1 & 2 & 3 \\
            3 & 1 & 2
          \end{pmatrix}
        }_{
          \cycle{ 1, 3, 2 }
        },
      \underbrace
        {
          \begin{pmatrix}
            1 & 2 & 3 \\
            1 & 3 & 2
          \end{pmatrix}
        }_{
          \cycle{ 2, 3 }
        }
    }
  \end{equation*}

  We can observe the following:
  \begin{itemize}
    \item The permutations \( \cycle{ 1, 2, 3 } \) and \( \cycle{ 1, 3, 2 } \) are inverses of each other and all other permutations are involutions.

    \item Every conjugation automorphism is unique. This can be verified explicitly. Therefore, the \hyperref[def:inner_and_outer_automorphisms]{inner automorphism group} \( \op{inn}(S_3) \) is isomorphic to \( S_3 \).

    \item The \hyperref[def:alternating_group]{alternating group} \( A_3 \) consists of the identity and the odd-length cycles \( (1, 2, 3) \) and \( (1, 3, 2) \).

    \item When restricted to \( A_3 \), all conjugation automorphisms are trivial. This can be verified explicitly. Therefore, the inner automorphism group \( \op{inn}(A_3) \) is trivial, and hence
    \begin{equation*}
      \aut(A_3) \cong \op{out}(A_3).
    \end{equation*}

    \item The map \( \sigma \mapsto \sigma^{-1} \), which fixes the identity and exchanges the two other permutations, is an automorphism of \( A_3 \). It is distinct from the identity, hence it is an outer automorphism.

    This map is given by the restriction of the conjugation \( \sigma \mapsto \cycle{1, 2} \sigma \cycle{1, 2} \) to \( A_3 \). It is an inner automorphism of \( S_3 \), but an outer automorphism of \( A_3 \).
  \end{itemize}
\end{example}

\begin{proposition}\label{thm:group_epimorphisms_are_surjective}\mcite[exer. I.5.5]{MacLane1994}
  Every \hyperref[def:morphism_invertibility/right_cancellative]{epimorphism} in \hyperref[def:group/category]{\( \cat{Grp} \)} is \hyperref[def:function_invertibility/surjective]{surjective}.
\end{proposition}
\begin{proof}
  Let \( \varphi: G \to H \) be an epimorphism and suppose that it is not surjective. Let \( M \) be the smallest normal subgroup of \( H \) containing \( \img \varphi \).

  If \( M \) has index \( 2 \) in \( H \), consider the quotient map \( \pi: H \to H / M \) and the constant map \( c(h) \coloneqq M \). Then
  \begin{equation*}
    \pi \bincirc \varphi = c \bincirc \varphi.
  \end{equation*}

  Since \( \varphi \) is an epimorphism, we have \( \pi = c \). But we have deliberately taken \( \pi \) and \( c \) so that \( \pi \neq c \). The obtained contradiction shows that \( M \) must have an index greater than \( 2 \).

  Let \( M \), \( uM \) and \( vM \) be different cosets. Define \( \sigma: H \to H \) as the \hyperref[def:symmetric_group/permutation]{permutation} on \( H \) that exchanges \( xu \) with \( xv \) for every \( x \in M \). Define the homomorphism
  \begin{equation*}
    \begin{aligned}
      &\psi: H \to S(H) \\
      &\psi(h) \coloneqq (x \mapsto hx),
    \end{aligned}
  \end{equation*}
  where \( S(H) \) is the \hyperref[def:symmetric_group]{symmetric group}.

  This is indeed a homomorphism by \fullref{thm:cayleys_theorem}. By \fullref{thm:group_conjugation_action}, another homomorphism is
  \begin{equation*}
    \begin{aligned}
      &\theta: H \to S(H) \\
      &\theta(h) \coloneqq \sigma^{-1} \bincirc \psi(h) \bincirc \sigma.
    \end{aligned}
  \end{equation*}

  Since \( \sigma \) fixes the members of \( M \) in-place, we have \( \theta(h)\restr_M = \psi(h)\restr_M \). Since \( M \) contains the image of \( \varphi \), this implies
  \begin{equation*}
    \psi \bincirc \varphi = \theta \bincirc \varphi.
  \end{equation*}

  Since \( \varphi \) is an epimorphism, we have \( \psi = \theta \). But we have deliberately constructed \( \psi \) and \( \theta \) such that \( \psi \neq \theta \). The obtained contradiction shows that \( \img \varphi \) cannot be a strict subgroup of \( G \). Therefore, \( \varphi \) must be surjective.
\end{proof}

\begin{definition}\label{def:dynamical_system}\mimprovised
  Suppose that \( \cat{C} \) is a \hyperref[def:concrete_category]{concrete category} and let \( X \) be an object of \( \cat{C} \).

  A \term{dynamical system} is a \hyperref[def:monoid_action]{monoid action} \( \Phi: T \times X \to X \). We call \( X \) the \term{phase space} of the system. In applications, we interpret the monoid \( T \) as \term{time} and consider it to be \hyperref[rem:additive_magma]{additive}. We call \( \Phi \) the \term{evolution function} of the system.

  \begin{thmenum}
    \thmitem{def:dynamical_system/ifs} If \( T \) is either the additive monoid of the \hyperref[def:set_of_natural_numbers]{natural numbers} or the additive group of the \hyperref[def:set_of_integers]{integers}, we say that the dynamical system has \term{discrete time}.

    Due to \eqref{eq:def:monoid_action/family/compatibility}, \( \Phi_{n+1} = \Phi_n \bincirc \Phi_1 \) for any integer \( n \). Using \hyperref[rem:induction/peano_arithmetic]{natural number induction} and \fullref{thm:def:group/negative_power}, we can show that \( \Phi_n = \Phi_1^n \) for every integer \( n \).

    Therefore, the entire evolution function of a discrete-time dynamical system is determined by a single endofunction \( \varphi: X \to X \). For this reason, we also refer to discrete-time dynamical systems as \term{iterated function systems}.

    \thmitem{def:dynamical_system/semiflow} If \( T \) is the additive monoid of \hyperref[def:set_of_real_numbers]{real numbers}, with or without \hyperref[def:extended_real_numbers]{an infinite element}, we say that the system is a \term{semiflow}.

    \thmitem{def:dynamical_system/flow} If \( T \) is the additive group of \hyperref[def:set_of_real_numbers]{real numbers}, we say that the system is a \term{flow}.
  \end{thmenum}

  We will call the system \term{discrete} if \( T \) is the monoid of zero-based \hyperref[def:set_of_natural_numbers]{natural numbers} and \term{continuous} if \( T \) is the monoid of nonnegative \hyperref[def:set_of_real_numbers]{real numbers}, with or without \hyperref[def:extended_real_numbers]{an infinite element}.

  The monoid \( T \) can theoretically be a \hyperref[def:group]{group}, in which case we consider \hyperref[def:group_action]{group actions}, however negative time is not as often needed in practice.
\end{definition}

\begin{definition}\label{def:dynamical_system_trajectory}
  Fix a \hyperref[def:dynamical_system]{dynamical system} with evolution function \( \Phi: T \times X \to X \).

  A \term{trajectory} in a starting at the \term{initial state} \( x_0 \in X \) is an \hyperref[def:cartesian_product/indexed_family]{indexed family} \( \seq{ x_t }_{t \in T} \) obtained as
  \begin{equation*}
    x_t \coloneqq \Phi_t(x_0).
  \end{equation*}

  The condition \ref{eq:def:monoid_action/family/identity} ensures that \( \Phi_0(x_0) = x_0 \), and \ref{eq:def:monoid_action/family/compatibility} ensures that
  \begin{equation*}
    x_{t + s}
    =
    \Phi_{t + s}(x_0)
    =
    \Phi_t(x_s).
  \end{equation*}

  For discrete dynamical systems, trajectories are sequences.
\end{definition}


\begin{quote}
    Spectral sequences are one of those things for which anybody who is
    anybody must suffer through. Once you've done that, it's like linear
    algebra. You stop thinking so much about the `inner workings' later.

    -- Haynes Miller
\end{quote}
\section{The spectral sequence of a filtered complex}
Our goal will be to describe a method for computing the homology of a chain
complex. We will approach this problem by assuming that our chain complex is
equipped with a filtration; then we will discuss how to compute the associated
graded of an induced filtration on the homology, given the homology of the
associated graded of the filtration on our chain complex.

We will start off with a definition.
\begin{definition}
    A \emph{filtered chain complex} is a chain complex $C_\ast$ along with a
    sequence of subcomplexes $F_s C_\ast$ such that the group $C_n$ has a
    filtration by
    $$F_0 C_n\subset F_1 C_n\subseteq \cdots,$$
    such that $\bigcup F_s C_n = C_n$.
\end{definition}
The differential on $C_\ast$ begets the structure of a chain
complex on the associated graded $\gr_s C_n = F_s C_n/F_{s-1} C_n$; in other
words, the differential on $C_\ast$ respects the filtration, hence begets a
differential $d:\gr_s C_n\to \gr_s C_{n-1}$.

The canonical example of a filtered chain complex to keep in mind is the
homology of a filtered space (such as a CW-complex). Let $X$ be a filtered
space, i.e., a space equipped with a filtration $X_0\subseteq X_1\subseteq
\cdots$ such that $\bigcup X_n = X$. We then have a filtration of the chain
complex $C_\ast(X)$ by the subcomplexes $C_\ast(X_n)$.

For ease of notation, let us write
$$E^0_{s,t} = \gr_s C_{s+t} = F_s C_{s+t}/F_{s-1} C_{s+t},$$
so the differential on $C_\ast$ gives a differential $d^0:E^0_{s,t}\to
E^0_{s,t-1}$. A first approximation to the homology of $C_\ast$ might therefore
be the homology $H_{s+t}(\gr_s C_\ast)$. We will denote this group by
$E^1_{s,t}$. This is the homology of the associated graded of the filtration
$F_\ast C_\ast$.

We can get an even better approximation to $H_\ast C_\ast$ by noticing that
there is a differential even on $E^1_{s,t}$. By construction, there is a short
exact sequence of chain complexes
$$0\to F_{s-1} C_\ast\to F_s C_\ast\to \gr_s C_\ast\to 0,$$
so we get a long exact sequence in homology. The differential on $E^1_{s,t}$ is
the composite of the boundary map in this long exact sequence with the natural
map $H_\ast(F_{s-1} C_\ast)\to H_\ast(\gr_{s-1} C_\ast)$; more precisely, it is
the composite
$$d^1:E^1_{s,t} = H_{s+t}(\gr_s C_\ast)\xar{\partial} H_{s+t-1}(F_{s-1}
C_\ast)\to H_{s+t-1}(\gr_{s-1}C_\ast) = E^1_{s-1,t}.$$
It is easy to check that $(d^1)^2 = 0$.

This construction is already familiar from cellular chains: in this case,
$E^1_{s,t}$ is exactly $H_{s+t}(X_{s},X_{s-1})$, which is exactly the cellular
$s$-chains when $t=0$ (and is $0$ if $t\neq 0$). The $d^1$ differential is
constructed in exactly the same way as the differential on cellular chains.

In light of this, we define $E^2_{s,t}$ to be the homology of the chain complex
$(E^1_{\ast,\ast}, d^1)$; explicitly, we let
$$E^2_{s,t} = \ker(d^1:E^1_{s,t}\to E^1_{s-1,t})/\img(d^1:E^1_{s+1,t}\to
E^1_{s,t}).$$
Does this also have a differential $d^2$? The answer is yes. We will
inductively define $E^r_{s,t}$ via a similar formula: if $E^{r-1}_{\ast,\ast}$
and the differential $d^{r-1}:E^{r-1}_{s,t}\to E^{r-1}_{s-r+1,t+r-2}$ are both
defined, we set
$$E^{r}_{s,t} = \ker(d^{r-1}:E^{r-1}_{s,t}\to
E^{r-1}_{s-r+1,t+r-2})/\img(d^{r-1}:E^{r-1}_{s+r-1,t-r+2}\to E^{r-1}_{s,t}).$$
The differential $d^{r}:E^{r}_{s,t}\to E^{r}_{s-r,t+r-1}$ is defined as
follows. Let $[x]\in E^r_{s,t}$ be represented by an element of $x\in
E^1_{s,t}$, i.e., an element of $H_{s+t}(\gr_s C_\ast)$. As above, the boundary
map induces natural maps $\partial:H_{s+t}(\gr_s C_\ast)\to H_{s+t-1}(F_{s-1}
C_\ast)$ and $\partial:H_{s+t-1}(F_{s-r} C_\ast)\to H_{s+t-1}(\gr_{s-r}
C_\ast)$. The element $\partial x\in H_{s+t-1}(F_{s-1} C_\ast)$ in fact lifts
to an element of $H_{s+t-1}(F_{s-r} C_\ast)$. The image of this element under
$\partial$ inside $H_{s+t-1}(\gr_{s-r} C_\ast) = E^1_{s-r,t+r-1}$ begets a
class in $E^r_{s-r,t+r-1}$; this is the desired differential.
\begin{exercise}
    Fill in the missing details in this construction of $d^r$, and show that
    $(d^r)^2 = 0$.
\end{exercise}
We have proven most of the statements in the following theorem.
\begin{thm-defn}\label{filtered-sseq}
    Let $F_\ast C$ be a filtered complex. Then there exist natural
    \begin{enumerate}
	\item bigraded groups $(E^r_{s,t})_{s\geq 0, t\in\Z}$ for any $r\geq
	    0$, and
	\item differentials $d^r:E^r_{s,t} \to E^r_{s-r,t+r - 1}$ for any
	    $r\geq 0$.
    \end{enumerate}
    such that $E^{r+1}_{s,t}$ is the homology of $(E^r_{\ast,\ast},d^r)$, and
    $(E^0, d^0)$ and $(E^1, d^1)$ are as above. If $F_\ast C$ is bounded
    below, then this spectral sequence \emph{converges to $\gr_\ast
    H_\ast(C)$}, in the sense that there is an isomorphism:
    \begin{equation}\label{convergence}
	E^\infty_{s,t} \simeq \gr_s H_{s+t}(C).
    \end{equation}
\end{thm-defn}
This is called a \emph{homology spectral sequence}. One should think of each
$E^r_{\ast,\ast}$ as a ``page'', with lattice points $E^r_{s,t}$. We still need
to describe the symbols used in the formula \eqref{convergence}.

There is a filtration $F_s H_n(C):=\img(H_n(F_s C) \to H_n(C))$, and $\gr_s
H_\ast(C)$ is the associated graded of this filtration. Taking formula
\eqref{convergence} literally, we only obtain information about the associated
graded of the homology of $C_\ast$. Over vector spaces, this is sufficient to
determine the homology of $C_\ast$, but in general, one needs to solve an
extension problem.

To define the notation $E^\infty$ used above, let us assume that the filtration
$F_\ast C$ is bounded below (so $F_{-1} C = 0$). It follows that $E^0_{s,t} =
F_s C_{s+t}/F_{s-1} C_{s+t} = 0$ for $s<0$, so the spectral sequence of
Theorem-Definition \ref{filtered-sseq} is a ``right half plane'' spectral
sequence. It follows that in our example, the differentials from the group in
position $(s,t)$ must have vanishing $d^{s+1}$ differential.

In turn, this implies that there is a surjection $E^{s+1}_{s,t} \to
E^{s+2}_{s,t}$. This continues: we get surjections
$$E^{s+1}_{s,t}\to E^{s+2}_{s,t}\to E^{s+3}_{s,t}\to\cdots,$$
and the direct limit of this directed system is defined to be $E^\infty_{s,t}$.

For instance, in the case of cellular chains, we argued above that $E^1_{s,t} =
H_{s+t}(X_s, X_{s-1})$, so that $E^1_{s,t} = 0$ if $t\neq 0$, and the $d^1$
differential is just the differential in the cellular chain complex. It follows
that $E^2_{s,t} = H_s^{cell}(X)$ if $t=0$, and is $0$ if $t\neq 0$. All higher
differentials are therefore zero (because either the target or the source is
zero!), so $E^r_{s,t} = E^2_{s,t}$ for every $r\geq 2$. In particular
$E^\infty_{s,t} = H_s^{cell}(X)$ when $t=0$, and is $0$ if $t\neq 0$. There are
no extension problems either: the filtration on $X$ is bounded below, so
Theorem-Definition \ref{filtered-sseq} implies that $\gr_s H_{s+0}(X) = H_s(X)
\simeq H_s^{cell}(X) = E^\infty_{s,t}$.

%OK, so for our theorem, we have the following picture of $E^\infty_{\ast,\ast}$:
%\begin{equation*}
%    \xymatrix{
%	\gr_0 H_n(C) \simeq E^\infty_{0,n} & & & \\
%	& \gr_1 H_n(C) \simeq E^\infty_{1,n-1} & & \\
%	& & \gr_2 H_n(C) \simeq E^\infty_{2,n-2} & & \\
%	& & & \ddots
%    }
%\end{equation*}
%Note that $\gr_0 H_n(C) = F_0 H_n(C) = \img(H_n(F_0 C) \to H_n(C))$.
%
%Maybe you still don't get the homology of $n$ (like if $F_\ast$ is $0$).
%But if $F_\ast C$ is exhaustive, then $F_\ast H_\ast C$ is also exhaustive (I said this on Monday).
%With this assumption, then we get all the associated graded pieces.
In a very precise sense, the datum of the spectral sequence of a filtered
complex $F_\ast C_\ast$ determines the homology of $C_\ast$:
\begin{corollary}
    Let $C\xrightarrow{f} D$ be a map of filtered complexes.
    Assume that the filtration on $C$ and $D$ are bounded below and exhaustive.
    Assume also that $E^r(f)$ is an isomorphism for some $r$.
    Then $f_\ast : H_\ast(C) \to H_\ast(D)$ is an isomorphism.
\end{corollary}
\begin{proof}
    The map $E^r(f)$ is an isomorphism which is also also a chain map, i.e., it
    is compatible with the differential $d^r$. It follows that $E^{r+1}(f)$ is
    an isomorphism. By induction, we conclude that $E^\infty_{s,t}(f)$ is an
    isomorphism for all $s,t$. Theorem-Definitino \ref{filtered-sseq} implies
    that the map $\gr_s(f_\ast):\gr_s H_\ast(C) \to \gr_s H(D)$ is an
    isomorphism.

    We argue by induction using the short exact sequence:
    $$
    0 \to F_s H_\ast(C) \to F_{s+1} H_\ast(C) \to \gr_{s+1} H_\ast(C) \to 0.
    $$
    We have $\gr_0 H_n(C) = F_0 H_n(C) = \img(H_n(F_0 C) \to H_n(C))$, so the
    base case follows from the five lemma. In general, $f$ induces an
    isomorphism an isomorphism on the groups on the left (by the inductive
    hypothesis) and right (by the above discussion), so it follows that $F_s
    f_\ast$ is an isomorphism by the five lemma. Since the filtration $F_\ast
    C_\ast$ was exhaustive, it follows that $f_\ast$ is an isomorphism.
\end{proof}
\subsection{Serre spectral sequence}\label{serre-sseq}
In this book, we will give two constructions of the Serre spectral sequence.
The second will appear later. Fix a fibration $E\xrightarrow{p} B$, with $B$ a
CW-complex. We obtain a filtration on $E$ by taking the preimage of the
$s$-skeleton of $B$, i.e., $E_s = p^{-1} \sk_s B$. It follows that there is a
filtration on $S_\ast(E)$ given by
$$F_s S_\ast (E) = \img(S_\ast(p^{-1} \sk_s(B)) \to S_\ast E).$$
This filtration is bounded below and exhaustive. The resulting spectral
sequence of Theorem-Definition \ref{filtered-sseq} is the Serre spectral
sequence.
%The low terms might depend on the CW-structure, but higher terms won't.

Let us be more explicit. We have a pushout square:
\begin{equation*}
    \xymatrix{
	E_{s-1}\ar[r]\ar[d] & E_s\ar[d]\\
	B_{s-1}\ar[r] & B_s\\
	\coprod_{\alpha\in\Sigma_s}S^{s-1}_\alpha\ar[r]\ar[u] & \coprod_{\alpha\in\Sigma_s} D^s_\alpha\ar[u]
    }
\end{equation*}
%I can pullback $E_s$ via:
%\begin{equation*}
%    \xymatrix{
%	\coprod_{\alpha\in \Sigma_s} D^s_\alpha\times F_\alpha\ar[r]\ar[d] & E_s\ar[d]\\
%	\coprod_{\alpha\in \Sigma_s} D^s_\alpha\ar[r] & B_s
%    }
%\end{equation*}
Let $F_\alpha$ be the preimage of the center of $\alpha$ cell. In particular,
we have a pushout:
\begin{equation*}
    \xymatrix{
	E_{s-1}\ar[r] & E_s\\
	\coprod_{\alpha\in\Sigma_s} S^{s-1}_\alpha\times F_\alpha\ar[r]\ar[u] & \coprod_{\alpha\in\Sigma_s} D^s_\alpha \times F_\alpha\ar[u]
    }
\end{equation*}
We know that
$$E^1_{s,t} = H_{s+t}(E_s,E_{s-1}) = \bigoplus_{\alpha\in \Sigma_s}
H_{s+t}(D^s_\alpha\times F_\alpha, S^{s-1}_\alpha\times F_\alpha).$$
We can suggestively view this as $\bigoplus_{\alpha\in\Sigma_s}
H_{s+1}((D^s_\alpha, S^{s-1}_\alpha)\times F_\alpha)$. By the K\"unneth
formula (at least, if our coefficients are in a field), this is exactly
$\bigoplus_{\alpha\in\Sigma_s} H_t(F_\alpha)$. In analogy with our discussion
above regarding the spectral sequence coming from the cellular chain complex,
one would like to think of this as ``$C_s(B;H_t(F_\alpha))$''. Sadly, there are
many things wrong with writing this.

For instance, suppose $B$ isn't connected. The fibers $F_\alpha$ could have
completely different homotopy types, so the symbol $C_s(B;H_t(F_\alpha))$
does not make any sense. Even if $B$ was path-connected, there would still be
no canonical way to identify the fibers over different points. Instead, we
obtain a functor $H_t(p^{-1}(-)):\Pi_1(B) \to \mathbf{Ab}$, i.e., a ``local
coefficient system'' on $B$. So, the right thing to say is ``$E^2_{s,t} =
H_s(B;\underline{H_t(\mathrm{fiber})})$''.

To define precisely what $H_s(B;\underline{H_t(\mathrm{fiber})})$ means, let us
pick a basepoint in $B$, and build the universal cover $\widetilde{B}\to B$.
This has an action of $\pi_1(B,\ast)$, so we obtain an action of
$\pi_1(B,\ast)$ on the chain complex $S_\ast(\widetilde{B})$. Said differently,
$S_\ast(\widetilde{B})$ is a chain complex of right modules over
$\Z[\pi_1(B)]$. If $B$ is connected, a local coefficient system on $B$ is the
same thing as a (left) action of $\pi_1(B)$ on $H_t(p^{-1}(\ast))$. Then, we
define a chain complex:
$$
S_\ast(B;\underline{H_t(p^{-1}(\ast))}) = S_\ast(\widetilde{B})
\otimes_{\Z[\pi_1(B)]} H_t(p^{-1}(\ast));
$$
the differential is induced by the $\Z[\pi_1(B)]$-equivariant differential on
$S_\ast(\widetilde{B})$. Our discussion above implies that the homology of this
chain complex is the $E^2$-page.

We will always be in the case where that local system is trivial, so that
$H_\ast(B;\underline{H_\ast(p^{-1}(\ast))})$ is just
$H_\ast(B;H_\ast(p^{-1}(\ast)))$. For instance, this is the case if $\pi_1(B)$
acts trivially on the fiber. In particular, this is the case if $B$ is simply
connected.


\documentclass[fleqn]{article}

\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\usepackage[colorlinks=true]{hyperref}
\usepackage{tikz}
\usetikzlibrary{calc,patterns,angles,quotes}

\begin{document}
\begin{center}
  {\bfseries Solution to assignment \#2}\\
  Introduction to GR, 2020 Fall\\
  International Centre for Theoretical Sciences\\
  Instructor: Prof. Bala Iyer, Tutor: Md Arif Shaikh\footnote{\href{mailto: arif.shaikh@icts.res.in}{arif.shaikh@icts.res.in}}\\
  % Due on October 04, 2020 11:59 PM.
\end{center}
\hrule

\section{Parallel transport along $r=$ constant line on the surface of a cone}

\begin{center}
  \begin{tikzpicture}
  \draw[cyan] (0,3) ellipse (2cm and 0.5cm);
  \draw[->] (0, 0) -- (0, 4) node[above] {$z$};
  \draw[->] (0, 0) -- (4, 0) node[right] {$y$};
  \draw[->] (0, 0) -- (-3, -2) node[left] {$x$};
  \draw[cyan] (0, 0) -- (2, 3);
  \draw[cyan] (0, 0) -- (-2, 3);
  \draw (0, 0.5) arc (90:110:1) node[left] {$\alpha$} ;
  \draw[orange] (0, 1.5) ellipse (1cm and 0.25cm);
  \draw[fill=red] (0.5, 1.28) circle (0.05cm);
  \draw (0, 1.5) -- (0.5, 1.28) node[right] {$(r, \phi)$};
  \draw (0, 1.5) -- (-3, -0.5);
  \draw (0, 1.5) -- (4, 1.5);
  \draw[red] (0.5, 1.28) arc (-80:-100:2.3) node[below] {$\phi$};
\end{tikzpicture}
\end{center}

We have a cone with opening angle $2\alpha$ embedded in the 3-dimensional flat space. $r$ is the distance measured from the apex. A constant $r$ line on the surface of the cone would be parameterised by the angle $\phi$. The 3-dimensional flat metric in spherical polar coordinate is given by

\begin{equation}
  \label{eq:3-d-flat-metric}
  ds^2_{3d} = dr^2 + r^2d\theta^2 + r^2\sin^2\theta d\phi^2.
\end{equation}
$\theta$ is the angle w.r.t to the $z$-axis. On the surface of the cone, $\theta=\alpha=$ constant. Thus the metric on the surface of the cone becomes
\begin{equation}
  \label{eq:2-d-metric-on-cone}
  \boxed{ds^2 = dr^2 + r^2\sin^2\alpha d\phi^2.}
\end{equation}

\noindent\fbox{\parbox{\textwidth}{{\bfseries What is parallel transport of a tensor?}
    Parallel transport is defined in the following way: A tensor field $T^{\mu...}_{\nu...}$  is said to be {\itshape parallel transported} along a curve $\gamma:=x^\alpha(\lambda)$ if the covariant derivative of the tensor field along the curve vanishes: $D_\lambda T^{\mu...}_{\nu...} = u^\eta \nabla_\eta T^{\mu...}_{\nu...}= 0$, where $u^\eta = dx^\eta/d\lambda$.}}

\vspace{0.5cm}

In the given problem we are asked to compute the rotation of a vector $V^\mu$ when it is parallel transported along the $r=$ constant line from $\phi=0$ to $\phi=2\pi$. Thus the curve $\gamma$ is represented by $x^\mu(\lambda) = (r_0, \phi(\lambda))$. The condition for parallel transport of $V^\mu$ along $\gamma$ then becomes

\begin{equation}
  \label{eq:parallel-transport-along-r-constant}
  u^\mu\nabla_\mu V^\nu = 0 \to \dot{\phi}\nabla_\phi V^\mu = 0\to \nabla_\phi V^\mu = 0 \to \boxed{\partial_\phi V^\mu + \Gamma^\mu_{\phi \nu} V^\nu = 0}.
\end{equation}

To find out the Christofell symbols we use the geodesic equations. The geodesic equations could be obtained from the Lagrangian $L = (1/2)g_{\mu\nu}\dot{x}^\mu\dot{x}^\nu$ where $\dot{x}^\mu = dx^\mu/d\tau$ (we take $\lambda = \tau$ the propertime). The geodesic e.o.m is given by
\begin{equation}
  \label{eq:geodesic-eom}
  \frac{d}{d\tau}\left(\frac{\partial L}{\partial \dot{x^\mu}}\right) - \frac{\partial L}{\partial x^\mu} = 0
\end{equation}

With the Lagrangian given by
\begin{equation}
  \label{eq:Lagrangian}
  L = \frac{1}{2}(\dot{r}^2 + r^2\sin^2\alpha\dot{\phi}^{2})
\end{equation}
The e.o.m for $r$ becomes
\begin{equation}
  \label{eq:eom-r}
  \ddot{r} - r\sin^2\alpha \dot{\phi}^{2} = 0,
\end{equation}
which provides $\Gamma^{r}_{\phi\phi} = - r\sin^2\alpha$.
Similarly e.o.m for $\phi$ is given by
\begin{equation}
  \label{eq:eom-phi}
  \ddot{\phi} + \frac{2}{r}\dot{r}\dot{\phi} = 0,
\end{equation}
which provides $\Gamma^{\phi}_{r\phi} = \Gamma^{r}_{\phi r} = \frac{1}{r}$. Thus we have
\begin{equation}
  \label{eq:Christofell-symbols}
  \boxed{\Gamma^{r}_{\phi\phi} = - r\sin^2\alpha,\qquad \Gamma^{\phi}_{r\phi} = \Gamma^{r}_{\phi r} = \frac{1}{r}}.
\end{equation}

Thus Eq. (\ref{eq:parallel-transport-along-r-constant}) becomes
\begin{equation}
  \label{eq:parallel-transport}
  \partial_\phi V^{\mu} + \Gamma^{\mu}_{\phi\nu}V^\nu = 0.
\end{equation}

For $\mu=r,\phi$ this gives the following equations
\begin{equation}
  \label{eq:r-phi}
  \partial_\phi V^{r} + \Gamma^{r}_{\phi\nu}V^\nu = 0,\qquad
  \partial_\phi V^{\phi} + \Gamma^{\phi}_{\phi\nu}V^\nu = 0.
\end{equation}
which using Eq.~\eqref{eq:Christofell-symbols} becomes
\begin{equation}
  \label{eq:r-phi-2}
 	 \partial_\phi V^{r} + \Gamma^{r}_{\phi\nu}V^\nu = 0,\qquad
  \partial_\phi V^{\phi} + \Gamma^{\phi}_{\phi\nu}V^\nu = 0.
\end{equation}

or after differentiating with respect to $\phi$,
\begin{equation}
  \label{eq:r-phi-3}
  \partial_\phi^2 V^r + \sin^2\alpha V^r = 0,\qquad   \partial_\phi^2 V^\phi + \sin^2\alpha V^\phi = 0
\end{equation}
Which has the following general solutions
\begin{equation}
  \label{eq:r-phi-solution}
  \boxed{V^r = A^r_1 \sin(\sin\alpha \phi) + A^r_2 \cos(\sin\alpha \phi),\quad V^\phi = A^\phi_1 \sin(\sin\alpha \phi) + A^\phi_2 \cos(\sin\alpha \phi)}.
\end{equation}
Denoting the values of the components at $\phi=0$ with suffix `0' the solutions becomes

\begin{equation}
  \label{eq:r-phi-solution-2}
  \boxed{V^r = A^r_1 \sin(\sin\alpha \phi) + V^r_0 \cos(\sin\alpha \phi),\quad V^\phi = A^\phi_1 \sin(\sin\alpha \phi) + V^\phi_0 \cos(\sin\alpha \phi)}.
\end{equation}
Now, the constants are not all independent, there are only two independent constants. Thus the other two components could be written in terms of the $A^r_0$ and $A^\phi_0$ using equation \eqref{eq:r-phi-2}. This provides
\begin{equation}
  \label{eq:constants}
  A^r_1 = r \sin\alpha V^\phi_0,\quad A^\phi_1 = - V^r_0/r\sin\alpha.
\end{equation}
Thus finally we have the solutions
\begin{equation}
  \label{eq:r-phi-solution-final}
  \boxed{V^r =  V^\phi_0 r \sin\alpha \sin(\phi\sin\alpha) + V^r_0 \cos(\phi\sin\alpha),\quad V^\phi =  - \frac{V^r_0}{r\sin\alpha} \sin(\phi\sin\alpha) + V^\phi_0 \cos(\phi\sin\alpha)}.
\end{equation}
Now we move to a orthonormal set of basis given by $E_r = \partial_r, E_\phi = (1/\sin\alpha)\partial_\phi$. In this basis, we can rewrite the components of the $V$ as
\begin{equation}
  \label{eq:V-in-orthonormal}
  \hat{V}^r = V^r,\quad \hat{V}^\phi = r\sin\alpha V^\phi.
\end{equation}
Thus in this basis, we have the transformation
\begin{equation}
  \label{eq:transformation-orthonormal}
  \boxed{\begin{bmatrix}
      \hat{V}^r \\
      \hat{V}^\phi
    \end{bmatrix} =
    \begin{bmatrix}
      \cos(\phi\sin\alpha) & \sin(\phi\sin\alpha)\\
      -\sin(\phi\sin\alpha) & \cos(\phi\sin\alpha)
    \end{bmatrix}
    \begin{bmatrix}
      \hat{V}^r_0 \\
      \hat{V}^\phi_0
    \end{bmatrix}}
\end{equation}
Thus the components are rotated by an angle $\beta = \phi\sin\alpha$. For $\alpha = 2\pi$ this rotation equals $\beta = 2\pi\sin\alpha$.

\end{document}


%% LyX 2.3.2-1 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{luainputenc}
\usepackage{babel}
\usepackage{array}
\usepackage{textcomp}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[unicode=true]
 {hyperref}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}

\makeatother

\begin{document}
\title{Chapter 7: Chi-square Test}
\maketitle

\section{Example}
\begin{enumerate}
\item $H_{0}:$ The die is fair $\left(p=\frac{1}{6}\right)$
\item $H_{1}:$ The die is unfair $\left(p\neq\frac{1}{6}\right)$
\item At $\alpha=0.05$, critical value = $\chi_{\alpha;m-t-1}^{2}$.
\item ~
\begin{align*}
\chi_{0.05;6-0-1}^{2} & =\chi_{0.05;5}^{2}\\
 & =11.070
\end{align*}
\item Rejection region: (remember Chi-square distribution does NOT have
a negative region)
\[
\chi^{2}>11.07
\]
\item %
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
Number & 1 & 2 & 3 & 4 & 5 & 6 & Total\tabularnewline
\hline
\hline
$O_{i}$ & 89 & 113 & 98 & 104 & 117 & 79 & 600\tabularnewline
\hline
$E_{i}$ & 100 & 100 & 100 & 100 & 100 & 100 & 600\tabularnewline
\hline
$O_{i}-E_{i}$ & -11 & 13 & -2 & -4 & 17 & -21 & \tabularnewline
\hline
$\left(O_{i}-E_{i}\right)^{2}$ & 121 & 169 & 4 & 16 & 289 & 441 & \tabularnewline
\hline
$\frac{\left(O_{i}-E_{i}\right)^{2}}{E_{i}}$ & 1.21 & 1.69 & 0.04 & 0.16 & 2.89 & 4.41 & 10.40\tabularnewline
\hline
\end{tabular}
\item Since $\chi^{2}=10.40<11.07$, we failed to reject $H_{0}$ at 5\%
significance level. Hence, we do not have enough evidence to conclude
that the observed frequencies are significantly different from those
expected of a fair die.
\end{enumerate}

\section{Example}

Since every city have equal sales potential, therefore, each sale
should be $\frac{\sum x}{n}$, which is the mean.
\begin{enumerate}
\item Hypothesis
\begin{enumerate}
\item Claim: Each of the seven cities have equal sales potential. $\left(H_{0}\right)$
\item Opposite: Each of the seven cities do not have equal sales potential.
$\left(H_{1}\right)$
\item $H_{0}:A=B=C=D=E=F=G$
\item $H_{1}:A\neq B\neq C\neq D\neq E\neq F\neq G$
\end{enumerate}
\item Find the critical value
\begin{enumerate}
\item $\alpha=0.05$
\item $\chi_{0.05;7-1}^{2}=\chi_{0.05;6}^{2}=12.592$
\end{enumerate}
\item Find the rejection region
\begin{enumerate}
\item $\chi^{2}>12.592$
\end{enumerate}
\item %
\begin{tabular}{|c|c|c|c|c|c|c|c|c|}
\hline
City & A & B & C & D & E & F & G & Total\tabularnewline
\hline
\hline
$O_{i}$ & 120 & 185 & 260 & 190 & 210 & 175 & 260 & \tabularnewline
\hline
$E_{i}$ & 200 & 200 & 200 & 200 & 200 & 200 & 200 & 1400\tabularnewline
\hline
$\frac{\left(O_{i}-E_{i}\right)^{2}}{E_{i}}$ & $\frac{\left(120-200\right)^{2}}{200}=32$ & $\frac{\left(185-200\right)^{2}}{200}=1.125$ & $\frac{\left(260-200\right)^{2}}{200}=18$ & $\frac{\left(190-200\right)^{2}}{200}=0.5$ & $\frac{\left(210-200\right)^{2}}{200}=0.5$ & $\frac{\left(175-200\right)^{2}}{200}=3.125$ & $\frac{\left(260-200\right)^{2}}{200}=18$ & 73.25\tabularnewline
\hline
\end{tabular}
\item Since $\chi^{2}=73.25>12.592$, we reject $H_{0}$and do not have
enough evidence to conclude that each of the seven cities have equal
sales potential.
\end{enumerate}

\section{Example}
\begin{enumerate}
\item Hypothesis
\begin{enumerate}
\item Claim: The local hospital follows the national pattern. $\left(H_{0}\right)$
\item Oppo: The local hospital do not follow the national pattern. $\left(H_{1}\right)$
\end{enumerate}
\item Find the rejection region
\begin{enumerate}
\item $\alpha=0.05$
\item $\chi_{0.05;7-1}^{2}=\chi_{0.05;6}^{2}=12.592$
\item Rejection region: $\chi^{2}>12.592$
\end{enumerate}
\item Find the Chi-square score
\item %
\begin{tabular}{|c|c|c|c|c|c|c|c|c|}
\hline
Number of times admitted & 1 & 2 & 3 & 4 & 5 & 6 & 7 & Total\tabularnewline
\hline
\hline
$O_{i}$ & 165 & 79 & 50 & 44 & 32 & 20 & 10 & 400\tabularnewline
\hline
$E_{i}$ & 400{*}40\%=160 & 80 & 56 & 40 & 32 & 24 & 8 & \tabularnewline
\hline
$\frac{\left(O_{i}-E_{i}\right)^{2}}{E_{i}}$ & $\frac{\left(165-160\right)^{2}}{160}$ & $\frac{\left(79-80\right)^{2}}{80}$ & $\frac{\left(50-56\right)^{2}}{56}$ & $\frac{\left(44-40\right)^{2}}{40}$ & $\frac{\left(32-32\right)^{2}}{32}$ & $\frac{\left(20-24\right)^{2}}{24}$ & $\frac{\left(10-8\right)^{2}}{8}$ & 2.378\tabularnewline
\hline
\end{tabular}
\item Since $\chi^{2}=2.378<12.592$, we failed to reject $H_{0}$. Hence,
we conclude that the local hospital follows the national pattern.
\end{enumerate}

\section{Example}
\begin{enumerate}
\item Hypothesis
\begin{enumerate}
\item Claim: The results support the theory $\left(H_{0}\right)$
\item Opposite: The results do not support the theory $\left(H_{1}\right)$
\end{enumerate}
\item Find the rejection region
\begin{enumerate}
\item $\chi_{0.05;3-1}^{2}=5.991$
\item $\chi^{2}>5.991$
\end{enumerate}
\item Calculate the Chi-score
\begin{enumerate}
\item %
\begin{tabular}{|c|c|c|c|c|}
\hline
Color & $O_{i}$ & $E_{i}$ & $\frac{\left(O_{i}-E_{i}\right)^{2}}{E_{i}}$ & \tabularnewline
\hline
\hline
Red & 84 & 83.25 & 0.00676 & \tabularnewline
\hline
Blue & 92 & 83.25 & 0.91967 & \tabularnewline
\hline
Purple & 157 & 166.5 & 0.54204 & \tabularnewline
\hline
 & 333 &  & 1.46847 & \tabularnewline
\hline
\end{tabular}
\end{enumerate}
\item $\chi^{2}=1.46847<5.991$. We failed to reject $H_{0}$ at $\alpha=0.05$
and conclude that the result support the genetic theory.
\end{enumerate}

\section{Example}
\begin{enumerate}
\item Hypothesis
\begin{enumerate}
\item Claim: The random number generator is working incorrectly. $H_{1}$
\item Hypo: The random number generator is working correctly. $H_{0}$
\end{enumerate}
\item The critical value
\begin{enumerate}
\item $\chi_{0.05;6-1}^{2}=11.070$
\item Rejection region: $\chi^{2}>11.070$
\end{enumerate}
\item Find the test statistic
\begin{enumerate}
\item %
\begin{tabular}{|c|c|c|c|c|}
\hline
Interval & $O_{i}$ & Probability, $P_{i}$ & $E_{i}=500*P_{i}$ & $\frac{\left(O_{i}-E_{i}\right)^{2}}{E_{i}}$\tabularnewline
\hline
\hline
$s<4$ & 10 & $P\left(Z<\frac{4-6}{1}\right)=P\left(Z<\text{\textminus}2\right)=0.02275$ & 11.375 & 0.16621\tabularnewline
\hline
$4\le s<5$ & 75 & 0.13595 & 67.975 & 0.74601\tabularnewline
\hline
$5\le s<6$ & 163 & 0.34130 & 170.65 & 0.34294\tabularnewline
\hline
$6\le s<7$ & 174 & 0.34130 & 170.65 & 0.06576\tabularnewline
\hline
$7\le s<8$ & 66 & 0.13595 & 67.975 & 0.05738\tabularnewline
\hline
$s\ge8$ & 12 & 0.02285 & 11.375 & 0.3434\tabularnewline
\hline
Total &  & 1.0000 & 500 & \textbf{1.39264}\tabularnewline
\hline
\end{tabular}
\item Note: For the probability, use the Z-score
\[
P\left(s>\bar{x}\right)=P\left(Z>\frac{\bar{x}-\mu}{\sigma}\right)
\]
\item Use \href{http://onlinestatbook.com/2/calculators/normal_dist.html}{Normal Distribution Calculator from OnlineStatBook}
to quickly calculate without converting to normal.
\end{enumerate}
\item Conclusion
\begin{enumerate}
\item Since $\chi_{2}=1.39264<11.070$, we failed to reject $H_{0}$, and
hence conclude that the random number generator is working correctly.
\end{enumerate}
\end{enumerate}

\section{Example}
\begin{enumerate}
\item Hypothesis
\begin{enumerate}
\item Claim: The distribution of X is $B\left(3,0.25\right)$ $\left(H_{0}\right)$
\item Oppo: The distribution of X is not $B\left(3,0.25\right)$ $\left(H_{1}\right)$
\end{enumerate}
\item Find the critical value
\[
\alpha=0.01
\]

\begin{enumerate}
\item Critical value
\begin{align*}
\chi_{\alpha;m-t-1}^{2} & =\chi_{0.01;3-0-1}^{2}\\
 & =\chi_{0.01;2}^{2}\\
 & =9.210
\end{align*}
\end{enumerate}
\item Rejection region
\[
\chi^{2}>9.210
\]

\begin{enumerate}
\item If this is true, the probability distribution of X is
\[
P\left(X=x\right)=^{3}C_{x}\left(0.25\right)^{x}0.75^{3-x}
\]
\end{enumerate}
\item %
\begin{tabular}{|c|c|c|c|c|c|}
\hline
X & $O_{i}$ & Probability, $p_{i}$ & $E_{i}=64p_{i}$ & $\frac{\left(O_{i}-E_{i}\right)^{2}}{E_{i}}$ & Total\tabularnewline
\hline
\hline
0 & 21 & $\frac{21}{21+31+12+0}=0.4219$ & 27 & 1.333 & \tabularnewline
\hline
1 & 31 & 0.4219 & 27 & 0.5926 & \tabularnewline
\hline
2,3 & 12 & 0.1563 & 10 & 0.4 & 2.3259\tabularnewline
\hline
\end{tabular}
\begin{enumerate}
\item $p_{0}=^{3}C_{0}*\left(0.25\right)^{0}*\left(0.75\right)^{3}=0.4219$
\item $p_{1}=^{3}C_{1}*\left(0.25\right)^{1}*\left(0.75\right)^{2}=0.4219$
\item $p_{2+3}=^{3}C_{2}*\left(0.25\right)^{2}*\left(0.75\right)^{1}+{}^{3}C_{3}*\left(0.25\right)^{3}=0.1563$
\end{enumerate}
\item Since $\chi^{2}=2.3259<9.210.$ We failed to reject $H_{0}$, and
hence do not have enough evidence to show that the recorded data do
not fit $B\left(3,0.25\right)$.
\end{enumerate}

\section{Example}

Note: We should not round it from 2.02 to 2.00, oterhwise it will
be inaccurate during exams.

\section{Example}

\subsection{Extra Notes}

By following the probability multiplication rule, if they are independent,
the expected frequency for a field in a two-way table will be
\begin{enumerate}
\item Proportion probability of something happening in the row, multiple
by the proportion probability of something happening in a column (to
get row {*} column proportion) and then multipled by the sample size.
\item Eg:
\[
1000\left(sample\right)*\left(\frac{100}{1000}\left(row\right)*\frac{100}{1000}\left(column\right)\right)=10\left(expected\right)
\]
\end{enumerate}

\subsection{Example}
\begin{enumerate}
\item Hypothesis
\begin{enumerate}
\item The number of accidents depend on the visits by the inspector. $\left(H_{0}\right)$
\item The number of accidents do not depend on the visits by the inspector.
$\left(H_{1}\right)$
\end{enumerate}
\item Critical value
\begin{align*}
\chi_{0.05;\left(4-1\right)\left(2-1\right)}^{2} & =\chi_{0.05;3}^{2}\\
 & =7.815
\end{align*}

\begin{enumerate}
\item Note : $D.O.F.=\left(Row-1\right)\left(Column-1\right)$
\item ~\includegraphics[width=0.8\paperwidth,height=0.8\textheight,keepaspectratio]{lyx-img/c7q8expected}
\end{enumerate}
\item Rejection region
\[
\chi^{2}>7.815
\]
\item Find the test-statistic
\begin{align*}
\chi^{2} & =\frac{\left(33-27.778\right)^{2}}{27.778}+\frac{\left(8-13.889\right)^{2}}{13.889}+\frac{\left(5-5.556\right)^{2}}{5.556}+\frac{\left(4-2.778\right)^{2}}{5.556}+\frac{\left(67-72.222\right)^{2}}{72.222}+\frac{\left(42-36.111\right)^{2}}{36.111}+\frac{\left(15-14.444\right)^{2}}{14.444}+\frac{\left(6-7.222\right)^{2}}{7.222}\\
 & =5.3692
\end{align*}
\item Conclusion
\begin{enumerate}
\item Since $\chi^{2}=5.3692<7.815$. We failed to reject $H_{0}$, and
hence do not have enough evidence to conclude that the number of accidents
do not depend on the visits by the inspector.
\end{enumerate}
\end{enumerate}

\section{Example}

\section{Example}
\begin{enumerate}
\item Hypothesis
\begin{enumerate}
\item Hypo: The coin is fair $\left(H_{1}\right)$
\item Oppo: The coin is unfair $\left(H_{0}\right)$
\end{enumerate}
\item Critical value at $\alpha=0.05$
\begin{enumerate}
\item Critical value: $\chi_{0.05;2-0-1}^{2}=\chi_{0.05;1}^{2}=3.841$
\end{enumerate}
\item Rejection range: $\chi^{2}>3.841$
\item Test-statistics
\begin{align*}
\chi^{2} & =\sum_{i=1}^{m}\frac{\left(\left|O_{i}-E_{i}\right|-0.5\right)^{2}}{E_{i}}\\
 & =\frac{\left(\left|115-100\right|-0.5\right)^{2}}{100}+\frac{\left(\left|85-100\right|-0.5\right)^{2}}{100}\\
 & =4.205
\end{align*}
\end{enumerate}

\section{Example}
\begin{enumerate}
\item Hypothesis
\begin{enumerate}
\item $\left(H_{0}\right)$ There is no association between taking the new
drug and attack by the disease
\item $\left(H_{1}\right)$ There is an association between taking the new
drug and attack by the disease
\end{enumerate}
\item Critical value
\begin{enumerate}
\item $\chi_{0.05;\left(2-1\right)\left(2-1\right)}^{2}=\chi_{0.05;1}^{2}=3.841$
\end{enumerate}
\item Rejection range
\begin{enumerate}
\item $\chi^{2}>3.841$
\end{enumerate}
\item Test-statistic (apply Yate's correction because $D.O.F.=1$)
\begin{enumerate}
\item ~%
\begin{tabular}{|>{\centering}p{0.8\textwidth}|c|c|c|}
\hline
 & Drugged & Drugless & Total row\tabularnewline
\hline
\hline
Attacked & 24 & 32 & 56\tabularnewline
\hline
Expected & (35.47) & (20.53) & \tabularnewline
\hline
Not attacked & 52 & 12 & 64\tabularnewline
\hline
Expected & (40.53) & (23.47) & \tabularnewline
\hline
Total column & 76 & 44 & 120\tabularnewline
\hline
\end{tabular}
\item $\chi^{2}=\frac{\left(\left|24-35.47\right|-0.5\right)^{2}}{35.47}+\frac{\left(\left|32-20.53\right|-0.5\right)^{2}}{20.53}+\frac{\left(\left|52-40.53\right|-0.5\right)^{2}}{40.53}+\frac{\left(\left|12-23.47\right|-0.5\right)^{2}}{23.47}=17.351$
\end{enumerate}
\item Conclusion
\begin{enumerate}
\item Since $\chi^{2}=17.351>3.841$, we reject $H_{0}$. Therefore we have
enough evidence to conclude that there is an association between taking
the new drug and attack by the disease.
\end{enumerate}
\end{enumerate}

\end{document}


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

\begin{document}
\subsection{Worksheet - Lagrangians and Coordinate Transformations}
\begin{p}
If we transform $x, y$ into polar coordinates, what happens to the principle of least action? What do Lagrange’s equations become for a particle in a two-dimensional potential $U(x,y)$, now using polar coordinates. What are the generalized forces and generalized momenta?
\end{p}
\begin{s}
Since the Lagrangian is invariant of the choice of coordinates, nothing happens; the principle of least action still holds (the Lagrangian and action integral are equivalent between the two coordinate systems):
\[S[r, \theta] = \int_{t_1}^{t_2}\LL(r, \dot{r}, \theta, \dot{\theta}, t)dt = \int_{t_1}^{t_2} \LL(x, \dot{x}, y, \dot{y}, t)dt = S[x, y]\]
Using the fact that $\v{r} = r\rhat$ and $\dot{\v{r}} = \dot{r}\rhat + r\dot{\phi}\phihat$ The Lagrangian becomes:
\[\LL = T - U = \frac{1}{2}m\dot{\v{r}}^2 - U(x,y) = \frac{1}{2}m(\dot{r}^2 + r^2\dot{\phi}^2) - U(r, \theta)\]
So Lagrange's equations become:
\[\dpd{\LL}{r} = \dod{}{t}\dpd{\LL}{\dot{r}} \implies -\dpd{U}{r} + mr\dot{\phi}^2 = m\ddot{r}\]
So the generalized force is $-\dpd{U}{r} + mr\dot{\phi}^2$ and the generalized momentum is $m\dot{r}$.
\[\dpd{\LL}{\phi} = \dod{}{t}\dpd{\LL}{\dot{\phi}} \implies -\dpd{U}{\phi} = mr^2\ddot{\phi}  \]
So the generalized force is $-\dpd{U}{\phi}$ (which is just the torque!) and the generalized momentum is $mr^2\dot{\phi}$ (which is the angular momentum!).
\end{s}

\begin{p}
Write the Lagrangian for two particles interacting through a potential $U(\v{r}_1, \v{r}_2)$, using the “lab frame” coordinates $\v{r}_1, \v{r}_2$. How does the potential simplify if it is translationally-invariant? How does it simplify if it is orientationally-invariant (i.e. central)?
\end{p}
\begin{s}
The Lagrangian is given by:
\[\LL = \frac{1}{2}m_1\dot{\v{r}}_1^2 + \frac{1}{2}m_2\dot{\v{r}}_2^2 - U(x,y)\]
If the potential is translationally invariant, then there is no difference if we move the entire system through space; hence, it can only depend on the difference, i.e. $U(\v{r}_1 - \v{r}_2)$. If it is orientationally-invariant (central), then it only depends on the magnitude of the the difference, i.e. $U(\abs{\v{r}_1 - \v{r}_2})$.
\end{s}

\begin{p}
Rewrite the kinetic energy in terms of the centre of mass (CM) and relative coordinates, $\v{R}, \v{r}$. What are the Lagrange equations in these coordinates?
\begin{center}
    \includegraphics[scale=0.6]{Lecture-3/W3-img1.png}
\end{center}
\end{p}
\begin{s}
We have that the relative coordinate is $\v{r} = \v{r}_1 - \v{r}_2$ and $U = U(\abs{\v{r}})$. The CM position is given by:
\[\v{R} = \frac{m_1\v{r}_1 + m_2\v{r}_2}{m_1 + m_2}\]
Let us also define the combined mass $M = m_1 + m_2$, we then have that:
\[T = \frac{1}{2}\left(m_1\dot{\v{r}}_1^2 + m_2\dot{\v{r}}_2^2\right) = \frac{1}{2}\left(m_1\left(\dot{\v{R}} + \frac{m_2}{M}\dot{\v{r}}\right)^2 + m_2\left(\dot{\v{R}} - \frac{m_1}{M}\dot{\v{r}}\right)^2\right) = \frac{1}{2}\left(M\dot{\v{R}}^2 + \frac{m_1m_2}{M}\dot{\v{r}}^2\right)\]
So defining the reduced mass $\mu = \frac{m_1m_2}{M}$ we have:
\[\LL = T - U = \frac{M}{2}\dot{\v{R}}^2 + \left(\frac{\mu}{2}\dot{\v{r}}^2 - U(r)\right)\]
We end up with a Lagrangian that has essentially two independent terms; a COM motion term (which is trivial, just a particle of mass $M$) and a relative position term which is equivalent to a particle of mass $\mu$ subject to potential $U(r)$. We have essentially converted a two particle problem into what is effectively a one particle problem. This makes the two-body problem analytically (somewhat) easy to solve with this method.
\end{s}

\begin{p}
Write the expressions for $\v{r}_1$ and $\v{r}_2$ in terms of appropriate generalized coordinates, for the double pendulum.
\begin{center}
    \includegraphics[scale=0.6]{Lecture-3/W3-img2.png}
\end{center}
\end{p}
\begin{s}
Trigonometry to get the position vectors:
\[\v{r}_1 = l_1\sin\phi_1\xhat + l_1\cos\phi_1\yhat\]
\[\v{r}_2 = \left(l_1\sin\phi_1 + l_2\sin\phi_2\right)\xhat + \left(l_1\cos\phi_1 + l_2\cos\phi_2\right)\yhat\]
This problem has four degrees of freedom (motion in the plane) but two constraints that $\abs{\v{r}_1} = l_1$ and $\abs{\v{r}_2 - \v{r}_1} = l_2$. This leaves to two generalized coordinates. Note that the constraints $f(\v{r}_1, \cdots, \v{r}_n, t) = 0$ are called "holonomic" and are in general nice for solving problems.
\end{s}
\end{document}


\documentclass{homework}
\course{Math 5522H}
\author{Jim Fowler}
\input{preamble}

\begin{document}
\maketitle

\begin{inspiration}
Some of the most important results (e.g. Cauchy's theorem) are so surprising at first sight that nothing short of a proof can make them credible.
\byline{Sir Harold Jeffreys} % and where is this quotation from?
\end{inspiration}

\section{Terminology}

\begin{problem}
  What is a \textbf{Jordan curve}?
\end{problem}

\begin{problem}
  Define the \textbf{winding number} $n(\gamma,z)$ of a piecewise
  smooth closed curve $\gamma$ around a point $z \in \C$.
\end{problem}

\section{Numericals}

\begin{problem} Compute the \textbf{Fresnel integrals}
  \[
    \int_0^\infty \sin \left( x^2 \right) \, dx \mbox{ and } \int_0^\infty \cos \left( x^2 \right) \, dx.
  \]
\end{problem}

\begin{problem}
  For an integrable function $f : \R \to \C$, define the
  \textbf{Fourier transform} of $f$, denoted $\hat{f}$, by
  \[
    {\hat {f}}(\xi ) := \int _{-\infty }^{\infty} f(x) \, e^{-2\pi ix \xi} \,dx.
  \]
  Find the Fourier transform of $f(x) = e^{-\pi x^2}$.
\end{problem}

\section{Exploration}

\begin{problem}
  Does the function $f : \C \to \C$ given by $f(z) = \conj{z}$ have a
  primitive?
\end{problem}

\begin{problem}
  We proved Goursat's theorem for rectangles.  Without simply
  recapitalulating the proof (e.g., your argument should not again
  invoke \ref{nested-subsets-convergence}), deduce a theorem for
  \textit{triangles} from our result about rectangles.
\end{problem}

\begin{problem}
  Suppose $f, g : \C \to \C$ are holomorphic and agree on the unit
  circle.  How do $f$ and $g$ relate?  Morally, this problem is
  related to \ref{identity-theorem}.
\end{problem}

 \begin{problem}
   Suppose $f : \C \to \C$ is holomorphic, and consider the circle
   $\gamma$ with center $z_0$.  How does the real part of the average
   value of $f$ on the circle $\gamma$ relate to $f(z_0)$?
 \end{problem}

 \begin{problem}
   Recalling \ref{harmonic-conjugate}, suppose $u, v : \C \to \R$ are
   harmonic functions and $f = u + iv$ is holomorphic, so $u$ and $v$
   are harmonic conjugates.  Find the \textbf{Poisson kernel} for the
   unit disc, i.e., find a function $P_r(\theta)$ so that
   \[
     u(re^{i\theta}) = \frac {1}{2\pi} \int_{-\pi }^{\pi } P_{r}(\theta -t) \, u(e^{it}) \, dt
   \]
   for $r < 1$.
 \end{problem}

\section{Prove or Disprove and Salvage if Possible}

\begin{problem}
  Suppose $D = \{ z \in \C : \abs{z} < 1 \}$ and $f : D \to \C$ is
  continuous and $\gamma : [a,b] \to D$ is a piecewise smooth curve.
  Then $\displaystyle\int_\gamma f\, dz = 0$.
\end{problem}

\begin{problem}
  Suppose $U$ is an open set and $f : U \to \C$ is analytic and
  $\gamma : [a,b] \to U$ is a piecewise smooth curve.  Then
  $\displaystyle\int_\gamma f \, dz = 0$.
\end{problem}

\begin{problem}
  Define $\gamma_r : [0,2\pi] \to \C$ by
  $\gamma_r(\theta) = r e^{i \theta}$, and for real numbers
  $R > r > 0$, define the annulus
  \[
    A(r,R) := \{ z \in \C : r < |z| < R \}
  \]
  and suppose $f : A(r/2,2R) \to \C$ is holomorphic.  Then
  \[
    \int_{\gamma_r} f \, dz = \int_{\gamma_R} f \, dz.
  \]
\end{problem}

\begin{problem}\label{cauchy-integral-formula}Define $B_R(0) := \{ z \in C : \abs{z} < R \}$ and suppose
  $f : B_R(0) \to \C$ is holomorphic and let $\gamma$ be the
  positively-oriented circle of positive radius $r < R$.  Then
  \[
    f(a) = \int_\gamma \frac{f(z)}{z-a} \, dz.
  \]
  and moreover
  \[
    f'(a) = \int_\gamma \frac{f(z)}{(z-a)^2} \, dz.
  \]
\end{problem}

\begin{problem}\label{cauchy-inequalities}If $f : U \to \C$ is
  holomorphic and $U \supset B_r(z_0)$, then
  \[
     \abs{f(z_0)} \leq \sup_{z \in \partial B_r(z_0)} \abs{f(z)}
   \]
   and
   \[
     \abs{f'(z_0)} \leq \sup_{z \in \partial B_r(z_0)} \abs{f(z)}. % missing (1/r) factor
   \]
 \end{problem}

\begin{problem}\label{liouville-theorem}Recall that a function $f : U \to \C$ is
  \textbf{bounded} if there exists $M > 0$ so that for all $z \in U$
  we have $\abs{f(z)} \leq M$.  A bounded holomorphic function
  $f : U \to \C$ is constant.
\end{problem}

\begin{problem}
  For every polynomial $p \in \C[z]$ there is $z \in \C$ so that $p(z) = 0$.
\end{problem}

\end{document}


\section{Working Principle}

Feature Kernel can be implemented in various ways, here we'll describe our implementation.

\subsection{Usage Ratio} \label{sec:usage-ratio}
One of the first decisions that need to be made is size of the sub model.
First of all, we can define the \emph{Usage Ratio} (ur) as
\begin{align}
    ur := \frac{\text{Sub model size}}{\text{Full model size}} \label{eq:usage-ratio}
\end{align}

Of course a fixed $ur$, very easy to program, is not a good idea.
It is completely arbitrary and it may be to much in some case and not enough in other situations.
A good choice is to having an automatically adjusting $ur$. In the current implementation $ur$ is initially set to the fixed value\footnote{This value is hard-coded} of $0.01$, so initially
a sub model large one hundredth of the whole model. This value has been chosen because it is small enough, so it is very unlikely that a sub problem so small
is already feasible, but also it is not too small because it can lead to a slow convergence.

$ur$ value is automatically adjusted according to the status of the current sub problem:

\subsubsection*{Sub problem linearly infeasible}\label{subsec:lin-infeasible-action}

    In this case the random sub model is so small that is very unlikely that another random sub model
    with the same size can be feasible. So to find a feasible sub model (at least in the continuous)
    it is necessary to increase $ur$ significantly. This is the function used to update $ur$ in this case.
    \begin{align}
        &ur_{i+i} = \sqrt[m]{u_{i}^{n}}\label{eq:ur-infease-grow} \\
        With:&\nonumber \\
        &m > n > 1 \nonumber
    \end{align}

    This function, or better class of functions, has been chosen for three reasons:
    \begin{itemize}
        \item It has a fixed point in 1, so is not possible that such a series produces an $ur$ larger then 1.
        \item It is pretty fast as the beginning and than it becomes slower as $ur$ gets closer to 1.
        \item It allows to have a large number of points during the growth.
    \end{itemize}

    \begin{figure}[H]
        \centering
        \includegraphics[width=\textwidth,keepaspectratio]{plot_initial_increase}
        \caption{Infeasible $ur$ Growth example}\label{fig:inf-grow-plot}
    \end{figure}

    In Figure \ref{fig:inf-grow-plot} are shown four different configuration. This possible to notice that those function
    grows quickly at the beginning, approximately from $ur = 0.01$ to $ur = 0.6 / 0.8$ then it starts settling
    to $ur = 0.95 / 1$.

    Because the porpoise is to grow $ur$ until the generate model is large enough to be feasible, but not so large
    that the sub model is practically as complex as the whole model. Also we'd like to have $ur$ to grow fast, so the number
    of infeasible models is as limited as possible, but not too fast otherwise we'll get sub model that are too large for their
    purpose. Last but not least we'd like to have an large number of points so the number of iteration to get to one should be high
    but not excessive.
    For those reason the current Feature Kernel implementation uses $n = 4$ and $m = 5$ to define the growth function.

\subsubsection*{Sub problem is linearly feasible}
    \begin{align}
        &u_{i+i} = 1.1 u_{i} \label{eq:ur-lin-fease-grow}
    \end{align}

    Once the model is proven to be feasible in the continuous, Feature Kernel tries to make it also feasible in the
    integer. This can be done by simply trying over and over, and by chance it is possible that some of those sub models
    become integer feasible. Feature Kernel does not rely (too much) on chance and to increase its possibility to get
    a feasible sub model it increase $ur$ by 10\%. This value has been chosen hoping that when the solution is feasible
    in the continuous it is also close to be feasible in the integer. So this 10\% increase should be done just a few times
    before getting a feasible integer problem. If that holds true $ur$ should never become too close to 1.
    It also possible that some models requires all the variables to become integer feasible. In this case this 10\% increase
    can lead to a $ur > 1$, if this happens Feature Kernel simply set $ur = 1$.

\subsubsection*{Sub problem is integer feasible}
    \begin{align}
        &u_{i+i} = 0.9 u_{i} \label{eq:ur-fease-grow}
    \end{align}

    If an integer feasible sub model is found means that the current $ur$ is able to provide some other integer feasible solutions.
    The Feature Kernel goal is to find a ranking based on a machine learning technique, so to find a valuable answer Feature Kernel needs
    some sub models that are integer feasible and some other that are feasible only in the continuous. This is why when an integer feasible
    sub model is found Feature Kernel decreases $ur$ by 10\%. This value has been chosen to mirror the value from Eq \ref{eq:ur-lin-fease-grow}.
    Of course a 10\% decrease can lead to a very small $ur$ in few iterations, but consider that once the problem turn again into an integer infeasible
    size the growth function turns into the method described in \Cref{subsec:lin-infeasible-action}.

Those three growth function will try to keep $ur$ switching between integer feasibility, continuous feasibility and infeasibility. This should provide
a meaningful dataset, rich of different statuses sub problem, to fed into the machine learning algorithm.

\subsubsection{Feasibility Threshold}

Now it is possible to define those two indexes:
\begin{itemize}
    \item Continuous Feasibility Threshold (CFT): is the average $ur$ of sub problems that are feasible in the continuous but not in the integer.
    \item Integer Feasibility Threshold (IFT): is the average $ur$ of sub problems that are integer feasible.
\end{itemize}

Those values allow the user to get an idea of some properties of the specific instance. They allow to understand if the problem is suitable for Kernel Search or not.
For example is it happens that IFT is very close to 1 it is very unlikely that an incremental solution, like the one built by Kernel Search, can provide a good solution in
a shot period of time. On the other side if IFT (and/or CFT) are reasonably low it is possible for this problem to be solved using Kernel Search, in fact in this situation
an incremental solution is a good idea to solve the problem, potentially to a value vary close to the optimal.

\subsection{Sub Problem Construction}

The algorithm to build the random sub model is presented in the following pseudocode
\input{algorithms/generate_random_sub_model.tex}

\subsection{Sub Problem Solution}
Each sub problem needs to be solved in order to understand if it is integer feasible, continuous feasible or infeasible.
This is done in two steps: first prove continuous feasibility, second prove integer feasibility.

\subsubsection{Continuous Feasibility}
In this first step the sub model is relaxed (integer constraints are removed) and then it is solved to the optimal. The optimal solution is needed for a
practical reason: Random Forrest requires for each variable of each instance to have a value. This value cannot be a random one or simply one or zero. It
must be a significant value, so we'll use the value of the variable in the linear solution. Out of base variables are not set to any special value, they are
simply kept to zero. Base variables of course are set to their base value.

If the sub problem happens to be infeasible in the continuous domain then this sub problem is considered as meaningless and it will not be uses in the training of the Random Forrest

\subsubsection{Integer Feasibility}
In the second step the model is solved as it is. In this scenario is of course possible to solve the problem at the optimal but is pointless:
\begin{itemize}
    \item it's slow
    \item there is already a value for the variables
    \item we are looking for feasibility not for a solution
\end{itemize}
So in our implementation the solver is set to search for just one solution, so we are able to prove if the problem is feasible or not: if a solution is found then the model is feasible, otherwise
is infeasible.

\subsubsection{Time Limit}\label{sec:timeout}
In some cases even a sub problem solved once may take to long. This issue can be unacceptable within a method like Feature Kernel where the number of sub problem to solve can be very high: it
is pointless to use a method for a faster initial kernel generation if it take more then the standard method. To avoid this issue is important to properly set a time limit. Feature Kernel
supports two time limits:
\begin{itemize}
    \item Minimum Time: this is the time limit used at the beginning of method and is increased each time a sub model end due to a timeout
    \item Maximum Time: the upper time limit, when this value is reached the actual time limit value won't increase even if the model ends due to a timeout
\end{itemize}

\subsubsection{Possible Sub Model Results}\label{sec:submodel-result}
Considering the various steps and their configuration a sub problem can end with four different status:
\begin{enumerate}
    \item Infeasible: the model is infeasible in the continuous domain
    \item Linear Feasible: the model is feasible in the continuous but not in the integer
    \item Integer Feasible: the model is feasible in the integer
    \item Timeout: the solver reach the configured time limit, nothing could be said about the feasibility.
\end{enumerate}

\input{algorithms/solve_sub_model.tex}

\subsection{Kernel Construction}

This is the final step and is  made out of two components: variable sorting and variable split.
Variable sorting is the step involving   the Random Forrest, where the solved models are joined into a dataset and then used to train the Model. The second component, namely variable split,
takes care for the split of variables between the initial kernel and the bucket variables.

\subsubsection{Variable Sort}
When all the sub problem have been solved those solutions must be joined into a dataset. In our implementation Feature Kernel build the dataset only from instances
with final status of integer or continuous feasibility. Of course infeasible instances cannot be used in the dataset: variables does not have a value. For the same reason
also sub problems ended in timeout are to be considered insignificant, also them haven't a value.

In order to train the Random Forrest is important to modify the collected solution accordingly to the Random Forrest requirements. Once built the dataset it is possible to
start training the Random Forrest. In general it is an extremely fast process. We won't show a general pseudocode about this
step because it is very reach of implementation details.
The only thing that meters is that now we have a variable ranking.

\subsubsection{Variable Split}
Once we've got a variable ranking, Feature Kernel sorts the variables (from the highest ranking one). The top variables will be uses as kernel variables, the bottom ones will be
the buckets. Now Feature Kernel need to now the point to split kernel and variables. In our implementation this point is computed automatically according to the $ur$.
At the current time it is possible to use four different split points:
\begin{itemize}
    \item Minimum Continuous Feasibility: the size of the smallest sub model that happens to be continuous feasible
    \item  Maximum Continuous Feasibility: the size of the largest sub model that happens to be continuous feasible
    \item Minimum Integer Feasibility: the size of the smallest sub model that happens to be integer feasible
    \item Maximum Integer Feasibility: the size of the largest sub model that happens to be integer feasible
\end{itemize}

Once the variables are split Feature Kernel can build\footnote{Depending on the actual Kernel Search implementation} the initial Kernel and the buckets. From now on Kernel Search can
proceed as usual.

\subsubsection{Feature Kernel Pseudocode}
At this point, after all this theoretical description, we'll provide a pseudocode that should provide a guide for those who wants to implement Feature Kernel them self.

\input{algorithms/feature_kernel.tex}

\input{algorithms/build_solutions.tex}


\chapter{Spinless \Pelectron + \Pmuon scattering}
For the following calculations we will consider the elastic electromagnetic scattering of scalar electrons and muons. That is, the particles considered are solutions of the Klein-Gordon equation.

The process has one diagram:
\begin{figure}[h]
\centering
\include{figures/emuscatter}
\caption{Diagram for the t-channel process \HepProcess{\Pelectron+\Pmuon\to\Pelectron+\Pmuon} with scalar particles.\label{fig:emuscatter}}
\end{figure}

\section{Electrodynamics of scalars}\label{sec:EMdynamics}
The equations of motion for a particle may be modified to include the electromagnetic interaction via a 4-potential $A$ via the substitution
\begin{equation}
p^\mu \rightarrow p^\mu + eA^\mu.
\end{equation}
Then the Klein-Gordon equation, \eqref{eq:KleinGordon}, becomes
\begin{equation}
\left( i\partial_\mu + eA_\mu \right)\left( i\partial^\mu + eA^\mu \right)\psi = m^2\psi.
\end{equation}
Expanding out the left-hand side and collecting the free-particle kinetic and mass terms, we can identify an expression for the electromagnetic potential, $V$,
\begin{equation}
\left( \partial_\mu\partial^\mu + m^2 \right)\psi = \left( ie\partial_\mu A^\mu + ieA_\mu\partial^\mu + e^2A_\mu A^\mu \right)\psi \equiv -V(x) \,\psi.
\end{equation}
Under the weak field approximation, we may ignore the second-order term $A_\mu A^\mu$, so that
\begin{equation}
V(x) \approx -ie\left( \partial_\mu A^\mu + A_\mu\partial^\mu \right)
\end{equation}

\section{Scattering amplitude}
The amplitude for a particle with wavefunction $\phi_i$ to scatter from potential $V$ and subsequently have the wavefunction $\phi_f$ is given by
\begin{align}
T_{fi} &= -i \int \dd[4]{x} \, \phi_f^* \, V \, \phi_i \\
&= -i \int \dd[4]{x} \, \phi_f^* \, (-ie) \left( \partial_\mu A^\mu + A_\mu\partial^\mu \right) \, \phi_i
\end{align}
where the weak field form of the EM potential has been substituted for $V$. Integrating by parts, the first term in the integral evaluates to
\begin{equation}
\int \dd[4]{x} \, \phi_f^* \, \partial_\mu A^\mu \, \phi_i = \left[ \phi_f^* \, A^\mu \, \phi_i \right]_{-\infty}^{+\infty} - \int \dd[4]{x} \, \left( \partial_\mu \phi_f^* \right) A^\mu \, \phi_i
\end{equation}
and the boundary term in square brackets goes to zero for a vanishing (i.e.~local) potential. Therefore, the scattering amplitude becomes
\begin{align}
T_{fi} &= -i \int \dd[4]{x} \,(-ie)\left( \phi_f^* A_\mu \partial^\mu \phi_i - (\partial_\mu \phi_f^*) A^\mu \phi_i \right) \nonumber \\
&= -i \int \dd[4]{x} \, A^\mu \,(-ie)\left( \phi_f^* \partial_\mu \phi_i - (\partial_\mu \phi_f^*) \phi_i \right) \nonumber \\
&= -i \int \dd[4]{x} \, A^\mu \, j_\mu^{fi} \label{eq:scatterAmp}
\end{align}
where we have identified the current density,
\begin{equation}
j_\mu^{fi} = -ie \left( \phi_f^* \partial_\mu \phi_i - (\partial_\mu \phi_f^*) \phi_i \right).
\end{equation}
This is the current-potential formulation, where we identify the scattering process with a current $j_\mu^{fi}$ and potential $A^\mu$.

At the vertex changing A to C, the scalar electron has plane wavefunctions,
\begin{equation}
\phi_A(x) = N_A \, e^{-iP_Ax}, \quad \phi_C(x) = N_C \, e^{-iP_Cx},
\end{equation}
giving the current,
\begin{equation}
j_\mu^{CA} = -e \, N_C^* \, N_A \, e^{i(P_C-P_A)x} \, (P_A + P_C)_\mu. \label{eq:current}
\end{equation}
This will be the current in the current-potential formulation. Similarly, the current flowing through the other vertex is given by
\begin{equation}
j_\mu^{DB} = -e \, N_D^* \, N_B \, e^{i(P_D-P_B)x} \, (P_B + P_D)_\mu.
\end{equation}

We wish to identify the potential $A^\mu$ associated with the current $j_\mu^{DB}$. For the potential to describe fields that behave according to Maxwell's equations, it must itself obey the Poisson equation (see Section \ref{sec:maxwell} below),
\begin{equation}
\partial^2 A^\mu = j^\mu.
\end{equation}
It can be verified that the potential
\begin{equation}
A_{DB}^\mu = \frac{- g^{\mu\nu} j^{DB}_\nu}{q^2} \label{eq:potential}
\end{equation}
is a solution via substitution,
\begin{align}
\partial^2 \left( \frac{-g^{\mu\nu} j^{DB}_\nu}{q^2} \right) &= -\frac{1}{q^2} \left[ i(P_D - P_B) \right]^2 \, j_{DB}^\mu \nonumber \\
&= j_{DB}^\mu
\end{align}
where $q^2 = (P_D - P_B)^2 = t$ is the 4-momentum of the propagating photon.

Inserting the above forms for the current, \eqref{eq:current}, and potential, \eqref{eq:potential}, into the expression for the scattering amplitude, \eqref{eq:scatterAmp},
\begin{equation}
T_{fi} = \frac{ie^2}{q^2} \int \dd[4]{x} \, N_C^* \, N_A \, N_D^* \, N_B \, (P_A + P_C)_\mu (P_B + P_D)^\mu \, e^{i(P_C+P_D-P_A-P_B)x}
\end{equation}

\section{Scattering rate}
To calculate the cross-section, we would like to know the rate $W_{fi}$ of particles being scattered per unit time and volume,
\begin{equation}\boxed{
W_{fi} = \frac{T_{fi}^* T_{fi}}{T \times V}
}\end{equation}

Assume the scattering takes place in a volume $V$. We use the covariant normalisation to $2E$ particles in the volume, giving
\begin{equation}
N_i = \frac{1}{\sqrt{V}} \quad \text{for $i=A,B,C,D$.}
\end{equation}
Then the amplitude becomes
\begin{equation}
T_{fi} = \frac{ie^2}{q^2 \, V^2} \int \dd[4]{x} \, (P_A + P_C)_\mu (P_B + P_D)^\mu \, e^{i(P_C+P_D-P_A-P_B)x}
\end{equation}
giving a probability
\begin{align}
T_{fi}^* T_{fi} &= \frac{e^4}{q^4 \, V^4} \int_{TV} \dd[4]x \int_{TV} \dd[4]x^\prime \, \left[ (P_A + P_C)_\mu (P_B + P_D)^\mu \right]^2 \, e^{i(P_C+P_D-P_A-P_B)(x-x^\prime)} \\
&= \frac{e^4}{q^4 \, V^4} \left(\sqrt{2\pi}\right)^4 \, \sqrt{TV} \int_{TV} \dd[4]{x} \left[ (P_A + P_C)_\mu (P_B + P_D)^\mu \right]^2 \, e^{i(P_C+P_D-P_A-P_B)x} \nonumber \\
&= \frac{e^4}{q^4 \, V^4} \left(\sqrt{2\pi}\right)^8 \, \left(\sqrt{TV}\right)^2 \, \delta^{(4)}(P_C+P_D-P_A-P_B) \,  \left[ (P_A + P_C)_\mu (P_B + P_D)^\mu \right]^2 \nonumber \\
&= \frac{e^4}{q^4 \, V^4} \, (2\pi)^4 \, \left[ (P_A + P_C)_\mu (P_B + P_D)^\mu \right]^2\, \delta^{(4)}(P_C+P_D-P_A-P_B)\, TV
\end{align}
which gives the rate
\begin{equation}
W_{fi} = \frac{(2\pi)^4\,e^4}{q^4 \, V^4} \, \left[ (P_A + P_C)_\mu (P_B + P_D)^\mu \right]^2\, \delta^{(4)}(P_C+P_D-P_A-P_B).
\end{equation}

\section{Density of states}
The larger the number of final states per unit volume $N_f$ available to a process, the more likely it is to happen and hence the cross-section is proportional to $N_f$.

In the scattering problem the number of final states is the number of possible momenta inside $[\vec{p}, \vec{p}+\dd[3]{\vec{p}}]$ for the propagating photon with a given energy. This is given by
\begin{equation}
N_f = \frac{1}{2E} \frac{\dd[3]{\vec{p}}}{\Delta p}
\end{equation}
where $\Delta p$ is the separation in momentum space between adjacent states and the $1/2E$ factor is due to the fact that there are $2E$ particles inside the volume and we want the number of states for one particle.

Since the scattering process is modelled as happening inside a volume $V$, the propagating photon has the wavefunction of a particle in an infinite potential well with the dimensions of $V$ (Dirichlet boundary conditions, $\psi(0) = \psi(L) = 0$). This leads to the quantisation of its allowed momentum,
\begin{align}
p_x &= \frac{2\pi}{L_x}\, n_x, \quad
p_y = \frac{2\pi}{L_y}\, n_y, \quad
p_z = \frac{2\pi}{L_z}\, n_z.
\end{align}
Therefore, the separation between momentum states is $2\pi/L$ in each dimension. This leads to the density of states,
\begin{align}
N_f &= \frac{1}{2E} \frac{L_x}{2\pi} \frac{L_x}{2\pi} \frac{L_x}{2\pi} \dd[3]{\vec{p}} \nonumber \\
&= \frac{1}{2E} \frac{V}{(2\pi)^3} \dd[3]{\vec{p}}.
\end{align}

Now the photon's energy is shared amongst particles $C$ and $D$, so the density of final states becomes
\begin{align}
N_f^{CD} &= \frac{1}{2E_C} \frac{V}{(2\pi)^3} \dd[3]{\vec{p}_C} \, \frac{1}{2E_D} \frac{V}{(2\pi)^3} \dd[3]{\vec{p}_D} \\
&= \frac{1}{4E_CE_D}\frac{V^2}{(2\pi)^6} \dd[3]{\vec{p}_C} \, \dd[3]{\vec{p}_D}
\end{align}

\section{Incoming flux}
The rate $W_{fi}$ scales with the flux of incoming particles, so the in cross-section calculation, it should be divided by a flux factor, $\rho_A\rho_Bu_{AB}$, where $\rho_{AB}$ give the density of initial-state particles and $u_{AB} = u_A - u_B$ is their relative velocity.
\begin{align}
\rho_A\rho_Bu_{AB} &= \frac{2E_A}{V} \frac{2E_B}{V} \left( \frac{p_A}{E_A} - \frac{p_B}{E_B} \right) \\
&= \frac{4}{V^2} \left( p_A E_B - p_B E_A \right).
\end{align}
For a collider in the centre of momentum (CM) frame, we have $p_A = -p_B$,
\begin{equation}
\rho_A\rho_Bu_{AB} = \frac{4p_A}{V^2} (E_B + E_A) = \frac{4p_A\sqrt{s}}{V^2}
\end{equation}
where $\sqrt{s} = E_A + E_B$ is the CM energy.

\section{Cross-section}
Now we are ready to calculate the differential cross-section,
\begin{align}
\dd{\sigma} &= \frac{W_{fi}}{\rho_A\rho_Bu_{AB}} N_f \\
&= \left\{ \frac{(2\pi)^4\,e^4}{q^4 \, V^4} \, \left[ (P_A + P_C)_\mu (P_B + P_D)^\mu \right]^2\, \delta^{(4)}(P_C+P_D-P_A-P_B) \right\} \frac{V^2}{4p_A\sqrt{s}} \frac{1}{4E_CE_D}\frac{V^2}{(2\pi)^6} \dd[3]{\vec{p}_C} \, \dd[3]{\vec{p}_D} \nonumber \\
&= \frac{e^4}{q^4V^2} \frac{\left[ (P_A + P_C)_\mu (P_B + P_D)^\mu \right]^2}{4p_A\sqrt{s}} \, \dd{Q}
\end{align}
where $\dd{Q}$ is the Lorentz-invariant phase space factor
\begin{equation}
\dd{Q} = \frac{V}{2E_C} \frac{\dd[3]{\vec{p}_C}}{(2\pi)^3} \frac{V}{2E_D} \frac{\dd[3]{\vec{p}_D}}{(2\pi)^3} (2\pi)^4 \, \delta^{(4)}(P_C+P_D-P_A-P_B)
\end{equation}
In the CM frame, we have that $\vec{p}_A = -\vec{p}_B$, so
\begin{equation}
\dd{Q} = \frac{V^2}{(2\pi)^2} \, \delta(\sqrt{s} - E_C - E_D) \, \delta^{(3)}(\vec{p_C} + \vec{p_D}) \, \frac{\dd[3]{\vec{p}_C}}{2E_C} \frac{\dd[3]{\vec{p}_D}}{2E_D}.
\end{equation}
We now integrate over all momenta for $D$, the unobserved particle. This gives,
\begin{align}
\dd{Q} &= \frac{V^2}{(2\pi)^2} \frac{1}{4E_C E_D} \, \delta(\sqrt{s} - E_C - E_D) \, \dd[3]{\vec{p}_C} \\
&= \frac{V^2}{(2\pi)^2} \frac{1}{4E_C E_D} \, \delta(\sqrt{s} - E_C - E_D) \, p_C^2 \, \dd{p_C} \, \dd{\Omega}
\end{align}

Now from the relation $E^2 = p^2 + m^2$ we have that $E \dd{E} = p\dd{p}$, so
\begin{equation}
\dd{Q} = \frac{V^2}{(2\pi)^2} \frac{p_C}{4 E_D} \, \delta(\sqrt{s} - E_C - E_D)  \, \dd{E_C} \, \dd{\Omega}
\end{equation}

We next want to integrate over $E_C$. To do so, write the expression in the $\delta$ function as
\begin{align}
f(E_C) &= \sqrt{s} - E_C - E_D \\
&= \sqrt{s} - E_C - \sqrt{p_D^2 + m_D^2} \nonumber \\
&= \sqrt{s} - E_C - \sqrt{p_C^2 + m_D^2} \quad \text{since $\vec{p}_C = -\vec{p}_D$} \nonumber \\
&= \sqrt{s} - E_C - \sqrt{E_C^2 - m_C^2 + m_D^2}.
\end{align}
Therefore,
\begin{align}
\abs{\dv{f}{E_C}} &= 1 + \frac{E_C}{\sqrt{E_C^2 - m_C^2 + m_D^2}} \nonumber \\
&= \frac{\sqrt{s}}{E_D}
\end{align}
so the $\delta$-function becomes
\begin{equation}
\delta(\sqrt{s} - E_C - E_D) = \delta(E_C) \, \frac{E_D}{\sqrt{s}}
\end{equation}
and the Lorentz-invariant phase space is
\begin{equation}
\dd{Q} = \frac{V^2}{(2\pi)^2} \frac{p_C}{4\sqrt{s}} \, \delta(E_C)\, \dd{E_C} \, \dd{\Omega}.
\end{equation}
Integrating over the final-state particle's energy, $E_C$,
\begin{equation}
\dd{Q} = \frac{V^2}{(2\pi)^2} \frac{p_C}{4\sqrt{s}} \, \dd{\Omega}.
\end{equation}

Substituting this back into the expression for the differential cross section,
\begin{equation}\boxed{
\dv{\sigma}{\Omega} = \frac{1}{64\pi^2}\frac{e^4}{q^4} \left[ (P_A + P_C)_\mu (P_B + P_D)^\mu \right]^2 \frac{1}{s} \, \frac{p_C}{p_A}
}.\end{equation}
The fact that the cross-section is proportional to $1/s$, the inverse square of the SM energy means that we need increasingly higher luminosities to observe high energy scattering processes.

\section{Application: high-energy scattering}
Consider the ultra-relativistic case, where $E \gg m$ for all particles. In the CM frame, all particles now have the same energy $E = s/2$. Then we have that the Mandelstam $t$ variable is
\begin{align}
q^2 = t &= (P_A - P_C)^2 \\
&= \mqty(E_A - E_C \\ \vec{p}_A - \vec{p}_C)^2 \nonumber \\
&= -2E^2 (1-\cos\theta)
\end{align}

In this case, the differential cross-section becomes
\begin{equation}
\dv{\sigma}{\Omega} = \frac{e^4}{64\pi^2} \frac{\left[ (P_A + P_C)_\mu (P_B + P_D)^\mu \right]^2}{4E^4 (1-\cos\theta)^2} \frac{1}{s}.
\end{equation}

Now we have, in the CM frame,
\begin{equation*}
P_A = \mqty(E \\ \vec{p}) \, \quad P_B = \mqty(E \\ -\vec{p}) \, \quad P_C = \mqty(E \\ \vec{p^\prime}) \, \quad P_D = \mqty(E \\ -\vec{p^\prime}),
\end{equation*}
and therefore,
\begin{align}
(P_A + P_C)_\mu (P_B + P_D)^\mu &= \mqty(2E \\ \vec{p} + \vec{p^\prime}) \mqty(2E \\ -\vec{p} - \vec{p^\prime} ) \quad \text{with $\abs{\vec{p}} = \abs{\vec{p^\prime}} = E$} \nonumber \\
&= (2E)^2 + (\vec{p} + \vec{p^\prime})^2 \nonumber \\
&= 6E^2 + 2E^2 \cos\theta
\end{align}
\begin{equation}
\Rightarrow\quad \left[ (P_A + P_C)_\mu (P_B + P_D)^\mu \right]^2 = 4E^4 (3 + \cos\theta)^2
\end{equation}

So the final answer is
\begin{equation}
\dv{\sigma}{\Omega} = \frac{e^4}{64\pi^2} \left(\frac{3+\cos\theta}{1-\cos\theta}\right)^2 \frac{1}{s}.
\end{equation}

\section{$1 \to 2$ scattering (decay)}
For a single body of mass $M$ decaying into two particles, we replace the flux factor with the normalised energy density,
\begin{equation}
\rho = \frac{2M}{V}
\end{equation}
so the cross-section is given by
\begin{equation}
\dd{\sigma} = \frac{V}{2M} \, W_{fi} \, N_f.
\end{equation}
where for a two-body final state, $N_f$ is the same as for above. However, $T_{fi}$ will obviously be different.