\section{Signal modelling}
\label{sec:signal_model}

The parameterization of \mfl distributions based on simulated samples for signals are described in this section.
Several signal models are studied, including heavy Higgs like narrow-width signal (NWA) and large-width signal (LWA), as well as the modelling of Randall-Sundrum graviton (RSG) signal.

%% ========================================================================================================================
%% NWA

\subsection{Modelling of narrow-width signal}
\label{sec:signal_nwa}

For narrow-width (NWA) signal, the \mfl width is totally determined by detector resolution, which is modelled
by the sum of a Crystal Ball ($\mathcal{C}$) function~\cite{CrystalBall1,CrystalBall2} and a Gaussian ($\mathcal{G}$) function:

\begin{equation}
    \label{eq:cb_plus_g}
    P_{s} (\mfl) = f_{\mathcal{C}} \cdot \mathcal{C}(\mfl; \mu, \sigma_{\mathcal{C}}, \alpha_{\mathcal{C}}, n_{\mathcal{C}})
                   + (1 - f_{\mathcal{C}}) \cdot \mathcal{G}(\mfl; \mu, \sigma_{\mathcal{G}})
\end{equation}

The two functions share the same central value $\mu$, while the resolution parameters, $\sigma_{\mathcal{C}}$ and $\sigma_{\mathcal{G}}$, are different.
In the Crystal Ball function, the parameters $\alpha_{\mathcal{C}}$ and $n_{\mathcal{C}}$ model the shape of non-Gaussian tail,
and the fraction parameter $f_{\mathcal{C}}$ is used to ensure the relative normalization between two functions.

The parameters are obtained by fitting to signal MC simulations combining the mc16a, mc16d and mc16e campaigns for each category at each mass points from 200~\gev~ to 2000~\gev~ respectively,
and the shape of ggF and VBF signals are found to be similar.
Figure~\ref{fig:ggf_mass_signalParam_2mu2e} shows the \mfl distribution and fitted curves for ggF production at mass from 200~\gev~ to 2000~\gev~ in 2$e$2$\mu$ channel as examples.

\begin{figure}[htbp]
    \centering
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_mass_signal_200_H4l_2mu2e.eps}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_mass_signal_300_H4l_2mu2e.eps}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_mass_signal_400_H4l_2mu2e.eps}\\
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_mass_signal_500_H4l_2mu2e.eps}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_mass_signal_600_H4l_2mu2e.eps}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_mass_signal_700_H4l_2mu2e.eps}\\
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_mass_signal_800_H4l_2mu2e.eps}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_mass_signal_900_H4l_2mu2e.eps}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_mass_signal_1000_H4l_2mu2e.eps}\\
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_mass_signal_1200_H4l_2mu2e.eps}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_mass_signal_1400_H4l_2mu2e.eps}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_mass_signal_1600_H4l_2mu2e.eps}\\
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_mass_signal_1800_H4l_2mu2e.eps}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_mass_signal_2000_H4l_2mu2e.eps}
    \caption{Distributions of the $m_{2\mu 2e}$ and fit projection for signal samples between 200 to 3000~\gev for ggF production mode.
    Three MC campaigns, mc16a, mc16d and mc16e, are combined.
    The lower panel in each plot shows the pull distribution.}
    \label{fig:ggf_mass_signalParam_2mu2e}
\end{figure}

Then the $\mathcal{C}+\mathcal{G}$ parameters are fitted with a polynomial function as the function of generated mass points (\mH), as an example shown in figure~\ref{fig:ggf_fitParams_interpolation_2mu2e} for ggF production in 2$e$2$\mu$ channel.
The fitting quality can be measured by the Pearson's $\chi^2$, which is within 3 (2) for 2$e$2$\mu$ (4$e$ and 4$\mu$) channel.

\begin{figure}[htbp]
    \centering
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_graph_mass_mean_2mu2e_fit.eps}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_graph_f_cb_gauss_2mu2e_fit.eps}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_graph_mass_gauss_sigma_2mu2e_fit.eps} \\
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_graph_mass_cb_sigma_2mu2e_fit.eps}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_graph_mass_cb_alpha_2mu2e_fit.eps}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_graph_mass_cb_n_2mu2e_fit.eps}
    \caption{Polynomial fits of the parameters $\mu$, $f_{\mathcal{C}}$, $\sigma_{\mathcal{G}}$, $\sigma_{\mathcal{C}}$,
    $n_{\mathcal{C}}$ and $\alpha_{\mathcal{C}}$ for the signal $\mathcal{C}+\mathcal{G}$ model in the $2\mu 2e$ channel as a function of \mH for
    the ggF production mode. The combination of the mc16a, mc16d and mc16e MC campaigns is used.}
    \label{fig:ggf_fitParams_interpolation_2mu2e}
\end{figure}

In addition, possible difference on the signal yield extracted from parameterization and MC simulation is studied.
Figure~\ref{fig:ggf_graph_YieldCheckAll} shows this difference by computing $\frac{N_{\text{reco}}-N_{\text{fit}}}{N_{\text{fit}}}$, where $N_{\text{reco}}$ denotes the total number of reconstructed events observed from MC simulation at that mass point
and $N_{\text{fit}}$ depicts the number of events obtained from the fitted pdf.
The differences are treated as an additional systematic uncertainty with the value of 2\% (1\%) for 2$e$2$\mu$ (4$e$ and 4$\mu$) channel in statistical fit.

\begin{figure}[htbp]
    \centering
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_graph_YieldCheck_4mu_fixed.eps}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_graph_YieldCheck_4e_fixed.eps}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_graph_YieldCheck_2mu2e_fixed.eps}
    \caption{The difference between MC simulation and parameterization of
    $4\mu$ (left), $4e$ (middle) and $2\mu 2e$ (right) for the ggF production
    mode. The combination of the mc16a, mc16d and mc16e MC campaigns is used.}
    \label{fig:ggf_graph_YieldCheckAll}
\end{figure}

In summary, the final interpolated signal shapes for the ggF production mode are shown together in figure~\ref{fig:ggf_multipeak} for mass points with step of 100~\gev~ from 200~\gev~ to 3000~\gev.

\begin{figure}[htbp]
    \centering
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_multipeakplot_4mu.eps}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_multipeakplot_4e.eps}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/NWA//ggf_multipeakplot_2mu2e.eps}
    \caption{The final signal shapes for the ggF production mode, interpolated from the polynomial fit parameters.}
    \label{fig:ggf_multipeak}
\end{figure}

%%========================================================================================================================
%% LWA

\subsection{Modelling of large-width signal}
\label{sec:signal_lwa}

The \mfl shape of heavy Higgs model in large-width (LWA) hypothesis can be described by a convolution of a truth distribution and a resolution from detector effect.
The detector resolution effect is the one modelled by the function described in NWA parameterization, as in NWA model the truth level width is negligible.

The differential parton cross section for the heavy Higgs model can be written as~\cite{Goria:2011wa}:
\begin{equation}
    \sigma_{gg \to H \to ZZ} (s) = \frac{1}{2s}  \int d \Omega \left | A_{gg \to H}(s,\Omega) \right |^2 \frac{1}{ \left | s - s_H \right |^2}  \left | A_{H \to ZZ}(s,\Omega) \right |^2
\end{equation}
where $A_{gg \to H}(s,\Omega)$ and $A_{H \to ZZ}(s,\Omega)$ are corresponding Higgs production and decay amplitudes,
and $\frac{1}{s - s_H}$ denotes the Higgs propagator and $\Omega$ represents the phase space of the process.

Using the definition of a partial width,
\begin{equation} \label{eq:PartialWidth}
    \Gamma_{H \to F} (s) = \frac{1}{2\sqrt{s}}  \int d \Omega \left | A_{H \to F}(s,\Omega) \right |^2
\end{equation}
the parton cross section can be rewritten as,
\begin{equation} \label{eq:HiggsPartonXSection}
    \sigma_{gg \to H \to ZZ} (s) = 2 \frac{1}{ \left | s - s_H \right |^2}  \times \Gamma_{H \to gg} (s) \times \Gamma_{H \to ZZ} (s)
\end{equation}
with the components computed in Ref~\cite{Goria:2011wa,Spira1995}:
\begin{align} \label{eq:propagator}
\begin{split}
    \frac{1}{s - s_H} &= \frac{ 1 + i \cdot \overline{\Gamma}_H / \overline{m}_H} { s - \overline{m}_H^2 +  i \cdot s \cdot\overline{\Gamma}_H / \overline{m}_H }  \\
    \overline{m}_H &= \sqrt{\Gamma_H^2 + m_H^2} \\
    \overline{\Gamma}_H &= \overline{m}_H  \cdot \frac{\Gamma_H}{m_H}
\end{split}
\end{align}

\begin{equation} \label{eq:WidthZZ}
    \Gamma_{H \to ZZ} (s) = C \cdot s^{\frac{3}{2}} \cdot \left [ 1 - \frac{4m_Z^2}{s} + \frac{3}{4}\left ( \frac{4m_Z^2}{s} \right )^2 \right ] \cdot \left [ 1 - \frac{4m_Z^2}{s} \right ]^{\frac{1}{2}}
\end{equation}

\begin{align} \label{eq:WidthGG}
\begin{split}
    \Gamma_{H \to gg} (s) &= C \cdot s^{\frac{3}{2}} \cdot \left | A_t(\tau_t) \right |^{2} \\
    A_t(\tau) &= 2 \frac{\tau+(\tau-1)f(\tau)}{\tau^2} \\
    \tau_t &= \frac{s}{4m_t^2} \\
    f(\tau) &= \left\{\begin{matrix}
    \arcsin^2 (\sqrt{\tau}) , ~ \tau \leqslant 1
    \\
    - \frac{1}{4} \left [  \log{\frac{1+\sqrt{1-\tau^{-1}}}{1-\sqrt{1-\tau^{-1}}}}  - i  \pi \right ]^2 , ~ \tau > 1
    \end{matrix}\right.
\end{split}
\end{align}

where $m_f$ stands for the mass of a fermion $f$, and $\Gamma_H$ denotes an assumed total width of the heavy Higgs boson.

At the LHC, the \mfl line shape can be defined by a hadron cross section that is derived from
equation~\ref{eq:HiggsPartonXSection} by multiplication with gluon-gluon luminosity $\mathcal{L}_{gg}$ described in
\cite{Ball:2012wy}.
Meanwhile, the cross section is rewritten as a function of \mfl instead of $s$, which will give an extra power of mass dependence in the formula:
\begin{equation} \label{eq:HiggsHadronXSection}
    \sigma_{pp \to H \to ZZ} (m_{4\ell}) = 2 \cdot m_{4\ell} \cdot \mathcal{L}_{gg} \cdot  \frac{1}{ \left | s - s_H \right |^2}  \cdot \Gamma_{H \to gg} (m_{4\ell}^2) \cdot \Gamma_{H \to ZZ} (m_{4\ell}^2)
\end{equation}
The analytical shapes of truth level \mfl distribution of gg2VV MC samples is shown on figure~\ref{fig:truthShape}.

\begin{figure}[!htbp]
    \centering
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/LWA/450_5.png}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/LWA/450_10.png}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/LWA/450_15.png}\\
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/LWA/700_5.png}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/LWA/700_10.png}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/LWA/700_15.png}\\
    \caption{Comparison of the analytical shape to a truth $\mfl$ distribution of gg2VV MC samples for $\mH$ = 450~\gev (top), 700~\gev (bottom)
    and width equal to 5$\%$ (left), 10$\%$ (middle), 15$\%$ (right) of the mass.}
    \label{fig:truthShape}
\end{figure}

