\section{Test Description and Success Criteria}
This test is located in \texttt{simulation/dynamics/HingedRigidBodies/UnitTest/\newline
test\_hingedRigidBodyStateEffector.py}. In this integrated test there are two hinged rigid bodies connected to the spacecraft hub.  Depending on the scenario, there are different success criteria. These are outlined in the following subsections:
\subsection{Gravity and no damping scenario}
In this test the simulation is placed into orbit around Earth with point gravity and has no damping in the hinged rigid bodies. The following parameters are being tested.
\begin{itemize}
	\item Conservation of orbital angular momentum
	\item Conservation of orbital energy
	\item Conservation of rotational angular momentum
	\item Conservation of rotational energy
	\item Achieving the expected final attitude
\end{itemize}

\subsection{No gravity and no damping scenario}
In this test, the spacecraft is placed in free space (no gravity) and has no damping in the hinged rigid bodies. The following parameters describe the success criteria.
\begin{itemize}
\item Conservation of orbital angular momentum
\item Conservation of orbital energy
\item Conservation of rotational angular momentum
\item Conservation of rotational energy
\item Achieving the expected final attitude (same final attitude as the Gravity with no damping scenario)
\item Achieving the expected final position
\item Conservation of velocity of center of mass
\end{itemize}

\subsection{No gravity with damping scenario}
In this test, the spacecraft is placed in free space (no gravity) and has damping in the hinged rigid bodies. The following parameters describe the success criteria.
\begin{itemize}
\item Conservation of orbital angular momentum
\item Conservation of orbital energy
\item Conservation of rotational angular momentum
\item Conservation of velocity of center of mass
\end{itemize}

\subsection{Steady State Deflection Verification Scenario}

The BOE calculation for the steady state deflection can be seen in Fig.~\ref{fig:BOEThetaSS}. The resulting steady state deflection does not have a closed form solution so a root solving function must be used to converge on the solution. A Newton-Raphson method was chosen and the success criteria for this test is whether Basilisk gives the same results as this BOE calculation within a certain tolerance. The spacecraft has a constant force applied through the whole simulation with the hinged rigid bodies initially undeflected and they have damping. The force is always applied through the center of mass of the spacecraft and results in no rotation of the spacecraft.

\begin{figure}[htbp]
	\centerline{
		\includegraphics[width=0.8\textwidth]{Figures/BOEThetaSS}}
	\caption{Steady State Deflection BOE Calculation}
	\label{fig:BOEThetaSS}
\end{figure}

\subsection{Frequency and Amplitude Verification Scenario}

\subsubsection{Frequency Test Description}

The BOE calculation for the frequency of oscillation of flexing hinged rigid bodies when a constant force is being applied to the spacecraft is done by making simplifications to the flexing equation seen in the Model Description Section. The following assumptions are made to simplify the equations:

\begin{enumerate}
	\item The force is being directed through the center of mass of the spacecraft, along the $\hat{\bm b}_2$ direction
	\item The panels are initially undeflected and they are symmetric therefore the body will not rotate
	\item Rotation is no longer apart of the equations so the translation and solar panel equations are the only equations needed
	\item $\hat{\bm s}_{i,3}$ is assumed to be equal to $\hat{\bm h}_{i,3}$ in the equations of motion \label{item:4}
	\item No external torque is being applied directly to the hinged rigid bodies
	\item Non-linear terms are neglected \label{item:5}
\end{enumerate}
Using the third assumption from above, the rotational motion is taken out of the equations of motion:

\begin{equation}
m_{\text{sc}} \ddot{\bm r}_{B/N}+\sum_{i}^{N}m_{\text{sp}_i} d_i  \bm{\hat{s}}_{i,3}\ddot{\theta}_i = \bm F_{\textnormal{ext}} -\sum_{i}^{N}m_{\text{sp}_i}d_i\dot{\theta}_i^2 \bm{\hat{s}}_{i,1}
\label{eq:Rbddot6}
\end{equation}

\begin{equation}
m_{\text{sp}_i} d_i \hat{\bm s}_{i,3}^{T} \ddot{\bm r}_{B/N}
+ \left( I_{s_{i,2}} + m_{\text{sp}_i} d_i^{2} \right) \ddot \theta_i
= - k_i \theta_i - c_i \dot\theta_i + \hat{\bm s}_{i,2}^T \bm \tau_{\text{ext},H_i}
\label{eq:solar_panel_final9}
\end{equation}
Next, assumptions \ref{item:4}-\ref{item:5} are applied:
\begin{equation}
m_{\text{sc}} \ddot{\bm r}_{B/N}+\sum_{i}^{N}m_{\text{sp}_i} d_i  \bm{\hat{h}}_{i,3}\ddot{\theta}_i = \bm F_{\textnormal{ext}}
\label{eq:Rbddot7}
\end{equation}

\begin{equation}
m_{\text{sp}_i} d_i \hat{\bm h}_{i,3}^{T} \ddot{\bm r}_{B/N}
+ \left( I_{s_{i,2}} + m_{\text{sp}_i} d_i^{2} \right) \ddot \theta_i
= - k_i \theta_i - c_i \dot\theta_i
\label{eq:solar_panel_final10}
\end{equation}
Finally, knowing that the force is being directed along the $\hat{\bm b}_2$ axis and that the spacecraft will not rotate, the equations simplify to:
\begin{equation}
m_{\text{sc}} \ddot{y}_{B/N}+\sum_{i}^{N}m_{\text{sp}_i} d_i \ddot{\theta}_i = F_{y}
\label{eq:Rbddot9}
\end{equation}

\begin{equation}
m_{\text{sp}_i} d_i \ddot{y}_{B/N}
+ \left( I_{s_{i,2}} + m_{\text{sp}_i} d_i^{2} \right) \ddot \theta_i
= - k_i \theta_i - c_i \dot\theta_i
\label{eq:solar_panel_final12}
\end{equation}
Converting these equations to state space:
\begin{multline}
\begin{bmatrix}
1 & 0 & 0 & 0 & 0 & 0\\
0 & m_{\text{sc}} & 0 & m_{\text{sp}_1} d_1 & 0 & m_{\text{sp}_2} d_2 \\
0 & 0 & 1 & 0 & 0 & 0\\
0 & m_{\text{sp}_1} d_1 & 0 &  I_{s_{1,2}} + m_{\text{sp}_1} d_1^{2} & 0 & 0 \\
0 & 0 & 0 & 0 & 1 & 0\\
0 & m_{\text{sp}_2} d_2 & 0 & 0 & 0 & I_{s_{2,2}} + m_{\text{sp}_2} d_2^{2} \\
\end{bmatrix}
\begin{bmatrix}
\dot{y}_{B/N} \\
\ddot{y}_{B/N} \\
\dot \theta_1 \\
\ddot \theta_1 \\
\dot \theta_2 \\
\ddot \theta_2 \\
\end{bmatrix}
\\
=\begin{bmatrix}
0 & 1 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 1 & 0 & 0\\
0 & 0 & -k_1 & -c_1 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 1\\
0 & 0 & 0 & 0 & -k_2 & -c_2\\
\end{bmatrix}
\begin{bmatrix}
{y}_{B/N} \\
\dot{y}_{B/N} \\
\theta_1 \\
\dot \theta_1 \\
\theta_2 \\
\dot \theta_2 \\
\end{bmatrix}
+ \begin{bmatrix}
0 \\
F_y \\
0 \\
0 \\
0 \\
0 \\
\end{bmatrix}
\label{eq:solar_panel_final13}
\end{multline}
Written in a more compact form:
\begin{equation}
[M] \dot{\bm X} = [A] \bm X + \bm F
\end{equation}
The equivalent dynamics matrix for this coupled system is:
\begin{equation}
[\tilde{A}] = [M][A]
\end{equation}

Finding the eigenvalues of $[\tilde{A}]$ will describe the coupled natural frequencies of the combined system. The integrated test for this scenario ensures that the analytical coupled frequency of oscillation matches the frequency obtained from the simulation.

\subsubsection{Max Deflection While Force is Being Applied}

The next BOE calculation that is needed is to find the maximum deflection while the force is being applied and when the force is not being applied (with the assumption that there is no damping). When the force is being applied the following max deflection can be seen in the following equation:

\begin{equation}
\theta_{\textnormal{max}} = 2 \theta_{\textnormal{SS}}
\end{equation}
which uses the definition of $\theta_{\textnormal{SS}}$ from Fig.~\ref{fig:BOEThetaSS}.

\subsubsection{Max Deflection While Force is Not Being Applied}

Finally, the maximum deflection when the force is not being applied uses energy techniques. Once the force is no longer being applied, energy is conserved and the velocity of the center of mass is constant. The energy when the force is turned off is represented in the following equation:

\begin{equation}
E_0 = \frac{1}{2} m_{\textnormal{hub}} \dot{y}_{B/N}^2 + 2\Big[\frac{1}{2} m_{\textnormal{sp}} \dot{\bm r}_{\textnormal{sp}} \cdot \dot{\bm r}_{\textnormal{sp}}  +  \frac{1}{2} I_{\textnormal{sp}} \dot{\theta}^2 + \frac{1}{2} k \theta^2\Big]
\end{equation}
Where $\dot{\bm r}_{\textnormal{sp}}$ is
\begin{equation}
\dot{\bm r}_{\textnormal{sp}} = \begin{bmatrix}
-d \dot{\theta} \sin (\theta)\\
\dot{y}_{B/N}  + d \dot{\theta} \cos (\theta)\\
\end{bmatrix}
\end{equation}
Next, the velocity of the center of mass of the system is defined in the following equation:
\begin{equation}
v_{\textnormal{CoM}} = \frac{1}{m_{\textnormal{tot}}}(m_{\textnormal{hub}} \dot{y}_{B/N} + 2 m_{\textnormal{sp}}\dot{ r}_{\textnormal{sp},y})
\end{equation}
This value can be computed from the values at the time the force is shut off and is a conserved quantity.

When the panels are deflected at max deflection, $\dot{\theta} = 0$. Leveraging this assumption the final energy is defined as follows:
\begin{equation}
E_F = \frac{1}{2} m_{\textnormal{tot}} v_{\textnormal{CoM}}^2 + 2\Big[\frac{1}{2} k \theta_{\textnormal{max}}^2\Big]
\end{equation}
Conservation of energy states
\begin{equation}
E_0 = \frac{1}{2} m_{\textnormal{tot}} v_{\textnormal{CoM}}^2 + k \theta_{\textnormal{max}}^2
\end{equation}
Therefore, $\theta_{\textnormal{max}}$ is found using the following equation:
\begin{equation}
\theta_{\textnormal{max}} = \sqrt{\frac{E_0 - \frac{1}{2} m_{\textnormal{tot}} v_{\textnormal{CoM}}^2}{k}}
\end{equation}

\subsection{Lagrangian vs Basilisk Scenario}

In this scenario the equations of motion for a planar simulation of a spacecraft hub and two hinged rigid bodies using Lagrangian mechanics was developed using Mathematica. The mathematica script can be seen in the support folder in the following file name: PlanarFlexibleDynamicsDerivation. This simulation is ran independently in the integrated test and the results are compared vs Basilisk results. A force and torque is applied for a certain amount of time, then turned off. Then another pulse of a force and torque is applied and turn off and the simulation runs for another few seconds.

\section{Test Parameters}

Since this is an integrated test, the inputs to the test are the physical parameters of the spacecraft along with the initial conditions of the states. These parameters are outlined in Tables~\ref{tab:hub}-~\ref{tab:initial}. Additionally, the error tolerances can be seen in Table~\ref{tab:errortol}.

\begin{table}[htbp]
	\caption{Spacecraft Hub Parameters}
	\label{tab:hub}
	\centering \fontsize{10}{10}\selectfont
	\begin{tabular}{| c | c | c | c |} % Column formatting,
		\hline
		\textbf{Name}  & \textbf{Description}  & \textbf{Value} & \textbf{Units} \\
		\hline
		mHub  & mass & 750.0 & kg \\
		\hline
		IHubPntBc\_B & Inertia in $\cal{B}$ frame & $\begin{bmatrix}
		900.0 & 0.0 & 0.0\\
		0.0 & 600.0 & 0.0\\
		0.0 & 0.0 & 600.0
		\end{bmatrix}$ & kg-m$^2$ \\
		\hline
		r\_BcB\_B & CoM Location in $\cal{B}$ frame & $\begin{bmatrix}
		0.0 & 0.0 & 1.0 \end{bmatrix}^T$ & m \\
		\hline
	\end{tabular}
\end{table}

\begin{table}[htbp]
	\caption{Hinged Rigid Body 1 Parameters}
	\label{tab:panel1}
	\centering \fontsize{10}{10}\selectfont
	\begin{tabular}{| c | c | c | c |} % Column formatting,
		\hline
		\textbf{Name}  & \textbf{Description}  & \textbf{Value} & \textbf{Units} \\
		\hline
		mass  & mass & 100.0 & kg \\
		\hline
		IPntS\_S & Inertia in $\cal{S}$ frame & $\begin{bmatrix}
		100.0 & 0.0 & 0.0\\
		0.0 & 50.0 & 0.0\\
		0.0 & 0.0 & 50.0
		\end{bmatrix}$ & kg-m$^2$ \\
		\hline
		d & CoM location & 1.5 & m \\
		\hline
		k & Spring Constant & 100.0 & N-m/rad \\
		\hline
		c & Damping Term & 0.0 (6.0 - damping scenario) & N-m-s/rad \\
		\hline
		r\_HB\_B & Hinge Location in $\cal{B}$ frame & $\begin{bmatrix}
		0.5 & 0.0 & 1.0 \end{bmatrix}^T$ & m \\
		\hline
		dcm\_HB & $\cal{B}$ to $\cal{H}$ DCM & $\begin{bmatrix}
		-1.0 & 0.0 & 0.0\\
		0.0 & -1.0 & 0.0\\
		0.0 & 0.0 & 1.0
		\end{bmatrix}$ & - \\
		\hline
	\end{tabular}
\end{table}

\begin{table}[htbp]
	\caption{Hinged Rigid Body 2 Parameters}
	\label{tab:panel2}
	\centering \fontsize{10}{10}\selectfont
	\begin{tabular}{| c | c | c | c |} % Column formatting,
		\hline
		\textbf{Name}  & \textbf{Description}  & \textbf{Value} & \textbf{Units} \\
		\hline
		mass  & mass & 100.0 & kg \\
		\hline
		IPntS\_S & Inertia in $\cal{S}$ frame & $\begin{bmatrix}
		100.0 & 0.0 & 0.0\\
		0.0 & 50.0 & 0.0\\
		0.0 & 0.0 & 50.0
		\end{bmatrix}$ & kg-m$^2$ \\
		\hline
		d & CoM location & 1.5 & m \\
		\hline
		k & Spring Constant & 100.0 & N-m/rad \\
		\hline
		c & Damping Term & 0.0 (7.0 - damping scenario) & N-m-s/rad \\
		\hline
		r\_HB\_B & Hinge Location in $\cal{B}$ frame & $\begin{bmatrix}
		-0.5 & 0.0 & 1.0 \end{bmatrix}^T$ & m \\
		\hline
		dcm\_HB & $\cal{B}$ to $\cal{H}$ DCM & $\begin{bmatrix}
		1.0 & 0.0 & 0.0\\
		0.0 & 1.0 & 0.0\\
		0.0 & 0.0 & 1.0
		\end{bmatrix}$ & - \\
		\hline
	\end{tabular}
