% !TEX root = hott_intro.tex

\section{Contractible types and contractible maps}
\sectionmark{Contractible types and maps}

\index{contractible type|(}
A contractible type is a type which has, up to identification, only one term. In other words, a contractible type is a type that comes equipped with a point, and an identification of this point with any point.

We may think of contractible types as singletons up to homotopy, and indeed we show that the unit type is an example of a contractible type. Moreover, we show that contractible types satisfy an induction principle that is very similar to the induction principle of the unit type, provided that we formulate the computation rule using the identity type rather than postulating a judgmental computation rule.

Another case of an inductive type with a single constructor is the type of identifications $p:a=x$ with a fixed starting point $a:A$. To specify such an identification, we have to give its end point $x:A$ as well as the identification $p:a=x$, and the path induction principle asserts that in order to show something about all such identifications, it suffices to show that thing in the case where the end point is $a$, and the path is $\refl{a}$. This suggests that the total space
\begin{equation*}
  \sm{x:A}a=x
\end{equation*}
of all paths with starting point $a:A$ is contractible. This important fact will be shown in \cref{thm:total_path}, and it is the basis for the fundamental theorem of identity types (\cref{chap:fundamental}).

In the remainder of this section we will show that for any equivalence $e:A\simeq B$ and any $b:B$, the type of all $a:A$ equipped with a path $p:e(a)=b$ is contractible. In other words, if a map $f:A\to B$ is an equivalence, then the `preimage'
\begin{equation*}
  \sm{a:A}f(a)=b
\end{equation*}
is contractible for each $b:B$. The preimage of a map $f:A\to B$ at a point $b:B$ is called the fiber of $f$ at $b$, and we say that a map is contractible if all its fibers are contractible. This condition is of course analogous to the set theoretic notion of bijective map, or $1$-to-$1$-correspondence. We will see that a map is contractible if and only if it is an equivalence.

\subsection{Contractible types}

\begin{defn}
  We say that a type $A$ is \define{contractible} if it comes equipped with a term of type\index{is-cont(A)r@{$\iscontr(A)$}|see {contractible type}}
  \begin{equation*}
    \iscontr(A) \defeq \sm{c:A}\prd{x:A}c=x.
  \end{equation*}
  Given a term $(c,C):\iscontr(A)$, we call $c:A$ the \define{center of contraction}\index{center of contraction}\index{contractible type!center of contraction} of $A$, and we call $C:\prd{x:A}c=x$ the \define{contraction}\index{contraction}\index{contractible type!contraction} of $A$.
\end{defn}

\begin{rmk}
Suppose $A$ is a contractible type with center of contraction $c$ and contraction $C$. Then the type of $C$ is (judgmentally) equal to the type
\begin{equation*}
\const_c\htpy\idfunc[A].
\end{equation*}
In other words, the contraction $C$ is a \emph{homotopy} from the constant function to the identity function.
\end{rmk}

\begin{eg}
  The unit type is easily seen to be contractible.\index{unit type!is contractible}\index{is contractible!unit type} For the center of contraction we take $\ttt:\unit$. Then we define a contraction $\prd{x:\unit}\ttt=x$ by the induction principle of $\unit$. Applying the induction principle, it suffices to construct a term of type $\ttt = \ttt$, for which we just take $\refl{\ttt}$.
\end{eg}

\begin{defn}
  Suppose $A$ comes equipped with a term $a:A$. Then we say that $A$ satisfies \define{singleton induction}\index{singleton induction}\index{induction principle!singleton induction} if for every type family $B$ over $A$, the map\index{ev-pt@{$\evpt$}}
  \begin{equation*}
    \evpt:\Big(\prd{x:A}B(x)\Big)\to B(a)
  \end{equation*}
  defined by $\evpt(f)\defeq f(a)$ has a section. In other words, if $A$ satisfies singleton induction we have a function and a homotopy\index{sing-ind@{$\singind$}}\index{sing-comp@{$\singcomp$}}
  \begin{align*}
    \singind_{a} & : B(a)\to \prd{x:A}B(x) \\
    \singcomp_{a} & : \evpt\circ \singind_{a} \htpy \idfunc
  \end{align*}
  for any type family $B$ over $A$.
\end{defn}

\begin{eg}
  Note that the singleton induction principle is almost the same as the induction principle for the unit type, the difference being that the "computation rule" in the singleton induction for $A$ is stated using an \emph{identification} rather than as a judgmental equality. The unit type\index{unit type!singleton induction} $\unit$ comes equipped with a function
  \begin{equation*}
    \indunit:B(\ttt)\to \prd{x:\unit}B(x)
  \end{equation*}
  for every type family $B$ over $\unit$, satisfying the judgmental equality $\indunit(b,\ttt)\jdeq b$ for every $b:B(\ttt)$ by the computation rule. Thus we easily obtain the homotopy
  \begin{equation*}
    \lam{b}\refl{b}:\evpt\circ\indunit \htpy\idfunc,
  \end{equation*}
  and we conclude that the unit type satisfies singleton induction.
\end{eg}

\begin{thm}\label{thm:contractible}
Let $A$ be a type. The following are equivalent:\index{is contractible!iff singleton induction}\index{singleton induction!iff contractible}
\begin{enumerate}
\item The type $A$ is contractible.
\item The type $A$ comes equipped with a term $a:A$, and satisfies singleton induction.
\end{enumerate}
\end{thm}

\begin{proof}
Suppose $A$ is contractible with center of contraction $a$ and contraction $C$.
First we observe that, without loss of generality, we may assume that $C$ comes equipped with an identification $p:C(a)=\refl{a}$.
To see this, note that we can always define a new contraction $C'$ by
\begin{equation*}
C'(x)\defeq\ct{C(a)^{-1}}{C(x)},
\end{equation*}
which satisfies the requirement by the left inverse law, constructed in \cref{defn:id_invlaw}.

To show that $A$ satisfies singleton induction let $B$ be a type family over $A$, and suppose we have $b:B(a)$. Our goal is to define
\begin{equation*}
  \indsing_a(b):\prd{x:A}B(x).
\end{equation*}
Let $x:A$. Since we have an identification $C(x):a=x$, and a term $b$ in $B(a)$, we may transport $b$ along the path $C(x)$ to obtain
\begin{equation*}
  \indsing_a(b,x)\defeq \tr_B(C(x),b):B(x).
\end{equation*}
Therefore, the function $\indsing_a(b)$ is defined to be the dependent function $\lam{x}\tr_B(C(x),b)$. Now we have to show that $\indsing_a(b,a)=b$. Then we have the identifications
\begin{equation*}
\begin{tikzcd}
\tr_B(C(a),b) \arrow[r,equals,"\ap{\lam{\omega}\tr_B(\omega,b)}{p}"] &[4em] \tr_B(\refl{a},b) \arrow[r,equals,"\refl{b}"] & b.
\end{tikzcd}
\end{equation*}
This shows that the computation rule is satisfied, which completes the proof that $A$ satisfies singleton induction.

For the converse, suppose that $a:A$ and that $A$ satisfies singleton induction. Our goal is to show that $A$ is contractible. For the center of contraction we take the term $a:A$. By singleton induction applied to $B(x)\defeq a=x$ we have the map
\begin{equation*}
\indsing_{a} : a=a \to \prd{x:A}a=x.
\end{equation*}
Therefore $\indsing_{a}(\refl{a})$ is a contraction.
\end{proof}

\begin{thm}\label{thm:total_path}
For any $a:A$, the type
\begin{equation*}
\sm{x:A}a=x
\end{equation*}
is contractible.\index{identity type!total space is contractible}\index{is contractible!total space of identity type}
\end{thm}

\begin{proof}
  We will prove the statement by showing that $\sm{y:A}x=y$ satisfies singleton induction, and then use \cref{thm:contractible} to conclude that $\sm{x:A}a=x$ is contractible. We will use the term $(a,\refl{a}):\sm{x:A}a=x$ as the center of contraction.

  Now let $P$ be a type family over $\sm{x:A}a=x$. Note that we have a commuting triangle
  \begin{equation*}
    \begin{tikzcd}[column sep=0]
      \prd{t:\sm{x:A}a=x}P(t) \arrow[dr,swap,"\evpt"] \arrow[rr,"\evpair"] & & \prd{x:A}\prd{p:a=x}P(x,p) \arrow[dl,"\evrefl"] \\
      \phantom{\prd{x:A}\prd{p:a=x}P(x,p)} & P(a,\refl{a})
    \end{tikzcd}
  \end{equation*}
  where the maps $\evpair$ and $\evrefl$ are defined as
  \begin{align*}
    f & \mapsto \lam{x}\lam{p}f(x,p) \\
    g & \mapsto g(a,\refl{a}),
  \end{align*}
  respectively. By the induction principle for $\Sigma$-types it follows that $\evpair$ has a section, and by path induction it follows that $\evrefl$ has a section. Therefore it follows from \cref{ex:3_for_2} that the composite $\evpt$ has a section.
\end{proof}

\subsection{Contractible maps}

\index{contractible map|(}
\begin{defn}
  Let $f:A\to B$ be a function, and let $b:B$. The \define{fiber}\index{fiber}\index{homotopy fiber|see {fiber}} of $f$ at $b$ is defined to be the type\index{fib f b@{$\fib{f}{b}$}}
  \begin{equation*}
    \fib{f}{b}\defeq\sm{a:A}f(a)=b.
  \end{equation*}
\end{defn}

In other words, the fiber of $f$ at $b$ is the type of $a:A$ that get mapped by $f$ to $b$.
One may think of the fiber as a type theoretic version of the pre-image\index{pre-image|see {fiber}} of a point.

\index{fiber!characterization of identity type|(}
\index{characterization of identity type!fiber|(}
\index{identity type!of a fiber|(}
It will be useful to have a characterization of the identity type of a fiber, so we will make such a characterization immediately.

\begin{defn}
  Let $f:A \to B$ be a map, and let $(x,p),(x',p'):\fib{f}{y}$ for some $y:B$.
  Then we define\index{Eq fib@{$\Eqfib$}}\index{fiber!Eq fib@{$\Eqfib$}}
  \begin{equation*}
    \Eqfib_f((x,p),(x',p'))\defeq \sm{\alpha:x=x'}p=\ct{\ap{f}{\alpha}}{p'}
  \end{equation*}
  The relation $\Eqfib_f:\fib{f}{y}\to\fib{f}{y}\to\UU$ is a reflexive relation, since we have
  \begin{equation*}
    \lam{(x,p)}(\refl{x},\refl{p}):\prd{(x,p):\fib{f}{y}}\Eqfib_f((x,p),(x,p)).
  \end{equation*}
\end{defn}

\begin{lem}
  Consider a map $f:A\to B$ and let $y:B$. The canonical map
  \begin{equation*}
    ((x,p)=(x',p'))\to\Eqfib_f((x,p),(x',p'))
  \end{equation*}
  induced by the reflexivity of $\Eqfib_f$ is an equivalence for any $(x,p),(x',p'):\fib{f}{y}$.
\end{lem}

\begin{proof}
  The converse map
  \begin{equation*}
    \Eqfib_f((x,p),(x',p'))\to ((x,p)=(x',p'))
  \end{equation*}
  is easily defined by $\Sigma$-induction, and then path induction twice. The homotopies witnessing that this converse map is indeed a right inverse as well as a left inverse is similarly constructed by induction.
\end{proof}

\index{fiber!characterization of identity type|)}
\index{characterization of identity type!fiber|)}
\index{identity type!of a fiber|)}

Now we arrive at the notion of contractible map.

\begin{defn}
We say that a function $f:A\to B$ is \define{contractible} if there is a term of type\index{is-contr(f)@{$\iscontr(f)$}|see {contractible map}}\index{is a contractible map}
\begin{equation*}
\iscontr(f)\defeq\prd{b:B}\iscontr(\fib{f}{b}).
\end{equation*}
\end{defn}

\begin{thm}\label{thm:equiv_contr}
Any contractible map is an equivalence.\index{contractible map!is an equivalence}\index{is an equivalence!contractible map}
\end{thm}

\begin{proof}
Let $f:A\to B$ be a contractible map. Using the center of contraction of each $\fib{f}{y}$, we obtain a term of type
\begin{align*}
\lam{y}\pairr{g(y),G(y)}:\prd{y:B}\fib{f}{y}.
\end{align*}
Thus, we get map $g:B\to A$, and a homotopy $G:\prd{y:B} f(g(y))=y$. In other words, we get a section of $f$.

It remains to construct a retraction of $f$. Taking $g$ as our retraction, we have to show that $\prd{x:A} g(f(x))=x$. Note that we get an identification $p:f(g(f(x)))=f(x)$ since $g$ is a section of $f$. It follows that $(g(f(x)),p):\fib{f}{f(x)}$. Moreover, since $\fib{f}{f(x)}$ is contractible we get an identification $q:\pairr{g(f(x)),p}=\pairr{x,\refl{f(x)}}$. The base path $\ap{\proj 1}{q}$ of this identification is an identification of type $g(f(x))=x$, as desired.
\end{proof}

\subsection{Equivalences are contractible maps}

In \cref{thm:contr_equiv} we will show the converse to \cref{thm:equiv_contr}, i.e., we will show that any equivalence is a contractible map. We will do this in two steps.

First we introduce a new notion of \emph{coherently invertible map}, for which we can easily show that such maps have contractible fibers. Then we show that any equivalence is a coherently invertible map.

  Recall that an invertible map is a map $f:A\to B$ equipped with $g:B\to A$ and homotopies
  \begin{equation*}
    G : f\circ g \htpy \idfunc\qquad\text{and}\qquad H:g\circ f\htpy \idfunc.
  \end{equation*}
  Then we observe that both $G \cdot f$ and $f \cdot H$ are homotopies of the same type
  \begin{equation*}
    f\circ g\circ f \htpy f.
  \end{equation*}
  A coherently invertible map is an invertible map for which there is a further homotopy $G \cdot f\htpy f\cdot H$.

  \begin{defn}
    Consider a map $f:A\to B$. We say that $f$ is \define{coherently invertible}\index{coherently invertible map} if it comes equipped with
    \begin{align*}
      g & : B \to A \\
      G & : f \circ g \htpy \idfunc \\
      H & : g \circ f \htpy \idfunc \\
      K & : G \cdot f \htpy f \cdot H.
    \end{align*}
    We will write $\iscohinvertible(f)$\index{is-coh-invertible(f)@{$\iscohinvertible(f)$}} for the type of quadruples $(g,G,H,K)$.
  \end{defn}

  Although we will encounter the notion of coherently invertible map on some further occasions, the following lemma is our main motivation for considering it.

  \begin{lem}\label{lem:contr-inv}
    Any coherently invertible map has contractible fibers.\index{coherently invertible map!is a contractible map}
  \end{lem}

  \begin{proof}
    Consider a map $f:A\to B$ equipped with
    \begin{align*}
      g & : B \to A \\
      G & : f \circ g \htpy \idfunc \\
      H & : g \circ f \htpy \idfunc \\
      K & : G \cdot f \htpy f \cdot H,
    \end{align*}
    and let $y:B$. Our goal is to show that $\fib{f}{y}$ is contractible. For the center of contraction we take $(g(y),G(y))$. In order to construct a contraction, it suffices to construct a term of type
    \begin{equation*}
      \prd{x:A}\prd{p:f(x)=y}\Eqfib_f((g(y),G(y)),(x,p)).
    \end{equation*}
    By path induction on $p:f(x)=y$ it suffices to construct a term of type
    \begin{equation*}
      \prd{x:A}\Eqfib_f((g(f(x)),G(f(x))),(x,\refl{f(x)})).
    \end{equation*}
    By definition of $\Eqfib_f$, we have to construct a term of type
    \begin{equation*}
      \prd{x:A}\sm{\alpha:g(f(x))=x}G(f(x))=\ct{\ap{f}{\alpha}}{\refl{f(x)}}.
    \end{equation*}
    Such a term is constructed as $\lam{x}(H(x),K'(x))$, where the homotopy $H:g\circ f\htpy \idfunc$ is given by assumption, and the homotopy
    \begin{align*}
      K' & : \prd{x:A}G(f(x))=\ct{\ap{f}{H(x)}}{\refl{f(x)}}
    \end{align*}
    is defined as
    \begin{equation*}
      K'\defeq \ct{K}{\rightunithtpy(f\cdot H)^{-1}}.\qedhere
    \end{equation*}
  \end{proof}

  Our next goal is to show that for any map $f:A\to B$ equipped with
  \begin{equation*}
    g:B\to A,\qquad G:f\circ g \htpy \idfunc,\qquad\text{and}\qquad H:g\circ f\htpy \idfunc,
  \end{equation*}
  we can improve the homotopy $G$ to a new homotopy $G':f\circ g\htpy \idfunc$ for which there is a further homotopy
  \begin{equation*}
    f\cdot H\htpy G'\cdot f.
  \end{equation*}
  Note that this situation is analogous to the situation in the proof of \cref{thm:contractible}, where we improved the contraction $C$ so that it satisfied $C(c)=\refl{}$. The extra coherence $f\cdot H\htpy G'\cdot f$ is then used in the proof that the fibers of an equivalence are contractible.

\begin{defn}\label{defn:htpy_nat}\index{homotopy!naturality}
Let $f,g:A\to B$ be functions, and consider $H:f\htpy g$ and $p:x=y$ in $A$. We define the identification\index{nat-nat@{$\nathtpy$}}\index{homotopy!nat-htpy@{$\nathtpy$}}
\begin{equation*}
\nathtpy(H,p) \defeq  \ct{\ap{f}{p}}{H(y)}=\ct{H(x)}{\ap{g}{p}}
\end{equation*}
witnessing that the square
\begin{equation*}
\begin{tikzcd}
f(x) \arrow[r,equals,"H(x)"] \arrow[d,equals,swap,"\ap{f}{p}"] & g(x) \arrow[d,equals,"\ap{g}{p}"] \\
f(y) \arrow[r,equals,swap,"H(y)"] & g(y)
\end{tikzcd}
\end{equation*}
commutes. This square is also called the \define{naturality square}\index{naturality square of homotopies} of the homotopy $H$ at $p$.
\end{defn}

\begin{constr}
  By path induction on $p$ it suffices to construct an identification
  \begin{equation*}
    \ct{\ap{f}{\refl{x}}}{H(x)}=\ct{H(x)}{\ap{g}{\refl{x}}}
  \end{equation*}
  since $\ap{f}{\refl{x}}\jdeq \refl{f(x)}$ and $\ap{g}{\refl{x}}\jdeq\refl{g(x)}$, and since $\ct{\refl{f(x)}}{H(x)}\jdeq H(x)$, we see that the path $\rightunit(H(x))^{-1}$ is of the asserted type.
\end{constr}

\begin{defn}\label{defn:retraction_swap}
Consider $f:A\to A$ and $H: f\htpy \idfunc[A]$. We construct an identification $H(f(x))=\ap{f}{H(x)}$, for any $x:A$.
\end{defn}

\begin{constr}
By the naturality of homotopies with respect to identifications the square
\begin{equation*}
\begin{tikzcd}[column sep=large]
ff(x) \arrow[d,swap,equals,"\ap{f}{H(x)}"] \arrow[r,equals,"H(f(x))"] & f(x) \arrow[d,equals,"H(x)"] \\
f(x) \arrow[r,swap,equals,"H(x)"] & x
\end{tikzcd}
\end{equation*}
commutes. This gives the desired identification $H(f(x))=\ap{f}{H(x)}$.
\end{constr}

\begin{lem}\label{lem:coherently-invertible}
  Let $f:A\to B$ be a map, and consider $(g,G,H):\hasinverse(f)$. Then there is a homotopy $G':f\circ g\htpy \idfunc$ equipped with a further homotopy
  \begin{equation*}
    K : G'\cdot f \htpy f\cdot H.
  \end{equation*}
  Thus we obtain a map $\hasinverse(f)\to\iscohinvertible(f)$.
\end{lem}

\begin{proof}
  For each $y:B$, we construct the identification $G'(y)$ as the concatenation
  \begin{equation*}
    \begin{tikzcd}
      fg(y) \arrow[r,equals,"{G(fg(y))}^{-1}"] &[2.5em] fgfg(y) \arrow[r,equals,"\ap{f}{H(g(y))}"] &[2.5em] fg(y) \arrow[r,equals,"G(y)"] & y.
\end{tikzcd}
  \end{equation*}
  In order to construct a homotopy $G'\cdot f\htpy f\cdot H$, it suffices to show that the square
  \begin{equation*}
    \begin{tikzcd}[column sep=8em]
      fgfgf(x) \arrow[r,equals,"{G(fgf(x))}"] \arrow[d,equals,swap,"\ap{f}{H(gf(x))}"] & fgf(x) \arrow[d,equals,"\ap{f}{H(x)}"] \\
      fgf(x) \arrow[r,equals,swap,"G(f(x))"] & f(x)
    \end{tikzcd}
  \end{equation*}
  commutes for every $x:A$.
  Recall from \cref{defn:retraction_swap} that we have $H(gf(x))=\ap{gf}{H(x)}$. Using this identification, we see that it suffices to show that the square
  \begin{equation*}
    \begin{tikzcd}[column sep=8em]
      fgfgf(x) \arrow[r,equals,"G(fgf(x))"] \arrow[d,equals,swap,"\ap{fgf}{H(x)}"] & fgf(x) \arrow[d,equals,"\ap{f}{H(x)}"] \\
      fgf(x) \arrow[r,equals,swap,"G(f(x))"] & f(x)
    \end{tikzcd}
  \end{equation*}
  commutes. Now we observe that this is just a naturality square the homotopy $Gf:fgf\htpy f$, which commutes by \cref{defn:htpy_nat}.
\end{proof}

Now we put the pieces together to conclude that any equivalence has contractible fibers.

\begin{thm}\label{thm:contr_equiv}
Any equivalence is a contractible map.\index{equivalence!is a contractible map}\index{is a contractible map!equivalence}\index{is contractible!fiber of an equivalence}
\end{thm}

\begin{proof}
  We have seen in \cref{lem:contr-inv} that any coherently invertible map is a contractible map. Moreover, any equivalence has the structure of an invertible map by \cref{lem:inv_equiv}, and any invertible map is coherently invertible by \cref{lem:coherently-invertible}.
\end{proof}

\begin{cor}\label{cor:contr_path}
Let $A$ be a type, and let $a:A$. Then the type\index{is contractible!total space of opposite identity type}
\begin{equation*}
\sm{x:A}x=a
\end{equation*}
is contractible.
\end{cor}

\begin{proof}
By \cref{thm:id_equiv}, the identity function is an equivalence. Therefore, the fibers of the identity function are contractible by \cref{thm:contr_equiv}. Note that $\sm{x:A}x=a$ is exactly the fiber of $\idfunc[A]$ at $a:A$.
\end{proof}
\index{contractible map|)}

\begin{exercises}
\exercise \label{ex:prop_contr}Show that if $A$ is contractible, then for any $x,y:A$ the identity type $x=y$ is also contractible.\index{contractible type!identity types of}\index{is contractible!identity type of contractible type}\index{identity type!of contractible type}\index{characterization of identity type!contractible type}
\exercise \label{ex:contr_retr}Suppose that $A$ is a retract of $B$. Show that\index{contractible type!closed under retracts}
  \begin{equation*}
    \iscontr(B)\to\iscontr(A).
  \end{equation*}
\exercise \label{ex:contr_equiv}
  \begin{subexenum}
  \item Show that for any type $A$, the map $\const_\ttt : A\to \unit$ is an equivalence if and only if $A$ is contractible.\index{contractible type!is equivalent to 1@{is equivalent to $\unit$}}
  \item Apply \cref{ex:3_for_2} to show that for any map $f:A\to B$, if any two of the three assertions\index{contractible type!3-for-2 property}\index{3-for-2 property!of contractible types}
    \begin{enumerate}
    \item $A$ is contractible
    \item $B$ is contractible
    \item $f$ is an equivalence
    \end{enumerate}
    hold, then so does the third.
  \end{subexenum}
\exercise Show that for any two types $A$ and $B$, the following are equivalent:
  \index{contractible type!closed under cartesian product}
  \index{is contractible!factor of contractible cartesian product}
  \begin{enumerate}
  \item Both $A$ and $B$ are contractible.
  \item The type $A\times B$ is contractible.
  \end{enumerate}
\exercise \label{ex:contr_in_sigma} Let $A$ be a contractible type with center of contraction $a:A$. Furthermore, let $B$ be a type family over $A$. Show that the map $y\mapsto\pairr{a,y}:B(a)\to\sm{x:A}B(x)$ is an equivalence.\index{left unit law!of Sigma-types@{of $\Sigma$-types}}\index{dependent pair type!left unit law}
\exercise \label{ex:proj_fiber}Let $B$ be a family of types over $A$, and consider the projection map
  \begin{equation*}
    \proj 1 : \big(\sm{x:A}B(x)\big)\to A.
  \end{equation*}
  Show that for any $a:A$, the map
  \begin{equation*}
    \lam{((x,y),p)} \tr_B(p,y) : \fib{\proj 1}{a} \to B(a),
  \end{equation*}
  is an equivalence. Conclude that $\proj 1$ is an equivalence if and only if each $B(a)$ is contractible.
  \index{family!fibers of projection map}
  \index{pr 1@{$\proj 1$}!of contractible family is an equivalence}
  \index{is an equivalence!pr 1 of contractible family@{$\proj 1$ of contractible family}}
\exercise \label{ex:fib_replacement}Construct for any map $f:A\to B$ an equivalence $e:\eqv{A}{\sm{y:B}\fib{f}{y}}$ and a homotopy $H:f\htpy \proj 1\circ e$ witnessing that the triangle
  \begin{equation*}
    \begin{tikzcd}[column sep=0em]
      A \arrow[rr,"e"] \arrow[dr,swap,"f"] & & \sm{y:B}\fib{f}{y} \arrow[dl,"\proj 1"] \\
      \phantom{\sm{y:B}\fib{f}{y}} & B
    \end{tikzcd}
  \end{equation*}
  commutes. The projection $\proj 1 : (\sm{y:B}\fib{f}{y})\to B$ is sometimes also called the \define{fibrant replacement}\index{fibrant replacement} of $f$, because first projection maps are fibrations in the homotopy interpretation of type theory.
\end{exercises}
\index{contractible type|)}


% This LaTeX was auto-generated from an M-file by MATLAB.
% To make changes, update the M-file and republish this document.

%%% \documentclass{article}
%%% \usepackage{graphicx}
%%% \usepackage{color}

%%% \sloppy
%%% \definecolor{lightgray}{gray}{0.5}
\setlength{\parindent}{0pt}

%%% \begin{document}

\subsection*{Spurious Free Dynamic Range by means of Fast fourier transform}

\begin{par}
Example for algorithm SFDR.
\end{par} \vspace{1em}
\begin{par}
Calculates SFDR by calculating FFT spectrum.
\end{par} \vspace{1em}

\subsubsection*{Contents}

\begin{itemize}
\setlength{\itemsep}{-1ex}
   \item Generate sample data
   \item Call algorithm
   \item Display results
\end{itemize}

\subsubsection*{Generate sample data}

\begin{par}
First quantity \lstinline{y} representing 1 second of signal containing spurious component is prepared. Main signal component has nominal frequency 1 kHz, nominal amplitude 2 V, nominal phase 1 rad and offset 1 V sampled at sampling frequency 10 kHz.
\end{par} \vspace{1em}
\begin{lstlisting}[style=mcode]
DI = [];
fsnom = 1e4; Anom = 4; fnom = 100; phnom = 1; Onom = 0.2;
t = [0:1/fsnom:1-1/fsnom];
DI.y.v = Anom*sin(2*pi*fnom*t + phnom);
\end{lstlisting}
\begin{par}
A spurious component with amplitude at 1/100 of main carrier frequency is added. Thus by definition the SFDR in dBc has to be 40.
\end{par} \vspace{1em}
\begin{lstlisting}[style=mcode]
DI.y.v = DI.y.v + Anom./100*sin(2*pi*fnom*3.5*t + phnom);
\end{lstlisting}

\subsubsection*{Call algorithm}

\begin{par}
Use QWTB to apply algorithm \lstinline{SFDR} to data \lstinline{DI}.
\end{par} \vspace{1em}
\begin{lstlisting}[style=mcode]
DO = qwtb('SFDR', DI);
\end{lstlisting}

        \begin{lstlisting}[style=output]
QWTB: no uncertainty calculation
\end{lstlisting} \color{black}

\subsubsection*{Display results}

\begin{par}
Result is the SFDR (dBc).
\end{par} \vspace{1em}
\begin{lstlisting}[style=mcode]
SFDR = DO.SFDRdBc.v
\end{lstlisting}

        \begin{lstlisting}[style=output]

SFDR =

   40.0000

\end{lstlisting} \color{black}

%%% \end{document}


\documentclass[11pt]{article}

\input{preamble.tex}

\begin{document}

    % \maketitle

    \hypertarget{smooth-manifolds-made-concrete-for-dumbasses}{%
\section{Smooth Manifolds made Concrete for Dumbasses}\label{smooth-manifolds-made-concrete-for-dumbasses}}

The intention behind this document is to provide an extended and comprehensive example of a smooth
manifold for dumbasses like me who can't always grok the heavily abstract without a more concrete
example, or as the OO framework types would say, a reification. The extended example is the
prototypical/canonical stereographic projection considering the sphere \(S^2\) as a manifold.
Examples cover deriving the charts, finding the inverses functions between manifolds including
deriving an ellipsoid stereographic manifold, and tangent spaces including both equivalence classes
of curves and derivation based approaches, illustrating proofs of vector space closure and change
of basis of tangent vectors. The examples are based on using the open source
\href{https://www.sagemath.org/}{SageMath} Computer Algebra System (CAS) to create an interactive
notebook. Sage is available on most Linux distributions and the web site also has a Windows
installer. The notebook has also been converted to a Latex/SageTex document which hides most of
the Sage specific manipulation and shows just the mathematics for those who aren't interested in
Sage (although you lose the ability to interact with the content including the graphs).
Note Sage does have
\href{http://doc.sagemath.org/html/en/reference/manifolds/sage/manifolds/differentiable/manifold.html}{built in Manifold}
support, but this document won't be using it as the intention is to provide examples from first principles.
Errors or misunderstandings on my part or also more than likely as I am a computer scientist who dabbles in mathematics,
for Computer Vision, Machine Learning and Neural Networks, therefore any error corrections or suggestions
for improvements would also be welcome.

\begin{sagesilent}
clear_vars()

def stereographic(pole):
    o_n = vector(SR, pole)
    var('x', 'y', 'z', 'u', 'v', 'l')
    assume(x, 'real', y, 'real', z, 'real', u, 'real', v, 'real', l, 'real')
#     p = vector(SR, (x, y, sqrt(x^2 + y^2)))
    p = vector(SR, (x, y, z))
    s = vector(SR, (u, v, 0))
    lhs = o_n - p
    rhs = l*(o_n - s)
    eq1 = lhs[0] == rhs[0]
    eq2 = lhs[1] == rhs[1]
    eq3 = lhs[2] == rhs[2]
    l_s = solve(eq3, l)[0].rhs()
    return (solve(eq1.substitute(l=l_s), u)[0], solve(eq2.substitute(l=l_s), v)[0])

def the_solution(sols, submap):
    for sol in sols:
        if sol.rhs().substitute(submap) != 0:
            return sol
    return None

o_n = vector(SR, (0,0,1))
var('x', 'y', 'z', 'u', 'v', 'l')
assume(x, 'real', y, 'real', z, 'real', u, 'real', v, 'real', l, 'real')
p = vector(SR, (x, y, z))
s = vector(SR, (u, v, 0))
lhs = o_n - p
rhs = l*(o_n - s)
eq1 = lhs[0] == rhs[0]
eq2 = lhs[1] == rhs[1]
eq3 = lhs[2] == rhs[2]
\end{sagesilent}

\hypertarget{the-stereographic-projection-atlas}{%
\subsection{The Stereographic Projection
Atlas}\label{the-stereographic-projection-atlas}}

The sterographic projection is the canonical example for a
topological/smooth manifold. The example shown here will map \(S^2\) to
\(R^2\), although it can be extended to \(S^n \rightarrow R^n\).

The sphere \(S^2\) is seen as a manifold having an atlas with two open
sets and associated charts. The first chart is defined on the open set
defined by the full sphere excluding the north (top) pole \((0,0,1)\),
while the second chart is defined on a set that excludes only the south
(bottom) \((0,0,1)\) pole. Both charts project a point on the sphere
surface to the plane at \(z=0\) by extending a line from the excluded
pole through the point on the manifold (sphere) being charted onto the
plane.

To derive the chart equation let \(\vec{o_n} = (0, 0, 1)\),
\(\vec{p_n} = (x, y, z)\) be a point on the sphere and
\(\vec{s_n} = (u, v, 0)\) be the projection then (see the figure below):

\(\vec{o_n} - \vec{p_n} = l(\vec{o_n} - \vec{s_n}\))
which evaluates to: $\sage{lhs} = \sage{rhs}$

    Solving for the third component of the vector equation and substituting
into the first two:

\begin{sagesilent}
sol1 = solve(eq3, l)[0]
sol2 = solve(eq1, u)[0], solve(eq2, v)[0]
\end{sagesilent}
\begin{align*}
    \sage{sol1} \\
    \sage{sol2}
\end{align*}

\begin{sagesilent}
On = (0, 0, 1)
Os = (0, 0, -1)
Cn = stereographic(On)
Cs = stereographic(Os)
cn_0 = Cn[0].rhs()
cn_1 = Cn[1].rhs()
cs_0 = Cs[0].rhs()
cs_1 = Cs[1].rhs()
\end{sagesilent}

    \(\therefore\) the charts with chart coordinates given by \(u\) and \(v\) are given by.

North pole:\\

$(\sage{cn_0}, \sage{cn_1})$

    South pole:\\

    $(\sage{cn_0}, \sage{cn_1})$

    \hypertarget{visualization}{%
\subsection{Visualization}\label{visualization}}

To visualize the manifold and charts see Figure \ref{fig:stereo1} which demonstrates manifold points
\((\frac{1}{2}, \frac{1}{2},\frac{1}{\sqrt{2}})\) and \((\frac{1}{2}, \frac{1}{2},-\frac{1}{\sqrt{2}})\)
projected to the plane z = 0 (it does look a lot better in the original Jupyter notebook):

\begin{sagesilent}
from sage.plot.plot3d.shapes2 import Line
def to_float(v): # Temp fix to convert to float from Sage type (see https://trac.sagemath.org/ticket/28949) for Sage 9
    vv = [None] * len(v)
    for i in range(0, len(v)):
        vv[i] = float(v[i])
    return vv
twosq = 1/1.4142
Pn = (0.5, 0.5, twosq)
Ps = (0.5, 0.5, -twosq)
Sn = sphere(center=(0, 0, 0),size=1, color='green', aspect_ratio=[1,1,1], opacity=5/10)
Fn = plot3d(lambda x, y: 0, (-2,2), (-2,2))
on = point(On, rgbcolor=(1,0,0), size=20)
os = point(Os, rgbcolor=(0,0,0), size=20)
pn = point(Pn, rgbcolor=(1,0,0), size=20)
tpn = text3d('  (%.2f,%.2f,%.2f)'%(Pn[0], Pn[1], Pn[2]), (Pn[0], Pn[1], Pn[2]+0.2), horizontal_alignment='left',color='red', fonsize='x-small')
ps = point(Ps, rgbcolor=(0,0,0), size=20)
tps = text3d('  (%.2f,%.2f,%.2f)'%(Ps[0], Ps[1], Ps[2]), (Ps[0], Ps[1], Ps[2]-0.2), horizontal_alignment='left',color='black', fonsize='x-small')
Bn = (Cn[0].substitute({x:Pn[0], z:Pn[2]}).rhs(), Cn[1].substitute({y:Pn[1], z:Pn[2]}).rhs(), 0)
bn = point(Bn, rgbcolor=(0,0,0), size=20)
tbn = text3d('  (%.2f,%.2f)'%(Bn[0], Bn[1]), (Bn[0], Bn[1]+0.6, 0.2), horizontal_alignment='left',color='red', fonsize='x-small')
Bs = (Cs[0].substitute({x:Ps[0], z:Ps[2]}).rhs(), Cs[1].substitute({y:Ps[1], z:Ps[2]}).rhs(), 0)
bs = point(Bs, rgbcolor=(0,0,0), size=20)
#Ln = Line([On, Pn, Bn], color='red')
#Ls = Line([Os, Ps, Bs], color='black')
Ln = Line([to_float(On), to_float(Pn), to_float(Bn)], color='red')
Ls = Line([to_float(Os), to_float(Ps), to_float(Bs)], color='black')
#show(Sn+Fn+on+pn+tpn+bn+tbn+os+ps+tps+bs+Ln+Ls, figsize=8)
save(Sn+Fn+on+pn+tpn+bn+tbn+os+ps+tps+bs+Line([On, Pn, Bn], color='red')+Line([Os, Ps, Bs], color='black'), "stereo1.png")
\end{sagesilent}

\begin{figure}[ht]
    \centering
    \includegraphics[width=0.95\textwidth,keepaspectratio]{stereo1.png}
    \caption{Visualization of stereographic projection.}
    \label{fig:stereo1}
 \end{figure}

    \hypertarget{chart-inverses}{%
\subsection{Chart Inverses}\label{chart-inverses}}
\begin{sagesilent}
var('x', 'y', 'z', 'u', 'v', 'l')
assume(x, 'real', y, 'real', z, 'real', u, 'real', v, 'real', l, 'real')
o_n = vector(SR, On)
uv = vector(SR, (u, v, 0))
d = (o_n - uv).normalized()
Ln = o_n + d*l
\end{sagesilent}

The above charts are bijective and continuous within the domain
\(S^2 - (0, 0, 1), S^2 - (0, 0, -1)\) and codomain \((u, v) \in R^2\),
however to be valid charts they must also be bicontinuous, ie the
inverse must be continuous too, that is they must be homeomorphic to
\(R^2\).

To find the inverse first find the unit vector in the direction of the
line joining the pole to the projected coordinates, for example
\(\vec{d} = \frac{((0, 0, 1) - (u, v, 0))}{|(0, 0, 1) - (u, v, 0))|}\) = $\sage{d}$.

    Now express the line from the pole to the projection as a vector
equation:\\
\((0, 0, 1) + l \vec{d}\) = $\sage{Ln}$

\begin{sagesilent}
c_o = vector(SR, (0, 0, 0))
eq4 = (Ln - c_o).dot_product(Ln - c_o) == 1
sols = solve(eq4, l)
solution = the_solution(sols, {u:1, v:1})
In = (Ln - c_o).substitute(l=solution.rhs())
pretty_print(In)
cn_ix = In[0]
cn_iy = In[1]
cn_iz = In[2]
\end{sagesilent}

    The intersection of this line with the sphere occurs where
\(|(0, 0, 1) + l\vec{d} - (0, 0, 0)| = 1\), or more generally
\(|(0, 0, 1) + l\vec{d} - \vec{c}| = r\) where \(\vec{c}\) is the sphere
centre and r is the radius. This can also be expressed as
\([(0, 0, 1) + l\vec{d} - (0, 0, 0)] \cdot [(0, 0, 1) + l\vec{d} - (0, 0, 0)] = r\):\\
$\sage{eq4}$

    This quadratic will have one solution for \(l = 0\) at the pole. The
other solution will be the required \((x, y, z)\) on the sphere
manifold. Letting Sage do the PT:\\
% \begin{tcolorbox}
% sols = solve(eq4, l)\\
% \end{tcolorbox}
$\sage{sols}$

    and substituting the appropriate \(l\) back into the line equation:\\
 $\sage{In}$

    See also the
\href{https://en.wikipedia.org/wiki/Line\%E2\%80\%93sphere_intersection}{Wikipeadia}
page on sphere-line intersection (note their notation swops \(\vec{d}\)
and \(l\) as used in the above).

\begin{sagesilent}
o_s = vector(SR, Os)
d = (o_s - uv).normalized()
Ls = o_s + d*l
eq5 = (Ls - c_o).dot_product(Ls - c_o) == 1
sols = solve(eq5, l)
solution = the_solution(sols, {u:1, v:1})
Is = (Ls - c_o).substitute(l=solution.rhs())
cs_ix = Is[0]
cs_iy = Is[1]
cs_iz = Is[2]
\end{sagesilent}

    Similarly the inverse for the south pole chart is given by (it could
probably also be derived by symmetry):\\
$\sage{Is}$

    \hypertarget{verifying-the-charts}{%
\subsection{Verifying the Charts}\label{verifying-the-charts}}
\begin{sagesilent}
    uu = cs_0.substitute({x: cn_ix, z: cn_iz}).full_simplify()
    vv = cs_1.substitute({y: cn_iy, z: cn_iz}).full_simplify()
    pretty_print("(", uu, ", ", vv, ")")
\end{sagesilent}

    The two charts described above are homeomorphic and are also
differentiable with a differentiable inverse, therefore they are
diffeomorphic too. Assume the charts are named \(c_n\) and \(c_s\), then
to verify the two charts define a compatible atlas it is required that
the intersection of their domain open sets be empty ie
\(S^2 - (0, 0, 1) \cap S^2 - (0, 0, -1) = \emptyset,\) (definitely not
the case) or
\(c_s \circ c_n^{-1} : c_n(S^2 - (0, 0, 1) \cap S^2 - (0, 0, -1)) \rightarrow c_s(S^2 - (0, 0, 1) \cap S^2 - (0, 0, -1))\)
and the opposite (\(c_n \circ c_s^{-1}\)) is diffeomorphic. After
performing the composition we get:\\
$(\sage{uu}, \sage{vv})$

    which is homeomorphic and smooth over the specified domain.

    \hypertarget{smooth-functions-between-manifolds}{%
\subsection{Smooth Functions between
Manifolds}\label{smooth-functions-between-manifolds}}

A smooth map \(F: M \rightarrow N\) can be described \parencite{lee} as
\say{if for every \(p \in M\), there exist smooth charts
\((U, \phi)\) containing \(p\) and \((V, \psi)\) containing \(F(p)\)
such that \(F(U) \subseteq V\) and the composite map
\(\psi \circ F \circ \phi^{-1}\) is smooth from \(\phi(U)\) to
\(\psi(V)\)}.

We will start by defining a manifold E on an ellipsoid to use as the
destination manifold corresponding to N above for the map. U will then
correspond to either \(S^2 - (0, 0, 1)\) or \(S^2 - (0, 0, -1)\)
depending on the source chart selection. N will similarly correspond to
\(E - (0, 0, 1)\) or \(E - (0, 0, -1)\). Because E uses $ (0, 0, 1)$
and $(0, 0, -1)$ the a and b ellipse axes are arbitarily defined but
\(c = 1\) (the z semi-axis) to ensure that the poles are at
\((0, 0, 1)\) and \((0, 0, -1)\).

\hypertarget{the-ellipsoid-as-a-stereographical-manifold}{%
\subsubsection{The Ellipsoid as a Stereographical Manifold}\label{the-ellipsoid-as-a-stereographical-manifold}}
\begin{sagesilent}
en_0 = cn_0
en_1 = cn_1
es_0 = cs_0
es_1 = cs_1
var('x', 'y', 'z', 'u', 'v', 'l', 'a', 'b', 'c')
assume(x, 'real', y, 'real', z, 'real', u, 'real', v, 'real', l, 'real', a, 'real', b, 'real', c, 'real')
o_n = vector(SR, (0, 0, 1))
uv = vector(SR, (u, v, 0))
d = (o_n - uv).normalized()
Ln = o_n + d*l - vector(SR, (0, 0, 0))
\end{sagesilent}

The chart map from the ellipsoid to \(R^2\) can be derived similarly to
the sphere,resulting in \(u=-\frac{x}{z-1}, v=-\frac{y}{z-1}\) for the
north chart and \(u=\frac{x}{z+1}, v=\frac{y}{z+1}\), but with \(z\)
calculated for the ellipse. The inverse is a little more problematic
however. As with the sphere start by describing the line from the pole
to the projection in terms of a unit vector pointing in the direction of
the line:
\begin{equation}
\label{eq:ellipsoid-line}
\scriptstyle
L = (0, 0, 1) + l \frac{(0, 0, 1) - (u, v, 0)}{|(0, 0, 1) - (u, v, 0)|} = \sage{Ln}
\end{equation}

    Recall that a vector equation for an ellipsoid can be
\href{https://en.wikipedia.org/wiki/Ellipsoid\#In_general_position}{defined}
as \((\mathbf{x}-\mathbf{o})^{\mathrm{T}} A(\mathbf{x}-\mathbf{o})=1\)
where \(0\) is the origin coordinates and A is a positive definite
matrix which in the general case may include rotation, but in our case
contains only the ellipsoid axes:\\
\begin{sagesilent}
A = matrix(SR, 3, 3, [1/a^2, 0, 0,  0, 1/b^2, 0,   0, 0, 1]) # c = 1 to make (0,0,1) possible
el = Ln.row()*A*Ln
eq1 = el[0] == 1
sols = solve(eq1, l)
\end{sagesilent}
$\sage{A}$

The ellipsoid equation is then \(L^T A L\):\\
$\sage{eq1}$

with two solutions again with one at 0 corresponding to the pole:\\
$\sage{sols}$

Substituting back into \(L\) (Equation \ref{eq:ellipsoid-line}):\\
\begin{sagesilent}
solution = the_solution(sols, {u:1, v:1, a:1, b:1})
EIn = Ln.substitute(l=solution.rhs())
en_ix = EIn[0]
en_iy = EIn[1]
en_iz = EIn[2]

o_s = vector(SR, (0, 0, -1))
d = (o_s - uv).normalized()
Ls = o_s + d*l - vector(SR, (0, 0, 0))
el = Ls.row()*A*Ls
eq1 = el[0] == 1
sols = solve(eq1, l)
solution = the_solution(sols, {u:1, v:1, a:1, b:1})
EIs = Ls.substitute(l=solution.rhs())
es_ix = EIs[0]
es_iy = EIs[1]
es_iz = EIs[2]
\end{sagesilent}
$\sage{EIn}$

Similarly for the south pole we get:\\
$\sage{EIs}$

    \hypertarget{defining-the-inter-manifold-function}{%
\subsection{Defining the Inter-Manifold
Function}\label{defining-the-inter-manifold-function}}
\begin{sagesilent}
T = matrix(SR, 3, 3, [a, 0, 0,  0, b, 0,   0, 0, 1])
ev = vector(SR, (x, y, sqrt(1 - x^2 - y^2)))
F = T*ev
Fx = F[0]
Fy = F[1]
Fz = F[2]
Ellips = F.substitute({x: cn_ix, y: cn_iy})
# pretty_print(Ellips)
f1 = en_0.substitute({x:Ellips[0], z:Ellips[2]}).full_simplify()
f2 = en_1.substitute({y:Ellips[1], z:Ellips[2]}).full_simplify()
\end{sagesilent}

A linear transformation applied to a sphere results in an ellipse. In
this case we use a linear transformation matrix:\\
$\sage{T}$

Applied to $\sage{ev}$  resulting in \(F: S \rightarrow E\) where S is the sphere manifold and E
is the ellipsoid one:\\
$F = \sage{F}$

    Let the ellipse chart be \((V, e_n): V \subset E\) (or
\((V, e_s): V \subset E\)) and the sphere chart be
\((U, s_n): U \subset S\) (or \((U, s_s): U \subset S\)), then

\(e_n \circ F \circ s_n^{-1}[s_n(U)]\)

should be a smooth function from \(R^2\) (the stereographic projection
coordinates for the sphere) to \(R^2\) (the stereographic projection
coordinates for the ellipse) (its probably best to take Sage's word for
it unless you \textbf{really} enjoy Algebra):\\
$\Bigg(\sage{f1}, \sage{f2}\Bigg)$

    \hypertarget{tangent-vectors-and-spaces}{%
\subsection{Tangent Vectors and
Spaces}\label{tangent-vectors-and-spaces}}

Confusingly there are three different approaches to defining tangent
spaces on manifolds \parencite{montgomery}. These examples will
cover the geometrically based curve approach and the more algebraic
derivation approach.

\subsubsection{Tangent Spaces defined as Equivalence class of Curves}
 This approach starts with a curve with a domain on an
interval of \(R^1\) and the manifold \(M\) as the co-domain i.e
\(\lambda: I \subset R^1 \rightarrow M\). The simplest approach combines the
co-domain of the curve with a chart map to define curves as being
tangent at a point \(p\) if \parencite[see][pp. 73]{isham}:
\begin{enumerate}
    \item Values on the manifold correspond ie \(\lambda_{1}(t_0) = \lambda_{2}(t_1) = p\),
    \item The velocities at the point in a chart are the same ie
    \((c_n \circ \lambda_{1})^\prime\lvert_{t=t_0} = (c_n \circ \lambda_{2})^\prime\lvert_{t=t_1}\)
\end{enumerate}

The curve used in the example is a spiral on \(S^2\) (from
\href{https://math.stackexchange.com/questions/140541/finding-parametric-curves-on-a-sphere}{math.stackexchange})

\(\lambda_1 = (x, y, z): (\sqrt{1-t^{2}} \cos (a \pi t), \sqrt{1-t^{2}} \sin (a \pi t), t)\)

To find the geometric tangent vector at a point we use the north pole
chart to project a point from the manifold specified by the curve to the
\(R^2\) Euclidean space of the stereographic projection:\\
\begin{sagesilent}
var('s', 't', 'p_4', 'a', 'pt')
a = 3
pt = 4/5
p_4 = pi/a
K_1 = (sqrt(1-t*t)*cos(7*pi*t), sqrt(1-t*t)*sin(7*pi*t), t)
T1 = vector(SR, (cn_0.substitute({x:K_1[0], z:K_1[2]}), cn_1.substitute({y:K_1[1], z:K_1[2]})))
V = T1.diff(t)
\end{sagesilent}
As a reminder, the north chart: $(\sage{cn_0}, \sage{cn_1})$\\
$(c_n \circ \lambda_1) = \sage{T1}$

Next we differentiate the above to get the tangent vector:\\
$\scriptstyle \sage{V}$

Next to find another tangent vector with the necessary properties
(having the same value in the manifold at \(t\) and equal velocity
(derivitive) in the chart), we find the inverse of the tangent line in
the chart which results in a circle in the manifold (\(s\) is the
parametric variable for the tangent line/circle)
$\sage{T1.substitute(t=pt).n(digits=4)} + s \sage{V.substitute(t=pt).n(digits=4)}$:\\
\begin{sagesilent}
Tn = T1.substitute(t=pt) + V.substitute(t=pt)*s # Tangent line in projection
Tm = vector(SR, (cn_ix.substitute(u=Tn[0], v=Tn[1]), cn_iy.substitute(u=Tn[0], v=Tn[1]), cn_iz.substitute(u=Tn[0], v=Tn[1]))).simplify_full()
\end{sagesilent}
$\lambda_2 = \sage{Tm}$

Plotting the results on the manifold (Figure \ref{fig:stereo2}):\\
\begin{sagesilent}
Sn = sphere(center=(0, 0, 0),size=1, color='green', aspect_ratio=[1,1,1], opacity=0.7)
curv_1 = parametric_plot3d(K_1, (t,-1,1), color='red')
curv_2 = parametric_plot3d(Tm, (s,-1,1), color='blue')
Pn = (K_1[0].substitute(t=pt).n(), K_1[1].substitute(t=pt).n(), K_1[2].substitute(t=pt).n())
#Pn = (K_2[0].substitute(t=iss).n(), K_2[1].substitute(t=iss).n(), K_2[2].substitute(t=iss).n())
pn = point(Pn, rgbcolor=(1,0,0), size=20)
save(Sn+curv_1+curv_2+pn, "stereo2.png")
\end{sagesilent}

\begin{figure}[ht]
    \centering
    \includegraphics[width=0.95\textwidth,keepaspectratio]{stereo2.png}
    \caption{Visualization of tangent vector curves}
    \label{fig:stereo2}
 \end{figure}

    Verifying the two curves satisfy the equivalence class criteria:\\
    \textbf{Value on Manifold}:\\
    $(\sage{K_1[0].substitute(t=pt).n(digits=7)}, \sage{K_1[1].substitute(t=pt).n(digits=7)}, \sage{K_1[2].substitute(t=pt).n(digits=7)})$\\
    $(\sage{Tm.substitute(s=0).n(digits=7)})$\\
    \textbf{Velocity in chart}:\\
    $\sage{V.substitute(t=pt).n(digits=7)}$\\
    $\sage{Tn.diff(s).substitute(s=0).n(digits=7)}$\\

    \hypertarget{derivation-based-approach}{%
\subsection{Derivation based Approach}\label{derivation-based-approach}}

A derivation at a point in a \(C^\infty\) manifold is defined to be a
linear map \(D(C^\infty) \rightarrow R\),

\((D_{1}+D_{2})(f) = D_{1}(f)+D_{2}(f)\)

\((\lambda D)(f) = \lambda D(f)\) which also obeys the Leibnitz identity
\(D(f g)=D(f) \cdot g(x)+f(x) \cdot D(g)\).

Computer science types could see the derivation as defining an abstract
interface, with the actual derivitive being a concrete class
implementing the abstract interface.

See \textcite{parzygnat} (lecture 12 part 3) for a description of
derivations and associated associative algebra (in a Euclidean manifold
context, but most of what is covered also applies to general manifolds,
other than the manifold chart map directions are inverted).

A tangent vector can then be applied to a \(C^\infty\) function \(f\) given a curve \(\lambda\) by
\(D(f \circ \lambda)[t]\) where \(\lambda(t) = \vec{p} \in M\) where \(\vec{p}\) is the point in
the manifold where the tangent is taken. The derivation based velocities defined this way should
form a vector space similarly to the previous section tangent vectors which can fairly easily be
shown to form a vector space by adding/multiplying in chart space \parencite[see][pp. 76]{isham} .
Proving a vector space using the \(D(f \circ \lambda)[t]\) approach is a little more difficult.
Additive closure is covered quite lengthily in lesson 9 of \textcite{XylyXylyX} and more concisely
by \textcite{schuller} lecture 5, while Schuller also covers scalar multiplication.

The above proofs are regurgitated here for documentary purposes as I
couldn't find a book containing the proofs. Intermediate results in the
proofs are also illustrated using the stereographic example.

Multivariable differentation is denoted, as for derivations, with a \(D\) operator. For
multivariable functions and maps the differentation result will be a Jacobian, and in many cases
with tangent spaces mapping to \(R^1\) will be vectors, although transition maps between charts for
example will be matrices. In some cases the differention operator \(D\) will be subscripted with
the variables w.r.t. which the differentiation is taking place eg \(D_t\). This is in contrast with
many physics books which use the old fashioned multiple different chain rules to extensively
utilize component indexing, instead of one chain rule using linear transformations with Jacobian
matrices applying in all cases (as for example in \textcite{spivak} or more colorfully in
\textcites{ghrist}{ghrist-youtube}). Where applicable the comparable `standard' notation will also
be shown.

We will continue to use the curves defined in the previous section. We
also define \(f(\vec{p}) : S \rightarrow R = 2x + 2y + 2z\) (where z is
constrained to be on the manifold ie \(z = \sqrt{1 - x^2 - y^2}\)). Now
\(D(f \circ \lambda_1)\) and \(D(f \circ \lambda_2)\) are velocities:\\
\begin{sagesilent}
var('x', 'y', 'z')
f = 2*x + 2*y + 2*z
d1 = f.substitute(x = K_1[0], y = K_1[1], z = K_1[2]).diff(t)
d2 = f.substitute(x = Tm[0], y = Tm[1], z = Tm[2]).diff(s) #.full_simplify()
#print(latex(d2)) # Manually split the output
\end{sagesilent}

$\scriptstyle (f \circ \lambda_1)^\prime = \sage{d1}$
\begin{multline*}
    \scriptstyle
    (f \circ \lambda_2)^\prime =
    \frac{4 \, {({(3969 \, \pi^{2} + 625)} s + 225)}}{{(3969 \, \pi^{2} + 625)} s^{2} + 450 \, s + 90} -
    \frac{4 \, {({(3969 \, \pi^{2} + 625)} s^{2} + 450 \, s + 72)} {({(3969 \, \pi^{2} + 625)} s + 225)}}{{({(3969 \, \pi^{2} + 625)} s^{2} + 450 \, s + 90)}^{2}} -\\
    \scriptstyle
    \frac{6 \, {(63 \, \pi s {(\sqrt{5} - 1)} - {(25 \, s + 9)} \sqrt{2 \, \sqrt{5} + 10})} {({(3969 \, \pi^{2} + 625)} s + 225)}}{{({(3969 \, \pi^{2} + 625)} s^{2} + 450 \, s + 90)}^{2}} -
    \frac{6 \, {(63 \, \pi s \sqrt{2 \, \sqrt{5} + 10} + 25 \, s {(\sqrt{5} - 1)} + 9 \, \sqrt{5} - 9)} {({(3969 \, \pi^{2} + 625)} s + 225)}}{{({(3969 \, \pi^{2} + 625)} s^{2} + 450 \, s + 90)}^{2}} +\\
    \scriptstyle
    \frac{3 \, {(63 \, \pi {(\sqrt{5} - 1)} - 25 \, \sqrt{2 \, \sqrt{5} + 10})}}{{(3969 \, \pi^{2} + 625)} s^{2} + 450 \, s + 90} +
    \frac{3 \, {(63 \, \pi \sqrt{2 \, \sqrt{5} + 10} + 25 \, \sqrt{5} - 25)}}{{(3969 \, \pi^{2} + 625)} s^{2} + 450 \, s + 90}
\end{multline*}

    To demonstrate the curves form a vector space (for this example anyway), before providing a proof (of closure under addition and scalar multiplication
    - the rest is left as an exercise for the reader \smiley{}) we first set  $\lambda_3 = \lambda_1 + \lambda_2$ and then substituting the values for the
    intersection point specified by $s = 0$ and $t = \frac{4}{5}$ into the three different velocities.\\
\begin{sagesilent}
K_3 = vector(SR, ( (K_1[0] + Tm[0]).full_simplify(), (K_1[1] + Tm[1]), (K_1[2] + Tm[2]) ) ).simplify_full()
d3 = f.substitute(x = K_3[0], y = K_3[1], z = K_3[2]).diff(s).full_simplify()
\end{sagesilent}
$(D(f \circ \lambda_1)[\sage{pt}] = \sage{d1.substitute(t=pt).n(digits=7)}$\\
$(D(f \circ \lambda_2)[0] = \sage{d2.substitute(s=0).n(digits=7)}$\\
$(D(f \circ \lambda_3)[\sage{pt}] = \sage{d3.substitute(s=0, t=pt).n(digits=7)}$\\
% \begin{multline*}
% \scriptscriptstyle
% \lambda_3 = -\frac{750141 \, \sqrt{5} \pi^{3} s^{2}}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} -\\
% \scriptscriptstyle \frac{750141 \, \pi^{3} s^{2} \sqrt{2 \, \sqrt{5} + 10}}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} +\\
% \scriptscriptstyle \frac{750141 \, \pi^{3} s^{2}}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} -\\
% \scriptscriptstyle \frac{297675 \, \sqrt{5} \pi^{2} s^{2}}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} +\\
% \scriptscriptstyle \frac{297675 \, \pi^{2} s^{2} \sqrt{2 \, \sqrt{5} + 10}}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} +\\
% \scriptscriptstyle \frac{297675 \, \pi^{2} s^{2}}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} -\\
% \scriptscriptstyle \frac{214326 \, \sqrt{5} \pi^{2} s}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} -\\
% \scriptscriptstyle \frac{118125 \, \sqrt{5} \pi s^{2}}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} +\\
% \scriptscriptstyle \frac{214326 \, \pi^{2} s \sqrt{2 \, \sqrt{5} + 10}}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} -\\
% \scriptscriptstyle \frac{118125 \, \pi s^{2} \sqrt{2 \, \sqrt{5} + 10}}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} +\\
% \scriptscriptstyle \frac{500094 \, \pi^{2} s}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} +\\
% \scriptscriptstyle \frac{118125 \, \pi s^{2}}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} -\\
% \scriptscriptstyle \frac{46875 \, \sqrt{5} s^{2}}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} +\\
% \scriptscriptstyle \frac{46875 \, s^{2} \sqrt{2 \, \sqrt{5} + 10}}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} +\\
% \scriptscriptstyle \frac{46875 \, s^{2}}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} +\\
% \scriptscriptstyle \frac{17010 \, \sqrt{5} \pi}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} -\\
% \scriptscriptstyle \frac{33750 \, \sqrt{5} s}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} +\\
% \scriptscriptstyle \frac{17010 \, \pi \sqrt{2 \, \sqrt{5} + 10}}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} +\\
% \scriptscriptstyle \frac{33750 \, s \sqrt{2 \, \sqrt{5} + 10}}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} -\\
% \scriptscriptstyle \frac{17010 \, \pi}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} +\\
% \scriptscriptstyle \frac{78750 \, s}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} -\\
% \scriptscriptstyle \frac{5400 \, \sqrt{5}}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} +\\
% \scriptscriptstyle \frac{5400 \, \sqrt{2 \, \sqrt{5} + 10}}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100} +\\
% \scriptscriptstyle \frac{21600}{15752961 \, \pi^{4} s^{4} + 4961250 \, \pi^{2} s^{4} + 3572100 \, \pi^{2} s^{3} + 714420 \, \pi^{2} s^{2} + 390625 \, s^{4} + 562500 \, s^{3} + 315000 \, s^{2} + 81000 \, s + 8100}
% \end{multline*}

    \hypertarget{additive-closure-proof}{%
\subsubsection{Additive Closure Proof}\label{additive-closure-proof}}