The reconstruction level signal shape can then be modelled by the analytical truth shape convoluted with detector effects modelled in section~\ref{sec:signal_nwa}.
A comparison between the modelled shape and reconstruction level MC simulation for signal mass above 400~\gev~ (for ggF production in 2$e$2$\mu$ channel as an example) are shown in figure~\ref{fig:recoShape_2mu2e},
the shapes are well compatible between each other.
This modelling is not valid for lower masses due to the rapid change of detector resolution.

\begin{figure}[!htbp]
    \centering
    \includegraphics[width=.32\textwidth]{figures/HMHZZ/signal/LWA/cmp_400GeV_ATLAS_Signal_ggF_ggF_2mu2e_13TeV_conv.pdf}
    \includegraphics[width=.32\textwidth]{figures/HMHZZ/signal/LWA/cmp_500GeV_ATLAS_Signal_ggF_ggF_2mu2e_13TeV_conv.pdf}
    \includegraphics[width=.32\textwidth]{figures/HMHZZ/signal/LWA/cmp_600GeV_ATLAS_Signal_ggF_ggF_2mu2e_13TeV_conv.pdf}\\
    \includegraphics[width=.32\textwidth]{figures/HMHZZ/signal/LWA/cmp_700GeV_ATLAS_Signal_ggF_ggF_2mu2e_13TeV_conv.pdf}
    \includegraphics[width=.32\textwidth]{figures/HMHZZ/signal/LWA/cmp_800GeV_ATLAS_Signal_ggF_ggF_2mu2e_13TeV_conv.pdf}
    \includegraphics[width=.32\textwidth]{figures/HMHZZ/signal/LWA/cmp_900GeV_ATLAS_Signal_ggF_ggF_2mu2e_13TeV_conv.pdf}\\
    \includegraphics[width=.32\textwidth]{figures/HMHZZ/signal/LWA/cmp_1200GeV_ATLAS_Signal_ggF_ggF_2mu2e_13TeV_conv.pdf}
    \includegraphics[width=.32\textwidth]{figures/HMHZZ/signal/LWA/cmp_1400GeV_ATLAS_Signal_ggF_ggF_2mu2e_13TeV_conv.pdf}
    \includegraphics[width=.32\textwidth]{figures/HMHZZ/signal/LWA/cmp_1600GeV_ATLAS_Signal_ggF_ggF_2mu2e_13TeV_conv.pdf}\\
    \includegraphics[width=.32\textwidth]{figures/HMHZZ/signal/LWA/cmp_1800GeV_ATLAS_Signal_ggF_ggF_2mu2e_13TeV_conv.pdf}
    \caption{Comparison between the analytical shape convoluted with detector effects and the reconstructed $m_{2\mu 2e}$ MC
    distribution for mass points ranging from 400 to 1800~$\gev$ and width equal to $15\%$ of the mass.}
    \label{fig:recoShape_2mu2e}
\end{figure}

\subsection{Modelling of interference}
\label{sec:int_model}

There are three processes sharing the same $gg$ initial state and $ZZ$ final state:
\begin{itemize}
	\item The SM \ggZZ process with an amplitude $A_{B}$
	\item The SM (light) Higgs at mass of around 125~\gev~ with an amplitude $A_{h}$
	\item The BSM heavy Higgs we are searching in this analysis with an amplitude $A_{H}$
\end{itemize}
The three processes can interfere with each other due to the same initial and final states.
The parton cross section for these processes can be written as:

\begingroup
%\small
\begin{equation} \label{eq:xsec_parton_int}
\begin{split}
    \sigma_{gg \to (X) \to ZZ} (s) &= \frac{1}{2s}  \int d \Omega \left | A_h(s,\Omega) + A_H(s,\Omega) + A_B(s,\Omega) \right |^2 \\
    &= \frac{1}{2s}  \int d \Omega  \left (  \left | A_h(s,\Omega)  \right |^2 +  \left | A_H(s,\Omega)  \right |^2 +  \left | A_B(s,\Omega)  \right |^2  \right )  + \\
    &+ \frac{1}{s}  \int d \Omega  \big( Re \left [ A_h(s,\Omega) \cdot A^*_B(s,\Omega)  \right ] \\
    &+ Re \left [ A_H(s,\Omega) \cdot A^*_B(s,\Omega)  \right ] + Re \left [ A_H(s,\Omega) \cdot A^*_h(s,\Omega)  \right ]  \big) \\
    %&+ \frac{1}{s} \mathrm{Re} \left [ \frac{1}{s-s_H}  \int d \Omega \cdot A_H^P(s,\Omega)  \cdot A_H^D(s,\Omega) \cdot A^*_B(s,\Omega)  \right ] \\
    %&+ \frac{1}{s} \int d \Omega \cdot \mathrm{Re} \left [A_H^P(s,\Omega)\cdot  \frac{1}{s-s_H}   \cdot A_H^D(s,\Omega) \cdot A_h^{P*}(s,\Omega)\cdot  \frac{1}{(s-s_h)^*}   \cdot A_h^{D*}(s,\Omega)   \right ]
\end{split}
\end{equation}
\endgroup

The first term in equation~\ref{eq:xsec_parton_int} denotes the on-shell SM Higgs contribution, which is negligible in this analysis.
The second term corresponds to the heavy Higgs contribution, whose line shape has been described in previous section.
The third term is the \ggZZ continuum process, while the forth term is the interference between SM Higgs and \ggZZ continuum.
The fifth and sixth terms are the interferences between heavy Higgs and \ggZZ continuum (H-B), and between heavy Higgs and SM Higgs (H-h) that we are interested in.
More details about the parameterization of these two interferences are described as below.

\subsubsection{Interference between heavy Higgs and \ggZZ continuum}

The parton cross section of this interference term can be expressed as:
\begin{equation}
	\sigma_{gg} (s) = \frac{1}{s} \mathrm{Re} \left [ \frac{1}{s-s_H}  \int d \Omega \cdot A_H^P(s,\Omega)  \cdot A_H^D(s,\Omega) \cdot A^*_B(s,\Omega)  \right ]
\end{equation}
By assuming that this function has a smooth behaviour, it can be replaced with complex polynomial:
\begin{equation}
    \int d \Omega \cdot A_H^P(s,\Omega)  \cdot A_H^D(s,\Omega) \cdot A^*_B(s,\Omega)  \approx  (a_0 + a_1 \cdot \sqrt{s} + \dots) + i \cdot (b_0 + b_1 \cdot \sqrt{s} + \dots)
\end{equation}

The parameters $a_i$ and $b_i$ can be extracted by fitting to the \mfl distribution from truth level MC simulation after analysis selection.
Since the signal mass and width does not enter into this function, the parameters should be independent for every tested signal hypothesis.

Same as description for equation~\ref{eq:HiggsHadronXSection}, the parton cross section can be transformed into a hadron cross section as a function of \mfl:

\begingroup
\small
\begin{equation} \label{eq:HBHadronXSection}
    \sigma_{pp} (m_{4\ell}) = \mathcal{L}_{gg} \cdot \frac{1}{m_{4\ell}} \cdot \mathrm{Re} \left [   \frac{1}{s-s_H}  \cdot  \left ( (a_0 + a_1 \cdot m_{4\ell} + \dots) + i \cdot (b_0 + b_1 \cdot m_{4\ell} + \dots) \right )\right ]
\end{equation}
\endgroup
where the propagators are shown in equation~\ref{eq:propagator}.

Figure~\ref{fig:HB_Int_2mu2e} shows the distributions of interference function obtained by simultaneous fitting to \mfl shape from truth level H-B interference simulation at different mass in 2$e$2$\mu$ channel as an example.

\begingroup
\small
\begin{figure}[!htbp]
    \centering
    \includegraphics[width=1.\textwidth]{figures/HMHZZ/signal/Interference/HB_Int_2mu2e.pdf}
    \caption{The interference (H-B) model fitted to the truth~\mfl~MC distribution after signal region selection for $2\mu2e$~channel. \label{fig:HB_Int_2mu2e} }
\end{figure}
\endgroup

\subsubsection{Interference between heavy Higgs and SM Higgs}

The parton cross section of this interference term can be written as:
\begingroup
\small
\begin{equation}
	\sigma_{gg} (s) = \frac{1}{s} \int d \Omega \cdot \mathrm{Re} \left [A_H^P(s,\Omega)\cdot  \frac{1}{s-s_H}   \cdot A_H^D(s,\Omega) \cdot A_h^{P*}(s,\Omega)\cdot  \frac{1}{(s-s_h)^*}   \cdot A_h^{D*}(s,\Omega)   \right ]
\end{equation}
By assuming the production and decay amplitudes are the same for heavy Higgs boson and SM Higgs boson, the cross section function can be simplified to:
\begin{equation}
    \sigma_{gg} (s) = \frac{1}{s}  \int d \Omega \cdot \mathrm{Re} \left [\frac{1}{s-s_H} \cdot  \frac{1}{(s-s_h)^*} \right ] \cdot \left | A_{gg \to H}(s,\Omega) \right |^2 \left | A_{H \to ZZ}(s,\Omega) \right |^2
\end{equation}
\endgroup

Taking into account Equation~\ref{eq:PartialWidth}:

\begin{equation} \label{eq:HhInterference_2}
    \sigma_{gg} (s) = 4 \cdot \mathrm{Re} \left [\frac{1}{s-s_H} \cdot  \frac{1}{(s-s_h)^*} \right ] \cdot  \Gamma_{H \to gg} (s) \cdot \Gamma_{H \to ZZ} (s)
\end{equation}

where the propagators are described in equation~\ref{eq:propagator}, and the partial widths are described in equations~\ref{eq:WidthZZ}~and~\ref{eq:WidthGG}.

Same as previous procedure, the parton cross section can be transformed to a hadron cross section as a function of \mfl:

\begin{equation} \label{eq:HhInterference}
    \sigma_{pp} (m_{4\ell}) = 4 \cdot m_{4\ell} \cdot  \mathcal{L}_{gg}\cdot \mathrm{Re} \left [\frac{1}{s-s_H} \cdot  \frac{1}{(s-s_h)^*} \right ] \cdot  \Gamma_{H \to gg} (m_{4\ell}) \cdot \Gamma_{H \to ZZ} (m_{4\ell})
\end{equation}

%This equation is similar to the differential cross section of signal only production with the only difference in propagator.
%Since the propagator does not affect the kinematic performance of the final state, this interference process can be reproduced by reweighting the signal events with weights defined as:
%
%\begin{equation}
%    w(m_{4\ell}) = \frac{2 \cdot \mathrm{Re} \left [\frac{1}{s-s_H} \cdot  \frac{1}{(s-s_h)^*} \right ] }{\frac{1}{\left | s - s_H \right |^2}}
%\end{equation}

The modelling procedure of interference is the same as the way for large-width signal described in section~\ref{sec:signal_lwa}.
The truth line shape is measured as analytical function from equation~\ref{eq:HhInterference}, and then convolute with detector effect from NWA parameterization to get the reconstruction level shape.

For LWA signal model, these two interferences are carefully taken into account, and the integration of the pure LWA signal with the interferences is used for further studies.
Figure~\ref{fig:LWASignalModel} shows the signal model for large-width scenario at mass points of 400~\gev, 600~\gev, 800~\gev, for three different signal widths: 5\%, 10\%, 15\%, with and without interference.
Additionally, the contribution of the interference between heavy Higgs and SM Higgs (H-h) is shown together with the one between heavy Higgs and SM \ggZZ background (H-b).
One can see the interference effect on signal shape becomes less important when going to higher mass.