\end{table}

\begin{table}[htbp]
	\caption{Initial Conditions for Energy Momentum Conservation Scenarios}
	\label{tab:initial}
	\centering \fontsize{10}{10}\selectfont
	\begin{tabular}{| c | c | c | c |} % Column formatting,
		\hline
		\textbf{Name}  & \textbf{Description}  & \textbf{Value} & \textbf{Units} \\
		\hline
		(Panel 1) thetaInit  & (Panel 1) Initial $\theta$ & 5.0 & deg \\
		\hline
		(Panel 1) thetaDotInit  & (Panel 1) Initial $\dot{\theta}$ & 0.0 & deg \\
		\hline
		(Panel 2) thetaInit  & (Panel 2) Initial $\theta$ & 0.0 & deg \\
		\hline
		(Panel 2) thetaDotInit  & (Panel 2) Initial $\dot{\theta}$ & 0.0 & deg \\
		\hline
		r\_CN\_NInit & Initial Position of S/C (gravity scenarios) & $\begin{bmatrix}
		-4020339 &	7490567 & 5248299
		\end{bmatrix}^T$ & m \\
		\hline
		v\_CN\_NInit & Initial Velocity of S/C (gravity scenarios) & $\begin{bmatrix}
		-5199.78 & -3436.68 & 1041.58
		\end{bmatrix}^T$ & m/s \\
		\hline
		r\_CN\_NInit & Initial Position of S/C (no gravity) & $\begin{bmatrix}
		0.1 & -0.4 & 0.3
		\end{bmatrix}^T$ & m \\
		\hline
		v\_CN\_NInit & Initial Velocity of S/C (no gravity) & $\begin{bmatrix}
		-0.2 & 0.5 & 0.1
		\end{bmatrix}^T$ & m/s \\
		\hline
		sigma\_BNInit & Initial MRP of $\cal{B}$ frame & $\begin{bmatrix}
		0.0 & 0.0 & 0.0
		\end{bmatrix}^T$ & - \\
		\hline
		omega\_BN\_BInit & Initial Angular Velocity of $\cal{B}$ frame & $\begin{bmatrix}
		0.1 & -0.1 & 0.1
		\end{bmatrix}^T$ & rad/s \\
		\hline
	\end{tabular}
\end{table}

\begin{table}[htbp]
	\caption{Error Tolerance - Note: Relative Tolerance is $\textnormal{abs}(\frac{\textnormal{truth} - \textnormal{value}}{\textnormal{truth}}$)}
	\label{tab:errortol}
	\centering \fontsize{10}{10}\selectfont
	\begin{tabular}{| c | c |} % Column formatting,
		\hline
		Test   & Relative Tolerance \\
		\hline
		Energy and Momentum Conservation & 1e-10 \\
		\hline
		Steady State Deflection & 1e-6 \\
		\hline
		Frequency verification & 5e-3 \\
		\hline
		Max deflection with force on & 5e-3 \\
		\hline
		Max deflection with force off & 5e-3 \\
		\hline
		Lagrangian vs Basilisk comparison & 1e-10 \\
		\hline
	\end{tabular}
\end{table}

\clearpage

\section{Test Results}

The following figures show the conservation of the quantities described in the success criteria for each scenario. The conservation plots are all relative difference plots. All conservation plots show integration error which is the desired result. In the python test these values are automatically checked therefore when the tests pass, these values have all been confirmed to be conserved.

\subsection{Gravity with no damping scenario}
\input{AutoTex/ChangeInOrbitalAngularMomentumGravity}
\input{AutoTex/ChangeInOrbitalEnergyGravity}
\input{AutoTex/ChangeInRotationalAngularMomentumGravity}
\input{AutoTex/ChangeInRotationalEnergyGravity}
\clearpage

\subsection{No Gravity with no damping scenario}
\input{AutoTex/ChangeInOrbitalAngularMomentumNoGravity}
\input{AutoTex/ChangeInOrbitalEnergyNoGravity}
\input{AutoTex/ChangeInRotationalAngularMomentumNoGravity}
\input{AutoTex/ChangeInRotationalEnergyNoGravity}
\input{AutoTex/VelocityOfCenterOfMassNoGravity}
\input{AutoTex/ChangeInVelocityOfCenterOfMassNoGravity}
\clearpage

\subsection{No Gravity with damping scenario}
\input{AutoTex/ChangeInOrbitalAngularMomentumNoGravityDamping}
\input{AutoTex/ChangeInOrbitalEnergyNoGravityDamping}
\input{AutoTex/ChangeInRotationalAngularMomentumNoGravityDamping}
\input{AutoTex/VelocityOfCenterOfMassNoGravityDamping}
\input{AutoTex/ChangeInVelocityOfCenterOfMassNoGravityDamping}
\clearpage

\subsection{Steady State Deflection Scenario}
\input{AutoTex/BOECalculationForSteadyStateTheta1DeflectionVsSimulation}
\input{AutoTex/BOECalculationForSteadyStateTheta2DeflectionVsSimulation}
\clearpage

\subsection{Frequency and Amplitude Verification Scenario}
\begin{table}[htbp]
	\caption{Frequency and Amplitude Test Results}
	\label{tab:freqAmpResults}
	\centering \fontsize{10}{10}\selectfont
	\begin{tabular}{| c | c | c | c |} % Column formatting,
		\hline
		\textbf{Name}  & \textbf{BOE Calculation}  & \textbf{Basilisk Results} & \textbf{Relative Error} \\
		\hline
		Frequency  & \input{AutoTex/FrequencyResults} \\
		\hline
		Theta Max 1 & \input{AutoTex/Theta1Results} \\
		\hline
		Theta Max 2 & \input{AutoTex/Theta2Results} \\
		\hline
	\end{tabular}
\end{table}
\input{AutoTex/MaxThetaWhileForcing}

\subsection{Lagrangian vs Basilisk Scenario}
\input{AutoTex/XPositionLagrangianVsBasilisk}
\input{AutoTex/YPositionLagrangianVsBasilisk}
\input{AutoTex/ThetaLagrangianVsBasilisk}
\input{AutoTex/Theta1LagrangianVsBasilisk}
\input{AutoTex/Theta2LagrangianVsBasilisk}
\clearpage


\documentclass[t,usenames,dvipsnames]{beamer}
\usetheme{Copenhagen}
\setbeamertemplate{headline}{} % remove toc from headers
\beamertemplatenavigationsymbolsempty

\usepackage{amsmath, tkz-euclide, tikz, xcolor, pgfplots, array}
\usetkzobj{all}
\pgfplotsset{compat = 1.16}
\usetikzlibrary{arrows.meta, calc, decorations.pathreplacing}
\pgfplotsset{every axis/.append style = {axis lines = middle, axis line style = {<->}}}
\pgfplotsset{every tick label/.append style={font=\scriptsize}}
\everymath{\displaystyle}

\title{Inverse Trig Functions}
\author{}
\date{}

\AtBeginSection[]
{
  \begin{frame}
    \frametitle{Objectives}
    \tableofcontents[currentsection]
  \end{frame}
}

\begin{document}

\begin{frame}
    \maketitle
\end{frame}

\section{Find the values of inverse trig functions}

\begin{frame}{Trig Functions and the Horizontal Line Test}
Recall that for a function to have an \alert{inverse}, any horizontal line can only hit the function \underline{at most once}.  \newline\\  \pause

This creates a problem with periodic functions such as $y = \sin x$.
\end{frame}

\begin{frame}{Graph of $y=\sin x$ and $y = \frac{1}{2}$}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
    xmin = -7, xmax = 7,
    ymin = -2, ymax = 2,
    xtick = {-6.28, -4.71, -3.14, -1.57, 0, 1.57, 3.14, 4.71,  6.28},
    xticklabels = {$-2\pi$, $-\frac{3\pi}{2}$, $-\pi$, $-\frac{\pi}{2}$, , $\frac{\pi}{2}$, $\pi$, $\frac{3\pi}{2}$, $2\pi$}
]
\addplot [domain=-2*pi:2*pi, samples=200, smooth, very thick, color=blue] {sin(deg(x))};
\addplot [domain=-7:7, samples=200, smooth, thick, color=red] {0.5};
\end{axis}
\end{tikzpicture}
\end{center}
\end{frame}

\begin{frame}{Passing the Horizontal Line Test}
If we limit the graph to a smaller domain, then the Horizontal Line Test will demonstrate the function $y = \sin x$ will have an inverse: \newline\\  \pause

\begin{center}
\begin{tikzpicture}
\begin{axis}[
    xmin = -3.25, xmax = 3.25,
    ymin = -2, ymax = 2,
    xtick = {-3.14, -1.57, 0, 1.57, 3.14},
    xticklabels = {$-\pi$, $-\frac{\pi}{2}$, , $\frac{\pi}{2}$, $\pi$}
]
\addplot [domain=-pi/2:pi/2, samples=200, smooth, very thick, color=blue] {sin(deg(x))};
\end{axis}
\end{tikzpicture}
\end{center}
\end{frame}

\begin{frame}{Graph of $y = \sin^{-1} x$}
The inverse of $y=\sin x$ is
\[
y = \sin^{-1}x \qquad \text{or} \qquad y = \arcsin x
\]  \pause
\begin{center}
\begin{tikzpicture}
\begin{axis}[
    xmin = -1.25, xmax = 1.25,
    ymin = -2, ymax = 2,
    domain = -1:1, samples=500,
    ytick = {-1.57,0,1.57},
    yticklabels = {$-\frac{\pi}{2}$,{}, $\frac{\pi}{2}$}
]
\addplot [very thick, color=blue] {asin(x)/180*pi};
\end{axis}
\end{tikzpicture}
\end{center}
\end{frame}

\begin{frame}{Domains and Ranges for Inverse Trig Functions}
\begin{center}
\setlength{\extrarowheight}{8pt}
\begin{tabular}{ccc}
\textbf{Inverse Function} & \textbf{Domain (Input)} & \textbf{Range (Output)} \\ \hline
\onslide<2->{$y = \sin^{-1} x$ &
$[-1,1]$ &
$\left[-\frac{\pi}{2},\frac{\pi}{2}\right]$} \\[10pt]
\onslide<3->{$y = \cos^{-1} x$ &
$[-1,1]$ &
$[0,\pi]$}   \\[10pt]
\onslide<4->{$y = \tan^{-1} x$ &
$(-\infty, \infty)$ &
$\left(-\frac{\pi}{2},\frac{\pi}{2}\right)$} \\[12pt]
\onslide<5->{$y = \csc^{-1} x$ &
$(-\infty, -1] \cup [1, \infty)$ &
$\left[-\frac{\pi}{2},0\right) \cup \left(0, \frac{\pi}{2}\right]$}  \\[10pt]
\onslide<6->{$y = \sec^{-1} x$ &
$(-\infty, -1] \cup [1, \infty)$ &
$\left[0, \frac{\pi}{2}\right) \cup \left(\frac{\pi}{2}, \pi\right]$} \\[12pt]
\onslide<7->{$y = \cot^{-1} x$ &
$(-\infty, \infty)$ &
$(0, \pi)$} \\
\end{tabular}
\end{center}
\end{frame}

\begin{frame}{Example 1}
Find the exact value of each.   \newline\\
(a) \quad $\sin^{-1}\left(\frac{\sqrt{2}}{2}\right)$    \newline\\
\begin{minipage}{0.5\textwidth}
\vspace{18pt}
\onslide<2->{
\begin{tikzpicture}
\draw [<->] (-1,0) -- (3,0) node [right] {$x$};
\draw [<->] (0,-1) -- (0,2) node [above] {$y$};
\tkzDefPoints{0/0/A, 2/0/B, 2/1.5/C}
\tkzMarkRightAngle[color=red](C,B,A)
\tkzDrawPolygon(A,B,C)
\tkzLabelAngle[pos=0.5](B,A,C){\scriptsize $\theta$}
\tkzLabelSegment[right](B,C){\scriptsize $\sqrt{2}$}
\tkzLabelSegment(A,C){\scriptsize $2$}
\end{tikzpicture}}
\end{minipage}
\hspace{0.25cm}
\begin{minipage}{0.4\textwidth}
\begin{align*}
    \onslide<3->{\theta &= \sin^{-1}\left(\frac{\sqrt{2}}{2}\right)} \\[12pt]
    \onslide<4->{\theta &= 45^\circ} \\[12pt]
    \onslide<5->{\theta &= \frac{\pi}{4} }
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 1}
Find the exact value of each.   \newline\\
(b) \quad $\cos^{-1}\left(-\frac{\sqrt{3}}{2}\right)$    \newline\\
\begin{minipage}{0.5\textwidth}
\vspace{18pt}
\onslide<2->{
\begin{tikzpicture}
\draw [<->] (-3,0) -- (1,0) node [right] {$x$};
\draw [<->] (0,-1) -- (0,2) node [above] {$y$};
\tkzDefPoints{0/0/A, -2/0/B, -2/1.5/C}
\tkzMarkRightAngle[color=red](C,B,A)
\tkzDrawPolygon(A,B,C)
% \tkzLabelAngle[pos=0.5](B,A,C){\scriptsize $\theta$}
% \tkzLabelSegment[right](B,C){\scriptsize $\sqrt{2}$}
\tkzLabelSegment[below](A,B){\scriptsize $-\sqrt{3}$}
\tkzLabelSegment(A,C){\scriptsize $2$}
\draw [->] (0.5,0) arc (0:140:0.5) node [above right, xshift=0.5cm] {\scriptsize $\theta$};
\end{tikzpicture}}
\end{minipage}
\hspace{0.25cm}
\begin{minipage}{0.4\textwidth}
\begin{align*}
    \onslide<3->{\theta &= \cos^{-1}\left(\frac{-\sqrt{3}}{2}\right)} \\[12pt]
    \onslide<4->{\theta &= 150^\circ} \\[12pt]
    \onslide<5->{\theta &= \frac{5\pi}{6} }
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 1}
Find the exact value of each.   \newline\\
(c) \quad $\arctan\left(\sqrt{3}\right)$    \newline\\
\begin{minipage}{0.5\textwidth}
\vspace{18pt}
\onslide<2->{
\begin{tikzpicture}
\draw [<->] (-1,0) -- (3,0) node [right] {$x$};
\draw [<->] (0,-1) -- (0,2) node [above] {$y$};
\tkzDefPoints{0/0/A, 2/0/B, 2/1.5/C}
\tkzMarkRightAngle[color=red](C,B,A)
\tkzDrawPolygon(A,B,C)
\tkzLabelAngle[pos=0.5](B,A,C){\scriptsize $\theta$}
\tkzLabelSegment[right](B,C){\scriptsize $\sqrt{3}$}
\tkzLabelSegment[below](A,B){\scriptsize $1$}
\end{tikzpicture}}
\end{minipage}
\hspace{0.25cm}
\begin{minipage}{0.4\textwidth}
\begin{align*}
    \onslide<3->{\theta &= \arctan\left(\sqrt{3}\right)} \\[12pt]
    \onslide<4->{\theta &= 60^\circ} \\[12pt]
    \onslide<5->{\theta &= \frac{\pi}{3} }
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 1}
Find the exact value of each.   \newline\\
(d) \quad $\sec^{-1}\left(2\right)$    \newline\\
\begin{minipage}{0.5\textwidth}
\vspace{18pt}
\onslide<2->{
\begin{tikzpicture}
\draw [<->] (-1,0) -- (3,0) node [right] {$x$};
\draw [<->] (0,-1) -- (0,2) node [above] {$y$};
\tkzDefPoints{0/0/A, 2/0/B, 2/1.5/C}
\tkzMarkRightAngle[color=red](C,B,A)
\tkzDrawPolygon(A,B,C)
\tkzLabelAngle[pos=0.5](B,A,C){\scriptsize $\theta$}
\tkzLabelSegment[below](B,A){\scriptsize $1$}
\tkzLabelSegment[above](A,C){\scriptsize $2$}
\end{tikzpicture}}
\end{minipage}
\hspace{0.25cm}
\begin{minipage}{0.4\textwidth}
\begin{align*}
    \onslide<3->{\theta &= \sec^{-1}\left(2\right)} \\[12pt]
    \onslide<4->{\theta &= 60^\circ} \\[12pt]
    \onslide<5->{\theta &= \frac{\pi}{3} }