The proof starts with a construction, which given two existing curves
\(\lambda_1,\lambda_2\) intersecting at point \(\vec{p}\) at parameter
values \(t_1\) and \(t_2\), constructs a third curve \(\lambda_3\) also
intersecting \(\vec{p}\) at a parameter \(t_3\) ie
\(\lambda_1(t_1) = \lambda_2(t_2) = \lambda_3(t_3) = \vec{p}\):

\(\lambda_3(t) = c^{-1}\{ (c \circ \lambda_1)[t_1 + t] + (c \circ \lambda_2)[t_2 + t] - (c \circ \lambda_1)[t_1]\}\)

At \(t = 0\) this evaluates to
\(c^{-1}\{ c(\vec{p}) + c(\vec{p}) - c(\vec{p}) \} = c^{-1}(c(\vec{p})) = \vec{p}\)
so \(t_3 = 0\). Checking this construct results in the same values as
the other two curves:\\
\begin{sagesilent}
t1 = vector(SR, (cn_0.substitute(x=K_1[0], z=K_1[2]).substitute(t=t+pt), cn_1.substitute(y=K_1[1], z=K_1[2]).substitute(t=t+pt)))
t2 = vector(SR, (cn_0.substitute(x=Tm[0], z=Tm[2]), cn_1.substitute(y=Tm[1], z=Tm[2]))).substitute(s=t+0)
t3 = vector(SR, (cn_0.substitute(x=K_1[0], z=K_1[2]), cn_1.substitute(y=K_1[1], z=K_1[2]))).substitute(t=pt)
tt = t1 + t2 - t3
K3 = vector(SR, (cn_ix.substitute(u=tt[0], v=tt[1]), cn_iy.substitute(u=tt[0], v=tt[1]), cn_iz.substitute(u=tt[0], v=tt[1]))).simplify_full()
\end{sagesilent}
$\textbf{Value on Manifold:}~~" \sage{K3.substitute(t=0).n(digits=7)}$

    Because the third curve parameter \(t_3\) evaluates to 0, we can