\begin{figure}[htbp]
    \centering
    \includegraphics[width=1.0\textwidth]{figures/HMHZZ/signal/LWA/LWAModel.pdf}
    \caption{The signal modelling for the large-width scenario at \mH of 400 GeV (top), 600 GeV (middle) and 800 GeV (bottom), as well as three different signal width:  5\%  (left), 10\%  (middle) and 15\% (right).
    The contribution of the interference between heavy Higgs and SM Higgs (H-h) is shown together with the one between heavy Higgs and SM \ggZZ background (H-b).}
    \label{fig:LWASignalModel}
\end{figure}

\subsection{Modelling of spin-2 RS Graviton signal}

The search for Randall-Sundrum (RS) graviton is performed in mass region between 600 to 2000~\gev.
The width of resonance is determined by the \kOverMpl, which, as mentioned in section~\ref{sec:hmhzz_signal_mc}, is set to be 1.
In this configuration, the width of signal is expected to be about 6\% of its mass.

The reconstructed \mfl lineshape of graviton is also built by convolving the truth-level lineshape with a detector resolution function,
where the detector resolution effect is modelled by a Gaussian + Crystal Ball function, whose parameters are taken from the NWA signal parameterization in section~\ref{sec:signal_nwa}.
And the truth-level shape is modelled as the product of a relativistic Breit-Wigner (RBW) term, a term corresponding to the squared matrix element of the production process and a parton luminosity term $\mathcal{L}$ as given in ~\cite{Bijnens_2001}.
So the truth lineshape of \mfl is taken from:
\begin{equation*}
        \mfl^{\text{Truth}} \sim \mathcal{L}_{gg} \cdot s^2 \cdot \frac{s(1 + s)(1 + 2s + 2s^2)}{(s^2 - \mG^2)^2 + \mG^2 \Gamma^2}
\end{equation*}
The truth-level signal model is extracted by fitting to MC simulation at truth-level with the mass $\mG$ and width $\Gamma$ parameters floating at each mass points respectively.
And then the two parameters are parameterized as the function of \mH by a linear fit as shown in figure~\ref{fig:graviton_truth_param_vs_mG}.
\begin{figure}[htbp]
        \centering
        \includegraphics[width=0.4\textwidth]{figures/HMHZZ/signal/RSGraviton/graviton_param_m_RBW.eps}
        \includegraphics[width=0.4\textwidth]{figures/HMHZZ/signal/RSGraviton/graviton_param_G_RBW.eps}
        \caption{Fitted parameters of the graviton RBW, $m_{\text{RBW}}$ and $\Gamma_{\text{RBW}}$, as a function of the
        graviton resonance mass, \mG.}
        \label{fig:graviton_truth_param_vs_mG}
\end{figure}

The final signal model is obtained by convolving the truth-level lineshape with the detector resolution function.
To verify the result, figure~\ref{fig:graviton_reco_shape_2mu2e} compares the \mfl lineshape from parameterization with the one observed from reconstructed-level MC simulation in 2$e$2$\mu$ channel at masses of 600~\gev, 1600~\gev~and 2000~\gev~as examples.

\begin{figure}[htbp]
    \centering
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/RSGraviton/graviton_reco_shape_m4l_constrained_HM_600GeV_2mu2e.eps}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/RSGraviton/graviton_reco_shape_m4l_constrained_HM_1600GeV_2mu2e.eps}
    \includegraphics[width=0.32\textwidth]{figures/HMHZZ/signal/RSGraviton/graviton_reco_shape_m4l_constrained_HM_2000GeV_2mu2e.eps}
    \caption{Reconstructed \mfl distributions in the $2\mu 2e$ channel with the final signal
        model superimposed for each RS graviton signal sample at masses of 600~$\gev$, 1600~$\gev$ and 2000~$\gev$. The lower panel in each plot shows
        the pull distribution. The dashed green lines show the truth-level graviton signal models for reference.}
    \label{fig:graviton_reco_shape_2mu2e}
\end{figure}


\section*{Imbalance}
\subsection*{Cost Sensitive Classification}
Replace loss by: $l_{CS}(w;x,y) = c_y l(w;x,y)$

\subsection*{Metrics}
Accuracy: $\frac{TP+TN}{TP+TN+FP+FN}$, Precision: $\frac{TP}{TP+FP}$\\
TPR = Recall: $\frac{TP}{TP+FN}$, F1 score: $\frac{2TP}{2TP+FP+FN}$\\
FPR = $\frac{FP}{TN+FP}$


\begin{center}
	\LARGE{\textbf{Øving 8}}
\end{center}

\section*{13.3}

\subsection*{15}

\begin{gather*}
	z = x + i y
	|z|^2 Im \left(\frac{1}{z}\right)
	=
	\left(x^2 + y^2\right) \frac{y}{x^2 + y^2}
	=
	y
	\\
	z = 0 \Rightarrow y = 0 \Rightarrow |z|^2 \text{ Im} \left(\frac{1}{z}\right) = 0
	\Rightarrow f(z) \text{ is continous}
\end{gather*}

\subsection*{16}

\begin{gather*}
	\frac{\text{ Im } z^2}{|z|^2}
	=
	\frac{2 x y}{x^2 + y^2}
	\\
	\text{Limit along } x = y:
	\\
	\lim_{x \rightarrow 0}{\frac{2 x^2}{x^2 + x^2}}
	=
	1 \neq 0 \Rightarrow f(z) \text{ is discontinous}
\end{gather*}

\section*{13.4}

\subsection*{10}

\begin{gather*}
	f(z) = \ln{|z|} + i \text{ Arg } z = \ln{r} + i \theta = u(r, \theta) + i v(r, \theta)
	\\
	u_r = \frac{1}{r} = \frac{1}{r} v_\theta
	\\
	u_\theta = 0 = v_r
	\\
	f(z) \text{ is therefore analytic}
\end{gather*}

\subsection*{18}

\begin{gather*}
	u = x^3 - 3 x y^2
	\\
	u_{xx} + u_{yy} = 6 x - 6 x = 0 \Rightarrow u(x, y) \text{ is harmonic}
	\\
	u_x = 3 x^2 - 3 y^2 = v_y
	\\
	v = \int{\left(3 x^2 - 3 y^2\right) dy}
	=
	3 x^2 y - y^3 + C(x)
	\\
	u_y = -6 x y = -v_x
	\\
	v = \int{6 x y dx} = 3 x^2 y + C(y)
	\\
	v = 3 x^2 y - y^3 + C
\end{gather*}

\subsection*{19}

\begin{gather*}
	v = e^{-x} \sin{2 y}
	v_{xx} + v_{yy} = e^{-x} \sin{2 y} - 4 e^{-x} \sin{2 y} = -3 e^{-x} \sin{2 y} \neq 0
	\\
	v(x, y) \text{ is therefore not harmonic}
\end{gather*}

\section*{13.5}

\subsection*{20}

\begin{gather*}
	e^z = 4 + 3 i
	\\
	z = \ln{(4 + 3 i)} = \ln{5} + i (\text{ Arg } (4 + 3 i) + 2 \pi n)
\end{gather*}

\begin{center}
	\plot{Figurer/f1.tikz}{5}{4}
\end{center}

\section*{13.6}

\subsection*{10}

\begin{gather*}
	\sinh{(3 + 4 i)}
	=
	\frac{1}{2} \left(
		e^{3 + 4 i} - e^{- 3 - 4 i}
	\right)
	=
	\frac{1}{2} \left(
		e^3 e^{4 i} - e^{-3} e^{-4 i}
	\right) =
	\\
	\frac{1}{2} \left(
		e^3 (\cos{4} + i \sin{4}) - e^{-3} (\cos{4} - i \sin{4})
	\right)
	=
	\\
	\cos{4} \cdot \frac{1}{2} \left(
		e^3 - e^{-3}
	\right)
	+
	i \sin{4} \cdot \frac{1}{2} \left(
		e^{3} + e^{-3}
	\right)
	=
	\\
	\sinh{3} \cos{4} + i \cosh{3} \sinh{4}
	\\
	\\
	\\
	\cosh{(3 + 4 i)} = \cosh{3} \cos{4} + i \sinh{3} \sin{4}
\end{gather*}

\subsection*{16}

\begin{gather*}
	\sin{z} = 100
	\Rightarrow
	\frac{1}{2 i} \left(
		e^{i z} - e^{-i z}
	\right) = 100
	\\
	e^{i z} - e^{-i z} = 200 i
	\\
	e^{2 i z} - 1 = 200 i e^{i z}
	\Rightarrow
	\left(e^{i z}\right)^2 - 200 i e^{i z} - 1 = 0
	\\
	e^{i z} = \frac{200 i \pm \sqrt{(200 i)^2 - 4 \cdot 1 \cdot (-1)}}{2}
	=
	\frac{200 i \pm \sqrt{- 39996}}{2}
	=
	\\
	100 i \pm 3 i \sqrt{1111} \approx 199.995 \vee 0.005 i
	\\
	i z = \ln{199.995 i} = \pm \ln{199.995} + \ln{i} = \pm 5.298 + i \left(\frac{\pi}{2} + 2 \pi n\right)
	\\
	z = \frac{\pi}{2} + 2 \pi n \pm 5.298 i
\end{gather*}

\subsection*{19}

\begin{gather*}
	\sinh{z} = 0
	\Rightarrow
	\frac{1}{2} \left(
		e^{z} - e^{-z}
	\right) = 0
	\\
	e^{2 z} - 1 = 0
	\\
	2 z = \ln{1} = 2 \pi n i
	\\
	z = \pi n i
\end{gather*}

\section*{13.7}

\subsection*{15}

\begin{gather*}
	\ln{e^i}
	=
	i \ln{e} = i - 2 \pi n
\end{gather*}

\begin{center}
	\plot{Figurer/f2.tikz}{5}{4}
\end{center}

\subsection*{17}

\begin{gather*}
	\ln{(4 - 3 i)} = \ln{5} + i \text{ Arg } (4 - 3 i)
	=
	\ln{5} + i \text{atan}{\frac{-3}{4}} + 2 i \pi n
\end{gather*}

\begin{center}
	\plot{Figurer/f3.tikz}{5}{4}
\end{center}

\subsection*{26}

\begin{gather*}
	i^{\frac{i}{2}}
	=
	e^{\frac{i}{2} \ln{i}}
	=
	e^{\frac{i}{2} \cdot i \frac{\pi}{2}}
	=
	e^{-\frac{\pi}{4}} \approx 0.4559
\end{gather*}

\begin{minted}[mathescape, fontsize=\small, xleftmargin=0.5em]{julia}
using Plots
R = 0.0821
T = 243.6
isoterm(x) = R * T / x
v = 1 : 0.1 : 10
p = isoterm.(v)
plot(xlabel = "V[L]", ylabel = "P[atm]", xlims = (0, 15), ylims = (0, 25),
		xticks = 0 : 1 : 15, yticks = 0 : 2 : 25)
plot!(reverse(v), reverse(p);
		color = :red, label = "Trinn 1", arrow = :arrow, linewidth = 2)
plot!([1, 10], [20, 20];
		color = :blue, label = "Trinn 2", arrow = :arrow, linewidth = 2)
plot!([10, 10], [20, 2];
		color = "#007f00", label = "Trinn 3", arrow = :arrow, linewidth = 2)
\end{minted}
\includegraphics[width=\linewidth]{figures/oppg_1_1.pdf}


\chapter{Applications in Machine Learning }