\end{align*}
\end{minipage}
\end{frame}

\section{Find the values of the compositions of inverse trig functions}

\begin{frame}{Compositions of Inverse Trig Functions}
When dealing with problems like these, it helps to \alert{sketch a right triangle}, much like in the previous example. \newline\\

You may need to use the Pythagorean Theorem.
\end{frame}

\begin{frame}{Example 2}
Find the exact values of each (if possible).    \newline\\
(a) \quad $\cos\left(\cos^{-1}\left(\frac{1}{3}\right)\right)$  \newline\\
\begin{minipage}{0.5\textwidth}
\vspace{18pt}
\onslide<2->{
\begin{tikzpicture}
\draw [<->] (-1,0) -- (3,0) node [right] {$x$};
\draw [<->] (0,-1) -- (0,2) node [above] {$y$};
\tkzDefPoints{0/0/A, 2/0/B, 2/1.5/C}
\tkzMarkRightAngle[color=red](C,B,A)
\tkzDrawPolygon(A,B,C)
\tkzLabelAngle[pos=0.5](B,A,C){\scriptsize $\theta$}
\tkzLabelSegment[below](B,A){\scriptsize $1$}
\tkzLabelSegment[above](A,C){\scriptsize $3$}
\end{tikzpicture}}
\end{minipage}
\hspace{0.25cm}
\begin{minipage}{0.4\textwidth}
\begin{align*}
    \onslide<3->{\theta &= \cos^{-1}\left(\frac{1}{3}\right)} \\[12pt]
    \onslide<4->{\cos\theta &= \frac{x}{r}} \\[12pt]
    \onslide<5->{\cos\theta &= \frac{1}{3} }
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 2}
(b) \quad   $\sin\left(\arcsin\left(-\frac{3}{7}\right)\right)$   \newline\\
\begin{minipage}{0.5\textwidth}
\vspace{18pt}
\onslide<2->{
\begin{tikzpicture}
\draw [<->] (-1,0) -- (3,0) node [right] {$x$};
\draw [<->] (0,-2) -- (0,1) node [above] {$y$};
\tkzDefPoints{0/0/A, 2/0/B, 2/-1.5/C}
\tkzMarkRightAngle[color=red](C,B,A)
\tkzDrawPolygon(A,B,C)
\tkzLabelAngle[pos=0.5](B,A,C){\scriptsize $\theta$}
\tkzLabelSegment[right](B,C){\scriptsize $-3$}
\tkzLabelSegment[below](A,C){\scriptsize $7$}
\end{tikzpicture}}
\end{minipage}
\hspace{0.25cm}
\begin{minipage}{0.4\textwidth}
\begin{align*}
    \onslide<3->{\theta &= \arcsin\left(-\frac{3}{7}\right)} \\[12pt]
    \onslide<4->{\sin\theta &= \frac{y}{r}} \\[12pt]
    \onslide<5->{\sin\theta &= -\frac{3}{7} }
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 2}
(c) \quad   $\cos\left(\arccos\left(\frac{5}{4}\right)\right)$   \newline\\
\begin{minipage}{0.5\textwidth}
\vspace{18pt}
\onslide<2->{
\begin{tikzpicture}
\draw [<->] (-1,0) -- (3,0) node [right] {$x$};
\draw [<->] (0,-1) -- (0,2) node [above] {$y$};
\tkzDefPoints{0/0/A, 2/0/B, 2/1.5/C}
\tkzMarkRightAngle[color=red](C,B,A)
\tkzDrawPolygon(A,B,C)
\tkzLabelAngle[pos=0.5](B,A,C){\scriptsize $\theta$}
\tkzLabelSegment[below](B,A){\scriptsize $5$}
\tkzLabelSegment[above](A,C){\scriptsize $4$}
\end{tikzpicture}}
\end{minipage}
\hspace{0.25cm}
\begin{minipage}{0.4\textwidth}
\begin{align*}
    \onslide<3->{\theta &= \arccos\left(\frac{5}{4}\right)} \\[12pt]
    \onslide<4->{&\text{Domain error.}} \\[12pt]
    \onslide<5->{&\varnothing}
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 2}
(d) \quad   $\cos\left(\arctan\left(\frac{5}{12}\right)\right)$   \newline\\
\begin{minipage}{0.5\textwidth}
\vspace{18pt}
\onslide<2->{
\begin{tikzpicture}
\draw [<->] (-1,0) -- (3,0) node [right] {$x$};
\draw [<->] (0,-1) -- (0,2) node [above] {$y$};
\tkzDefPoints{0/0/A, 2/0/B, 2/1.5/C}
\tkzMarkRightAngle[color=red](C,B,A)
\tkzDrawPolygon(A,B,C)
\tkzLabelAngle[pos=0.5](B,A,C){\scriptsize $\theta$}
\tkzLabelSegment[below](B,A){\scriptsize $12$}
\tkzLabelSegment[right](B,C){\scriptsize $5$}
\onslide<5->{\tkzLabelSegment[above](A,C){\scriptsize $13$}}
\end{tikzpicture}}
\end{minipage}
\hspace{0.25cm}
\begin{minipage}{0.4\textwidth}
\begin{align*}
    \onslide<3->{\theta &= \arctan\left(\frac{5}{12}\right)} \\[12pt]
    \onslide<4->{12^2 + 5^2 &= r^2} \\[12pt]
    \onslide<5->{r &= \sqrt{169} = 13} \\[12pt]
    \onslide<6->{\cos\theta &= \frac{12}{13}}
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 2}
(e) \quad   $\sin\left(\arctan\left(\frac{3}{4}\right)\right)$   \newline\\
\begin{minipage}{0.5\textwidth}
\vspace{18pt}
\onslide<2->{
\begin{tikzpicture}
\draw [<->] (-1,0) -- (3,0) node [right] {$x$};
\draw [<->] (0,-1) -- (0,2) node [above] {$y$};
\tkzDefPoints{0/0/A, 2/0/B, 2/1.5/C}
\tkzMarkRightAngle[color=red](C,B,A)
\tkzDrawPolygon(A,B,C)
\tkzLabelAngle[pos=0.5](B,A,C){\scriptsize $\theta$}
\tkzLabelSegment[below](B,A){\scriptsize $4$}
\tkzLabelSegment[right](B,C){\scriptsize $3$}
\onslide<5->{\tkzLabelSegment[above](A,C){\scriptsize $5$}}
\end{tikzpicture}}
\end{minipage}
\hspace{0.25cm}
\begin{minipage}{0.4\textwidth}
\begin{align*}
    \onslide<3->{\theta &= \arctan\left(\frac{3}{4}\right)} \\[12pt]
    \onslide<4->{3^2 + 4^2 &= r^2} \\[12pt]
    \onslide<5->{r &= \sqrt{25} = 5} \\[12pt]
    \onslide<6->{\sin\theta &= \frac{3}{5}}
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 2}
(f) \quad   $\cot\left(\arcsin\left(-\frac{1}{3}\right)\right)$   \newline\\
\begin{minipage}{0.5\textwidth}
\vspace{18pt}
\onslide<2->{
\raisebox{1.5cm}{
\begin{tikzpicture}
\draw [<->] (-1,0) -- (3,0) node [right] {$x$};
\draw [<->] (0,-2) -- (0,1) node [above] {$y$};
\tkzDefPoints{0/0/A, 2/0/B, 2/-1.5/C}
\tkzMarkRightAngle[color=red](C,B,A)
\tkzDrawPolygon(A,B,C)
\tkzLabelAngle[pos=0.5](B,A,C){\scriptsize $\theta$}
\tkzLabelSegment[right](B,C){\scriptsize $-1$}
\tkzLabelSegment[below](A,C){\scriptsize $3$}
\onslide<5->{\tkzLabelSegment[above](B,A){\scriptsize $2\sqrt{2}$}}
\end{tikzpicture}} }
\end{minipage}
\hspace{0.25cm}
\begin{minipage}{0.4\textwidth}
\begin{align*}
    \onslide<3->{\theta &= \arcsin\left(-\frac{1}{3}\right)} \\[12pt]
    \onslide<4->{x^2 + 1^2 &= 3^2} \\[12pt]
    \onslide<5->{x &= \sqrt{8} = 2\sqrt{2}} \\[12pt]
    \onslide<6->{\cot\theta &= \frac{x}{y}} \\[12pt]
    \onslide<7->{\cot\theta &= \frac{2\sqrt{2}}{-1} = -2\sqrt{2}}
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 2}
(g) \quad   $\sec\left(\arccos\left(\frac{3}{4}\right)\right)$   \newline\\
\begin{minipage}{0.5\textwidth}
\vspace{18pt}
\onslide<2->{
\begin{tikzpicture}
\draw [<->] (-1,0) -- (3,0) node [right] {$x$};
\draw [<->] (0,-1) -- (0,2) node [above] {$y$};
\tkzDefPoints{0/0/A, 2/0/B, 2/1.5/C}
\tkzMarkRightAngle[color=red](C,B,A)
\tkzDrawPolygon(A,B,C)
\tkzLabelAngle[pos=0.5](B,A,C){\scriptsize $\theta$}
\tkzLabelSegment[below](B,A){\scriptsize $3$}
\tkzLabelSegment[above](A,C){\scriptsize $4$}
\end{tikzpicture}}
\end{minipage}
\hspace{0.25cm}
\begin{minipage}{0.4\textwidth}
\begin{align*}
    \onslide<3->{\theta &= \arccos\left(\frac{3}{4}\right)} \\[12pt]
    \onslide<4->{\sec\theta &= \frac{r}{x}} \\[12pt]
    \onslide<5->{\sec\theta &= \frac{4}{3}}
\end{align*}
\end{minipage}
\end{frame}

\section{Write an algebraic expression for the compositions of inverse trig functions}

\begin{frame}{Algebraic Inverse Trig}
In calculus, inverse trigonometric functions will be expressed algebraically (i.e. in terms of $x$).    \newline\\

Set up a right triangle and use the \alert{Pythagorean Theorem} to write the missing side in terms of $x$.
\end{frame}

\begin{frame}{Example 3}
Write each as an algebraic expression of $x$.   \newline\\
(a) \quad   $\cos\left(\sin^{-1} x\right)$  \newline\\
\begin{minipage}{0.5\textwidth}
\vspace{18pt}
\onslide<2->{
\raisebox{1.5cm}{
\begin{tikzpicture}
\draw [<->] (-1,0) -- (3,0) node [right] {$x$};
\draw [<->] (0,-1) -- (0,2) node [above] {$y$};
\tkzDefPoints{0/0/A, 2/0/B, 2/1.5/C}
\tkzMarkRightAngle[color=red](C,B,A)
\tkzDrawPolygon(A,B,C)
\tkzLabelAngle[pos=0.5](B,A,C){\scriptsize $\theta$}
\tkzLabelSegment[right](B,C){\scriptsize $x$}
\tkzLabelSegment[above](A,C){\scriptsize $1$}
\onslide<5->{\tkzLabelSegment[below](B,A){\scriptsize $\sqrt{1-x^2}$}}
\end{tikzpicture}} }
\end{minipage}
\hspace{-0.25cm}
\begin{minipage}{0.4\textwidth}
\begin{align*}
    \onslide<3->{\theta &= \arcsin\left(x\right)} \\[8pt]
    \onslide<4->{a^2 + x^2 &= 1^2} \\[8pt]
    \onslide<5->{a &= \sqrt{1-x^2}} \\[8pt]
    \onslide<6->{\cos\theta &= \frac{\text{adj}}{\text{hyp}}} \\[12pt]
    \onslide<7->{\cos\theta &= \frac{\sqrt{1-x^2}}{1} = \sqrt{1-x^2}}
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 3}
(b) \quad   $\sec\left(\tan^{-1} x\right)$  \newline\\
\begin{minipage}{0.5\textwidth}
\vspace{18pt}
\onslide<2->{
\raisebox{1.5cm}{
\begin{tikzpicture}
\draw [<->] (-1,0) -- (3,0) node [right] {$x$};
\draw [<->] (0,-1) -- (0,2) node [above] {$y$};
\tkzDefPoints{0/0/A, 2/0/B, 2/1.5/C}
\tkzMarkRightAngle[color=red](C,B,A)
\tkzDrawPolygon(A,B,C)
\tkzLabelAngle[pos=0.5](B,A,C){\scriptsize $\theta$}
\tkzLabelSegment[right](B,C){\scriptsize $x$}
\onslide<5->{\tkzLabelSegment[above,sloped](A,C){\scriptsize $\sqrt{1+x^2}$}}
\tkzLabelSegment[below](B,A){\scriptsize $1$}
\end{tikzpicture}} }
\end{minipage}
\hspace{-0.25cm}
\begin{minipage}{0.4\textwidth}
\begin{align*}
    \onslide<3->{\theta &= \arctan\left(x\right)} \\[8pt]
    \onslide<4->{1^2 + x^2 &= c^2} \\[8pt]
    \onslide<5->{c &= \sqrt{1+x^2}} \\[8pt]
    \onslide<6->{\sec\theta &= \frac{\text{hyp}}{\text{adj}}} \\[12pt]
    \onslide<7->{\sec\theta &= \frac{\sqrt{1+x^2}}{1} = \sqrt{1+x^2}}
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 3}
(c) \quad   $\tan\left(\sin^{-1}(2x)\right)$    \newline\\
\begin{minipage}{0.5\textwidth}
\vspace{18pt}
\onslide<2->{
\raisebox{1.5cm}{
\begin{tikzpicture}
\draw [<->] (-1,0) -- (3,0) node [right] {$x$};
\draw [<->] (0,-1) -- (0,2) node [above] {$y$};
\tkzDefPoints{0/0/A, 2/0/B, 2/1.5/C}
\tkzMarkRightAngle[color=red](C,B,A)
\tkzDrawPolygon(A,B,C)
\tkzLabelAngle[pos=0.5](B,A,C){\scriptsize $\theta$}
\tkzLabelSegment[right](B,C){\scriptsize $2x$}
\tkzLabelSegment[above](A,C){\scriptsize $1$}
\onslide<6->{\tkzLabelSegment[below](B,A){\scriptsize $\sqrt{1-4x^2}$}}
\end{tikzpicture}} }
\end{minipage}
\hspace{-1cm}
\begin{minipage}{0.5\textwidth}
\begin{align*}
    \onslide<3->{\theta &= \arcsin\left(2x\right)} \\[12pt]
    \onslide<4->{a^2 + (2x)^2 &= 1^2} \\[12pt]
    \onslide<5->{a^2 + 4x^2 &= 1} \\[12pt]
    \onslide<6->{a &= \sqrt{1-4x^2}}
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 3}
(c) \quad   $\tan\left(\sin^{-1}(2x)\right)$    \newline\\
\begin{minipage}{0.5\textwidth}
\vspace{18pt}
\raisebox{1.5cm}{
\begin{tikzpicture}
\draw [<->] (-1,0) -- (3,0) node [right] {$x$};
\draw [<->] (0,-1) -- (0,2) node [above] {$y$};
\tkzDefPoints{0/0/A, 2/0/B, 2/1.5/C}
\tkzMarkRightAngle[color=red](C,B,A)
\tkzDrawPolygon(A,B,C)
\tkzLabelAngle[pos=0.5](B,A,C){\scriptsize $\theta$}
\tkzLabelSegment[right](B,C){\scriptsize $2x$}
\tkzLabelSegment[above](A,C){\scriptsize $1$}
\tkzLabelSegment[below](B,A){\scriptsize $\sqrt{1-4x^2}$}
\end{tikzpicture}}
\end{minipage}
\hspace{-1cm}
\begin{minipage}{0.5\textwidth}
\begin{align*}
    \onslide<2->{\tan\theta &= \frac{\text{opp}}{\text{adj}}} \\[15pt]
    \onslide<3->{\tan\theta &= \frac{2x}{\sqrt{1-4x^2}}}  \\[15pt]
    \onslide<4->{\tan\theta &= \frac{2x\sqrt{1-4x^2}}{1-4x^2}}
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 3}
(d) \quad $\sin\left(\cot^{-1}\left(\frac{x}{5}\right)\right)$  \newline\\
\begin{minipage}{0.5\textwidth}
\vspace{18pt}
\onslide<2->{
\raisebox{1.5cm}{
\begin{tikzpicture}
\draw [<->] (-1,0) -- (3,0) node [right] {$x$};
\draw [<->] (0,-1) -- (0,2) node [above] {$y$};
\tkzDefPoints{0/0/A, 2/0/B, 2/1.5/C}
\tkzMarkRightAngle[color=red](C,B,A)
\tkzDrawPolygon(A,B,C)
\tkzLabelAngle[pos=0.5](B,A,C){\scriptsize $\theta$}
\tkzLabelSegment[right](B,C){\scriptsize $5$}
\onslide<5->{\tkzLabelSegment[above,sloped](A,C){\scriptsize $\sqrt{25+x^2}$}}
\tkzLabelSegment[below](B,A){\scriptsize $x$}
\end{tikzpicture}} }
\end{minipage}
\hspace{-0.25cm}
\begin{minipage}{0.4\textwidth}
\begin{align*}
    \onslide<3->{\theta &= \cot^{-1}\left(\frac{x}{5}\right)} \\[8pt]
    \onslide<4->{5^2 + x^2 &= c^2} \\[8pt]
    \onslide<5->{c &= \sqrt{25+x^2}}
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 3}
(d) \quad $\sin\left(\cot^{-1}\left(\frac{x}{5}\right)\right)$  \newline\\
\begin{minipage}{0.5\textwidth}
\vspace{18pt}
\raisebox{1.5cm}{
\begin{tikzpicture}
\draw [<->] (-1,0) -- (3,0) node [right] {$x$};
\draw [<->] (0,-1) -- (0,2) node [above] {$y$};
\tkzDefPoints{0/0/A, 2/0/B, 2/1.5/C}
\tkzMarkRightAngle[color=red](C,B,A)
\tkzDrawPolygon(A,B,C)
\tkzLabelAngle[pos=0.5](B,A,C){\scriptsize $\theta$}
\tkzLabelSegment[right](B,C){\scriptsize $5$}
\tkzLabelSegment[above,sloped](A,C){\scriptsize $\sqrt{25+x^2}$}
\tkzLabelSegment[below](B,A){\scriptsize $x$}
\end{tikzpicture}}
\end{minipage}
\hspace{-0.25cm}
\begin{minipage}{0.4\textwidth}
\begin{align*}
    \onslide<2->{\sin\theta &= \frac{\text{opp}}{\text{hyp}}} \\[12pt]
    \onslide<3->{\sin\theta &= \frac{5}{\sqrt{25+x^2}}}    \\[12pt]
    \onslide<4->{&= \frac{5\sqrt{25+x^2}}{25+x^2}}