therefore write the velocity vector for \(\lambda_3\) at \(\vec{p}\) as
\((f \circ \lambda_3)^\prime[t_3 = 0]\).

Inserting a chart and its inverse and using associativity results in

\(\{(f \circ c^{-1}) \circ (c \circ \lambda_3)\}^\prime[0]\).

Using the chain rule with the \(f \circ c^{-1}\) as the outer function:

\(D(f \circ c^{-1})[(c \circ \lambda_3)[0])~D(c \circ \lambda_3)[0]\)

Substituting the expression for \(\lambda_3\) into the right side term:

\(D(c \circ \lambda_3)[0] = D(c \circ c^{-1}\{ (c \circ \lambda_1)[t_1 + t] + (c \circ \lambda_2)[t_2 + t] - (c \circ \lambda_1)[t_1]\}) =\)

\(D((c \circ c^{-1} \circ c \circ \lambda_1))[t_1 + t] + (c \circ c^{-1} \circ c \circ \lambda_2)[t_2 + t]) - (c \circ c^{-1} \circ c \circ \lambda_1))[t_1])\)
(distributivity, associativity)

The third term is not dependent on \(t\) so the derivitive would be
\(0 \therefore\) is will disappear and the inner \(c^{-1} \circ c\) in
the other terms will cancel leaving:

\(D((c \circ \lambda_1))[t_1 + t] + (c \circ \lambda_2)[t_2 + t]))[0] = D(c \circ \lambda_1)[t_1] + D(c \circ \lambda_2)[t_2]\)

    The left hand term can also be simplified:

\(D(f \circ c^{-1})[(c \circ \lambda_3)[0]) \equiv D(f \circ c^{-1})[(c \circ \lambda_3[0])) = D(f \circ c^{-1})[c(\vec{p})]\)

as \(\lambda_3[0] = \vec{p}\) by construction.

Recombining the simplified left and right sides:

\begin{equation}
\label{eq:addition-close}
\scriptstyle
D(f \circ c^{-1})[c(\vec{p})] \cdot (D(c \circ \lambda_1)[t_1] + D(c \circ \lambda_2)[t_2]) = D(f \circ c^{-1})[c(\vec{p})] D(c \circ \lambda_1)[t_1] + D(f \circ c^{-1})[c(\vec{p})] D(c \circ \lambda_2)[t_2])
\end{equation}

Using the chain rule to differentiate \(D(f \circ \lambda_1)[t_1]\) to show that it is the same as the first term above:

\(D(f \circ \lambda_1)[t_1] = D((f \circ c^{-1}) \circ (c \circ \lambda_1))[t_1] =\)