\section{Certigrad}
A recent paper\cite{certigrad} by \textit{Daniel Selsam} verifies the computation graph of machine learning model. The project \textbf{Certigrad}\cite{certigrad_video} explains that it is very possible that conventional debugging techniques fail to explain ambiguous nature of a ML model failure (like memory overflow and corruption) that may be a result of setting some hyper-parameters or a flaw in program logic. Say for example the one of the functions diverge at a certain point then it might be very difficult to track that simple using a debugger. However when verified using a proof assistant, it correctly suggestes that the unexpected behaviour is outcome of mathematical error and not program logic. Similar logic can thus be extended to verify computation graphs of every machine learning model.

\section{Automated Proving}
While correcting ML model using program verification, new kind of proof assistant \textbf{Proving Ground}\cite{provingground} by Professor \textit{Siddhartha Gadgil} is also being developed that uses AI to help reduce steps furthermore.


\section{View Spectrum Data}
	This drop down has options that come directly from the data loaded into the main interface.

		\subsection{View Energies}
			This takes a set of energies, in MeV, separated by commas to draw vertical lines on the graph. These lines will be drawn as a dotted red line.
		\subsection{Change Zoom Location}
			Changes the minimum and maximum energies shown on the graph. Much like a zoom feature.
		\subsection{Calibration Energies}
			Takes a set of values, separated by commas to draw vertical lines representing calibration energies. These will appear as solid black lines.
		\subsection{Count Rates}
			Will display the count rate of all loaded spectrum in counts per second. If a time of 1 second has been entered for the accumulation time, the value displayed will be the total number of counts in the total spectrum.
		\subsection{ROI Uncertainties}
		This will compute the gross count rate, net count rate, and the associate uncertainties for each in a specified region of interest. The gross count uncertainties are found using $\sigma=\sqrt{N}$, where $\sigma$ is the standard deviation and $N$ is the number of counts in the region of interest. The net uncertainty is found using equation \ref{eq:net_uncer}, where $\sigma_F$ and $\sigma_B$ are foreground and background standard deviations respectively.
		\begin{equation}
			\sigma_{net}=\sqrt{\sigma_F^2+\sigma_B^2}
			\label{eq:net_uncer}
		\end{equation}

		\subsection{Energy Resolution}
			Once a spectrum has been plotted and is located in the Plotted Spectrum section, the option to view the energy resolution will be enabled. This option uses a peak finding algorithm to analyze and determine the peaks. The energy resoution is calculated as the full width half maximum of the identified peak divided by the peak centroid location. This is calculated and displayed for each peak found in the spectrum. The energy resolution is displayed next to a vertical line as a percentage.


\appendix

\section{Proof of the invertibility of the Farkas representation}
In this appendix, we prove~\cref{lem:farkinv} which is restated here
as~\cref{lem:farkinv_app}.

In the following lemma, we present an integral indentity involving the
Green's function of the oscillatory biharmonic equation.
\begin{lem}
Suppose that $\Gbh$ is the Green's function of the oscillatory biharmonic equation
with Helmholtz parameter $k$. Suppose that $v:\R^{2} \to \R$ is a compactly supported smooth
function. Then
\begin{equation}
\int_{\R^{2}} \Gbh(\xx,\yy) \Delta (\Delta + k^2) v(\yy) d\yy = v(\xx)
\end{equation}
\end{lem}
\begin{proof}
Suppose that $r>0$.
Let $B_{r}(\xx)$ denote the ball of radius $r$ centered at the origin
and let $\partial B_{r}(\xx)$ denote its boundary.
Then applying Green's second identity twice, we get
\begin{align}
\int_{\R^{2} \setminus B_{r}(\xx)} \Gbh(\xx,\yy) \Delta (\Delta +k^{2}) v(\yy)
&=
\int_{\R^{2} \setminus B_{r}(\xx)} \Delta \Gbh (\xx,\yy) (\Delta + k^2)
v(\yy) + \\
& \hspace{5ex}\int_{\partial B_{r}(\xx)} \Gbh(\xx,\yy) (\Delta + k^{2})
\frac{\partial}{\partial n}v(\yy) \, dS - \\
& \hspace{5ex}\int_{\partial B_{r}(\xx)} \frac{\partial }{\partial n} \Gbh(\xx,\yy)
(\Delta + k^2) v \, dS \\
&= \int_{\R^{2} \setminus B_{r}(\xx)} \Delta (\Delta + k^2)G(\xx,\yy) v(\yy)
d\yy  - \nonumber \\
& \hspace{5ex}\int_{\partial B_{r}(\xx)} (\Delta + k^2)
\frac{\partial }{\partial n} \Gbh(\xx,\yy) v \, dS + \nonumber\\
& \hspace{5ex}\int_{\partial B_{r}(\xx)} (\Delta + k^2)
\Gbh(\xx,\yy) \frac{\partial}{\partial n}v \, dS - \nonumber \\
& \hspace{5ex}\int_{\partial B_{r}(\xx)}
\frac{\partial }{\partial n} \Gbh(\xx,\yy) \Delta v\, dS + \\
& \hspace{5ex}
\int_{\partial B_{r}(\xx)} \Gbh(\xx,\yy) \Delta \frac{\partial v}{\partial n}
\, dS \nonumber
\end{align}
For all $\yy \in \partial B_{r}(x)$, there exists a constant $C$ such that
$\Gbh$ satisfies the following equations
\begin{align}
(\Delta + k^2) \frac{\partial }{\partial n} G(\xx,\yy) &=
-\frac{1}{2\pi r} \label{eq:estapp1}\\
\left|(\Delta + k^2) G(\xx,\yy) \right| &\leq C \log{(r)} \label{eq:estapp2}\\
\left|\frac{\partial }{\partial n} G(\xx,\yy) \right| &\leq C r\log{(r)}
\label{eq:estapp3}\\
\left| G(\xx,\yy) \right| &\leq C r^{2} \log{(r)} \label{eq:estapp4}\, .
\end{align}
Furthermore, $\Gbh$ satisfies $\Delta (\Delta + k^2) \Gbh(\xx,\yy) = 0$
for all $\yy \in \R^{2} \setminus B_{r}(\xx)$.
Using the estimates in~\cref{eq:estapp1,eq:estapp2,eq:estapp3,eq:estapp4},
and the smoothness of $v$, we get
\begin{equation}
\int_{\R^{2} \setminus B_{r}(\xx)} \Gbh(\xx,\yy) \Delta (\Delta + k^2) v(\yy)
d \yy = \frac{1}{2\pi r} \int_{\partial B_{r}(\xx)} v(\yy) dS +
O(r \log(r)) \, \label{eq:estapp5}.
\end{equation}
The result then follows by taking the limit $r\to 0$ in~\cref{eq:estapp5}.
\end{proof}
\label{sec:farkproof}

\section{Proof of invertibility of new representation}
The proof proceeds as follows:
\begin{itemize}
\item Show uniqueness of solutions to the impedence, velocity, and surface
traction boundary value problem in exterior domains for the oscillatory Stokes
PDEs. In order to prove this, we need the following lemmas:
\begin{itemize}
\item Deriving Green's theorem for exterior domains
\item Rellich's lemma
\item Uniqueness proof
\end{itemize}
\item The proof for the clamped plate problem proceeds in the manner
analogous to the Dirichlet biharmonic paper.
\end{itemize}

With this in mind, we first discuss the PDE theory for the impedence,
velocity and surface traction boundary value problems on unbounded
domains for the oscillatory Stokes equation.
We focus on the proof for the velocity boundary value problem.
The proofs for the surface traction and impedence problems is similar.

Suppose that $\Omega$ is a bounded simply connected domain and that
$E = \R^{2} \setminus \Omega$ is its exterior.
Let $\Gamma = \partial \Omega$ denote the boundary of $E$.
For a given function $\bh$ on the boundary,
the exterior velocity boundary value problem is given by:
\begin{align}
\Delta \bu + \omega^{2} \bu &= \nabla p \quad \bx \in E \, ,\\
\nabla \cdot \bu &= 0 \quad \bx \in E \, ,\\
\bu &= \bh \quad \bx \in \Gamma \, . \\
\end{align}
Let $\sigma$ denote the stress tensor associated with the velocity
field $\bu$, i.e.
\begin{equation}
\sigma = -p I + e(\bu) \, ,
\end{equation}
where $e(\bu)$ is the strain tensor given by
\begin{equation}
e(\bu) = \frac{1}{2}\left(D\bu + D\bu^{T} \right) \, .
\end{equation}
Let $\bn$ denote the outward normal to the boundary $\Gamma$, then
the surface traction $\ff$ on the boundary $\Gamma$ is given
by
\begin{equation}
\ff = \sigma \cdot \bn
\end{equation}
Analogous to the Helmholtz equation, we need to impose radiation conditions
at $\infty$.
We propose the following radiation conditions for the oscillatory Stokes
equation
\begin{equation}
\lim_{r\to \infty} \sqrt{r} \left| \ff - i \omega \bu \right| \to 0 \, ,
\label{eq:radcond}
\end{equation}
uniformly in direction.

\begin{lem}
\label{lem:rep}
Suppose that $\bu$ satisfies the oscillatory Stokes equation in
an unbounded region $E$ along with the radiaition
condition~\cref{eq:radcond}.
Then
\begin{equation}
\label{eq:repinfest}
\lim_{r\to\infty}
\int_{|\by|=r} \left( |\ff|^2 + |\omega|^2 |\bu|^2 \right) ds +
2 \text{Im}(\omega) \int_{E \cap B_{r}(0)} \left(|\omega|^2 |\bu|^2 + |e(\bu)|^2 \right)
dV = -2 \text{Im} \left( \omega \int_{\Gamma} \bu \cdot \overline{\ff} ds  \right)
\end{equation}
\end{lem}

\begin{proof}
Since $\bu$ satisfies the radiation condition, we have that
\begin{equation}
\lim_{r\to\infty} \int_{|\by|=r} | \ff - i \omega \bu|^2 ds =
\lim_{r\to\infty} \int_{|\by| =r} \left( |\ff|^2 + |\omega|^2|\bu|^2 + 2 \text{Im}
\left( \omega \bu\cdot \ff \right) ds \label{eq:raddecayproof1}
\right) = 0 \, .
\end{equation}
Since $\bu$ satisfies the oscillatory Stokes equation $E \cap B_{r}(0)$,
using a couple of applications of the divergence theorem, we have that
\begin{align}
\int_{E\cap B_{r}(0)} |e(\bu)|^2 dV &= \int_{E\cap B_{r}(0)} \left< e(\bu), \overline{e(\bu)} \right> dV  \\
&= \frac{1}{2}\left(\int_{E\cap B_{r}(0)} \left< e(\bu),\overline{D\bu} \right> + \left< e(\bu),\overline{D\bu}^{T} \right> \right) dV \\
&= \int_{E\cap B_{r}(0)} \left< e(\bu),\overline{D\bu} \right> dV \\
&= \int_{\partial }
-\int_{\Gamma} \bu \cdot \overline{\ff} ds
+ \int_{|\by|=r} \bu \cdot \overline{\ff} ds + \overline{\omega}^2
\int_{E \cap B_{r}(0)} |\bu|^2 dV \,. \label{eq:raddecayproof2}
\end{equation}
Combining~\cref{eq:raddecayproof1,eq:raddecayproof2}, we get
\begin{equation}
\lim_{r\to\infty} \int_{|\by|=r}\left(|\ff|^2 + |\omega|^2 |\bu|^2 \right) ds
+ 2\text{Im}(k)\int_{E \cap B_{r}(0)} \left(|e(\bu)|^2 + |\omega|^2 |\bu|^2
\right) dV = -2\text{Im} \int_{\Gamma} \omega \bu \cdot \overline{\ff} dS \, .
\end{equation}
\end{proof}