\end{align*}
\end{minipage}
\end{frame}

\end{document}


\documentclass[11pt]{article}

\usepackage{amsmath}
\usepackage{pgfplots}
\usepackage{siunitx}
\usepackage{pythontex}
\newcommand{\pymultiply}[2]{\py{#1*#2}}

\begin{document}

\begin{pycode}
print("Python says ``Hello!''")
\end{pycode}

\section{Histogram}

\begin{figure}
	\centering
        \input{histogram.pgf}
    \caption{A PGF histogram from \texttt{matplotlib}.}
\end{figure}

$8 \times 256 = \pymultiply{8}{256}$

\end{document}


\chapter{{\tt SolveMap}: Forward and Backsolve Map}
\par
The {\tt SolveMap} object is to assign submatrix operations to
threads or processors in a forward and backsolve.
\par
A front is {\it owned} by a single process,
and this ownership is defined by an {\tt owners[]} vector.
If process {\tt myid} owns front {\tt J}, then
$L_{{\tt J},{\tt J}}$, $D_{{\tt J},{\tt J}}$ and $U_{{\tt J},{\tt J}}$
are owned by {\tt myid}.
The off-diagonal submatrices in the upper block
and their owners are stored as triples in three vectors.
The {\tt ii}'th submatrix in the upper triangle has
row id {\tt rowidsUpper[ii]},
column id {\tt colidsUpper[ii]},
and is owned by thread or process {\tt mapUpper[ii]}.
A similar situation holds for the lower triangle when the
factorization is nonsymmetric.
\par


% !TEX root=/home/tavant/these/manuscript/src/manuscript.tex

\section{Validation of the sheath model }
  \label{sec-sheath_validation}

  The \ac{PIC} simulations used here do not need any sheath theory in order to model the plasma-wall interaction.
  Conversely, they rely on first principle models.
  Hence, they can be used in order to validate the sheath model introduced in \cref{sec-sheath} coming from the fluid theory.

  This sheath model links with \cref{eq-dphi_vs_Te_Maxw} the plasma potential drop $\dphi$ with the electron temperature $\Te$ and the electron emission rate $\rate$.
  \Cref{eq-seemaxw} can be used to estimate the electron emission rate given the mean electron temperature measured in the simulations, corresponding statistically to the plasma bulk temperature.
  In the \ac{PIC} simulations, $\rate$ can be computed using \cref{eq-seeyield} by counting the number of electrons attaining the wall and emitted during a time-step.
  We note \ratepic this measurement.
  \vspace{1em}

  \begin{figure}[hbt]
    \centering
    \includegraphics[width=\defaultwidth]{SEE_rates}
    \caption{Values of the electron emission rate $\ratepic$ (blue) measured in the \acs{PIC} simulations, and (orange) $ \ratemaxw$ obtained with \cref{eq-seemaxw} using the electron temperature shown in \cref{fig-Tevsproba}. }
    \label{fig-seeparamesMaxw}
  \end{figure}

  We can see in \Cref{fig-seeparamesMaxw} that the mean electron emission rate in the simulations $\ratepic$ lies between 0.6 for large $\crover$ and 1 at low $\crover$.
  The saturation of $\ratepic$ at 1 for high emissivity ($\crover < 50 \volt$) was not expected from \ratemaxw obtained with \cref{eq-seemaxw}.
  Indeed, $\probamax$ in \cref{eq-seemaxw} is equal to 2.9, and the electron temperature in the bulk measured, when used in \cref{eq-seemaxw}, predicts a rate between 1.4 and 2.8.
  This discrepancy at low $\crover$ is due to the \ac{SCL} regime.
  \citet{hobbs1967} predicted that in this regime, a potential well forms such that a fraction of the emitted electrons return to the wall, in order to maintain the effective emission rate to $\ratecr\sim1$.
  However, for $\crover > 50 \volt$, the sheath regime described in \cref{sec-sheath} should be valid.

  \begin{figure}[hbt]
    \centering
    \begin{tabular}{@{} cc}
      \includegraphics[width=0.49\textwidth]{phi_drop_6}
      &
      \includegraphics[width=0.49\textwidth]{Te_pic_2}
    \end{tabular}
    \caption{({\bf a}) Plasma potential drop to the wall normalized by the electron bulk temperature as a function of the electron rate, and ({\bf b}) the mean electron bulk temperature measured in the \acs{PIC} simulations as a function of the electron emission rate \rate, measured in the simulations, and the effective temperature expected from \cref{eq-Teeff}.  }
    \label{fig-Tevsproba}
  \end{figure}

  The electron temperature measured in the bulk of the simulation is presented in \cref{fig-Tevsproba}.{\bf b} for the same cases as in \cref{fig-seeparamesMaxw}.
  An \emph{effective} temperature that would correspond to the measured emission rate $\ratepic$ in \cref{eq-dphi_vs_Te_Maxw} is given by:
  \begin{equation} \label{eq-Teeff}
     \ratemaxw(\Te{}_{, eff}) = \ratepic \text{, hence } \Te{}_{, eff} = \frac{\ratepic - \sigo}{1 - \sigo} \frac{\crover}{2},
  \end{equation}
  We can see that when \rate increases, the electron temperature in the bulk $\Te$ monotonically decreases from 45V to around 30V.
  However, these values are not consistent with the measured emission rate \ratepic, even for $\crover > 50\volt$.
  The bulk electron temperature is much higher than the effective $\Te{}_{, eff}$ obtained to correctly predict the emission rate.

  \Cref{fig-Tevsproba}.{\bf a} shows the evolution of the potential drop to the wall measured in the \ac{PIC} simulation compared to the theory  \cref{eq-sheathhobbs} ).
  As expected by \cref{eq-dphi_scl}, $\dphi$ measured in the simulation saturates to $\Te$ for high emission rate ($\ratepic \sim 1$).
  However, we see that at low emission rate, the potential drop is significantly lower than expected.
  The sheath model of \cref{sec-sheath} used two hypotheses\string:
  \begin{itemize}
    \item Maxwellian distribution function to obtain $\ratemaxw$ from \cref{eq-seeyield},
    \item Isothermal electrons in the sheath.
  \end{itemize}
  These two hypotheses will be checked against the PIC simulations in the next chapter.


\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[left=2.5cm, right=2.5cm, top=2.5cm, bottom=2.5cm]{geometry}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{times}
\usepackage[bottom]{footmisc}
\usepackage{listings}
\usepackage{bm}
\usepackage{amsmath}
\usepackage{algpseudocode}
\usepackage{algorithm}
\usepackage{titlesec}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{xfrac}

\title{\textbf{Advanced Machine Learning -- Homework 2}}
\author{Anna Berger, Ashwin Sadananda Bhat (AML25)}

\begin{document}
	\maketitle

	\section*{Part 1: Mixture Models}
	\subsection*{Exercise 1.1}

	In this part we consider the mixture of two Bernoulli distributions. To be more specific: each observation $x=(h, t)$ is the outcome of 5 coin tosses with a specific coin, with $h$ --- the number of heads and $t$ --- the number of tails, so $h+t=5$. But there are two coins in play with possible different probabilities for heads. Hence it can be modelled as a mixture of two probability distributions:
	$$ p(x | \mu,\pi) = \pi_1 \cdot p(x|\mu_1) + \pi_2 \cdot p(x|\mu_2) $$

	Each probability distribution is of Bernoulli type, so:
	$$ p((h,t)|\mu) = \binom {h+t}{h} \cdot \mu^h \cdot (1-\mu)^t$$

	We assume that parameters of the model are initialised as $\pi = \left(
	 \frac{1}{3}, \frac{2}{3}\right)$, $\mu = \left(
	 \frac{2}{3}, \frac{1}{2}\right)$.

	First, for each observation and for each component we compute responsibilities:

	$$ \gamma(z_{11}) = \frac{\pi_1 \cdot p(x_1|\mu_1)}{\pi_1 \cdot p(x_1|\mu_1)+[\pi_2 \cdot p(x_1|\mu_2)} = \frac{\binom {5}{2} \cdot \frac{1}{3} \cdot (\frac{2}{3})^2 \cdot (\frac{1}{3})^3}{\binom {5}{2} \cdot \frac{1}{3} \cdot (\frac{2}{3})^2 \cdot (\frac{1}{3})^3+\binom {5}{2} \cdot \frac{2}{3} \cdot (\frac{1}{2})^2 \cdot (\frac{1}{2})^3}=\frac{64}{307} $$

	$$ \gamma(z_{12}) = \frac{\pi_2 \cdot p(x_1|\mu_2)}{\pi_1 \cdot p(x_1|\mu_1)+\pi_2 \cdot p(x_1|\mu_2)} = \frac{\binom {5}{2} \cdot \frac{2}{3} \cdot (\frac{1}{2})^2 \cdot (\frac{1}{2})^3}{\binom {5}{2} \cdot \frac{1}{3} \cdot (\frac{2}{3})^2 \cdot (\frac{1}{3})^3+\binom {5}{2} \cdot \frac{2}{3} \cdot (\frac{1}{2})^2 \cdot (\frac{1}{2})^3}=\frac{243}{307} $$

	$$ \gamma(z_{21}) = \frac{\pi_1 \cdot p(x_2|\mu_1)}{\pi_1 \cdot p(x_2|\mu_1)+\pi_2 \cdot p(x_2|\mu_2)} = \frac{\binom {5}{1} \cdot \frac{1}{3} \cdot (\frac{2}{3})^1 \cdot (\frac{1}{3})^4}{\binom {5}{1} \cdot \frac{1}{3} \cdot (\frac{2}{3})^1 \cdot (\frac{1}{3})^4+\binom {5}{1} \cdot \frac{2}{3} \cdot (\frac{1}{2})^1 \cdot (\frac{1}{2})^4}=\frac{32}{275} $$

	$$ \gamma(z_{22}) = \frac{\pi_2 \cdot p(x_2|\mu_2)}{\pi_1 \cdot p(x_2|\mu_1)+\pi_2 \cdot p(x_2|\mu_2)} = \frac{\binom {5}{1} \cdot \frac{2}{3} \cdot (\frac{1}{2})^1 \cdot (\frac{1}{2})^4}{\binom {5}{1} \cdot \frac{1}{3} \cdot (\frac{2}{3})^1 \cdot (\frac{1}{3})^4+\binom {5}{1} \cdot \frac{2}{3} \cdot (\frac{1}{2})^1 \cdot (\frac{1}{2})^4}=\frac{243}{275} $$

	$$ \gamma(z_{31}) = \frac{\pi_1 \cdot p(x_3|\mu_1)}{\pi_1 \cdot p(x_3|\mu_1)+\pi_2 \cdot p(x_3|\mu_2)} = \frac{\binom {5}{2} \cdot \frac{1}{3} \cdot (\frac{2}{3})^2 \cdot (\frac{1}{3})^3}{\binom {5}{2} \cdot \frac{1}{3} \cdot (\frac{2}{3})^2 \cdot (\frac{1}{3})^3+\binom {5}{2} \cdot \frac{2}{3} \cdot (\frac{1}{2})^2 \cdot (\frac{1}{2})^3}=\frac{64}{307} $$

	$$ \gamma(z_{32}) = \frac{\pi_2 \cdot p(x_3|\mu_2)}{\pi_1 \cdot p(x_3|\mu_1)+\pi_2 \cdot p(x_3|\mu_2)} = \frac{\binom {5}{2} \cdot \frac{2}{3} \cdot (\frac{1}{2})^2 \cdot (\frac{1}{2})^3}{\binom {5}{2} \cdot \frac{1}{3} \cdot (\frac{2}{3})^2 \cdot (\frac{1}{3})^3+\binom {5}{2} \cdot \frac{2}{3} \cdot (\frac{1}{2})^2 \cdot (\frac{1}{2})^3}=\frac{243}{307} $$

	$$ \gamma(z_{41}) = \frac{\pi_1 \cdot p(x_4|\mu_1)}{\pi_1 \cdot p(x_4|\mu_1)+\pi_2 \cdot p(x_4|\mu_2)} = \frac{\binom {5}{3} \cdot \frac{1}{3} \cdot (\frac{2}{3})^3 \cdot (\frac{1}{3})^2}{\binom {5}{3} \cdot \frac{1}{3} \cdot (\frac{2}{3})^3 \cdot (\frac{1}{3})^2+\binom {5}{3} \cdot \frac{2}{3} \cdot (\frac{1}{2})^3 \cdot (\frac{1}{2})^2}=\frac{128}{371} $$

	$$ \gamma(z_{42}) = \frac{\pi_2 \cdot p(x_4|\mu_2)}{\pi_1 \cdot p(x_4|\mu_1)+\pi_2 \cdot p(x_4|\mu_2)} = \frac{\binom {5}{3} \cdot \frac{2}{3} \cdot (\frac{1}{2})^3 \cdot (\frac{1}{2})^2}{\binom {5}{3} \cdot \frac{1}{3} \cdot (\frac{2}{3})^3 \cdot (\frac{1}{3})^2+\binom {5}{3} \cdot \frac{2}{3} \cdot (\frac{1}{2})^3 \cdot (\frac{1}{2})^2}=\frac{243}{371} $$

	Therefore, we obtain the following table with responsibilities:

	\begin{table}[H]
		\centering
		\begin{tabular}{lrr}
			x       & $\gamma (z_{n_1})$          & $\gamma (z_{n_2})$          \\ \midrule
			(2, 3) & $\sfrac{64}{307}$ & $\sfrac{243}{307}$  \\
			\addlinespace
			(1, 4) & $\sfrac{32}{275}$ & $\sfrac{243}{275}$  \\
			\addlinespace
			(2, 3) & $\sfrac{64}{307}$ & $\sfrac{243}{307}$  \\
			\addlinespace
			(3, 2) & $\sfrac{128}{371}$ & $\sfrac{243}{371}$  \\
			\bottomrule
		\end{tabular}
	\end{table}

	\subsection*{Exercise 1.2}

	Now we are ready to update $\pi$ and $\mu$:

	$$\pi_k = \frac{N_k}{N}, \quad N_k = \sum\limits_{n=1}^N \gamma(z_{n_k})$$

	First, we compute $N_1$ and $N_2$:

	$$ N_1 = \frac{64}{307} + \frac{32}{275} + \frac{64}{307} + \frac{128}{371} \approx 0.878$$
	$$ N_2 = \frac{243}{307} + \frac{243}{275} + \frac{243}{307} + \frac{243}{371} \approx 3.122$$

	Now, we can calculate $\pi_1$ and $\pi_2$:
	$$\pi_1 = \frac{N_1}{N} = \frac{0.878}{4} \approx 0.219$$
	$$\pi_2 = \frac{N_2}{N} = \frac{3.122}{4} \approx 0.781$$

	In order to update $\mu_1$, we need to calculate the updated number of H's and T's for $\gamma(z_{n_1})$:

	$$N_{H1}= 2 \cdot \frac{64}{307} + 1 \cdot  \frac{32}{275}  + 2 \cdot \frac{64}{307} + 3 \cdot \frac{128}{371} \approx 1.985$$

	$$N_{T1}= 3 \cdot \frac{64}{307} + 4 \cdot  \frac{32}{275}  + 3 \cdot \frac{64}{307} + 2 \cdot \frac{128}{371} \approx 2.406$$

	Now, $\mu_1$ can be calculated as:
	$$\mu_1 = \frac{1.985}{1.985+2.406} \approx 0.452 $$

	Similarly, in order to update $\mu_2$, we need to calculate the updated number of H's and T's for $\gamma(Z_{n2})$:

	$$N_{H2}= 2 \cdot \frac{243}{307} + 1 \cdot  \frac{243}{275}  + 2 \cdot \frac{243}{307} + 3 \cdot \frac{243}{371} \approx 6.015$$

	$$N_{T1}= 3 \cdot \frac{243}{307} + 4 \cdot  \frac{243}{275}  + 3 \cdot \frac{243}{307} + 2 \cdot \frac{243}{371} \approx 9.594$$

	Now, $\mu_2$ can be calculated as:
	$$\mu_2 = \frac{6.015}{6.015+9.594} \approx 0.385 $$

	\section*{Part 2:  HMM's}
	\textbf{Important note}: we assume that latent variables are enumerated as $z_1$ and $z_2$ (not $z_0$ and $z_1$), therefore, we have states 1 and 2. It stays true until the end of this exercise and influences all the notations used in this exercise.

	We consider the simple two-state hidden Markov model M based on the tossing of two coins. The parameters
	of M are:
	\begin{enumerate}
		\item The initial probabilities: $\pi = [0.4, 0.6]$.
		\item The transition probabilities
		$$ A = \left(\begin{smallmatrix} 0.4 & 0.6 \\ \\ 0.7 & 0.3 \end{smallmatrix} \right)  $$
		So the transition probability from state 1 to state 2 is $ A_{12} $ which equals 0.6.
		\item The emission probabilities $b_1 = [0.3, 0.7]$ , $b_2 = [0.6, 0.4]$, first number is probability of head H.
	\end{enumerate}

	The transition diagram corresponding to the described structure looks as follows:
	\begin{figure}[H]
		\centering{\includegraphics[width = 10cm]{figures/diagram.pdf}}
		\caption{Transition diagram of latent variables states with emission probabilities}
		\label{fig:diagram}
	\end{figure}

	\subsection*{Exercise 2.1}

	We observe sequence $ O=THTH$.

	To compute the forward variable $\alpha$ and the backward variable $\beta$ we make use of forward-backward algorithm and unfold a state transition diagram over time into a lattice \ref{fig:lattice}:

	\begin{figure}[H]
		\centering{\includegraphics[width = 10cm]{figures/lattice.pdf}}
		\caption{Lattice over time}
		\label{fig:lattice}
	\end{figure}

	We use the following formulae for $\alpha$ computation:

	$$ \alpha_1(i) = \pi_i \cdot b_i(O_1), \quad \alpha_{t+1} = \left[ \sum_{i=1}^2 \alpha_t(i) \cdot A_{ij} \right] \cdot b_j (O_{t+1})$$

	\begin{itemize}
	\item $\alpha_1^1(1) = \pi_1 \cdot b_1(T) = 0.4 \cdot 0.7 = 0.28$
	\item $\alpha_1^1(2) = \pi_2 \cdot b_2(T) = 0.6 \cdot 0.4 = 0.24$
	\item $\alpha_2^1(1) = (\alpha_1^1(1) \cdot A_{11} + \alpha_1^1(2) \cdot A_{21}) \cdot b_1(H) = (0.28 \cdot 0.4 + 0.24 \cdot 0.7) \cdot 0.3 = 0.084$
	\item $\alpha_2^1(2) = (\alpha_1^1(1) \cdot A_{12} + \alpha_1^1(2) \cdot A_{22}) \cdot b_2(H) = (0.28 \cdot 0.6 + 0.24 \cdot 0.3) \cdot 0.6 = 0.144$
	\item $\alpha_3^1(1) = (\alpha_2^1(1) \cdot A_{11} + \alpha_2^1(2) \cdot A_{21}) \cdot b_1(T) = (0.084 \cdot 0.4 + 0.144 \cdot 0.7) \cdot 0.7 = 0.09408$
	\item $\alpha_3^1(2) = (\alpha_2^1(1) \cdot A_{12} + \alpha_2^1(2) \cdot A_{22}) \cdot b_2(T) = (0.084 \cdot 0.6 + 0.144 \cdot 0.3) \cdot 0.4 = 0.03744$
	\item $\alpha_4^1(1) = (\alpha_3^1(1) \cdot A_{11} + \alpha_3^1(2) \cdot A_{21}) \cdot b_1(H) = (0.09408 \cdot 0.4 + 0.03744 \cdot 0.7) \cdot 0.3 = 0.019152$
	\item $\alpha_4^1(2) = (\alpha_3^1(1) \cdot A_{12} + \alpha_3^1(2) \cdot A_{22}) \cdot b_2(H) = (0.09408 \cdot 0.6 + 0.03744 \cdot 0.3) \cdot 0.6 = 0.040608$

	\end{itemize}

	Similarly we use a recursion relation for $\beta$:

	$$ \beta_4(i) = 1, \quad \beta_t(i) = \sum_{j = 1}^2 A_{ij} \cdot b_j(O_{t + 1}) \cdot \beta_{t + 1}(j)$$

	\begin{itemize}
		\item $ \beta_4^1(1) = 1 $
		\item $ \beta_4^1(2) = 1 $
		\item $ \beta_3^1(1) = A_{11} \cdot b_1(H) \cdot \beta_4^1(1) +  A_{12} \cdot b_2(H) \cdot \beta_4^1(2) = 0.4 \cdot 0.3 \cdot 1 + 0.6 \cdot 0.6 \cdot 1 = 0.48$
		\item $ \beta_3^1(2) = A_{21} \cdot b_1(H) \cdot \beta_4^1(1) +  A_{22} \cdot b_2(H) \cdot \beta_4^1(2) = 0.7 \cdot 0.3 \cdot 1 + 0.3 \cdot 0.6 \cdot 1 = 0.39$
		\item $ \beta_2^1(1) = A_{11} \cdot b_1(T) \cdot \beta_3^1(1) +  A_{12} \cdot b_2(T) \cdot \beta_3^1(2) = 0.4 \cdot 0.7 \cdot 0.48 + 0.6 \cdot 0.4 \cdot 0.39 = 0.228$
		\item $ \beta_2^1(2) = A_{21} \cdot b_1(T) \cdot \beta_3^1(1) +  A_{22} \cdot b_2(T) \cdot \beta_3^1(2) = 0.7 \cdot 0.7 \cdot 0.48 + 0.3 \cdot 0.4 \cdot 0.39 = 0.282$
		\item $ \beta_1^1(1) = A_{11} \cdot b_1(H) \cdot \beta_2^1(1) +  A_{12} \cdot b_2(H) \cdot \beta_2^1(2) = 0.4 \cdot 0.3 \cdot 0.228 + 0.6 \cdot 0.6 \cdot 0.282 = 0.12888$
		\item $ \beta_1^1(2) = A_{21} \cdot b_1(H) \cdot \beta_2^1(1) +  A_{22} \cdot b_2(H) \cdot \beta_2^1(2) = 0.7 \cdot 0.3 \cdot 0.228 + 0.3 \cdot 0.6 \cdot 0.282 = 0.09864$
	\end{itemize}

	\subsection*{Exercise 2.2}

	If we look at our hidden Markov model unfolded over time as at the Bayesian network (Figure \ref{fig:network}), we can find $P(O | M) $ with the help of marginalisation.

	\begin{figure}[H]
		\centering{\includegraphics[width = 10cm]{figures/network.pdf}}
		\caption{Network unfolded in time}
		\label{fig:network}
	\end{figure}

	$$ p(O) = \sum_{x_1, x_2, x_3, x_4} p(x_1) p(o_1 | x_1) p(x_2 | x_1) p(o_2 |x_2) p(x_3 |x_2) p(o_3|x_3) p(x_4 |x_3) p(o_4 | x_4) $$

	We perform several sum-product reorderings in order to simplify the calculations:

	$$ p(x_2) = \phi_1(x_2) = \sum_{x_1} p(x_1) p(o_1 |x_1) p(x_2 | x_1) $$

	$$ p(O) = \sum_{x_2, x_3, x_4}p(x_2) p(o_2 |x_2) p(x_3 |x_2) p(o_3|x_3) p(x_4 |x_3) p(o_4 | x_4) $$

	$$ p(x_3) = \phi_2(x_3) = \sum_{x_2} p(x_2) p(o_2 |x_2) p(x_3 | x_2) $$

	$$ p(O) = \sum_{x_3, x_4} p(x_3) p(o_3|x_3) p(x_4 |x_3) p(o_4 | x_4) $$

	$$ p(x_4) = \phi_3(x_4) = \sum_{x_3} p(x_3) p(o_3 |x_3) p(x_4 | x_3) $$

	$$ p(O) = \sum_{x_4} p(x_4) p(o_4 | x_4) =  \sum_{x_4} p(o_4, x_4) = \sum_{j} \alpha_4(j)$$

	$$ p(O^1) = \alpha_4^1(1) + \alpha_4^1(2) = 0.019152 + 0.040608 = 0.05976 $$

	\subsection*{Exercise 2.3}

	In this exercise we are applying one step of the batch approach of EM algorithm. To do so, we need to obtain $\alpha$ and $\beta$ for both observed sequences $O^1 = THTH$ and $O^2 = THHT$, then compute responsibilities $\gamma_t(i)$ and conditional probabilities $\xi_t(i, j)$ (E-step of the algorithm). After that, we update the model parameters (M-step of the algorithm).

	We have already computed $\alpha$ and $\beta$ for the first sequence in \textbf{Exercise 2.1}.
	Now we can compute the responsibilities	$\gamma_t(i)$ for the first sequence:

	$$  \gamma_t(i) = \frac{\alpha_t(i) \cdot \beta_t(i)}{\sum_{j = 1}^2 \alpha_t(j) \cdot \beta_t(j)} = \frac{\alpha_t(i) \cdot \beta_t(i)}{p(O)} $$
	\begin{itemize}
		\item $\gamma_1^1(1) = \frac{\alpha_1^1(1) \cdot \beta_1^1(1)}{p(O^1)} =  \frac{0.28 \cdot 0.12888}{0.05976} \approx 0.6039$
		\item $\gamma_1^1(2) = \frac{\alpha_1^1(2) \cdot \beta_1^1(2)}{p(O^1)} =  \frac{0.24 \cdot 0.09864}{0.05976} \approx 0.3961$
		\item $\gamma_2^1(1) = \frac{\alpha_2^1(1) \cdot \beta_2^1(1)}{p(O^1)} =  \frac{0.084 \cdot 0.228}{0.05976} \approx 0.3205$
		\item $\gamma_2^1(2) = \frac{\alpha_2^1(2) \cdot \beta_2^1(2)}{p(O^1)} =  \frac{0.144 \cdot 0.282}{0.05976} \approx 0.6795$
		\item $\gamma_3^1(1) = \frac{\alpha_3^1(1) \cdot \beta_3^1(1)}{p(O^1)} =  \frac{0.09408 \cdot 0.48}{0.05976} \approx 0.7556$
		\item $\gamma_3^1(2) = \frac{\alpha_3^1(2) \cdot \beta_3^1(2)}{p(O^1)} =  \frac{0.03744 \cdot 0.39}{0.05976} \approx 0.2444$
		\item $\gamma_4^1(1) = \frac{\alpha_4^1(1) \cdot \beta_4^1(1)}{p(O^1)} =  \frac{0.019152 \cdot 1}{0.05976} \approx 0.3246$
		\item $\gamma_4^1(2) = \frac{\alpha_4^1(2) \cdot \beta_4^1(2)}{p(O^1)} =  \frac{0.040608 \cdot 1}{0.05976} \approx 0.6795$
	\end{itemize}

	After that we are ready to estimate conditional probabilities $\xi_t(i, j)$:

	$$ \xi_t(i, j) = \frac{\alpha_t(i) \cdot A_{ij} \cdot b_j(O_{t+1}) \beta_{t+1}(j)}{\sum_{k = 1}^2 \sum_{l = 1}^2\alpha_t(k) \cdot A_{kl} \cdot b_l(O_{t+1}) \beta_{t+1}(l)} = \frac{\alpha_t(i) \cdot A_{ij} \cdot b_j(O_{t+1}) \beta_{t+1}(j)}{p(O)} $$

	\begin{itemize}
		\item $ \xi_1^1(1, 1) = \frac{\alpha_1^1(1) \cdot A_{11} \cdot b_1(H) \beta_{2}^1(1)}{p(O^1)} =  \frac{0.28 \cdot 0.4 \cdot 0.3 \cdot 0.228}{0.05976} \approx 0.1282 $
		\item $ \xi_1^1(1, 2) = \frac{\alpha_1^1(1) \cdot A_{12} \cdot b_2(H) \beta_{2}^1(2)}{p(O^1)} =  \frac{0.28 \cdot 0.6 \cdot 0.6 \cdot 0.282}{0.05976} \approx 0.4757 $
		\item $ \xi_1^1(2, 1) = \frac{\alpha_1^1(2) \cdot A_{21} \cdot b_1(H) \beta_{2}^1(1)}{p(O^1)} =  \frac{0.24 \cdot 0.7 \cdot 0.3 \cdot 0.228}{0.05976} \approx 0.1923 $
		\item $ \xi_1^1(2, 2) = \frac{\alpha_1^1(2) \cdot A_{22} \cdot b_2(H) \beta_{2}^1(2)}{p(O^1)} =  \frac{0.24 \cdot 0.3 \cdot 0.6 \cdot 0.282}{0.05976}\approx 0.2038 $
		\item $ \xi_2^1(1, 1) = \frac{\alpha_2^1(1) \cdot A_{11} \cdot b_1(T) \beta_{3}^1(1)}{p(O^1)}=  \frac{0.084 \cdot 0.4 \cdot 0.7 \cdot 0.48}{0.05976} \approx 0.1889 $
		\item $ \xi_2^1(1, 2) = \frac{\alpha_2^1(1) \cdot A_{12} \cdot b_2(T) \beta_{3}^1(2)}{p(O^1)} =  \frac{0.084 \cdot 0.6 \cdot 0.4 \cdot 0.39}{0.05976} \approx 0.1316 $
		\item $ \xi_2^1(2, 1) = \frac{\alpha_2^1(2) \cdot A_{21} \cdot b_1(T) \beta_{3}^1(1)}{p(O^1)} =  \frac{0.144 \cdot 0.7 \cdot 0.7 \cdot 0.48}{0.05976} \approx 0.5667 $
		\item $ \xi_2^1(2, 2) = \frac{\alpha_2^1(2) \cdot A_{22} \cdot b_2(T) \beta_{3}^1(2)}{p(O^1)}=  \frac{0.144 \cdot 0.3 \cdot 0.4 \cdot 0.39}{0.05976} \approx 0.1128 $
		\item $ \xi_3^1(1, 1) = \frac{\alpha_3^1(1) \cdot A_{11} \cdot b_1(H) \beta_{4}^1(1)}{p(O^1)} =  \frac{0.09408 \cdot 0.4 \cdot 0.3 \cdot 1}{0.05976} \approx 0.1889 $
		\item $ \xi_3^1(1, 2) = \frac{\alpha_3^1(1) \cdot A_{12} \cdot b_2(H) \beta_{4}^1(2)}{p(O^1)} =  \frac{0.09408 \cdot 0.6 \cdot 0.6 \cdot 1}{0.05976} \approx 0.5667 $
		\item $ \xi_3^1(2, 1) = \frac{\alpha_3^1(2) \cdot A_{21} \cdot b_1(H) \beta_{4}^1(1)}{p(O^1)} =  \frac{0.03744 \cdot 0.7 \cdot 0.3 \cdot 1}{0.05976} \approx 0.1316 $
		\item $ \xi_3^1(2, 2) = \frac{\alpha_3^1(2) \cdot A_{22} \cdot b_2(H) \beta_{4}^1(2)}{p(O^1)}=  \frac{0.03744 \cdot 0.3 \cdot 0.6 \cdot 1}{0.05976} \approx 0.1128 $
	\end{itemize}

Similarly, we perform all the computations for observed sequence $O^2 = THHT$.

\begin{itemize}
	\item $\alpha_1^2(1) = 0.28$
	\item $\alpha_1^2(2) = 0.24$
	\item $\alpha_2^2(1) = 0.084$
	\item $\alpha_2^2(2) = 0.144$
	\item $\alpha_3^2(1) = (\alpha_2^2(1) \cdot A_{11} + \alpha_2^2(2) \cdot A_{21}) \cdot b_1(H) = (0.084 \cdot 0.4 + 0.144 \cdot 0.7) \cdot 0.3 = 0.04032$
	\item $\alpha_3^2(2) = (\alpha_2^2(1) \cdot A_{12} + \alpha_2^2(2) \cdot A_{22}) \cdot b_2(H) = (0.084 \cdot 0.6 + 0.144 \cdot 0.3) \cdot 0.6 = 0.05616$
	\item $\alpha_4^2(1) = (\alpha_3^2(1) \cdot A_{11} + \alpha_3^2(2) \cdot A_{21}) \cdot b_1(T) = (0.04032 \cdot 0.4 + 0.05616 \cdot 0.7) \cdot 0.7 = 0.038808$
	\item $\alpha_4^2(2) = (\alpha_3^2(1) \cdot A_{12} + \alpha_3^2(2) \cdot A_{22}) \cdot b_2(T) = (0.04032 \cdot 0.6 + 0.05616 \cdot 0.3) \cdot 0.4 = 0.016416$

\end{itemize}

	$$ p(O^2) = \sum_{j} \alpha_4^2(j) = \alpha_4^2(1) + \alpha_4^2(2) = 0.038808 + 0.016416 = 0.055224 $$

	\begin{itemize}
		\item $ \beta_4^2(1) = 1 $
		\item $ \beta_4^2(2) = 1 $
		\item $ \beta_3^2(1) = A_{11} \cdot b_1(T) \cdot \beta_4^2(1) +  A_{12} \cdot b_2(T) \cdot \beta_4^2(2) = 0.4 \cdot 0.7 \cdot 1 + 0.6 \cdot 0.4 \cdot 1 = 0.52$
		\item $ \beta_3^2(2) = A_{21} \cdot b_1(T) \cdot \beta_4^2(1) +  A_{22} \cdot b_2(T) \cdot \beta_4^2(2) = 0.7 \cdot 0.7 \cdot 1 + 0.3 \cdot 0.4 \cdot 1 = 0.61$
		\item $ \beta_2^2(1) = A_{11} \cdot b_1(H) \cdot \beta_3^2(1) +  A_{12} \cdot b_2(H) \cdot \beta_3^2(2) = 0.4 \cdot 0.3 \cdot 0.52 + 0.6 \cdot 0.6 \cdot 0.61 = 0.282$
		\item $ \beta_2^2(2) = A_{21} \cdot b_1(H) \cdot \beta_3^2(1) +  A_{22} \cdot b_2(H) \cdot \beta_3^2(2) = 0.7 \cdot 0.3 \cdot 0.52 + 0.3 \cdot 0.6 \cdot 0.61 = 0.219$
		\item $ \beta_1^2(1) = A_{11} \cdot b_1(H) \cdot \beta_2^2(1) +  A_{12} \cdot b_2(H) \cdot \beta_2^2(2) = 0.4 \cdot 0.3 \cdot 0.282 + 0.6 \cdot 0.6 \cdot 0.219 = 0.11268$
		\item $ \beta_1^2(2) = A_{21} \cdot b_1(H) \cdot \beta_2^2(1) +  A_{22} \cdot b_2(H) \cdot \beta_2^2(2) = 0.7 \cdot 0.3 \cdot 0.282 + 0.3 \cdot 0.6 \cdot 0.219 = 0.09864$
	\end{itemize}

	\begin{itemize}
		\item $\gamma_1^2(1) = \frac{\alpha_1^1(1) \cdot \beta_1^1(1)}{p(O^1)} =  \frac{0.28 \cdot 0.11268}{0.055224} \approx 0.5713$
		\item $\gamma_1^2(2) = \frac{\alpha_1^1(2) \cdot \beta_1^1(2)}{p(O^1)} =  \frac{0.24 \cdot 0.09864}{0.055224} \approx 0.4287$
		\item $\gamma_2^2(1) = \frac{\alpha_2^1(1) \cdot \beta_2^1(1)}{p(O^1)} =  \frac{0.084 \cdot 0.282}{0.055224} \approx 0.429$
		\item $\gamma_2^2(2) = \frac{\alpha_2^1(2) \cdot \beta_2^1(2)}{p(O^1)} =  \frac{0.144 \cdot 0.219}{0.055224} \approx 0.571$
		\item $\gamma_3^2(1) = \frac{\alpha_3^1(1) \cdot \beta_3^1(1)}{p(O^1)} =  \frac{0.04032 \cdot 0.52}{0.055224} \approx 0.3797$
		\item $\gamma_3^2(2) = \frac{\alpha_3^1(2) \cdot \beta_3^1(2)}{p(O^1)} =  \frac{0.05616 \cdot 0.61}{0.055224} \approx 0.6203$
		\item $\gamma_4^2(1) = \frac{\alpha_4^1(1) \cdot \beta_4^1(1)}{p(O^1)} =  \frac{0.038808 \cdot 1}{0.055224} \approx 0.7027$
		\item $\gamma_4^2(2) = \frac{\alpha_4^1(2) \cdot \beta_4^1(2)}{p(O^1)} =  \frac{0.016416 \cdot 1}{0.055224} \approx 0.2973$
	\end{itemize}

	\begin{itemize}
		\item $ \xi_1^2(1, 1) = \frac{\alpha_1^2(1) \cdot A_{11} \cdot b_1(H) \beta_{2}^2(1)}{p(O^2)} =  \frac{0.28 \cdot 0.4 \cdot 0.3 \cdot 0.282}{0.055224} \approx 0.1716 $
		\item $ \xi_1^2(1, 2) = \frac{\alpha_1^2(1) \cdot A_{12} \cdot b_2(H) \beta_{2}^2(2)}{p(O^2)} =  \frac{0.28 \cdot 0.6 \cdot 0.6 \cdot 0.219}{0.055224} \approx 0.2997 $
		\item $ \xi_1^2(2, 1) = \frac{\alpha_1^2(2) \cdot A_{21} \cdot b_1(H) \beta_{2}^2(1)}{p(O^2)} =  \frac{0.24 \cdot 0.7 \cdot 0.3 \cdot 0.282}{0.055224} \approx 0.2574 $
		\item $ \xi_1^2(2, 2) = \frac{\alpha_1^2(2) \cdot A_{22} \cdot b_2(H) \beta_{2}^2(2)}{p(O^2)} =  \frac{0.24 \cdot 0.3 \cdot 0.6 \cdot 0.219}{0.055224}\approx 0.1713 $
		\item $ \xi_2^2(1, 1) = \frac{\alpha_2^2(1) \cdot A_{11} \cdot b_1(H) \beta_{3}^2(1)}{p(O^2)}=  \frac{0.084 \cdot 0.4 \cdot 0.3 \cdot 0.52}{0.055224} \approx 0.0949 $
		\item $ \xi_2^2(1, 2) = \frac{\alpha_2^2(1) \cdot A_{12} \cdot b_2(H) \beta_{3}^2(2)}{p(O^2)} =  \frac{0.084 \cdot 0.6 \cdot 0.6 \cdot 0.61}{0.055224} \approx 0.3341 $
		\item $ \xi_2^2(2, 1) = \frac{\alpha_2^2(2) \cdot A_{21} \cdot b_1(H) \beta_{3}^2(1)}{p(O^2)} =  \frac{0.144 \cdot 0.7 \cdot 0.3 \cdot 0.52}{0.055224} \approx 0.2847 $
		\item $ \xi_2^2(2, 2) = \frac{\alpha_2^2(2) \cdot A_{22} \cdot b_2(H) \beta_{3}^2(2)}{p(O^2)}=  \frac{0.144 \cdot 0.3 \cdot 0.6 \cdot 0.61}{0.055224} \approx 0.2863 $
		\item $ \xi_3^2(1, 1) = \frac{\alpha_3^2(1) \cdot A_{11} \cdot b_1(T) \beta_{4}^2(1)}{p(O^2)} =  \frac{0.04032 \cdot 0.4 \cdot 0.7 \cdot 1}{0.055224} \approx 0.2044 $
		\item $ \xi_3^2(1, 2) = \frac{\alpha_3^2(1) \cdot A_{12} \cdot b_2(T) \beta_{4}^2(2)}{p(O^2)} =  \frac{0.04032 \cdot 0.6 \cdot 0.4 \cdot 1}{0.055224} \approx 0.1753 $
		\item $ \xi_3^2(2, 1) = \frac{\alpha_3^2(2) \cdot A_{21} \cdot b_1(T) \beta_{4}^2(1)}{p(O^2)} =  \frac{0.05616 \cdot 0.7 \cdot 0.7 \cdot 1}{0.055224} \approx 0.4983 $
		\item $ \xi_3^2(2, 2) = \frac{\alpha_3^2(2) \cdot A_{22} \cdot b_2(T) \beta_{4}^2(2)}{p(O^2)}=  \frac{0.05616 \cdot 0.3 \cdot 0.4 \cdot 1}{0.055224} \approx 0.122 $
	\end{itemize}

	After that we have everything to perform M-step of the EM-algorithm.

	First, we reestimate the initial probabilities:

	$$\widehat{\pi_i} = \frac{\sum_{k=1}^K \gamma_1^k(i)}{K} $$

	\begin{itemize}
		\item $ \widehat{\pi_1} = \frac{ \gamma_1^1(1) +  \gamma_1^2(1)}{2} = \frac{ 0.6039 + 0.5713}{2} = 0.5876$
		\item $ \widehat{\pi_2}= \frac{ \gamma_1^1(2) +  \gamma_1^2(2)}{2} = \frac{ 0.3961 + 0.4287}{2} = 0.4124$
	\end{itemize}

	$$ \widehat{\pi} = (0.5876, 0.4124) $$

	Furthemore, we recompute the transition probabilities:

	$$ \widehat{A_{ij}} = \frac{\sum_{k=1}^K \sum_{t = 1}^{T_k - 1} \xi_t^k(i, j) }{\sum_{k=1}^K \sum_{t = 1}^{T_k - 1} \gamma_t^k(i) } $$

	\begin{itemize}
		\item $ \widehat{A_{11}} = \frac{\xi_1^1(1, 1) + \xi_2^1(1, 1) + \xi_3^1(1, 1) + \xi_1^2(1, 1) + \xi_2^2(1, 1)+ \xi_3^2(1, 1) }{ \gamma_1^1(1) + \gamma_2^1(1) + \gamma_3^1(1) + \gamma_1^2(1) + \gamma_2^2(1) + \gamma_3^2(1)} \approx 0.3192 $
		\item $ \widehat{A_{12}} = \frac{\xi_1^1(1, 2) + \xi_2^1(1, 2) + \xi_3^1(1, 2) + \xi_1^2(1, 2) + \xi_2^2(1, 2)+ \xi_3^2(1, 2) }{ \gamma_1^1(1) + \gamma_2^1(1) + \gamma_3^1(1) + \gamma_1^2(1) + \gamma_2^2(1) + \gamma_3^2(1)} \approx 0.6808 $
		\item $ \widehat{A_{21}} = \frac{\xi_1^1(2, 1) + \xi_2^1(2, 1) + \xi_3^1(2, 1) + \xi_1^2(2, 1) + \xi_2^2(2, 1)+ \xi_3^2(2, 1) }{ \gamma_1^1(2) + \gamma_2^1(2) + \gamma_3^1(2) + \gamma_1^2(2) + \gamma_2^2(2) + \gamma_3^2(2)} \approx 0.6568 $
		\item $ \widehat{A_{22}} = \frac{\xi_1^1(2, 2) + \xi_2^1(2, 2) + \xi_3^1(2, 2) + \xi_1^2(2, 2) + \xi_2^2(2, 2)+ \xi_3^2(2, 2) }{ \gamma_1^1(2) + \gamma_2^1(2) + \gamma_3^1(2) + \gamma_1^2(2) + \gamma_2^2(2) + \gamma_3^2(2)} \approx 0.3432 $
	\end{itemize}

	$$ \widehat{A} = \left(\begin{smallmatrix} 0.3192 & 0.6808  \\ \\ 0.6568 & 0.3432  \end{smallmatrix} \right)$$

	Finally, we recalculate the emission probabilities. Let's summarize what responsibilities we obtained so far (the third column stands for the observed variable at this point):
	$$ \gamma^1(z_1, z_2) = \left(\begin{smallmatrix} 0.6039 & 0.3961 & (T) \\ \\ 0.3205 & 0.6795 & (H) \\ \\ 0.7556 & 0.2444 & (T) \\ \\ 0.3245 & 0.6795 & (H) \end{smallmatrix} \right)  $$

	$$ \gamma^2(z_1, z_2) = \left(\begin{smallmatrix} 0.5713 & 0.4287 & (T) \\ \\ 0.429 & 0.571 & (H) \\ \\ 0.3797 & 0.6203 & (H) \\ \\ 0.7027 & 0.2973 & (T) \end{smallmatrix} \right)  $$

	$$ b_j(v_m) = \frac{\sum_{k=1}^K \sum_{t = 1}^{T_k}  \gamma_t^k(j) 1(O_t^k = v_m) }{ \sum_{k=1}^K \sum_{t = 1}^{T_k}  \gamma_t^k(i) } $$

	\begin{itemize}
		\item We choose all the responsibilities for $z_1$ when the observed variable is $H$: \\
		$ \widehat{b_1}(H) = \frac{\gamma_2^1(1) + \gamma_4^1(1) + \gamma_2^2(1) + \gamma_3^2(1)}{ \gamma_1^1(1) + \gamma_2^1(1) + \gamma_3^1(1)  + \gamma_4^1(1) + \gamma_1^2(1) + \gamma_2^2(1) + \gamma_3^2(1) + \gamma_4^2(1) } \approx 0.3557$

		\item We choose all the responsibilities for $z_1$ when the observed variable is $T$: \\
		$ \widehat{b_1}(T) = \frac{\gamma_1^1(1) + \gamma_3^1(1) + \gamma_1^2(1) + \gamma_4^2(1)}{ \gamma_1^1(1) + \gamma_2^1(1) + \gamma_3^1(1)  + \gamma_4^1(1) + \gamma_1^2(1) + \gamma_2^2(1) + \gamma_3^2(1) + \gamma_4^2(1) } \approx 0.6443$

		\item We choose all the responsibilities for $z_2$ when the observed variable is $H$: \\
		$ \widehat{b_2}(H) = \frac{\gamma_2^1(2) + \gamma_4^1(2) + \gamma_2^2(2) + \gamma_3^2(2)}{ \gamma_1^1(2) + \gamma_2^1(2) + \gamma_3^1(2)  + \gamma_4^1(2) + \gamma_1^2(2) + \gamma_2^2(2) + \gamma_3^2(2) + \gamma_4^2(2) } \approx 0.6541$

		\item We choose all the responsibilities for $z_2$ when the observed variable is $T$: \\
		$ \widehat{b_2}(T) = \frac{\gamma_1^1(2) + \gamma_3^1(2) + \gamma_1^2(2) + \gamma_4^2(2)}{ \gamma_1^1(2) + \gamma_2^1(2) + \gamma_3^1(2)  + \gamma_4^1(2) + \gamma_1^2(2) + \gamma_2^2(2) + \gamma_3^2(2) + \gamma_4^2(2) } \approx 0.3459$
	\end{itemize}

	$$ \widehat{b_1} = (0.3557, 0.6443), \quad  \widehat{b_2} = (0.6541, 0.3459)$$

\end{document}


Final results of this thesis are presented. The
`expected' limits are interpreted.
\pagebreak
\section{Limits on Higgs decay width}
\begin{figure}[htb]
    \centering
    \includegraphics[width=.8\linewidth]{fig/Final_fit_mu_offshell.pdf}
    \caption{Maximum likelihood fit of $\mu^\mathrm{H}_\mathrm{off-shell}$ (off-shell rate ratio).
    For all systematics (red), no Electroweak syst.~(green),
    0 syst.~(orange): y-intersect=\{2.82, 3.49, 3.59\}, 1$\sigma$ lower limits=\{0.075, 0.075, 0.075\},
1$\sigma$ higher limits=\{2.45, 2.13, 2.1\}, 95\% CL limits=\{3.5, 2.9, 2.9\}, respectively.}
    \label{fig:final_fit_mu}
\end{figure}
After running through Combined Limited tool~\cite{combine1, combine2, combine3} for likelihood fitting, we first extract the significance
of the off-shell rate.~(Fig.~\ref{fig:final_fit_mu})
The y-axis is understood to be $\sigma^2$ in terms of significance. Thus
the intersection with the y-axis is the signal sensitivity. In other words,
rejection of the 0 width hypothesis (no off-shell) has a significance of
$\sqrt{1.61} \approx 1.26\sigma$ in this fit with all the systematic uncertainties included.
As the systematics are `turned off', the constraint becomes tighter, producing an error band for the expected
final result in the upcoming official analysis. The electroweak uncertainty is displayed individually as
it encompasses most of the systematic uncertainties.

\begin{figure}[h]
    \centering
    \includegraphics[width=.8\linewidth]{fig/Final_fit_width.pdf}
    \caption{Maximum likelihood fit of Higgs decay width. For all systematics (red), no Electroweak syst.~(green),
    0 syst.~(orange): y-intersect=\{2.82, 3.49, 3.59\}, 1$\sigma$ lower limits=\{0.20, 0.31, 0.31\} MeV,
1$\sigma$ higher limits=\{10.38, 8.75, 8.65\} MeV, 95\% CL limits=\{15.67, 12.72, 12.62\} MeV, respectively.}
\label{fig:final_fit_width}
\end{figure}
Furthermore, by un-constraining the $\mu_\mathrm{F}$ and $\mu_\mathrm{V}$, which are the production rate
of Higgs from fermion fusion vs.\ massive boson fusion as mentioned in the Eqn.~\ref{eqn:diff_xsec}, we can
obtain the limit on the $\Gamma_\mathrm{H}$ itself.
We adopt the range suggested~\cite{rfrv_higgs_pas} for these two systematics. The constraint on the decay width of Higgs $\Gamma_\mathrm{H}$ is shown in
Fig.~\ref{fig:final_fit_width}. The minimal (max likelihood) falls on \SI{4.07}{\mega\electronvolt},
which is consistent with the standard model hypothesis.
Again, 1$\sigma$ and 95\% CL are marked respectively. And a final result of
$\Gamma_\mathrm{H}<\SI{16.38}{\mega\electronvolt}$ 95\% CL can be quoted.

% without that, what you are showing is actually off-shell signal strength with the assumption that the ratio
% of the signal strengths for gg and EW productions are as in the SM.


% A collection of PGF/TikZ figures for Deep Learning,
% using a decompossed method to illustrate.
% Written by Ling KangJie<1815428489@qq.com>

% Reference: https://github.com/PetarV-/TikZ
\documentclass{article}
\usepackage[margin=12mm]{geometry}
\usepackage{hyperref}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{etoolbox}
\usepackage{xcolor}
\usepackage{amssymb}
\usepackage{xcolor}
\usepackage{pgfplots}
\usepackage{braids}
\usepackage{etoolbox}
\usepackage{tkz-graph}
\usepackage{pgfplots}
\usepackage{amsbsy}
\usepackage{etoolbox}

\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri, decorations.pathreplacing,shadows,calc}
\usetikzlibrary{automata, chains, decorations.pathmorphing, positioning}
\usepackage{relsize}
\usetikzlibrary{automata, patterns,positioning}
\usepackage{bm}

\usepackage{tkz-graph}
\usetikzlibrary{snakes}

\usetikzlibrary{arrows,backgrounds}
\usetikzlibrary{positioning, decorations.pathmorphing, shapes}
\usetikzlibrary{matrix}
\usetikzlibrary{calc}

\definecolor{olivegreen}{rgb}{0,0.6,0}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{listings}
\usepackage{color}
\definecolor{listinggray}{gray}{0.92}
\lstset{ %
language=[LaTeX]TeX,
breaklines=true,
frame=single,
basicstyle=\footnotesize\ttfamily,
backgroundcolor=\color{listinggray},
keywordstyle=\color{blue}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\hypersetup{
  colorlinks=true,
  linkcolor=blue,
  anchorcolor=black,
  citecolor=olive,
  filecolor=magenta,
  menucolor=red,
  urlcolor=blue
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\demo}[2][1]{
\begin{minipage}{.49\linewidth}
\centering
\resizebox{#1\linewidth}{!}{
\input{demo/#2}
}
\end{minipage}
\hspace{0.01\linewidth}
\begin{minipage}{0.5\linewidth}
\lstinputlisting{demo/#2}
\end{minipage}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\example}[1]{
\resizebox{\linewidth}{!}{
\input{demo/#1}
}
\lstinputlisting{demo/#1}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{A Collection of PGF/TikZ Examples for Deep Learning}
\author{\href{1815428489@qq.com}{Ling KangJie}}
\date{\today{}~(v0.1.0)}
\maketitle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{abstract}
  This document is a collection of common examples for scientific papers particularly for Deep Learning topics by using PGF/TikZ package.
Reference:
  \href{https://github.com/PetarV-/TikZ}{https://github.com/PetarV-/TikZ}.
\end{abstract}

\tableofcontents

\section{Deep Learning}

\subsection{2D Convolution Operation}
\example{2d_convolution}
\subsection{A3C execution}
\example{a3c_execution}
\subsection{A3C Neural Network}
\example{a3c_neural_network}
\subsection{Amplitude Modulation}
\example{amplitude_modulation}
\subsection{A Trous Convolutions}
\example{a_trous_convolutions}
\subsection{Bidirectional Long Short Term Memory}
\example{bidirectional_long_short-term_memory}
\subsection{BWT}
\example{bwt}
\subsection{Convolutional Autoencoder}
\example{convolutional_autoencoder}
\subsection{Convolutional Cross-connection}
\example{convolutional_cross-connection}

\subsection{Coordinate Systems}
\example{coordinate_systems}
\subsection{CRT Rendering}
\example{crt_rendering}
\subsection{Cyclegan}
\example{cyclegan}
\subsection{Deep Belif Network}
\example{deep_belief_network}
\subsection{Deep Graph Infomax}
\example{deep_graph_infomax}
\subsection{de-bruijn-graph}
\example{de_bruijn_graph}

\subsection{DNA}
\example{dna}
\subsection{Dropout}
\example{dropout}
\subsection{Emulator Modules}
\example{emulator_modules}
\subsection{Fetch Decode Execute cycle}
\example{fetch-decode-execute_cycle}

\subsection{Frequence Modulation}
\example{frequency_modulation}
\subsection{Fully Connected Cross Connection}
\example{fully-connected_cross-connection}
\subsection{GameBoy Joypad Register}
\example{gameboy_joypad_register}
\subsection{Gameboy Palette Translation}
\example{gameboy_palette_translation}
\subsection{Gameboy Tiling System}
\example{gameboy_tiling_system}

\subsection{Gat Layer}
\example{gat_layer}
\subsection{Generative Adversarial Network}
\example{generative_adversarial_network}
\subsection{Gene Expression}
\example{gene_expression}
\subsection{Git Dataflow}
\example{git_dataflow}
\subsection{Git WorkFlow}
\example{git_workflow}
\subsection{Gamhmm}
\example{gmhmm}
\subsection{Graph Convolution}
\example{graph_convolution}
\subsection{Hamitonian Graph}
\example{hamiltonian_graph}
\subsection{Hierachical Graph Classifier}
\example{hierarchical_graph_classifier}

\subsection{Hmm Transition Smoothing}
\example{hmm_transition_smoothing}
\subsection{Insruction Execution}
\example{instruction_execution}
\subsection{IQ Sampling}
\example{iq_sampling}
\subsection{Lego Deep Learning}
\example{lego_deep_learning}
\subsection{Long Short Term Memory}
\example{long_short-term_memory}
\subsection{Maximum Flow Problem}
\example{maximum_flow_problem}
\subsection{MCL}
\example{mcl}
\subsection{Message Passing Neural Network}
\example{message_passing_neural_network}
\subsection{Multilayer Network}
\example{multilayer_network}

\subsection{Multilayer Perceptron}
\example{multilayer_perceptron}
\subsection{Multiplex Chain Gmhmm}
\example{multiplex_chain_gmhmm}
\subsection{Multiplex Chain Gmhmm Beta}
\example{multiplex_chain_gmhmm_beta}
\subsection{Multiplex Epidemic Awareness Network}
\example{multiplex_epidemics-awareness_network}
\subsection{Multiplex Network Underlying Graph}
\example{multiplex_network_underlying_graph}
\subsection{Muxstep Pipeline}
\example{muxstep_pipeline}
\subsection{Progressive Alignment}
\example{progressive_alignment}
\subsection{Progressive Neural Network}
\example{progressive_neural_network}
\subsection{Reinforcement Learning Greedy Policy}
\example{reinforcement_learning_greedy_policy}
\subsection{Relational Network}
\example{relational_network}
\subsection{RN Object Extraction}
\example{rn_object_extraction}
\subsection{Sampling}
\example{sampling}

\subsection{Self-attention}
\example{self-attention}
\subsection{Semi-supervised Embedding}
\example{semi-supervised_embedding}
\subsection{Semi-supervised Learning}
\example{semi-supervised_learning}
\subsection{Shortest Path Problem}
\example{shortest_path_problem}
\subsection{Sparse DGI}
\example{sparse_dgi}
\subsection{Supervised Learning Setup}
\example{supervised_learning_setup}
\subsection{Variational Denoising Autoencoder}
\example{variational_denoising_autoencoder}
\subsection{Web Graph}
\example{web_graph}
\subsection{X-CNN}
\example{x-cnn}
\subsection{X-LSTM}
\example{x-lstm}

\end{document}


\subsubsection{TopologicalDecomposition}
\label{TopologicalDecomposition}
The \textbf{TopologicalDecomposition} post-processor will compute an
approximated hierarchical Morse-Smale complex which will add two columns to a
dataset, namely \texttt{minLabel} and \texttt{maxLabel} that can be used to
decompose a dataset.
%

The topological post-processor can also be run in `interactive' mode, that is
by passing the keyword \texttt{interactive} to the command line of RAVEN's
driver.
%
In this way, RAVEN will initiate an interactive UI that allows one to explore
the topological hierarchy in real-time and adjust the simplification setting
before adjusting a dataset. Use in interactive mode will replace the parameter
\xmlNode{simplification} described below with whatever setting is set in the UI
upon exiting it.

In order to use the \textbf{TopologicalDecomposition} post-processor, the user
needs to set the attribute \xmlAttr{subType}:
\xmlNode{PostProcessor \xmlAttr{subType}=\xmlString{TopologicalDecomposition}}.
The following is a list of acceptable sub-nodes:
\begin{itemize}
  \item \xmlNode{graph} \xmlDesc{, string, optional field}, specifies the type
  of neighborhood graph used in the algorithm, available options are:
  \begin{itemize}
    \item \texttt{beta skeleton}
    \item \texttt{relaxed beta skeleton}
    \item \texttt{approximate knn}
    %\item Delaunay \textit{(disabled)}
  \end{itemize}
  \default{\texttt{beta skeleton}}
  \item \xmlNode{gradient}, \xmlDesc{string, optional field}, specifies the
  method used for estimating the gradient, available options are:
  \begin{itemize}
    \item \texttt{steepest}
    %\item \xmlString{maxflow} \textit{(disabled)}
  \end{itemize}
  \default{\texttt{steepest}}
  \item \xmlNode{beta}, \xmlDesc{float in the range: (0,2], optional field}, is
  only used when the \xmlNode{graph} is set to \texttt{beta skeleton} or
  \texttt{relaxed beta skeleton}.
  \default{1.0}
  \item \xmlNode{knn}, \xmlDesc{integer, optional field}, is the number of
  neighbors when using the \xmlString{approximate knn} for the \xmlNode{graph}
  sub-node and used to speed up the computation of other graphs by using the
  approximate knn graph as a starting point for pruning. -1 means use a fully
  connected graph.
  \default{-1}
  \item \xmlNode{weighted}, \xmlDesc{boolean, optional}, a flag that specifies
  whether the regression models should be probability weighted.
  \default{False}
  \item \xmlNode{interactive}, if this node is present \emph{and} the user has
  specified the keyword \texttt{interactive} at the command line, then this will
  initiate a graphical interface for exploring the different simplification
  levels of the topological hierarchy. Upon exit of the graphical interface, the
  specified simplification level will be updated to use the last value of the
  graphical interface before writing any ``output'' results.
  \item \xmlNode{persistence}, \xmlDesc{string, optional field}, specifies how
  to define the hierarchical simplification by assigning a value to each local
  minimum and maximum according to the one of the strategy options below:
  \begin{itemize}
    \item \texttt{difference} - The function value difference between the
    extremum and its closest-valued neighboring saddle.
    \item \texttt{probability} - The probability integral computed as the
    sum of the probability of each point in a cluster divided by the count of
    the cluster.
    \item \texttt{count} - The count of points that flow to or from the
    extremum.
    % \item \xmlString{area} - The area enclosed by the manifold that flows to
    % or from the extremum.
  \end{itemize}
  \default{\texttt{difference}}
  \item \xmlNode{simplification}, \xmlDesc{float, optional field}, specifies the
  amount of noise reduction to apply before returning labels.
  \default{0}
  \item \xmlNode{parameters}, \xmlDesc{comma separated string, required field},
  lists the parameters defining the input space.
  \item \xmlNode{response}, \xmlDesc{string, required field}, is a single
  variable name defining the scalar output space.
\end{itemize}
\textbf{Example:}
\begin{lstlisting}[style=XML,morekeywords={subType}]
<Simulation>
  ...
  <Models>
    ...
    <PostProcessor name="***" subType='TopologicalDecomposition'>
      <graph>beta skeleton</graph>
      <gradient>steepest</gradient>
      <beta>1</beta>
      <knn>8</knn>
      <normalization>None</normalization>
      <parameters>X,Y</parameters>
      <response>Z</response>
      <weighted>true</weighted>
      <simplification>0.3</simplification>
      <persistence>difference</persistence>
    </PostProcessor>
    ...
  <Models>
  ...
<Simulation>
\end{lstlisting}


\documentclass{memoir}
\usepackage{notestemplate}

%\logo{./resources/pdf/logo.pdf}
%\institute{Rice University}
%\faculty{Faculty of Whatever Sciences}
%\department{Department of Mathematics}
%\title{Class Notes}
%\subtitle{Based on MATH xxx}
%\author{\textit{Author}\\Gabriel \textsc{Gress}}
%\supervisor{Linus \textsc{Torvalds}}
%\context{Well, I was bored...}
%\date{\today}

\begin{document}

% \maketitle

% Notes taken on 01/25/21

\chapter{Modules}
\label{cha:modules}

\section{Ring Review}
\label{sec:ring_review}

Recall the definition of a ring.

\begin{defn}[Ring]
	A \textbf{ring} is a nonempty set \(R\) with two operations: addition and multiplication, which has the properties
	\begin{itemize}
		\item \(R^{+}\) is an abelian group
		\item \(R^{\times }\) is a semigroup
		\item \(\times \) distributes over \(+\) :
			\begin{align*}
				a(b+c) = ab+ac \quad (b+c)a = ba+ca
			\end{align*}
	\end{itemize}
\end{defn}

\begin{defn}[Types of Rings]
	A ring \(R\) is \textbf{commutative} if \(\times \) is commutative. Furthermore, we say a ring is \textbf{unital} if there exists an element \(1_R \in R\) so that \(1_R a = a_{1_R} = a\) for all \(a \in R\).\\

The ring \(R\) is \textbf{(in)finite} if it is (in)finite as a set.\\

A \textbf{subring} of \(R\) is an additive subgroup \(S\) of \(R\) that is closed under the multiplication of \(R\). Furthermore, if it contains \(1_R\) then it is a \textbf{unital subring}.\\

A \textbf{unit} of \(R\) is an element \(a \in R\) that has a multiplicative inverse, i.e. \(\exists b \in R\) so that \(ab = ba = 1_R\). The set of units of \(R\) is sometimes denoted by \(R^{\times }\).
\end{defn}

In order to better classify commutative rings, we introduce a few more terminology.

\begin{defn}[Irreducibles and Primes]
	We say that \(r \in R\) is \textbf{irreducible} if
	\begin{align*}
		r = ab \implies a \text{ or }b \text{ is a unit}.
	\end{align*}
	We impose a stronger condition that \(r \in R\) is \textbf{prime} if
	\begin{align*}
		r \mid ab \implies r\mid a \text{ or }r \mid b.
	\end{align*}

\end{defn}
Note that every prime is irreducible, but not vice versa.\\

\begin{figure}[ht]
    \centering
     \def\svgwidth{1\linewidth}
     \input{./figures/hierarchy-of-commutative-rings.pdf_tex}
    \caption{Hierarchy of Commutative Rings}
    \label{fig:hierarchy-of-commutative-rings}
\end{figure}

\end{document}

Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture1 - RingReview.tex


\chapter{Proof of Assertion~\ref{Sec:assertion8}}
\label{Sec:Appendix-B}
It is proved in this appendix that for a Newtonian boost,
for the function $G_0$ defined in Eq.~(\ref{def-G0}),
it is true that arcs $\Elab' = \Ebin$ and
$\Ecm' = \text{const}$ in Figure~\ref{Fig:boost-regions} intersect if and only if
$G_0( \Ebin, \Ecm', E ) \ge 0$.

The clearest way to prove this assertion is to
argue four cases directly:
 \begin{align}
  G_0( \Ebin',  \Ecm', E ) \ge 0 & \quad \text{and}
    \quad \Etrans' + \Ecm' \ge \Ebin',
    \label{first-G0}\\
  G_0( \Ebin',  \Ecm', E ) \ge 0 & \quad \text{and}
    \quad \Etrans' + \Ecm' < \Ebin', \\
  G_0( \Ebin',  \Ecm', E ) < 0 & \quad \text{and}
    \quad \Etrans' + \Ecm' \ge \Ebin', \\
   G_0( \Ebin',  \Ecm', E ) < 0 & \quad \text{and}
    \quad \Etrans' + \Ecm' < \Ebin'.
 \end{align}
 In these inequalities $\Etrans'$ is as defined in Eq.~(\ref{E_trans}).

A geometric condition for the intersection of
the two arcs is presented first.  It is then shown that this geometric condition is equivalent
to the non-negativity of~$G_0$.

\section{An equivalent geometric condition}
The geometric condition is that for given values of $\Ebin'$, $\Ecm'$ and~$E$,
the arcs $\Elab' = \Ebin'$ and
$\Ecm' = \text{const}$ in Figure~\ref{Fig:boost-regions} intersect if and only if
\begin{equation}
  \left( \sqrt{\Etrans'} - \sqrt{\Ecm'} \right)^2 \le \Ebin' \le
    \left( \sqrt{\Etrans'} + \sqrt{\Ecm'} \right)^2.
  \label{Elab-range}
\end{equation}

For the purposes of this argument, it is
convenient to use units of mass such that the mass of the outgoing particle
is $\myo = 2$.  Thus, its speed in the center-of-mass frame is
$\Vcm' = \sqrt{\Ecm'}$.  The arcs in
Figure~\ref{Fig:boost-regions} may be viewed either as curves of constant energy or constant speed.  For given
energy $E$ of the incident particle, the speed $\vtrans = \sqrt{\Etrans'}$ of
the center of mass is determined.  In terms of the speeds with
$\vbin' = \sqrt{\Ebin'}$, the condition
Eq.~(\ref{Elab-range}) is equivalent to
\begin{equation}
  \vtrans^2 + {\vcm'}^2 - 2 \vtrans \vcm' \le {\vbin'}^2 \le
  \vtrans^2 + {\vcm'}^2 + 2 \vtrans \vcm'.
 \label{Elab-range-speed}
\end{equation}

For emission in the forward direction, the speed of the outgoing particle
in the laboratory frame is
$$
  \vlab' = \vtrans + \vcm',
$$
so that its energy in the laboratory frame is
$$
  {\vlab'}^2 = \vtrans^2 + {\vcm'}^2 + 2 \vtrans \vcm'.
$$
In backward emission, the speed of the outgoing particle
in the laboratory frame is
$$
  \vlab' = \left| \vtrans - \vcm' \right|,
$$
and its energy in the laboratory frame is
$$
  {\vlab'}^2 = \vtrans^2 + {\vcm'}^2 - 2 \vtrans \vcm'.
$$
It follows that if condition Eq.~(\ref{Elab-range-speed}) is true,
then there exists a center-of-mass direction cosine $\mucm$ with
$-1 \le \mucm \le 1$ for which the emitted particle has the
desired laboratory energy
$$
 {\vbin'}^2 =
  \vtrans^2 + {\vcm'}^2 + 2 \mucm \vtrans \vcm'.
$$
The two arcs $\Elab' = \Ebin'$ and $\Ecm' = \text{const}$ intersect at this
value of~$\mucm$.  It is seen that if the geometric condition Eq.~(\ref{Elab-range})
is satisfied, then the arcs $\Elab' = \Ebin'$ and $\Ecm' = \text{const}$
do intersect.

It is now shown that if Eq.~(\ref{Elab-range-speed}) is false, then then arcs
$\Elab' = \Ebin'$ and $\Ecm' = \text{const}$ do not intersect.
One way for Eq.~(\ref{Elab-range-speed}) to be false is that
\begin{equation}
  \vbin' > \vtrans + \vcm'.
  \label{big-Elab}
\end{equation}
In this case, forward emission has insufficient energy in the laboratory frame,
and  the arc $\Ecm' = \text{const}$ in Figure~\ref{Fig:boost-regions}
is entirely enclosed within the arc $\Elab' = \Ebin'$.

If
\begin{equation}
   \vbin' < \left| \vtrans - \vcm' \right|,
 \label{small-Elab}
\end{equation}
there are two more ways for Eq.~(\ref{Elab-range-speed}) to be false,
depending on whether
\begin{equation}
  \vcm' < \vtrans
 \label{small-Vcm}
\end{equation}
or
\begin{equation}
  \vcm' > \vtrans.
 \label{small-Vtrans}
\end{equation}

Under the conditions in Eq.~(\ref{small-Vcm}),
backward emission in the center-of-mass frame boosts to forward
emission in the laboratory frame.  The condition Eq.~(\ref{small-Elab})
implies that
$$
   \vbin' <  \vtrans - \vcm',
$$
so that the arc $\Elab' = \Ebin'$ is completely to the left of
the arc $\Ecm' = \text{const}$ in Figure~\ref{Fig:boost-regions}.  (In fact, one pair of such
arcs is shown in Figure~\ref{Fig:boost-regions}.)

The final way for Eq.~(\ref{Elab-range-speed}) to be false is that
conditions Eqs.~(\ref{small-Elab}) and~(\ref{small-Vtrans}) be
valid.  In this case, backward emission in the center-of-mass
frame produces backward emission in the laboratory frame with
$$
  \vbin' < \vcm' - \vtrans.
$$
In this case, the arc $\Elab' = \Ebin'$ is completely contained
within the arc $\Ecm' = \text{const}$ in Figure~\ref{Fig:boost-regions}.  This finishes the proof
of the assertion that the arcs $\Elab' = \Ebin'$ and $\Ecm' = \text{const}$
in Figure~\ref{Fig:boost-regions} intersect if ans only if Eq.~(\ref{Elab-range}) is true.

\section{Proof of the assertion}

Consider the case Eq.~(\ref{first-G0}) above.  That is, suppose that
\begin{equation}
   G_0( \Ebin',  \Ecm', E ) \ge 0
 \label{B-G0-positive}
\end{equation}
and
\begin{equation}
 \Etrans' + \Ecm' \ge \Ebin'.
 \label{B-Ebin-small}
\end{equation}
It is now shown that these two inequalities lead to the geometric
condition Eq.~(\ref{Elab-range}) for intersection of the two arcs.
The inequality Eq.~(\ref{B-G0-positive}) may be rewritten in the form
$$
  4 \Ecm' \Etrans' - ( \Etrans' + \Ecm' - \Ebin' )^2 \ge 0.
$$
Because of the fact that $\Etrans' + \Ecm' - \Ebin' \ge 0$,
it is possible to take positive square roots
to obtain the relation
$$
  2 \sqrt{ \Ecm' \Etrans' } \ge \Etrans' + \Ecm' - \Ebin',
$$
which may be rearranged as
$$
  \Ebin' \ge \left( \sqrt{\Etrans'} - \sqrt{\Ecm'} \right)^2.
$$
The first of the inequalities Eq.~(\ref{Elab-range}) is now verified.

The second inequality Eq.~(\ref{Elab-range}) follows trivially
from the assumption Eq.~(\ref{B-Ebin-small}),
$$
  \Ebin' \le \Etrans' + \Ecm' \le
  \Etrans' + \Ecm' +  2 \sqrt{ \Ecm' \Etrans' }.
$$

The other three cases may be analyzed in a similar fashion.