\(D(f \circ c^{-1})[(c \circ \lambda_1)[t_1]] \cdot D(c \circ \lambda_1)[t_1] =\)

\(D(f \circ c^{-1})[(c(\vec{p})] \cdot D(c \circ \lambda_1)[t_1]\)

which is the first term in the previous expression (Equation \ref{eq:addition-close}) (combining the
simplified left and right sides).

Similarly the second term
\(D(f \circ c^{-1})[c(\vec{p})] D(c \circ \lambda_2)[t_2])\) can be
shown by reversing the chain rule to be
\(D(f \circ \lambda_2)[t_2] \therefore\) the equation that shall remain
unnumbered can be reduced to:

\(D(f \circ \lambda_1)[t_1] + D(f \circ \lambda_2)[t_2]\)

which proves closure under addition of velocity vectors in the tangent space. We can verify the above terms for our concrete example:\\
\begin{sagesilent}
fl1 = f.substitute(x=K_1[0], y=K_1[1], z=K_1[2]).simplify_full()
fl2 = f.substitute(x=Tm[0], y=Tm[1], z=Tm[2]).simplify_full()
fl3 = f.substitute(x=K3[0], y=K3[1], z=K3[2]).simplify_full()
vv1 = fl1.diff(t).substitute(t=pt).n(digits=7)
vv2 = fl2.diff(s).substitute(s=0).n(digits=7)
vv3 = fl3.diff(t).substitute(t=0).n(digits=7)
\end{sagesilent}
$f \circ \lambda_{1,2,3} = \sage{fl1.substitute(t=pt).n(digits=7)}, \sage{fl2.substitute(s=0).n(digits=7)}, \sage{fl3.substitute(t=0).n(digits=7)}$\\
$D(f \circ \lambda_1) + D(f \circ \lambda_2) = \sage{vv1} + \sage{vv2} = \sage{vv1+vv2} = D(f \circ \lambda_3) = \sage{vv3}$