In the next lemma, we prove the analogue of Rellich's lemma
for the oscillatory Stokes equation.
\begin{lem}
\label{lem:rellich}
Suppose that $\bu$ satisfies the oscillatory Stokes equation in an unbounded
region $E$.
Suppose further that
\begin{equation}
\lim_{r \to \infty} \int_{|\by|=r} |\bu|^2 dS = 0
\, . \label{eq:decayatinf}
\end{equation}
Then each component of $\bu$ is harmonic and has a convergent Laurent
expansion in $E$.
\end{lem}
\begin{proof}
We first note that each component of $\bu= (u_{1},u_{2})$ satisfies the
oscillatory biharmonic equation in $E$, i.e.
\begin{equation}
\Delta (\Delta + \omega^2) u_{j} = 0 \quad j=1,2 \,.
\end{equation}
For $r$ sufficiently large, we can express $u_{j}$ in the Fourier basis as
\begin{equation}
u_{j}(r,\theta) = \sum_{n=-\infty}^{\infty} a_{j,n}(r) e^{i n \theta}  \quad
j=1,2 \, .
\end{equation}
Using Parseval's identity then
\begin{equation}
\int_{|\by|=r} |\bu|^2 ds = r\sum_{n=-\infty}^{\infty} |a_{1,n}(r)|^2  +
|a_{2,n}(r)|^2 \, .
\end{equation}
Since $\bu$ satisfies~\cref{eq:decayatinf}, we conclude that
\begin{equation}
\lim_{r\to\infty} r|a_{j,n}(r)|^2 = 0 \quad j=1,2 \, , \label{eq:adecay}
\end{equation}
Since $u_{j}$, $j=1,2$ satisfies the oscillatory biharmonic equation,
the functions $a_{j,n}$ are linear combinations of
\begin{equation}
r^{|n|}, r^{-|n|}, H^{1}_{n}(\omega r), H^{2}_{n}(\omega r) \, , \quad
n\neq 0 \, ,
\end{equation}
and
\begin{equation}
1, \log{(r)}, H^{1}_{0}(\omega r), H^{2}_{0}(\omega r) \quad n=0 \, ,
\end{equation}
where $H_{n}^{1,2}(\cdot)$ are the Hankel functions of the first and
second kind of order $n$.
Since $a_{j,n}(r)$ satisfy~\cref{eq:adecay}, and using the asymptotic
expansion of $H_{n}^{1,2}(r)$, we note that the projection of
$a_{j,n}$ on $r^{|n|}$, and $H_{n}^{j}(\omega r)$ must be zero.
Thus,
\begin{equation}
u_{j}(r,\theta) = \sum_{n=-\infty}^{\infty} \frac{a_{j,n} e^{i n \theta}}{r^{|n|}}
\, .
\end{equation}
\end{proof}
\begin{remark}
Note that each component of $\bu$ is harmonic and thus $\bu$ then satisfies
\begin{align}
\omega^2 \bu &= \nabla p  \quad \label{eq:massconsred} \\
\nabla \cdot \bu &= 0 \, .
\end{align}
Taking the inner product with $\nabla^{\perp}$ in~\cref{eq:massconsred},
we note that $\bu$ satisfies both $\nabla^{\perp} \cdot \bu = 0$
and $\nabla \cdot \bu = 0$.
This remark will be useful for the impedence problem...
\end{remark}
\begin{remark}
Note that in Rellich's lemma $\bu$ need not be a radiating solution.
All we know of $\bu$ is that it satifies the PDE in $E$.
\end{remark}

\begin{thm}
(Uniqueness Dirichlet)
Suppose that $\text{Im}(\omega)\geq 0$ and
that $\bu$ is a radiating solution to the oscillatory Stokes
equation in $E$ with $\bu =0$ on the boundary $\Gamma$, then
$u \equiv 0$ in $E$.
\end{thm}

\begin{proof}
Since $\bu = 0$ on $\Gamma$, it follows from~\cref{eq:repinfest} that
\begin{equation}
\lim_{r\to\infty}
\int_{|\by|=r} \left( |\ff|^2 + |\omega|^2 |\bu|^2 \right) ds +
2 \text{Im}(\omega) \int_{E \cap B_{r}(0)} \left(|\omega|^2 |\bu|^2 + |e(\bu)|^2 \right)
dV = 0
\end{equation}
In particular, this implies that
\begin{equation}
\lim_{r\to\infty} \int_{|\by|=r} |\bu|^2 ds = 0 \, .
\end{equation}
Thus, the conditions for $\bu$ in Rellich's lemma (~\cref{lem:rellich})
are satisfied, and each component of $\bu$ is a harmonic function
with $\bu \to 0$ as $r \to \infty$. Furthermore, since $\bu=0$ on
$\Gamma$, from uniqueness of solutions to the Dirichlet problem
on exterior domains, we conclude that $\bu \equiv 0$ in $E$.
\end{proof}

The proof for the Neumann problem proceeds in a similar manner.


\chapter{Code: Numerical Solver}

Some extra bits of code to help check if a bipartite state's ket vector can be separated numerically.\\
A copy can be obtained from\\
https://github.com/saad440/undergrad-project

\begin{verbatim}
# -*- coding: utf-8 -*-
"""
This module contains simple solver functions to check if a given state
ac|00>+ad|01>+bc|10>+bd|11> is separable and if it is, solve for a,b,c,d.

Project: Investigation of Entanglement Measures in QuTiP
         (IIUI, Fall 2015)

@author: Muhammad Saad <muhammad.saad@yandex.com>
"""

__all__ =  ['solve_coefficients', 'verify_separability',
            'is_separable_coeffs', 'is_separable']

from scipy.optimize import fsolve
import numpy as np

def solve_coefficients(coeffprod):
    """ Simple solver to separate a,b,c,d from products ac,ad,bc,bd

    Parameters
    ----------
    coeffprod : list
                [ac,ad,bc,bd] of which to separate a, b, c and d.

    -------
    z :       list
                The solutions [a,b,c,d]

    Examples
    --------
    >>>

    """
    ac,ad,bc,bd = coeffprod
    def f(x):
        a,b,c,d = x
        r = np.zeros(4)
        r[0] = a*c - ac
        r[1] = a*d - ad
        r[2] = b*c - bc
        r[3] = b*d - bd
        return r
    z = fsolve(f,[1,1,1,1])
    return z

def verify_separability(coeffprod,coeffsepd,tol=6):
    """ Verify that the solutions obtained are actually valid

    Parameters
    ----------
    coeffprod : list
                [ac,ad,bc,bd] of which to separate a, b, c and d.
    coeffsepd : list
                [a,b,c,d], the solutions obtained from solve_coefficients

    -------
    vrfy :      bool
                True: match, False: donot match

    """
    a,b,c,d = coeffsepd
    ac,ad,bc,bd = coeffprod
    vrfy = [np.round((a*c-ac),tol)==0, np.round((a*d-ad),tol)==0,
            np.round((b*c-bc),tol)==0, np.round((b*d-bd),tol)==0]
    if all(vrfy):
        return True

def is_separable_coeffs(coeffprod,tol=6):
    """ Check whether a list of coefficients to a state is separable

    Parameters
    ----------
    coeffprod : list
                [ac,ad,bc,bd] of which to separate a, b, c and d.
    tol :       int
                rounding error tolerance

    -------
    separable : bool
                True: Coefficients are separable, False: not separable

    """
    ac,ad,bc,bd = coeffprod
    a,b,c,d = solve_coefficients(coeffprod)
    coeffsepd = a,b,c,d
    separable = verify_separability(coeffprod,coeffsepd)
    return bool(separable)

def is_separable(kt,tol=6):
    """ Check whether a state vector represents a separable state
    Note: Currently limited to 2-level product states of two particles

    Parameters
    ----------
    kt  :       ket state vector
                [ac,ad,bc,bd] of which to separate a, b, c and d.
    tol :       int
                rounding error tolerance

    -------
    separable : bool
                True: State is separable, False: not separable

    """
    # Current limitations. Need to generalize
    limitations = [ kt.isket, kt.shape==[4,1] ] # kt.dims==[[2,2],[1,1]]
    if not all(limitations):
        raise ValueError("Currently limited to 2-level product states of 2 particles")
    ac,ad,bc,bd = kt.full()
    ac,ad,bc,bd = ac[0],ad[0],bc[0],bd[0]
    coeffprod = ac,ad,bc,bd
    is_sp = is_separable_coeffs(coeffprod,tol)
    return is_sp
\end{verbatim}


% Part: first-order-logic
% Chapter: sequent-calculus
% Section: quantifier-rules

\documentclass[../../../include/open-logic-section]{subfiles}

\begin{document}

\olfileid{fol}{seq}{qrl}

\olsection{Quantifier Rules}

\subsection{Rules for $\lforall$}

\begin{defish}
\Axiom$ !A(t), \Gamma \fCenter \Delta$
\RightLabel{\LeftR{\lforall}}
\UnaryInf$ \lforall[x][!A(x)],\Gamma \fCenter \Delta$
\DisplayProof
\hfill
\Axiom$ \Gamma \fCenter \Delta, !A(a) $
\RightLabel{\RightR{\lforall}}
\UnaryInf$ \Gamma \fCenter \Delta, \lforall[x][!A(x)]$
\DisplayProof
\end{defish}

In \LeftR{\lforall}, $t$ is a closed term (i.e., one without
variables). In \RightR{\lforall}, $a$~is !!a{constant} which must
not occur anywhere in the lower sequent of the \RightR{\lforall}
rule. We call $a$ the \emph{eigenvariable} of the \RightR{\forall}
inference.

\subsection{Rules for $\lexists$}

\begin{defish}
\Axiom$ !A(a), \Gamma \fCenter \Delta $
\RightLabel{\LeftR{\lexists}}
\UnaryInf$ \lexists[x][!A(x)], \Gamma \fCenter \Delta$
\DisplayProof
\hfill
\Axiom$ \Gamma \fCenter \Delta, !A(t) $
\RightLabel{\RightR{\lexists}}
\UnaryInf$ \Gamma \fCenter \Delta, \lexists[x][!A(x)]$
\DisplayProof
\end{defish}

Again, $t$~is a closed term, and $a$~is !!a{constant} which does
not occur in the lower sequent of the \LeftR{\lexists} rule. We call
$a$ the \emph{eigenvariable} of the \LeftR{\lexists} inference.

The condition that an eigenvariable not occur in the lower sequent of
the \RightR{\lforall} or \LeftR{\lexists} inference is called the
\emph{eigenvariable condition}.

\begin{explain}
We use the term ``eigenvariable'' even though $a$ in the above rules
is !!a{constant}. This has historical reasons.

In \RightR{\lexists} and \LeftR{\lforall} there are no restrictions on
the term~$t$. On the other hand, in the \LeftR{\lexists} and
\RightR{\lforall} rules, the eigenvariable condition requires that the
!!{constant}~$a$ does not occur anywhere outside of~$!A(a)$ in the
upper sequent. It is necessary to ensure that the system is sound,
i.e., only !!{derive}s sequents that are valid. Without this
condition, the following would be allowed:
\begin{prooftree}
  \Axiom$!A(a) \fCenter !A(a)$
  \RightLabel{*\LeftR{\lexists}}
  \UnaryInf$\lexists[x][!A(x)] \fCenter !A(a)$
  \RightLabel{\RightR{\lforall}}
  \UnaryInf$\lexists[x][!A(x)] \fCenter \lforall[x][!A(x)]$
  \DisplayProof\bottomAlignProof
  \qquad
  \Axiom$!A(a) \fCenter !A(a)$
  \RightLabel{*\RightR{\lforall}}
  \UnaryInf$!A(a) \fCenter \lforall[x][!A(x)]$
  \RightLabel{\LeftR{\lexists}}
  \UnaryInf$\lexists[x][!A(x)] \fCenter \lforall[x][!A(x)]$
\end{prooftree}
However, $\lexists[x][!A(x)] \Sequent \lforall[x][!A(x)]$ is not valid.
\end{explain}

\end{document}


\section{Skewness and Vector-Valued Data-Constructed QoI Maps}
In our first example, we show that for the problem in \ref{subsec:pde-example}, a small change in the decision of how to aggregate the measurements collected on the response surface can induce a 2-dimensional map $\qoi_\text{2D}^\prime$ which is ``effectively'' one-dimensional; the two components provide highly correlated information.
Such a map is, by definition, more skewed than the one we presented with $\qoi_\text{2D}$.
Therefore, $\qoi_\text{2D}^\prime$ leads to MUD-point solutions that exhibit similar behavior to those obtained with $\qoi_\text{1D}$.
This decreased precision demonstrates that skewness\---although reviewed and analyzed in the previous chapter within the context of accuracy of set-valued solutions\---is a relevant measure of a map's utility for solving parameter identification problems.

The examples in Sections~\ref{subsec:ode-example} and \ref{subsec:pde-example} motivate the use of a data-constructed QoI in order to incorporate an arbitrary number of measurements in a system into a scalar-valued map.
These examples are chosen so that $\text{dim}({\Lambda}) = 1$ for simplicity and to establish a baseline for convergence results.
The linear examples in Section~\ref{sec:high-dim-linear-example} demonstrate that the DCI framework maintains the accuracy of least-squares while incorporating initial beliefs for higher-dimensional linear maps.
In those examples, we show that the ability to resolve a true parameter improves as the gap between input dimension and operator row-rank decreases.

The rank-deficiency of an operator is attributed to either the ill-conditioning of an operator $A:P\to P$, or when $P>D$ for a full-rank $A:P\to D$.
In scenarios where $S>P$ observations are available, we are motivated to leverage the form of Eq.~\eqref{eq:qoi_WME} to construct a vector-valued version of the QoI map incorporating subsets of $S$ for each component.
For example, a system for which spatial measurements are available over time may motivate constructing a scalar-valued QoI map using the WME functional for each spatial location.
If distinct observable quantities are available (e.g., perhaps with different physical units), then these may be collapsed into each component of the map.

The discussion of how to optimally construct such maps is beyond the scope of this work, and is highly problem specific, requiring nuances involving measurement sensitivities and combinatorial design-spaces.
However, we summarize that the extension of the equations presented in Section~\ref{sec:MUD_analysis} follows directly by constructing the resultant $1\times P$ matrices $A$ and scalar-valued $b$ for each component and then stacking them to form a $D\times P$ system, where we are motivated to minimize $P-D$.
The choice of how to form each of the (up to) $\dimP$ components will directly impact the precision of the parameter estimate.


\documentclass[twoside]{MATH77}
\usepackage{multicol}
\usepackage[fleqn,reqno,centertags]{amsmath}
\begin{document}
\begmath 9.2 Local Minimum of a Multivariate Function \hbox{with Linear Constraints}