\hypertarget{scalar-multiplication-closure}{%
\subsubsection{Scalar Multiplication
Closure}\label{scalar-multiplication-closure}}

Proving closure under scalar multiplication is easier and does not
involve any charts. Again start with a construction for the new curve
\(\lambda_3\) tangent at \(\vec{p}\) ie
\(\lambda_1(t_1) = \lambda_3(t_3) = \vec{p}\) in terms of \(\lambda_1\):

\(\lambda_3(t) = \lambda_1(a t + t_1) = (\lambda_1 \circ u_a)[t_3]~~a \in R,~u_a(t) :R \rightarrow R = a t + t_1\)

At \(t = 0\) this evaluates to
\(\lambda_3(0) = \lambda_1(0 \cdot a + t_1) = \lambda_1(t_1) = \vec{p}\)
so \(t_3 = 0\).

\(D(f \circ \lambda_3)[t_3] = D(f \circ \lambda_3)[0] = D((f \circ \lambda_1) \circ u_a)[0]\)

Applying the chain rule:

\(D(f \circ \lambda_1)[u_a(0)] \cdot D(u_a)[0] = D(f \circ \lambda_1)[t_1] \cdot a = a D(f \circ \lambda_1)[t_1]\)

which proves closure under scalar multiplication.

    \hypertarget{chart-realizations-for-tangent-space}{%
\subsection{Chart Realizations for Tangent
Space}\label{chart-realizations-for-tangent-space}}

We start by introducing a chart \(c\) into a velocity vector applied to
an arbitrary function \(f\) for a curve
\(\lambda(t_1) = \vec{p} \in U \subseteq M\):

\(D((f \circ c^{-1}) \circ (c \circ \lambda))[t_1]\)

Applying the chain rule once again:

\(D_{u,v}(f \circ c^{-1})[c \circ \lambda(t_1)] \cdot D_t(c \circ \lambda)[t_1] = D_t(c \circ \lambda)[t_1] \cdot D_{u,v}(f \circ c^{-1})[c(\vec{p})]\)

The representation of derivation based tangent space vectors w.r.t
charts as used above in the proofs is quite complicated, so a simplified
representation, otherwise known as syntactic sugar in the computer
science community, is conventionally used, particularly in Physics,
which is shown here along with an example.

We start by investigating what the left and right hand sides of the
above look like for a concrete example using the north chart of the
stereographic projection and the spiral curve on the sphere. To do this
we take the Jacobian of both sides and then do matrix multiplication (or
dot product as they are both vectors) on the jacobians:\\
\begin{sagesilent}
t1 = vector(SR, (cn_0.substitute(x=K_1[0], z=K_1[2]), cn_1.substitute(y=K_1[1], z=K_1[2])))
lhs = jacobian(t1, (t)).transpose()

_pp = vector(SR, (cn_0.substitute(x=Pn[0], z=Pn[2]), cn_1.substitute(y=Pn[1], z=Pn[2])))
_f = f.substitute(x=cn_ix, y=cn_iy, z=cn_iz).simplify_full()
rhs = jacobian(_f, [u,v])
res = (lhs.substitute(t=pt)*rhs.transpose().substitute({u:_pp[0], v:_pp[1]})).n(digits=6)
\end{sagesilent}
\begin{multline*}
    \scriptstyle LHS =
\left(\begin{array}{rr}
    \scriptstyle
    \frac{7 \, \pi \sqrt{-t^{2} + 1} \sin\left(7 \, \pi t\right)}{t - 1} + \frac{t \cos\left(7 \, \pi t\right)}{\sqrt{-t^{2} + 1} {\left(t - 1\right)}} + \frac{\sqrt{-t^{2} + 1} \cos\left(7 \, \pi t\right)}{{\left(t - 1\right)}^{2}} & -\frac{7 \, \pi \sqrt{-t^{2} + 1} \cos\left(7 \, \pi t\right)}{t - 1} +\\
    \frac{t \sin\left(7 \, \pi t\right)}{\sqrt{-t^{2} + 1} {\left(t - 1\right)}} + \frac{\sqrt{-t^{2} + 1} \sin\left(7 \, \pi t\right)}{{\left(t - 1\right)}^{2}}
    \end{array}\right)
    \Big[t = \sage{pt} \Big]
\end{multline*}

$\scriptstyle RHS = \sage{rhs.transpose()}\Big[(u,v) = \sage{_pp.n(digits=6)} \Big]$

The right hand side of the expression is simplified as follows:
\begin{enumerate}[itemsep=1pt, topsep=1pt, partopsep=0pt]
    \item As the derivative is being taken Leibnitz notation is used (odd - one would have thought physicists would prefer Newton), the D is replaced with a
    del ie \(\partial\),
    \item The function is used in the numerator and the chart is used in the denominator in the Leibnitz notation for differentiation
    i.e.~\(\frac{\partial f}{\partial c}\),
    \item The coordinate index of the component being differentiated in the vector is used as a superscript in the denominator (the use of vectors and
    matrices was implied in the Jacobian differentiation operator used in most of this document) \(\frac{\partial f}{\partial c^i}\),
    \item Finally the point on the manifold is given as a subscript i.e \((\frac{\partial f}{\partial c^i})_p\).
\end{enumerate}

The left hand side is also simplified:
\begin{enumerate}[itemsep=1pt, topsep=1pt, partopsep=0pt]
    \item As the curve is being differentiated with respect to a parameter which can be interpreted as time, Newton finally arrives on the scene,
    with the Newtonian notation with a dot on top of the curve being used i.e.~\(\dot \lambda\),
    \item As with the RHS the component index is used as a superscript (which also ties in with using Einstein summation for the entire expression)
    i.e.~\(\dot \lambda^i\),
    \item The curve is used as a subscript ie \(\dot \lambda^i_c\) 4. Finally the point in the manifold is added i.e.~\(\dot \lambda^i_c(t_1)\)
\end{enumerate}

The entire shorthand expression for a component is expressed as an operator which operates on
\(C^\infty\) functions: \(\dot \lambda^i_c(t_1) (\frac{\partial }{\partial c^i})_pf\)

The \((\frac{\partial }{\partial c^i})_p\) part (or more accurately its full expansion) forms a
basis for the vector space of derivations defining the tangent space.
\Textcite[see][pp.~82-86]{isham} provides a proof of this as well as the isomorphism between the
derivation and the previously described geometric tangent space. This basis is known as a chart
induced basis.

The example shows the basis dependent on \(u,v\) and the components on
\(t\):\\
\begin{multline*}
    \left(\begin{array}{r}
        \scriptstyle
        4 \, {\left(\frac{7 \, \pi \sqrt{-t^{2} + 1} \sin\left(7 \, \pi t\right)}{t - 1} + \frac{t \cos\left(7 \, \pi t\right)}{\sqrt{-t^{2} + 1} {\left(t - 1\right)}} + \frac{\sqrt{-t^{2} + 1} \cos\left(7 \, \pi t\right)}{{\left(t - 1\right)}^{2}}\right)} {\left(\frac{u + 1}{u^{2} + v^{2} + 1} - \frac{{\left(u^{2} + v^{2} + 2 \, u + 2 \, v - 1\right)} u}{{\left(u^{2} + v^{2} + 1\right)}^{2}}\right)} -\\
        \scriptstyle
        4 \, {\left(\frac{7 \, \pi \sqrt{-t^{2} + 1} \cos\left(7 \, \pi t\right)}{t - 1} - \frac{t \sin\left(7 \, \pi t\right)}{\sqrt{-t^{2} + 1} {\left(t - 1\right)}} - \frac{\sqrt{-t^{2} + 1} \sin\left(7 \, \pi t\right)}{{\left(t - 1\right)}^{2}}\right)} {\left(\frac{v + 1}{u^{2} + v^{2} + 1} - \frac{{\left(u^{2} + v^{2} + 2 \, u + 2 \, v - 1\right)} v}{{\left(u^{2} + v^{2} + 1\right)}^{2}}\right)}
        \end{array}\right)
        = \sage{res[0]}
\end{multline*}

\hypertarget{change-of-basis-for-tangent-space-components}{%
\subsection{Change of basis for Tangent Space
Components}\label{change-of-basis-for-tangent-space-components}}

Given two charts \((U, c_1)\) and \((V, c_2)\) where
\(U \cap V \neq \emptyset\), where the tangent vector to a point
\(\vec{p} \in U,V\) is known relative to say \(U\), then the equivalent
basis vector for \(V\) can be derived:

\begin{enumerate}[itemsep=1pt, topsep=1pt, partopsep=0pt]
\item
  Recall the expression for the basic component from the previous
  section and once again apply the idiom of using the inverse of a map
  after the map, in this case the map being the chart from \(V\).
  \((\frac{\partial f}{\partial c_1^{i:1\cdots m}})_p = D(f \circ c_1^{-1})[c_1(\vec{p})] = D((f \circ c_2^{-1}) \circ (c_2 \circ c_1^{-1})[c_1(\vec{p})]\)
\item
  Utilise the chain rule again:
  \(D_{u,v}(f \circ c_2^{-1})[c_2 \circ c_1^{-1}(c_1(\vec{p})] \cdot D_{u,v}(c_2 \circ c_1^{-1})[c_1(\vec{p})] = D_{u,v}(c_2 \circ c_1^{-1})[c_1(\vec{p})] \cdot D_{u,v}(f \circ c_2^{-1})[c_2(\vec{p})]\).
\item
  The full expression for the tangent vector in \(U\) is given by:
  \(\dot \lambda^i_{c_1}(t_1) (\frac{\partial f}{\partial c_1^{i:1\cdots m}})_p = D(c_1 \circ \lambda)[t_1] \cdot D(f \circ c^{-1}_1)[c_1(\vec{p})]\)
  Substituting the expression from 2:
  \(D(c_1 \circ \lambda)[t_1] \cdot D(f \circ c^{-1})[c(\vec{p})] = D_t(c_1 \circ \lambda)[t_1] \cdot D_{u,v}(c_2 \circ c_1^{-1})[c_1(\vec{p})] \cdot D_{u,v}(f \circ c_2^{-1})[c_2(\vec{p})]\)
\item
  The full expression for the tangent vector in \(V\) is given by:
  \(\dot \lambda^i_{c_2}(t_2) (\frac{\partial f}{\partial c_2^{i:1\cdots n}})_p = D(c_{2} \circ \lambda)[t_2] \cdot D(f \circ c^{-1}_{2})[c_2(\vec{p})]\)
\item
  As the curve on the manifold remains the same, the tangent vector is
  also the same, its just expressed differently in the two bases,
  therefore these expressions can be equated:
  \(D_t(c_{2} \circ \lambda)[t_2] \cdot D_{u,v}(f \circ c^{-1}_{2})[c_2(\vec{p})] = D_t(c_1 \circ \lambda)[t_1] \cdot D_{u,v}(c_2 \circ c_1^{-1})[c_1(\vec{p})] \cdot D_{u,v}(f \circ c_2^{-1})[c_2(\vec{p})]\)
  The components in V are thus
  \(D_t(c_1 \circ \lambda)[t_1] \cdot D_{u,v}(c_2 \circ c_1^{-1})[c_1(\vec{p})]\)
\end{enumerate}

The \(D_{u,v}(c_2 \circ c_1^{-1})[c_1(\vec{p})]\) (Jacobian of the
overlap function between \(U\) and \(V\)) is \(R^m \rightarrow R^n\) so
the Jacobian will be a \(n{\times}m\) matrix. This matrix is multiplied
by a \(m{\times}1\) vector of the map from the curve to chart
coordinates via the manifold.

Applying this to the example using a change of basis from the north to
the south hemisphere of the stereographic projection (the point at which
the tangent are found is the northern hemisphere test point, and the
curve is the same as the one used in the previous tangent space
examples):\\
\begin{sagesilent}
pp1 = vector(SR, (cn_0.substitute(x=Pn[0], z=Pn[2]), cn_1.substitute(y=Pn[1], z=Pn[2])))
pp2 = vector(SR, (cs_0.substitute(x=Pn[0], z=Pn[2]), cs_1.substitute(y=Pn[1], z=Pn[2])))
fc2 = f.substitute(x=cs_ix, y=cs_iy, z=cs_iz).simplify_full()
c2c1 = vector(SR, (cs_0.substitute({x: cn_ix, z: cn_iz}).full_simplify(), cs_1.substitute({y: cn_iy, z: cn_iz}).full_simplify()))
c1l = vector(SR, (cn_0.substitute(x=K_1[0], z=K_1[2]), cn_1.substitute(y=K_1[1], z=K_1[2])))

Dc2c1 = jacobian(c2c1, (u, v))
Dc1l = jacobian(c1l, (t))
pretty_print(Dc2c1, LatexExpr("\\cdot"), Dc1l, LatexExpr("~=~"), Dc2c1*Dc1l)
pretty_print(Dc2c1.substitute(u=pp1[0], v=pp1[1]).n(digits=7), LatexExpr("\\cdot"), Dc1l.substitute(t=float(pt)).n(digits=7), LatexExpr("~=~"), (Dc2c1.substitute(u=pp1[0], v=pp1[1])*Dc1l.substitute(t=float(pt))).n(digits=7))
\end{sagesilent}
% \begin{multline*}
% \scriptstyle
% \sage{Dc2c1} \cdot \sage{Dc1l} =\\
% \sage{(Dc2c1.substitute(u=pp1[0], v=pp1[1])*Dc1l.substitute(t=float(pt))).n(digits=7)}
% \end{multline*}

\begin{multline*}
    \hspace{-1.6cm}
    \medmuskip=2mu
    \scriptstyle
    \sage{Dc2c1} \cdot \sage{Dc1l}[t=\sage{float(pt)}] = \\
    \scriptstyle \sage{(Dc2c1*Dc1l.substitute(t=pt))}
\end{multline*}

\begin{multline*}
    \hspace{-1.6cm}
    \medmuskip=2mu
    \scriptstyle \sage{(Dc2c1*Dc1l.substitute(t=pt))}\Big[\begin{array}{c} u = \sage{pp1[0].n(digits=5)} \\ v = \sage{pp1[1].n(digits=5)}\end{array}\Big] =\\
    \scriptstyle \sage{(Dc2c1.substitute(u=pp1[0], v=pp1[1])*Dc1l.substitute(t=float(pt))).n(digits=7)}
\end{multline*}

    We can test the change of basis by calculating the component representation in the south chart directly:\\
\begin{sagesilent}
lhss = vector(SR, (cs_0, cs_1))
lhs = jacobian(vector(SR, (cs_0.substitute(x=K_1[0], z=K_1[2]), cs_1.substitute(y=K_1[1], z=K_1[2]))), (t)).transpose()
\end{sagesilent}
\begin{multline*}
    \hspace{-1.6cm}
    \medmuskip=2mu
    D_{x,y,z}\sage{lhss}\Big[\begin{array}{c} x = \sage{K_1[0]} \\ y = \sage{K_1[1]} \\ z = \sage{K_1[2]}\end{array}\Big] =\\
    \hspace{-1.6cm}
    \scriptstyle \sage{lhs}\big[t=\sage{float(pt)}\big] =\\
    \scriptstyle \sage{lhs.substitute(t=pt).n(digits=6)}
\end{multline*}

Most (physics) textbooks use a shorthand notation for \(D_{u,v}(c_2 \circ c_1^{-1})[c_1(\vec{p})]
\cdot D_t(c_1 \circ \lambda)[t_1]\), namely \(\frac{\partial c_2^j}{\partial c_1^i} \cdot
X^i_{c_1}\) where the \(\frac{\partial c_2^j}{\partial c_1^i}\) refers to the Jacobian matrix with
the superscript indices corresponding to rows and columns from the matrix, while the \(X^i_{c_1}\)
term is a generic reference to the components in the convert-from chart minus any curve
information.

\printbibliography
\end{document}


\documentclass[11pt]{article}

\usepackage[margin=1in, paperwidth=8.5in, paperheight=11in]{geometry}
\usepackage{amsfonts}

\begin{document}
\title{Mathematical}
\author{Mrinmoi Hossain}
\date{\today}
\maketitle

\section{Mathematical Notation}
\begin{enumerate}
\item The set of nutural number is denoted by $\mathbb{N}$.
\item The set of real number is denoted by $\mathbb{R}$.
\end{enumerate}

\end{document}


% Copyright 2018-2021 Melvin Eloy Irizarry-Gelpí
\setcounter{chapter}{3}
\chapter{Faraday's Law of Induction}
%
In this experiment you will learn about Faraday's law of induction and a relationship between electric and magnetic phenomena.
%
\section{Preliminary}
%
Faraday's law of induction is a statement relating an \textbf{electric} phenomenon to a \textbf{magnetic} phenomenon. It states that a certain amount of \textbf{voltage} $\mathcal{E}$ is equal to the negative \textbf{rate of change of the magnetic flux} $\Phi_{B}$ with time:
\begin{equation}
	\mathcal{E} = -\frac{\Delta \Phi_{B}}{\Delta t}
	\label{eq.04.faradays.law}
\end{equation}
Here $\mathcal{E}$ is known as the \textbf{electro-motive force} or EMF. Although ``force'' is part of its name, an EMF quantity has nothing to do with force (which is measured in newtons): an EMF quantity has units of volts.
%
\subsection{Magnetic flux and its rate of change}
%
The \textbf{magnetic flux} is defined as the product of the amount of \textbf{magnetic field} $B$ and the amount of \textbf{area} $a$ in a surface where the magnetic field lines pass through:
\begin{equation}
	\Phi_{B} = B a
\end{equation}
The \textbf{SI unit} for magnetic field is the \textbf{tesla} (T). The \textbf{SI unit} for area is the square meter (m$^{2}$). Thus, magnetic flux is measured in units of T {\textperiodcentered} m\textsuperscript{2}.

A non-zero EMF $\mathcal{E}$ requires the magnetic flux $\Phi_{B}$ to change with time. In this experiment you are going to keep the \textbf{area fixed} and let the \textbf{magnetic field change with time}. In this setting, the rate of change of the magnetic flux with time is proportional to the rate of change of the magnetic field with time:
\begin{align}
	\Phi_{B} = B a && \Longrightarrow && \frac{\Delta \Phi_{B}}{\Delta t} = \left(\frac{\Delta B}{\Delta t}\right) a
	\label{eq.04.flux.rate}
\end{align}
The rate of change of magnetic flux is measured in units of T {\textperiodcentered} m\textsuperscript{2}/s. But according to Faraday's law, these units are the same as the units for EMF (volts), so you must have the equivalence:
\begin{equation}
	1 \ \text{V} = 1 \ \text{T {\textperiodcentered} m\textsuperscript{2}/s}
\end{equation}
This allows you to express the tesla unit in terms of volts, meters, and seconds:
\begin{equation}
	1 \ \text{T} = 1 \ \text{V {\textperiodcentered} s/m\textsuperscript{2}}
\end{equation}
%
\subsection{Producing the magnetic field}
%
Wires with electric current produce magnetic fields. You are going to use a particular wire called a \textbf{solenoid coil}. The \textbf{magnetic field} $B$ inside the cylindrical space of a solenoid coil is (almost) uniform and the amount of field is directly proportional to the amount of current $I$ flowing through the coil:
\begin{equation}
	B = \left(\frac{\mu_{0} N_{1}}{L}\right) I
	\label{eq.04.B.coil}
\end{equation}
Here
\begin{itemize}
	\item $B$ is the amount of \textbf{magnetic field} (unit: T)
	\item $\mu_{0} = 4 \pi \times 10^{-7}$ T {\textperiodcentered} m/A  is a universal physical \textbf{constant}
	\item $N_{1}$ is the \textbf{number of turns} in the (primary) coil (no units)
	\item $L$ is the \textbf{length} of the (primary) coil (unit: m)
	\item $I$ is the amount of \textbf{electric current} through the (primary) coil (unit: A)
\end{itemize}
For a given coil you are going to keep the \textbf{number of turns fixed}, and the \textbf{length fixed}, but you are going to use a \textbf{current that changes with time}. In this case, the rate of change of the magnetic field with time is proportional to the rate of change of the current with time:
\begin{align}
	B = \left(\frac{\mu_{0} N_{1}}{L}\right) I && \Longrightarrow && \frac{\Delta B}{\Delta t} = \left( \frac{\mu_{0} N_{1}}{L} \right) \frac{\Delta I}{\Delta t}
	\label{eq.04.B.rate}
\end{align}
Using Equation (\ref{eq.04.B.rate}) in Equation (\ref{eq.04.flux.rate}) gives
\begin{equation}
	\frac{\Delta \Phi_{B}}{\Delta t} = \left( \frac{\mu_{0} N_{1} a}{L} \right) \frac{\Delta I}{\Delta t}
\end{equation}
Thus, according to Faraday's law, for a solenoid coil you should have
\begin{equation}
	\mathcal{E} = -\left( \frac{\mu_{0} N_{1} a}{L} \right) \frac{\Delta I}{\Delta t}
	\label{eq.04.emf.solenoid}
\end{equation}
That is, the EMF associated with the area $a$ is proportional to the rate of change of the electric current with respect to time.
%
\section{Experiment}
%
The overall goal of the experiment is to check that the EMF behaves like the rate of change of the electric current. To do this you need to measure the EMF voltage and the current. From the current you can estimate the rate of change and confirm that it agrees with the EMF data.

You are going to look at \textbf{five ways for the current to change with time}:
\begin{enumerate}
	\item \textbf{Sinusoidal}: current will change according to a \textbf{sine or cosine} profile.
	\item \textbf{Square}: current will stay almost \textbf{constant}, but the \textbf{sign changes}.
	\item \textbf{Triangular}: current will increase \textbf{linearly}, then decrease \textbf{linearly}.
	\item \textbf{Ramp-up}: current will \textbf{increase linearly}, then \textbf{abruptly drop} to its base value.
	\item \textbf{Ramp-down}: current will \textbf{decrease linearly}, then \textbf{abruptly rise} to its base value.
\end{enumerate}
Each profile for the current leads to different results for the induced EMF.
%
\subsection{Rates of Change}
%
Here is a quick review of rates of change.
%
\subsubsection{Constant Quantity}
%
The rate of change of a \textbf{constant quantity} is \textbf{zero}. That is, if the quantity is not changing, then no amount is being gained or lost.
%
\subsubsection{Quantity Increasing Linearly}
%
The rate of change of a \textbf{quantity that increases linearly with time} is a \textbf{constant}. Increasing linearly is the same as being proportional to time. This means that the slope is constant. Moreover, since the quantity is increasing, the \textbf{slope is positive}.
%
\subsubsection{Quantity Decreasing Linearly}
%
The rate of change of a \textbf{quantity that decreases linearly with time} is a \textbf{constant}. Decreasing linearly is the same as being proportional to time. This means that the slope is constant. However, since the quantity is decreasing, the \textbf{slope is negative}.
%
\subsubsection{Sinusoidal Change}
%
The rate of change of the \textbf{sine function} is a cosine function:
\begin{equation}
	\frac{\Delta \sin(t)}{\Delta t} = \cos(t)
\end{equation}
Similarly, the rate of change of the \textbf{cosine function} is proportional to a sine function:
\begin{equation}
	\frac{\Delta \cos(t)}{\Delta t} = -\sin(t)
\end{equation}
Here the sign is not important. What is important is to remember that sine and cosine are very similar functions and that a cosine is the same as a sine function shifted by 90 deg (or $\pi/2$ rad):
\begin{align}
	\cos(t) = \sin(t + 90\text{\textdegree}), && \sin(t) = \cos(t - 90\text{\textdegree})
\end{align}
Thus, if the quantity is sinusoidal, then the rate of change will also be sinusoidal but shifted by 90 deg. In particular, when $\sin(t)$ is at a peak or valley, then $\cos(t)$ is crossing the horizontal axis (i.e. close to zero), and when $\sin(t)$ is crossing the horizontal axis (i.e. close to zero), then $\cos(t)$ is either at a valley or a peak.
%
\subsection{Solenoid Coils}
%
You are going to use two solenoid coils. The smaller one fits inside the larger one. The smaller one is called the \textbf{secondary coil}. This is the coil used to measure the EMF value. The larger coil is called the \textbf{primary coil}. This coil is the one with the current and the one that produces the magnetic field.

The \textbf{primary coil} has a length of 10 cm and 3300 turns. Thus,
\begin{align}
	L = 10 \ \text{cm} = 0.1 \ \text{m,} && N_{1} = 3300
\end{align}
The \textbf{secondary coil} has 150 turns and an outer diameter of 1.8 cm. The inner diameter I measured it to be close to 1.1 cm. The average of these two diameters correspond to the diameter half-way between these two. This average is 1.45 cm. Since the wire was very thick, I think it is more accurate to use the average of the diameters to calculate the area of each loop. Thus,
\begin{align}
	d = 1.45 \ \text{cm} = 0.0145 \ \text{m,} && N_{2} = 150
\end{align}
The area enclosed by a circular loop with diameter $d$ is given by
\begin{equation}
	a_{\text{loop}} = \frac{1}{4} \pi d^{2} = \frac{1}{4} \pi \left(0.0145 \ \text{m}\right)^2 = 1.65 \times 10^{-4} \ \text{m\textsuperscript{2}}
\end{equation}
This is the amount of \textbf{area-per-loop} in the secondary coil. The \textbf{total amount of area} $a$ is the area-per-loop $a_{\text{loop}}$ multiplied by the number of loops $N_{2}$ in the secondary coil:
\begin{equation}
	a = N_{2} a_{\text{loop}} = 150 \times \left(1.65 \times 10^{-4} \ \text{m\textsuperscript{2}}\right) = 2.48 \times 10^{-2} \ \text{m\textsuperscript{2}}
\end{equation}
This is the amount of area that you will use to measure the magnetic flux.
%
\section{Analysis}
%
According to (\ref{eq.04.emf.solenoid}), the amount of EMF is directly proportional to the amount of rate of change of the current with time. The constant of proportionality is
\begin{equation}
	\frac{\mu_{0} N_{1} a}{L} = 1.03 \times 10^{-3} \ \text{V {\textperiodcentered} s/A} = 1.03 \ \text{mV {\textperiodcentered} s/A}
	\label{eq.04.slope}
\end{equation}
This is the expected value. In principle, if you could chart $\mathcal{E}$ versus $\Delta I / \Delta t$, the slope should correspond to the negative of this value. You can only do this for the triangular current profile.
%
\subsection{Sinusoidal Current Profile}
%
For the sinusoidal current profile, one way to check the validity of Faraday's law is by comparing the fit parameters for a sinusoidal fit for both current and voltage. A ``sine'' sinusoidal fit for the current is of the form
\begin{equation}
	I(t) = A \sin(B t + C) + D
\end{equation}
Note that
\begin{itemize}
	\item The current amplitude $A$ has units of amps (A)
	\item The current angular frequency $B$ has units of radians-per-second (rad/s)
	\item The current angular shift $C$ has units of radians (rad)
	\item The current shift $D$ has units of amps (A)
\end{itemize}
A ``cosine'' sinusoidal fit for the EMF is of the form
\begin{equation}
	\mathcal{E}(t) = W \cos(X t + Y) + Z
\end{equation}
Note that
\begin{itemize}
	\item The EMF amplitude $W$ has units of volts (V)
	\item The EMF angular frequency $X$ has units of radians-per-second (rad/s)
	\item The EMF angular shift $Y$ has units of radians (rad)
	\item The EMF shift $Z$ has units of volts (V)
\end{itemize}
If the sensors were zeroed correctly, you should find that both $D$ and $Z$ are close to \textbf{zero}, and thus they can be neglected. There are three simple checks:
\begin{enumerate}
	\item The value of $W$ should be very close to
	\begin{equation}
		A B \left(\frac{\mu_{0} N_{1} a}{L}\right)
	\end{equation}
	\item The value of $B$ should be very close to the value of $X$.
	\item The value of $\vert C - Y \vert$ should be very close to $\pi$.
\end{enumerate}
Another check, similar to what you did for simple harmonic motion, is to make a \textbf{phase space} chart, with EMF voltage in the vertical axis, and current in the horizontal axis. Just like for the mass on the spring, the phase space chart should have the \textbf{shape of an ellipse}.
%
\subsection{Square Current Profile}
%
Since the square current profile consists of segments where the current is almost constant, the rate of change of the current should be almost zero. This will result in an EMF value that is also almost zero. You can confirm this by examining a scatter chart with EMF voltage on the vertical axis and time in the horizontal axis.
%
\subsection{Triangular Current Profile}
%
For the triangular current, the chart of current versus time has regions of increasing current and regions of decreasing current. In the same time regions, the EMF voltage is approximately constant but either positive or negative.

You can isolate a time region of linear increase of current and find the slope. (In the spreadsheet use \texttt{=SLOPE(Y,X)} with \texttt{Y} the current and \texttt{X} the time). This slope is a value for the rate of change of current with respect to time ($\Delta I / \Delta t$). The slope should be \textbf{positive} since the current is increasing. In approximately the same time region the EMF voltage is constant (make sure you only include the region where the EMF is approximately flat and not suddenly rising or falling). You can calculate the time-average of the EMF in this time region. This time average value corresponds to the best direct estimate for the EMF ($\mathcal{E}$).

In a similar way, you can analyze the time regions where the current decreases in a linear way. Now the rate of change of the current will be \textbf{negative}. The EMF should be almost flat and \textbf{positive}.

After finding \textbf{at least six pairs} of EMF and rate of change of current with respect to time, you can plot these quantities to test the relation in Equation (\ref{eq.04.emf.solenoid}) and find the slope. Then you can compare this value with the expected slope in Equation (\ref{eq.04.slope}). The chart should have two clusters of points. The best-fit line should be connecting these two clusters.
%
\subsection{Ramp-Up and Ramp-Down Current Profiles}
%
For the ramp-up current profile, the current only increases linearly. This means that the rate of change of the current should be a positive constant always. You can repeat the steps followed above with the triangular current and find the rate of change for the current and also the time-average EMF. However, you cannot plot $\mathcal{E}$ and $dI/dt$ anymore, so instead just calculate the ratio
\begin{equation}
	\text{ratio } = -\frac{\mathcal{E}}{\Delta I/\Delta t}
	\label{eq.04.ratio}
\end{equation}
This ratio should be somewhat close to the expected value of the slope in Equation (\ref{eq.04.slope}). A similar result holds for the ramp-down current profile.
%
\section{My Data}
%
My data consist of five runs:
\begin{itemize}
	\item Run 1: Sinusoidal current profile
	\item Run 2: Square current profile
	\item Run 3: Triangular current profile
	\item Run 4: Ramp-up current profile
	\item Run 5: Ramp-down current profile
\end{itemize}
Here are some comments from each run.
%
\subsection{Run 1}
%
The analysis for this run is qualitative. Figure \ref{figure.04.run.1.I} contains the current data over time, and Figure \ref{figure.04.run.1.V} contains the EMF voltage data over time. You can see that the EMF voltage behaves like the rate of change of the current because whenever the current is at a peak or valley, the EMF voltage is close to zero, and whenever the current is close to zero, the EMF voltage is at a peak or valley. The phase phase chart in Figure \ref{figure.04.run.1.phase.space} also shows the expected elliptical shape.
%
\subsection{Run 2}
%
The analysis for this run is also qualitative. Figure \ref{figure.04.run.2.I} contains the current data over time, and Figure \ref{figure.04.run.2.V} contains the EMF voltage data over time. As expected, when the square current profile is used, the EMF voltage is zero whenever the current has a fixed value.
%
\subsection{Run 3}
%
The analysis for this run has a quantitative aspect. Figure \ref{figure.04.run.3.I} contains the current data over time, and Figure \ref{figure.04.run.3.V} contains the EMF voltage data over time. Since the current increases or decreases in a linear way, the EMF voltage is expected to be constant but switching signs. That is indeed the case. Furthermore, the slope for the current can be calculated. Table \ref{table.04.run.3.I.V} contains the current slope and the time-average EMF voltage for a six segments. These six segments lead to two clusters in Figure \ref{figure.04.run.3}, where the slope is close to the expected value. The results are in Table \ref{table.04.run.3}.
%
\subsection{Run 4}
%
The analysis for this run has a quantitative aspect. Figure \ref{figure.04.run.4.I} contains the current data over time, and Figure \ref{figure.04.run.4.V} contains the EMF voltage data over time. Since the current only increases before abruptly taking the base value, you expect the EMF voltage to be constant and negative. That is indeed the case. The results are in Table \ref{table.04.run.4}, where the last column contains the ratio in Equation (\ref{eq.04.ratio}). These values are close to the expected slope.
%
\subsection{Run 5}
%
The analysis for this run has a quantitative aspect. Figure \ref{figure.04.run.5.I} contains the current data over time, and Figure \ref{figure.04.run.5.V} contains the EMF voltage data over time. Since the current only decreases before abruptly taking the base value, you expect the EMF voltage to be constant and positive. That is indeed the case. The results are in Table \ref{table.04.run.5}, where the last column contains the ratio in Equation (\ref{eq.04.ratio}). These values are also close to the expected slope.
%
\section{Your Data}
%
You should have five runs:
\begin{itemize}
	\item Run 1: Sinusoidal current profile
	\item Run 2: Square current profile
	\item Run 3: Triangular current profile
	\item Run 4: Ramp-up current profile
	\item Run 5: Ramp-down current profile
\end{itemize}
For each run you should have three columns of data: time, voltage (electric potential), and current.
% Note that the voltage column is in mV and should be converted to volts:
% \begin{equation}
% 	1 \text{ mV} = 0.001 \ \text{V}
% \end{equation}
% Otherwise, agreement with the slope in Equation (\ref{eq.04.slope}) will be off by some orders of magnitude.
%
% \newpage
% \section{Your Lab Report}
% %
% For \textbf{run 1}, your lab report should include:
% \begin{itemize}
% 	\item A scatter chart with \textbf{current} in the vertical axis, and time in the horizontal axis.
% 	\item A scatter chart with \textbf{voltage} in the vertical axis, and time in the horizontal axis.
% 	\item A brief argument discussing whether the voltage that you measured behaves \textbf{qualitatively} like the rate of change of current with time.
% 	\item A scatter chart with \textbf{voltage} in the vertical axis, and \textbf{current} in the horizontal axis. Does this chart have the elliptical shape?
% \end{itemize}
% For \textbf{run 2}, your lab report should include:
% \begin{itemize}
% 	\item A scatter chart with \textbf{current} in the vertical axis, and time in the horizontal axis.
% 	\item A scatter chart with \textbf{voltage} in the vertical axis, and time in the horizontal axis.
% 	\item A brief argument discussing whether the voltage that you measured behaves \textbf{qualitatively} like the rate of change of current with time.
% \end{itemize}
% For \textbf{run 3}, your lab report should include:
% \begin{itemize}
% 	\item A scatter chart with \textbf{voltage} in the vertical axis, and time in the horizontal axis.
% 	\item A brief argument discussing whether the voltage that you measured behaves \textbf{qualitatively} like the rate of change of current with time.
% 	\item A table like Table \ref{table.04.run.3.I.V} with at least six values for the current slope, and the time-average EMF voltage.
% 	\item A scatter chart with EMF voltage in the vertical axis, and current slope in the horizontal axis. Include the best-fit line, and display the equation in the legend.
% 	\item A table like Table \ref{table.04.run.3} with the expected slope, the experimental slope, and the percent difference.
% \end{itemize}
% For \textbf{run 4} and \textbf{run 5}, your lab report should include:
% \begin{itemize}
% 	\item A scatter chart with \textbf{voltage} in the vertical axis, and time in the horizontal axis.
% 	\item A brief argument discussing whether the voltage that you measured behaves \textbf{qualitatively} like the rate of change of current with time.
% 	\item A table like Table \ref{table.04.run.4} and Table \ref{table.04.run.5} with at least four values for the current slope, the time-average EMF voltage, and the ratio (\ref{eq.04.ratio}).
% \end{itemize}
%
\newpage
\section{Tables}
%
\begin{table}[ht!]
	\centering
	\begin{tabular}{r|r}
		\textbf{Current Slope} (A/s) & \textbf{Time-Average EMF Voltage} (mV) \\
		\hline
		\textminus 2.247 & 2.65 \\
		2.274 & \textminus 2.67 \\
		\textminus 2.266 & 2.66 \\
		2.243 & \textminus 2.67 \\
		\textminus 2.280 & 2.66 \\
		2.275 & \textminus 2.68 \\
		\hline
	\end{tabular}
	\caption{Current slope and EMF time-average results for run 3}
	\label{table.04.run.3.I.V}
\end{table}
%
\begin{table}[ht!]
	\centering
	\begin{tabular}{r|r|r}
		\textbf{Expected Slope} (mV$\cdot$s/A) & \textbf{Observed Slope} (mV$\cdot$s/A) & \textbf{P.D.} (\%) \\
		\hline
		\textminus 1.03 & \textminus 1.18 & 14.55 \\
		\hline
	\end{tabular}
	\caption{Results for run 3}
	\label{table.04.run.3}
\end{table}
%
\begin{table}[ht!]
	\centering
	\begin{tabular}{r|r|r}
		\textbf{Current Slope} (A/s) & \textbf{Time-Average EMF Voltage} (mV) & \textbf{Ratio} (mV$\cdot$s/A) \\
		\hline
		0.507 & \textminus 0.607 & \textminus 1.20 \\
		0.516 & \textminus 0.612 & \textminus 1.19 \\
		0.505 & \textminus 0.599 & \textminus 1.19 \\
		0.505 & \textminus 0.600 & \textminus 1.19 \\
		\hline
	\end{tabular}
	\caption{Results for run 4}
	\label{table.04.run.4}
\end{table}
%
\begin{table}[ht!]
	\centering
	\begin{tabular}{r|r|r}
		\textbf{Current Slope} (A/s) & \textbf{Time-Average EMF Voltage} (mV) & \textbf{Ratio} (mV$\cdot$s/A) \\
		\hline
		\textminus 0.507 & 0.596 & \textminus 1.17 \\
		\textminus 0.516 & 0.596 & \textminus 1.17 \\
		\textminus 0.505 & 0.600 & \textminus 1.19 \\
		\textminus 0.505 & 0.601 & \textminus 1.18 \\
		\hline
	\end{tabular}
	\caption{Results for run 5}
	\label{table.04.run.5}
\end{table}
%
\FloatBarrier
\newpage
\section{Figures}
%
\begin{figure}[ht]
	\centering
	\includegraphics[scale=0.74]{image/04-faraday/run-1-I.pdf}
	\caption{Run 1 -- Current}
	\label{figure.04.run.1.I}
\end{figure}
%
\begin{figure}[ht]
	\centering
	\includegraphics[scale=0.74]{image/04-faraday/run-1-V.pdf}
	\caption{Run 1 -- EMF Voltage}
	\label{figure.04.run.1.V}
\end{figure}
%
\begin{figure}[ht]
	\centering
	\includegraphics[scale=0.74]{image/04-faraday/run-1-phase-space.pdf}
	\caption{Run 1 -- Phase Space}
	\label{figure.04.run.1.phase.space}
\end{figure}
%
\begin{figure}[ht]
	\centering
	\includegraphics[scale=0.74]{image/04-faraday/run-2-I.pdf}
	\caption{Run 2 -- Current}
	\label{figure.04.run.2.I}
\end{figure}
%
\begin{figure}[ht]
	\centering
	\includegraphics[scale=0.74]{image/04-faraday/run-2-V.pdf}
	\caption{Run 2 -- EMF Voltage}
	\label{figure.04.run.2.V}
\end{figure}
%
\begin{figure}[ht]
	\centering
	\includegraphics[scale=0.74]{image/04-faraday/run-3-I.pdf}
	\caption{Run 3 -- Current}
	\label{figure.04.run.3.I}
\end{figure}
%
\begin{figure}[ht]
	\centering
	\includegraphics[scale=0.74]{image/04-faraday/run-3-V.pdf}
	\caption{Run 3 -- EMF Voltage}
	\label{figure.04.run.3.V}
\end{figure}
%
\begin{figure}[ht]
	\centering
	\includegraphics[scale=0.74]{image/04-faraday/run-4-I.pdf}
	\caption{Run 4 -- Current}
	\label{figure.04.run.4.I}
\end{figure}
%
\begin{figure}[ht]
	\centering
	\includegraphics[scale=0.74]{image/04-faraday/run-4-V.pdf}
	\caption{Run 4 -- EMF Voltage}
	\label{figure.04.run.4.V}
\end{figure}
%
\begin{figure}[ht]
	\centering
	\includegraphics[scale=0.74]{image/04-faraday/run-5-I.pdf}
	\caption{Run 5 -- Current}
	\label{figure.04.run.5.I}
\end{figure}
%
\begin{figure}[ht]
	\centering
	\includegraphics[scale=0.74]{image/04-faraday/run-5-V.pdf}
	\caption{Run 5 -- EMF Voltage}
	\label{figure.04.run.5.V}
\end{figure}
%
\begin{figure}[ht]
	\centering
	\includegraphics[scale=0.74]{image/04-faraday/run-3.pdf}
	\caption{Run 3}
	\label{figure.04.run.3}
\end{figure}