\silentfootnote{$^\copyright$1997 Calif. Inst. of Technology, \thisyear \ Math \`a la Carte, Inc.}

\subsection{Purpose}

The subroutine DMLC01 finds a local minimum of a continuously differentiable
function $f$ of $n$ variables. Variables may be subject to bounds, and
linear equality and inequality constraints. The problem statement is%
\begin{gather}
\text{Minimize }f({\bf x}),\text{ subject to}\notag\\
\label{O1}A{\bf x} \leq {\bf b},\text{ and}\\
\label{O2}XL_j\leq x_j\leq XU_j,\quad j=1,...,n
\end{gather}
where $A$ is an $m\times n$ matrix, ${\bf b}$ is an $m$-vector, and ${\bf x}$ is
the $n $-vector to be determined. It can be specified that the first MEQ
rows of the system $A{\bf x} \leq  {\bf b}$ are to be equality constraints.
This subroutine is also applicable to an unconstrained problem as one can
set $m=0 $ and set the contents of XL() and XU() to have large magnitudes.

\subsection{Usage}

\subsubsection{Program Prototype, Double Precision}
\begin{description}
\item[INTEGER]  \ {\bf N, M, MEQ, LDA, IPRINT,\\ MXEVAL, LIW, LW, IW}(LIW)
\item[DOUBLE PRECISION]  {\bf A}(LDA,$\geq $N){\bf , B}($\geq $M){\bf ,\\
XL}($\geq $N){\bf, XU}($\geq $N){\bf , X}($\geq $N){\bf, ACC, W}(LW)
\item[EXTERNAL]  {\bf \ DMLCFG }
\end{description}
Assign values to N, M, MEQ, A(,), B(), XL(), XU(), X(), ACC, IPRINT, MXEVAL,
LIW, and LW.
\begin{center}
\fbox{\begin{tabular}{@{\bf }c}
CALL DMLC01 (DMLCFG, N, M, MEQ, A,\\
LDA, B, XL, XU, X, ACC, IPRINT,\\
MXEVAL, IW, LIW, W, LW)\\
\end{tabular}}
\end{center}
Results are returned in X(), IW(), and W().
\subsubsection{Argument Definitions}
\begin{description}
\item[DMLCFG]  \ [in] The name of a subroutine provided by the user to
compute the function value, $f({\bf x})$, and optionally the gradient
vector, ${\bf g}$, $g_j=\partial f/\partial x_j$, $j=1$, ..., N,
using the current ${\bf x}$-vector given in X(). It must have an interface
of the form:
{\tt \begin{tabbing}
SUBROUTINE DMLCFG(N, X, F, G, HAVEG)\\
INTEGER N\\
DOUBLE PRECISION X(N), F, G(N)\\
LOGICAL HAVEG
\end{tabbing}}
DMLCFG must store the function value in F.

DMLCFG may either compute the gradient vector or let the package compute an
estimate of the gradient vector by computing finite differences of function
values. Performance will generally be more reliable if DMLCFG computes the
gradient vector.

If DMLCFG computes the gradient vector it must store it in G(1:N) and set
HAVEG = .true. If DMLCFG does not compute the gradient it must set HAVEG =
.false. and must not store anything into G().

DMLCFG must not change the values of N or X().

In some applications DMLCFG may need additional data that may have been
input by the user's main program. One way to handle this in Fortran~77 is by
use of named COMMON blocks.

\item[N]  \ [in] Number of components in the vector ${\bf x}$. Require N $\geq
1.$

\item[M]  \ [in] Number of general linear constraints, $i.e.$, number of
rows in the matrix $A$ and components in the vector ${\bf b}$. Require
M $\geq 0.$

\item[MEQ]  \ [in] Specifies that rows~1 through MEQ of the system $A{\bf x} %
\leq {\bf b}$ are to be interpreted as equality constraints. Require $0\leq
\text{MEQ}\leq \text{M}.$

\item[A(,)]  \ [in] Array containing the M$\times $N matrix $A$. Even if M $=0$
the array A(,) must be declared and given positive dimensions. This is a
Fortran~77 language requirement.

\item[LDA]  \ [in] The leading dimension of the array A(,). Require LDA $\geq
\max (1,\text{M}).$

\item[B()]  \ [in] Array containing the M-vector {\bf b}. Even if M = 0 the
array B() must be declared and given a positive dimension. This is a Fortran
77 language requirement.

\item[XL(), XU()]  \ [in] Lower and upper bounds on the variables. See
Eq.\,(2) above. Require XL($j)\leq $ XU($j)$ for $j=1$,\ ...,\ N. To
leave a solution component effectively unconstrained, set its lower bound to
a negative number of large magnitude and its upper bound to a large positive
number. Do not set these bounds to such large magnitudes that computation of
the difference, XU($j)-$ XL($j)$, would overflow for some $j$. Setting XL($%
j)=$ XU($j)$ is permitted and has the effect of fixing $x_j$ at the value XL(%
$j).$

\item[X()]  \ [inout] The vector of variables of the optimization
calculation. On entry X() must contain an initial estimate of ${\bf x}$. The
subroutines can usually cope with a poor estimate, and the initial ${\bf x}$
is not required to satisfy Eqs.~(1) and (2). On return X() will contain the
subroutine's best estimate of the solution vector ${\bf x}$.

\item[ACC]  \ [in] A tolerance on the first order Kuhn-Tucker
conditions that the solution must satisfy. See Eq.\,(4),
page~\pageref{O4} and Remark~4 in Section~C.  Setting ACC $=0.0$ is
permitted and essentially means the user wants as much accuracy as
possible on the host computer. The termination will then usually be
with INFO $=2$, meaning Eq.\,(4) could not be satisfied.

\item[IPRINT]  \ [in] Contains five print control parameters, packed as
follows:
\begin{tabbing}
\hspace{.2in}\=IPRINT = IPFREQ $\times $ 100 + IPTOL $\times $ 8 +\\
\>\quad IPFRST $\times $ 4 + IPMORE $\times $ 2 + IPLAST
\end{tabbing}

Iteration counting only begins after a first feasible ${\bf x}$ is found. The
items to be printed are selected by IPMORE. The other parameters specify
when to print. If any of IPFREQ, IPTOL, IPFRST, or IPLAST are nonzero, there
will be an initial printing of N, M, MEQ, ACC, RELACC, and TOL.
\begin{description}
\item[\rm IPFREQ] is zero or positive. If positive, printing is done on
iterations 0, IPFREQ, 2*IPFREQ, etc.

\item[\rm IPTOL] = 0 or 1. 1 means to print the new TOL value and the standard items
each time TOL is changed. TOL is described in Section D.

\item[\rm IPFRST] = 0 or 1. 1 means to print on the first iteration, $i.e$. on
iteration number~0.

\item[\rm IPMORE] = 0 or 1. Items always printed are
\begin{description}
\item[\rm ITERC ---]  The iteration count.

\item[\rm NFVALS ---]  The count of function evaluations, which is tested
against MXEVAL.

\item[\rm F ---]  The current value of $f({\bf x}).$

\item[\rm TOL ---]  See Section D.

\item[\rm $\|\rho \|$ ---]  The Euclidean norm of RESKT(1:N).  This is the
quantity that will be compared with ACC for the main convergence test. See
Section D.

\item[\rm X(1:N) ---]  The current value of ${\bf x}$.
\end{description}

When IPMORE = 1 the package also prints G(1:N), RESKT(1:N), IACT(1:NACT),
and PAR(1:NACT). These quantities are described in Section D.

\item[\rm IPLAST] = 0 or 1. 1 means to print the final results, and the
reason for termination.
\end{description}

\item[MXEVAL]  \ [in] If positive, this sets an upper limit on the number of
function evaluations. Gradient evaluations and function evaluations for
estimating the gradient are not counted. If MXEVAL = 0, there is no upper
limit.

\item[IW()]  \ [work, out] Integer work space of length LIW. Also used to
return status information. On return IW() contains information as follows:

\begin{description}
\item[IW(1)]  contains INFO. Indicates reason for termination as follows:

\begin{itemize}
\item[1]  means successful termination. X() is feasible and the
convergence test involving ACC is satisfied.

\item[2]  means X() is feasible and satisfaction of the ACC test
seems to be prevented by the precision of arithmetic being used. This mode
of termination will commonly occur if the user sets ACC = 0.

\item[3]  means X() is feasible but the objective function fails to
decrease, although a decrease is predicted by the current gradient vector.
This may be due to limitation of computational precision as with INFO = 2,
however, if the final RESKT() has components of large magnitude and the user
has provided code to compute the gradient vector, this could be due to an
error in the gradient code. One should also question the coding of the
gradient when the final rate of convergence is slow.

\item[4]  means bad input values. See requirements on N, M, MEQ,
XL(), XU(), LIW, and LW. No solution is computed in this case.

\item[5]  means the equality constraints are inconsistent. These
constraints include any components of ${\bf x}$ that are frozen by setting XL($%
j)=$ XU($j).$

\item[6]  means the equality constraints and the bounds on the
variables are inconsistent.

\item[7]  means there is no ${\bf x}$ satisfying all of the
constraints. Specifically, when this return or an INFO = 6 return occurs,
the current active constraints indexed in IACT(1:NACT) prevent any change in
X() that reduces the sum of constraint violations.

\item[8]  means the limit set by MXEVAL has been reached, and there
would have been further calculation otherwise.

\item[9]  means the solution is uniquely determined by the
constraints, so there is no further freedom for minimization of $f({\bf x})$. In
this case the results returned in W() will include $f$ evaluated at the
solution, but will not include PAR() and RESKT(), and will include G() only
if DMLCFG computes G().
\end{itemize}

\item[IW(2)]  contains ITERC. Number of iterations used.

\item[IW(3)]  contains NFVALS. Number of function evaluations, not counting
extra function evaluations done to estimate the gradient when the gradient
is not computed explicitly. In this latter case the actual number of
function evaluations will be ($\text{K}+1)\times \text{NFVALS}$, where K is the number
of solution components whose lower and upper bounds are not equal.

\item[IW(4)]  contains NACT. The number of active constraints at the final
${\bf x}$. Will be in the interval [MEQ, N].

\item[IW(5:4+NACT)]  contains IACT(1:NACT).\newline
IACT() is used as work space of length $\text{M} +2\times $ N. On return
the first NACT locations contain the
indices of the constraints that are active at the final point. Indices [1:M]
refer to rows of the system $A{\bf x} \leq  {\bf b}$. Indices [M+1:M+N]
refer to component lower bounds. Indices [M+N+1:M+2$\times $N] refer to
component upper bounds.
\end{description}

\item[LIW]  \ [in] Dimension of IW(). Require\newline
\rule{.4in}{0pt} LIW $\geq  4 + \text{M} + 2 \times \text{N}$.

\item[W()]  \ [work, out] Working space of floating point variables of
length LW. Also used to return auxiliary results. On return W() contains
information as follows:
\begin{description}
\item[W(1)] contains FVAL, the final value of the objective function, $f.$

\item[W(2)] contains the Euclidean norm of the Kuhn-Tucker residual vector, $i.e$. $%
\Vert \rho \Vert $ as described in Section D.

\item[W(3:2+N)] contains the final gradient vector, G(1:N).

\item[W(3+N:2+2$\times $N)] contains the Kuhn-Tucker residual vector, RESKT(1:N).

\item[W(3+2$\times $N:2+2$\times $N+NACT)] contains the Lagrange multipliers,
PAR(1:NACT) where NACT has a value in [MEQ, N].
\end{description}
G(), RESKT(), and PAR() are described in Section D.

\item[LW]  \ [in] Dimension of W(). Require\newline
\rule{.4in}{0pt} LW $\geq $ 3 + M + N $\times $ (16 + N).
\end{description}

\subsubsection{Modifications for Single Precision}

For single precision usage change all subroutine names beginning with D,
except D1MACH, to begin with S. Change the name D1MACH to R1MACH. Change all
DOUBLE PRECISION type statements to REAL.

We suggest that the double precision version of this package be used,
except on machines such as the Cray J90, where single precision arithmetic
has precision of about~14.4 decimal places.

\subsection{Examples and Remarks}

{\bf Example}: Minimize ${\displaystyle f({\bf x})=\sum_{k=1}^4x_j\ln x_j.}$

Let us bound each variable in [0,1] and require the sum of variables to be
1. With just these constraints a unique minimum would occur when $x_j=0.25$,
for all $j$. We shall add two more constraints to break up the symmetry:%
\vspace{-4pt}%
\begin{align*}
x_1-x_2&=0.25\vspace{-4pt}\\
x_2-x_3&\geq 0.10
\end{align*}
Since inequality constraints must be expressed in less than or equal form,
we rewrite this last constraint as%
\begin{equation*}
-x_2+x_3\leq -0.10
\end{equation*}
In matrix form the three general linear constraints are%
\begin{equation*}
\left[
\begin{array}{rrrr}
1 & 1 & 1 & 1 \\
1 & -1 & 0 & 0 \\
0 & -1 & 1 & 0
\end{array}
\right] \ {\bf x}\leq \left[
\begin{array}{r}
1.00 \\
0.25 \\
-0.10
\end{array}
\right]
\end{equation*}
and we will specify that the first two rows are to be treated as equality
constraints by setting MEQ $=2.$

The program DRDMLC01 illustrates the use of DMLC01 to solve this problem,
and also uses DCKDER to check the consistency of the function and gradient
calculations. The output is shown in ODDMLC01. We have set ACC $= 0.0$,
meaning we want as much accuracy as the host computer can provide. Note that
the termination code is~2 indicating that the requested accuracy of~0.0
could not be attained. This is the usual termination code when the user has
set ACC $= 0.$

We have set the lower bounds in XL() to~1.0D-6 rather than zero to avoid the
possibility of the package requesting a function evaluation with some $x_j =
0$, since attempting to compute LOG(0.0D0) would cause an error stop.
Alternatively this issue could be handled with appropriate logic in the
function evaluation subroutine and XL() could be set to zero.

As print options we have selected printing only at the end (IPLAST = 1), and
the more extensive number of printed items (IPMORE = 1). This is indicated
by setting IPRINT $= 2 \times \text{IPMORE} + \text{IPLAST} = 3.$ Setting
MXEVAL = 0 means we are not setting any limit on the number of function
evaluations.

To illustrate the contents of IW() and W() on return we have printed the
results from these arrays.

\subparagraph{Remarks}

1. It is important to the success of DMLC01 that the initial guess be as
good as possible.

2. DMLC01 only finds a local minimum. Problems may have more than one local
minimum, so caution in accepting results is suggested. It may be useful to
solve the problem several times using significantly different starting
points.

3. Minimization of a nonlinear function is inherently difficult in many
cases, and sometimes may require some interaction with the user. The
intermediate output available from the subroutine may be useful if one has
questions about the performance of the subroutine. It is not uncommon to
make mistakes in writing the code for computing partial derivatives. This
mistake is likely to cause a return with IW($1) = 3$. The user can use the
subroutine DCKDER of Chapter~8.3 to check the consistency of code for
function and gradient evaluation.

4. It is reasonable to set ACC $=0.0$ the first time this subroutine is
applied to a new mathematical model. If one intends to solve more problems
of similar form and wishes to reduce the number of iterations, one could
turn on the intermediate output and try to determine a nonzero value of ACC
that gives a result of adequate accuracy in fewer iterations. From Eq.\,(3)
one sees that an appropriate nonzero value of ACC depends on the norms
of ${\bf g}$ and of the row vectors of $A$, and the constraints active at
the solution. If ${\bf g}$ is computed by finite-differences the magnitude
of $f$ must be considered also.

\subsection{Functional Description}

The algorithm provides for the bounds on the variables to be specified and
treated separately from the general linear constraints because this is
convenient for the user and allows for efficiencies in storage and execution
time. However, for analysis of the problem it is more convenient to treat
the bounds as additional general linear constraints. Thus the full set of
constraints can be expressed as%
\begin{equation*}
\left[
\begin{array}{r}
A \\
-I \\
I
\end{array}
\right] {\bf x\leq }\left[
\begin{array}{r}
{\bf b} \\ -XL \\
XU
\end{array}
\right]
\end{equation*}
with the first MEQ rows to be treated as equality constraints. Here I
denotes the N $\times $ N identity matrix, $XL$ denotes the N-vector of lower
bounds, and $XU$ denotes the N-vector of upper bounds.

Let $C$ denote the left-side matrix and {\bf d} the right-side vector in the
above expression. Thus the constraints can be written simply as $C{\bf x} %
\leq  {\bf d}$, where $C$ and ${\bf d}$ each have M + 2N rows. Let ${\bf c}_i$
denote the column vector which is the transpose of row $i$ of $C$.

If $XL_j = XU_j$ for some $j$, then row $\text{M}+j$ of $C{\bf x}
\leq {\bf d}$ will be treated as an equality constraint and row $\text{M}+
\text{N}+j$ will be ignored (not changing the indexing of
other rows).  A set {${\cal C}$} of linearly independent equality
constraints is identified. This will generally consist of the
constraints due to equality of lower and upper bounds, plus the first
MEQ rows. However, it may consist of a proper subset of these if this
set is not linearly independent. An internal variable, MEQL, is set
to the number of these constraints and their indices are stored in
IACT(1:MEQL). After setting MEQL and the contents of IACT(1:MEQL)
these will remain unchanged throughout the rest of the algorithm.

A vector ${\bf x}$ is feasible if it satisfies $C{\bf x} \leq  {\bf d}$, and
in addition achieves equality for the rows in the set {${\cal C}$}. With any
feasible ${\bf x}$ the algorithm considers, it associates a list of indices of
at most N of the rows of $C{\bf x} \leq  {\bf d}$ that are satisfied with
equality. These rows are called the active constraints (for ${\bf x}$) and the
indices are denoted by IACT$(k)$, $k = 1$, ..., NACT, where NACT depends on
${\bf x}$, but will satisfy MEQL $\leq $ NACT $\leq $ N.

The first-order Kuhn-Tucker necessary conditions for a solution ${\bf x}$ are
that ${\bf x}$ must be feasible and that the gradient, ${\bf g}$, of $f$ at ${\bf x}$
must be a linear combination of vectors ${\bf c}_i$ in the active set for ${\bf x}$,
with combining coefficients (called Lagrange coefficients) that are of
unrestricted sign for constraints in set {${\cal C}$}, and are nonpositive
for constraints not in set {${\cal C}$}. Thus define the {\em Kuhn-Tucker
residual vector}
\begin{equation}
\hspace{-15pt}\label{O3}{\bf \rho} ={\bf g}-\sum_{k=1}^{NACT}\lambda _k
{\bf c}_{IACT(k)},\ \ \text{with }\lambda _k\leq 0\text{ for } k>\text{MEQL}
\end{equation}
Then the Kuhn-Tucker condition on a vector ${\bf x}$ can be stated as the
requirement that there exist $\lambda _k$'s such that ${\bf \rho }$ is a
zero vector. The convergence test used in the package is
\begin{equation}
\label{O4}\Vert {\bf \rho} \Vert \leq \text{ACC}
\end{equation}
where $\Vert \cdot \Vert $ denotes the Euclidean vector norm.

Internally the package stores ${\bf g}$ in G(), ${\bf \rho }$ in RESKT(), and
the $\lambda_k$'s in PAR(). These can be printed using the IPRINT argument
and are returned in the W() array.

The package also uses internal tolerance parameters, RELACC and TOL. RELACC
is set to about 100~times the machine precision. TOL is initially set to
0.01, and is reduced as the algorithm progresses until it reaches the value
RELACC. TOL is used as a relative tolerance in checking the satisfaction of
constraints. The technique of starting with TOL fairly large and later
reducing it is a unique design feature of this algorithm. It has the effect
of avoiding many small changes to ${\bf x}$ in the early stages of the
algorithm.

The algorithm is described in detail by the author in
\cite{Powell:1989:TOL} and \cite{Powell:ATA:1988}.  He characterizes the
algorithm as an active set method as described in \cite{Gill:1987:PO},
using BFGS updating of second derivative approximations as described in
\cite{Powell:UCD:1987} and the matrix factorizations of
\cite{Goldfarb:1983:ANS}.  Examples from \cite{Hock:1981:TEN} were used by
the author in testing the package.

\bibliography{math77}
\bibliographystyle{math77}

\subsection{Error Procedures and Restrictions}

On all returns, successful or not, the reason for the return is indicated by
INFO, stored in IW(1). See the specification of IW(1) in Section B for the
interpretation of these values. On returns with IW(1) from~3 to~8 an error
message will be printed using the error message printing subroutines of
Chapter~19.2 with an error level of 0.

\subsection{Supporting Information}

The source language is ANSI Fortran~77.

\begin{tabular}{@{\bf}l@{\hspace{5pt}}l}
\bf Entry & \hspace{.35in} {\bf Required Files}\vspace{2pt} \\
DMLC01 & \parbox[t]{2.7in}{\hyphenpenalty10000 \raggedright
 AMACH, DERV1, DMLC, ERFIN, ERMOR, ERMSG, IERM1, IERV1\rule[-5pt]{0pt}{8pt}}\\
SMLC01 & \parbox[t]{2.7in}{\hyphenpenalty10000 \raggedright
 AMACH, ERFIN, ERMOR, ERMSG, IERM1, IERV1, SERV1, SMLC}\\
\end{tabular}

Cvonerted from Powell's code cited above by C. L. Lawson, April, 1990 (with
minor contribution from F. T. Krogh).

\begcode

\medskip\
\lstset{language=[77]Fortran,showstringspaces=false}
\lstset{xleftmargin=.8in}

\centerline{\bf \large DRDMLC01}\vspace{10pt}
\lstinputlisting{\codeloc{dmlc01}}
\newpage
\vspace{30pt}\centerline{\bf \large ODDMLC01}\vspace{10pt}
\lstset{language={}}
\lstinputlisting{\outputloc{dmlc01}}
\end{document}


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

\usepackage{amsmath, tikz, bm, tkz-euclide,pgfplots}
\pgfplotsset{compat = 1.16}
\usetkzobj{all}

\title{Complex Numbers}
\author{}
\date{}

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

\begin{document}

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

\section{Write square roots of negative numbers as imaginary numbers}

\begin{frame}{Background}
Imaginary numbers arose from trying to solve equations such as
\[x^2 = -1\] \pause

If we take the square root of both sides, we get
\[ x = \sqrt{-1} \]	\pause

We define the imaginary unit $i$ to be that value:
\[ i = \sqrt{-1} \]
\end{frame}

\begin{frame}{Writing Square Roots of Negative Numbers}
When writing square roots of negative values as imaginary numbers, we can factor out \[\sqrt{-1}\] from the expression \newline\\

{\color{blue}\textbf{as long as what remains is the square root of a positive number.}}
\begin{align*}
\onslide<2->{\sqrt{-25} &= \sqrt{-1} \cdot \sqrt{25} }\\[6pt]
\onslide<3->{&= i \cdot 5} \\[6pt]	\pause
\onslide<4->{&= 5i}
\end{align*}
\end{frame}

\begin{frame}{Example 1}
Write each as an imaginary number.	\newline\\
(a) \quad $\sqrt{-36}$
\begin{align*}
\onslide<2->{\sqrt{-36} &= \sqrt{-1} \cdot \sqrt{36}} \\[6pt]
\onslide<3->{&= i \cdot 6} \\[6pt]
\onslide<4->{&= 6i}
\end{align*}
\end{frame}

\begin{frame}{Example 1}
(b) \quad $\sqrt{-100}$
\begin{align*}
\onslide<2->{\sqrt{-100} &= \sqrt{-1} \cdot \sqrt{100}} \\[6pt]
\onslide<3->{&= i \cdot 10} \\[6pt]
\onslide<4->{&= 10i}
\end{align*}
\end{frame}

\begin{frame}{Example 1}
(c) \quad $\sqrt{-8}$
\begin{align*}
\onslide<2->{\sqrt{-8} &= \sqrt{-1} \cdot \sqrt{8}} \\[6pt]
\onslide<3->{&= i \cdot 2\sqrt{2}} \\[6pt]
\onslide<4->{&= 2i\sqrt{2}}
\end{align*}
\end{frame}

\section{Add and subtract complex numbers}

\begin{frame}{Complex Numbers}
A \alert{complex number} is a number written in the form
\[ a + bi \]
where $a$ (the \alert{real part}) and $b$ (the \alert{imaginary part}) are real numbers.
\end{frame}

\begin{frame}{Adding and Subtracting Complex Numbers}
Complex numbers can be added and subtracted much like combining like terms in Algebra 1.	\newline\\	\pause

The real parts are added (or subtracted) together, as are the imaginary parts.	\newline\\	\pause

Answers are then typically written in $a + bi$ form.
\end{frame}

\begin{frame}{Example 2}
Simplify each. \newline\\
(a) \quad $(3 + 2i) + (-1 + 8i)$
\begin{align*}
\onslide<2->{(3+2i)+(-1+8i)&= (3+(-1))+(2i+8i)} \\[6pt]
\onslide<3->{&= 2 + 10i}
\end{align*}
\end{frame}

\begin{frame}{Example 2}
(b) \quad $(-5-i) + (2+4i)$
\begin{align*}
\onslide<2->{(-5-i) + (2+4i)&= (-5+2)+(-i+4i)} \\[6pt]
\onslide<3->{&= -3+3i}
\end{align*}
\end{frame}

\begin{frame}{Example 2}
(c) \quad $(7-9i) - (3+5i)$
\begin{align*}
\onslide<2->{(7-9i) - (3+5i)&= 7-9i-3-5i} \\[6pt]
\onslide<3->{&= 4-14i}
\end{align*}
\end{frame}

\begin{frame}{Example 2}
(d) \quad $(-1+2i) - (-8+10i)$
\begin{align*}
\onslide<2->{(-1+2i) - (-8+10i)&= -1+2i+8-10i} \\[6pt]
\onslide<3->{&= 7-8i}
\end{align*}
\end{frame}

\section{Multiply complex numbers}

\begin{frame}{Multiplying Complex Numbers}
Complex numbers can be multiplied in the same manner that binomials are multiplied in Algebra 1, such as $(x+3)(x-8)$.	\newline\\	\pause

However, since $i = \sqrt{-1}$, if we \alert{square both sides} we get
\[ i^2 = -1 \]	\pause

So when multiplying complex numbers, you will substitute a $-1$ whenever you see an $i^2$.
\end{frame}

\begin{frame}{Example 3}
Multiply each.	\newline\\
(a) \quad $(2+3i)(5+6i)$	\newline\\
\onslide<2->{
\begin{center}
\begin{tikzpicture}
\draw[black] (0,0) grid (2,2);
\node at (0,1.5) [left] {$2$};
\node at (0,0.5) [left] {$3i$};
\node at (0.5,2) [above] {$5$};
\node at (1.5,2) [above] {$6i$};
\onslide<3->{\node at (0.5,1.5) {$10$};}
\onslide<4->{\node at (1.5,1.5) {$12i$};}
\onslide<5->{\node at (0.5,0.5) {$15i$};}
\onslide<6->{\node at (1.5,0.5) {$18i^2$};}
\onslide<7->{\node[fill=white, scale=2.5] at (1.5,0.5) {};}
\onslide<8->{\node at (1.5,0.5) {$-18$};}
\end{tikzpicture}
\end{center}
}
\onslide<9->{\[-8 + 27i\]}
\end{frame}

\begin{frame}{Example 3}
(b) \quad $(-1+i)(4-3i)$	\newline\\
\onslide<2->{
\begin{center}
\begin{tikzpicture}
\draw[black] (0,0) grid (2,2);
\node at (0,1.5) [left] {$-1$};
\node at (0,0.5) [left] {$1i$};
\node at (0.5,2) [above] {$4$};
\node at (1.5,2) [above] {$-3i$};
\onslide<3->{\node at (0.5,1.5) {$-4$};}
\onslide<4->{\node at (1.5,1.5) {$3i$};}
\onslide<5->{\node at (0.5,0.5) {$4i$};}
\onslide<6->{\node at (1.5,0.5) {$-3i^2$};}
\onslide<7->{\node[fill=white, scale=3] at (1.5,0.5) {};}
\onslide<8->{\node at (1.5,0.5) {$3$};}
\end{tikzpicture}
\end{center}
}
\onslide<9->{\[-1 + 7i\]}
\end{frame}

\begin{frame}{Example 3}
(c) \quad $(7-7i)(7+7i)$	\newline\\
\onslide<2->{
\begin{center}
\begin{tikzpicture}
\draw[black] (0,0) grid (2,2);
\node at (0,1.5) [left] {$7$};
\node at (0,0.5) [left] {$-7i$};
\node at (0.5,2) [above] {$7$};
\node at (1.5,2) [above] {$7i$};
\onslide<3->{\node at (0.5,1.5) {$49$};}
\onslide<4->{\node at (1.5,1.5) {$49i$};}
\onslide<5->{\node at (0.5,0.5) {$-49i$};}
\onslide<6->{\node at (1.5,0.5) {$-49i^2$};}
\onslide<7->{\node[fill=white, scale=3.55] at (1.5,0.5) {};}
\onslide<8->{\node at (1.5,0.5) {$49$};}
\end{tikzpicture}
\end{center}
}
\onslide<9->{\[98\]}
\end{frame}

\section{Divide complex numbers}

\begin{frame}{Dividing Complex Numbers}
Dividing complex numbers presents a bit of a challenge. \newline\\	\pause

The reason is that the denominator will have a square root, which is a big no-no in math:	\pause

\[\frac{3-i}{2+i} = \frac{3-\sqrt{-1}}{2+\sqrt{-1}} \]	\pause

To remedy this, we need to find the \alert{conjugate} of the {\color{blue}\textbf{denominator}}.
\end{frame}

\begin{frame}{Complex Conjugates}
The \alert{conjugate} of a complex number
\[ a + bi \]
is
\[a - bi \]
and vice versa
\end{frame}

\begin{frame}{Conjugate Examples}
\begin{center}
\begin{tabular}{cc}
\textbf{Number} & \textbf{Conjugate} \\ \hline
\onslide<2->{$7+2i$} & \onslide<3->{$7-2i$} \\[6pt]
\onslide<4->{$-3+i$} & \onslide<5->{$-3-i$} \\[6pt]
\onslide<6->{$5-4i$} & \onslide<7->{$5+4i$} \\[6pt]
\end{tabular}	\newline\\
\end{center}
\onslide<8->{When you multiply complex conjugates, you will always get a real number, like in Example 3c.}	\newline\\
\onslide<9->{So, to divide complex numbers, multiply both numerator and denominator by the {\color{blue}\textbf{conjugate of the denominator}}.}
\end{frame}

\begin{frame}{Example 4}
Divide $\dfrac{3-i}{2+i}$. Write your answer in $a+bi$ form.	\newline\\
\onslide<2->{The conjugate of $2+i$ is $2-i$}
\begin{align*}
\onslide<3->{\frac{3-i}{2+i}}\onslide<4->{\left(\frac{2-i}{2-i}\right)&} \\[10pt]
\onslide<5->{&=\frac{5-5i}{5}} \\[10pt]
\onslide<6->{&=1-i}
\end{align*}
\end{frame}

\end{document}