\documentclass{article}

\usepackage{geometry}
\geometry{
	a4paper,
	total={170mm,257mm},
	left=20mm,
	top=20mm,
}

\usepackage[utf8]{inputenc} % allow utf-8 input
\usepackage[T1]{fontenc}    % use 8-bit T1 fonts
\usepackage[hidelinks]{hyperref}       % hyperlinks
\usepackage{url}            % simple URL typesetting
\usepackage{tikz}
\usepackage{dsfont}
\usepackage{amsmath}
\usepackage{array}
\usepackage{float}
\usepackage{rotating}
\bibliographystyle{vancouver}

\title{Supplementary appendix to: \\ {\Large Adjusted age-specific mortality associated with COVID-19: a modelling study}}

\begin{document}

	\maketitle

	\section{Introduction}

	We developed an approach aimed at estimating the true mortality associated with COVID-19.
	With regards to a specific epidemic, the model relies upon data on cases by date of disease onset, mortality by date of death, and the age distribution of both cases and deaths.
	In a first step, we use an age-stratified susceptible-exposed-infected-removed (SEIR) compartmental model to describe the dynamics of transmission of the virus in the population of Hubei, including the decrease in incidence after the introduction of control measures on 20 January.
	In a second step, we estimate the mortality of infected individuals with regards to the probability of dying upon infection and the delay between symptom onset and death.
	We fit the model to data on the time dynamics and the age distribution of both reported cases and deaths.
	We implemented the model in a Bayesian framework using Stan.
	All code and data are available from \underline{\smash{\url{https://github.com/jriou/covid_adjusted_cfr/}}}.
	We applied this approach to COVID-19 epidemics in three different settings where appropriate data is available: Hubei, China, Northern Italy and South Korea.

	\section{Data}

	\subsection{General data}

	Some data and parameter values are not specific to the area considered.
	The mean incubation period was fixed to 5.9 days, following a study of cases and their contacts in Shenzhen, China \cite{Bi2020}.
	The mean time from disease onset to isolation was fixed to 2.4 days, following the same Shenzhen study \cite{Bi2020}.
	Other works have reported very similar values for both periods \cite{lauerincubation,linton2020incubation,backer2020incubation}.
	These values were transformed into rates and used in the system of ordinary differential equations (see below).
	As such, this results in exponential distributions of incubation times and time from disease onset to isolation, which is acceptable considering our aims.

	Conversely, one of the main objectives of this work was to account for bias due to the delay between disease onset and death.
	For the time from disease onset to death, we used a log-normal distribution with mean 20.2 and standard deviation 11.6 estimated from patient data and accounting from right-censoring \cite{linton2020incubation}.
	This continuous probability distribution was discretized by day in order to be used in the model (Figure \ref{fig:distribution_onset_to_death}).

	\begin{figure}[H]
		\centering
		\includegraphics{../format_output/figures/distribution_onset_to_death.pdf}
		\caption{Probability density function of the time from disease onset to death (red) and corresponding discretization by day between 1 and 60 days (columns).}
		\label{fig:distribution_onset_to_death}
	\end{figure}

	\subsection{Hubei, China}
	We model the dynamics of the COVID-19 epidemic in Hubei from January 1st to February 11th, 2020, considering the introduction of strong control measures from January 20th \cite{ChinaJointMissiononCoronavirusDisease2019Group2020}.
	Our analysis was based on a report published by the Chinese CDC describing all chinese COVID-19 cases reported up to February 11th, 2020 \cite{Team2020}.
	From this report, we extracted the number of confirmed cases of COVID-19 by day of disease onset (Figure )

	\begin{figure}[b]
		\centering
		\includegraphics{../format_output/figures/china_case_incidence.pdf}
		\caption{Probability density function of the time from disease onset to death (red) and corresponding discretization by day between 1 and 60 days (columns).}
		\label{fig:china_case_incidence.pdf}
	\end{figure}

	 publication of the Chinese CDC,

	\subsection{Northern Italy}

	\subsection{South Korea}

	\begin{table}[h]
		\centering
		\caption{Summary of data sources and fixed parameters.}
		\begin{tabular}{cp{7cm}lll}
			\hline
			Symbol & Comment & Value & Unit & Source \\
			\hline
			$\mathds{A}$ & Confirmed cases of COVID-19 in Hubei from 1 January to 11 February 2020  & see Fig \ref{fig:data}A & - & \cite{Team2020} \\
			$\mathds{B}$ & Age distribution of all confirmed cases in China up to 11 February 2020 (85\% of these are in Hubei, we assume the age distribution is the same in overall China) & see Fig \ref{fig:data}C & - & \cite{Team2020} \\
			$\mathds{C}$ & Deaths among patients with confirmed COVID-19 infection by day of report in China from 1 January to 11 February 2020 (95\% of these are in Hubei, so the numbers were scaled down by 5\%) & see Fig \ref{fig:data}A & - & \cite{Team2020} \\
			$\mathds{D}$ & Age distribution of the deaths among patients with confirmed COVID-19 infection that occurred in China up to 11 February 2020 (we assume the age distribution is the same in overall China) & see Fig \ref{fig:data}C & - & \cite{Team2020} \\
			$\mathds{E}$ & Age distribution of the population in China & see Fig \ref{fig:data}C & - & \cite{Worldometers.info} \\
			$\mathds{F}$ & $9\times 9$ matrix with contacts between each age class in Shanghai &  see Fig\ref{fig:data}D & per day & \cite{Zhang2019} \\
			$\mathds{G}$ & Distribution of time from disease onset to death & $\text{log-}\mathcal{N}(20.2,11.6)$ & days & \cite{Linton2020a} \\
			$1/\tau$ & Incubation period & 5.9 & days &  \cite{Bi2020} \\
%			$\psi$ & Proportion of symptomatics & $\text{Beta}(71,18)$ & - & \cite{Bi2020} \\
			$1/\mu$ & Time from disease onset to isolation & 2.4 & days & \cite{Bi2020} \\
			\hline
		\end{tabular}
	\end{table}

	\begin{figure}[H]
		\centering
		\includegraphics[width=.9\linewidth]{../figures/fig_desc.pdf}
		\caption{Data used to fit the model. (A) Reported confirmed cases of COVID-19 in Hubei by date of disease onset (blue) and reported deaths (red) from 8 December, 2019 until 11 February, 2020 (time point b). Strict control measures were implemented at time point a (23 January). (B) Age distribution of the Chinese population compared to that of confirmed cases of and deaths due to COVID-19. (C) Proportion of individuals infected by COVID-19 showing symptoms among passengers of the Diamond Princess ship (with 95\% credible interval).}
		\label{fig:data}
	\end{figure}

	\newpage

	\section{Model}

	\subsection{Transmission model structure}

	We use an age-stratified susceptible-exposed-infected-removed (SEIR) compartmental model using ordinary differential equations (ODEs), with a distinction between asymptomatic and symptomatic infections.
	We stratify the population in nine ten-year age groups ($0-9, 10-19, \ldots, 70-79, 80+$).
	The population of each age group $k$ is divided into five compartments: susceptible ($S_k$), incubating or exposed ($E_k$), infected with symptoms ($I_k$), infected and asymptomatic ($A_k$), and removed ($R_k$).
	Note that the number of individuals in each compartment is scaled by the total population of the Hubei province (59,020,000), so that the sum of all compartments is 1.
	Susceptible individuals may become infected through contact with infected individuals with symptoms (assuming that both incubating and asymptomatic individuals are not infectious) from any other age group.
	The force of infection $\lambda_k$ depends on the added number of infectious individuals in each age class, weighted by a contact matrix $\mathds{F}$ and the proportion of infection upon contact with an infectious individual $\beta$.

	In addition, we include a time-dependent forcing function to account for the reduction in transmissibility following the introduction of control measures in Hubei on 20 January 2020.
	We use the following logistic function:
	\begin{equation}
	f(t,\eta,\nu, \xi) = \eta + \frac{1-\eta}{1+\exp(\xi *(t-t_1-\nu))}
	\end{equation}
	where $\eta$ is the relative reduction in transmission after control measures are fully implemented, $\xi$ is the slope of the logistic function modelling the implementation of the control measures, and $\nu$ is the delay (in days after 23 January 2020) until the control measures are 50\% effective.

	The force of infection $\lambda_k$ can then be expressed as:
	\begin{equation}
	\lambda_k(t) = f(t,\eta,\nu, \xi) \beta S_k(t) \sum_{l=1}^9  \dfrac{I_l(t)}{\mathds{E}_l}  \mathds{F}_{k,l}
	\end{equation}

	\begin{figure}[H]
		\centering
		\includegraphics[width=.7\linewidth]{../figures/fig_ode.pdf}
		\caption{Schematic description of the COVID-19 transmission model.}
		\label{fig:ode}
	\end{figure}

	After the incubation period $1/\tau$, a proportion $\psi$ of infected people develop symptoms and become infectious while the remaining remain asymptomatic and do not transmit the disease further.
	After a period $1/\mu$, individuals with symptoms are identified and isolated, and thus removed from being infectious.
	The infection dynamics are thus controlled by 4 parameters: $\{\beta,\tau, \psi, \mu \}$

	\subsection{Initial conditions and simulation settings}

	The simulation start ($t=0$) is set on 30 December 2019, just before the closure of the market in Wuhan, after which all infections can be assumed to come from human-to-human transmission.
	At this date, most individuals are assumed to be susceptible and are distributed across age groups according to the  population age distribution in China $\mathds{E}$.
	The number of people in the exposed compartment at $t=0$ is controlled by a parameter $\pi$, and also distributed according to $\mathds{E}$.
	Other compartments are set to 0.

	\subsection{Dummy compartments and outputs}

	In addition to the five compartments per age group, we add two dummy compartments to record the cumulative incidence of new symptomatic infections by day of disease onset, $C_k$:
	\begin{equation}
	\frac{dC^I_k}{dt} = \tau \psi E_k
	\end{equation}
	and the cumulative incidence of new asymptomatic infections, $D_k$:
	\begin{equation}
	\frac{dC^A_k}{dt} = (1-\tau) \psi E_k
	\end{equation}

	Outputs from the ODE model include:

	%\begin{table}[h]
	%	\centering
	%	\caption{Summary of data sources.}
	%	\begin{tabular}{cp{9cm}ll}
	%		\hline
	%		Symbol & Definition & Formula\\
	%		\hline
	%		$D_{k,t}$ & number of new infections per day in each age group & $D_{k,t} =  C^I_k(t) - C^I_k(t-1)$\\
	%	$E_t $ & 	total number of new reported infections per day, according to an age-specific reporting rate $\rho_k$ & $E_t = \sum_k^9 \rho_k D_{k,t}$\\
	%		\hline
	%	\end{tabular}
	%
	%\end{table}

	\begin{itemize}
		\item the total number of new infections per day in each age group:
		\begin{equation}
		D_{k,t} =  C^I_k(t) - C^I_k(t-1)
		\end{equation}
		\item  the total number of new reported infections per day, summed over age groups, according to an age-specific reporting rate $\rho_k$:
		\begin{equation}
		E_t = \sum_k^9 \rho_k D_{k,t}
		\end{equation}
		\item the age distribution of all reported cases between simulation start and 11 February 2020 ($t=43$):
		\begin{equation}
		F_k =  \frac{\rho_kC^I_k(43)}{\sum_k^9 \rho_k C^I_k(43)}
		\end{equation}
		\item the total number of infections with symptoms:
		\begin{equation}
		G = \sum_k^9 C^I_k(43)
		\end{equation}
		\item the total number of infections with or without symptoms:
		\begin{equation}
		H = \sum_k^9 C^I_k(43) + C^A_k(43)
		\end{equation}
	\end{itemize}
	To allow identifiability of the parameters, the reporting rate of the highest age group $\rho_9$ is fixed to 1.
	This assumes that all individuals aged 80 and more that are infected with symptoms seek medical care, are identified and reported to the authorities.

	\subsection{Delayed mortality}

	Mortality is considered outside of the system of ODEs, using an age-specific mortality $\epsilon_k$.
	In accordance to data, we only consider the mortality among cases with a date of disease onset up to 11 February 2020.
	We consider all infected individuals with symptoms by date of disease onset, and include the discrete distribution of time from disease onset to death $\mathds{G}$. The following outputs are computed at this point:
	\begin{itemize}
		\item the daily number of deaths in age group $k$ for each day between simulation start and 60 days after 11 February 2020 ($t=103$), to account for the delay between disease onset and deaths:
		\begin{equation}
		M_{k,t}= \epsilon_k\sum_d^{60}  D_{k,t-d} \mathds{G}_d
		\end{equation}
		\item the daily number of deaths summed over age groups, assuming that all deaths are identified:
		\begin{equation}
		N_{t}= \sum_k^9 M_{k,t}
		\end{equation}
		\item the age distribution of all deaths occurring up to $t=43$:
		\begin{equation}
		O_k = \frac{\sum_t^{43} M_{k,t}}{\sum_k^9 \sum_t^{43} M_{k,t}}
		\end{equation}
		\item the total number of deaths occurring up to 11 February 2020:
		\begin{equation}
		P = \sum_k^9 \sum_t^{43} M_{k,t}
		\end{equation}
		\item the total number of deaths occurring among cases with disease onset up to 11 February 2020 ($t=43$), which can occur up to 60 days after 11 February 2020 ($t=103$):
		\begin{equation}
		Q = \sum_k^9 \sum_t^{103} M_{k,t}
		\end{equation}
	\end{itemize}

	\subsection{Inference}

	The objective of this step is to estimate the following parameters: $\theta=\{\beta, \eta, \xi, \nu, \psi, \epsilon_k, \rho_k, \pi,  \phi_1, \phi_2 \}$.
	We set weakly-informative priors for these parameters.

	\begin{table}[h]
		\centering
		\caption{Summary of parameters.}
		\begin{tabular}{cp{10cm}ll}
			\hline
			Symbol & Comment & Support & Prior \\
			\hline
			$\beta$ & Probability of transmission upon contact & $[0-1]$ & $\text{Beta}(1,1)$  \\
			$\eta$ & Reduction in transmission after control measures & $[0-1]$ & $\text{Beta}(1,1)$ \\
			$\xi$ & Slope of logistic function for control measures implementation & $[0.5-1.5]$ & $ \text{Beta}(1,1) + 0.5$  \\
			$\nu$ & Shift of logistic function for control measures implementation & $[0-\infty[$ & $\text{Exp}(1)$  \\
			$\psi$ & Proportion of symptomatics of 53\% on the Diamond Princess \cite{diamond2} & $$[0-1]$$ & $\text{Beta}(369,329)$ \\
			 & OR of 80\% among contacts of cases in Shenzen \cite{Bi2020} & $$[0-1]$$ & $\text{Beta}(71,18)$ \\
			$\epsilon_k$ & Proportion of deaths among symptomatic cases (by age group) & $$[0-1]$$ & $\text{Beta}(1,1)$  \\
			$\rho_k$ & Reporting rate of symptomatic cases (by age group) & $$[0-1]$$ & $\text{Beta}(1,1)$  \\
			$\pi$ & Initial proportion of exposed (at $t=0$) & $$[0-1]$$ & $\text{Beta}(1,999)$  \\
			$\phi_1$ & Overdispersion for cases & $[0-\infty[$ & $\text{Exp}(1/100)$  \\
			$\phi_2$ & Overdispersion for deaths & $[0-\infty[$ & $\text{Exp}(1/100)$  \\

			\hline
		\end{tabular}

	\end{table}

	We simultaneously fitted our model to four data sets:
	\begin{enumerate}
		\item the number of confirmed cases of COVID-19 by day of disease onset from January 1 to February 11:
		\begin{equation}
		\Pr(\theta| \mathds{A}) = \text{Neg-Bin}(\mathds{A}|E,\phi_1)
		\end{equation}

		\item the age distribution of all confirmed cases up to 11 February 2020:
		\begin{equation}
		\Pr(\theta| \mathds{B}) = \text{Multinomial}(\mathds{B}|F)
		\end{equation}

		\item the number of deaths among patients with confirmed COVID-19 infection by day of report from January 1 to February 11:
		\begin{equation}
		\Pr(\theta| \mathds{C}) = \text{Neg-Bin}(\mathds{C}|N,\phi_2)
		\end{equation}

		\item the age distribution of the deaths among patients with confirmed COVID-19 infection that occurred up to 11 February 2020 in China:
		\begin{equation}
		\Pr(\theta| \mathds{D}) = \text{Multinomial}(\mathds{D}|O)
		\end{equation}
	\end{enumerate}
	This leads to the following likelihood:
	\begin{equation}
	L(\theta | \mathds{A},\mathds{B},\mathds{C},\mathds{D}) = \Pr(\theta| \mathds{A}) \cdot \Pr(\theta| \mathds{B}) \cdot \Pr(\theta| \mathds{C}) \cdot \Pr(\theta| \mathds{D})
	\end{equation}

	\subsection{Final outputs}

	\begin{table}[h]
		\centering

		\begin{tabular}{ll}

			\hline
			Output & Formula \\
			\hline
			\textit{Case fatality ratio among symptomatic infections} &  \\
			Crude & $P/\sum E$  \\

			Adjusted for delayed mortality  &  $Q/\sum E$ \\

			Adjusted for unidentified symptomatic cases  &  $P/G$\\

			Adjusted for both &  $Q/G$\\

			\textit{Case fatality ratio among all symptomatic and asymptomatic infections} & \\
			Adjusted for both  &  $Q/H$ \\
			\hline
		\end{tabular}
	\end{table}

	%
	%In generated quantities we compute the following final outputs:
	%\begin{enumerate}
	%	\item crude CFR among symptomatics
	%	\item Adjusted for delayed mortality
	%	\item Adjusted for unidentified symptomatic cases
	%	\item Adjusted for both
	%\end{enumerate}
	\bibliography{sup_bib}

\end{document}


\section*{CONCLUSIONS}\label{conclusions}
This dataset is a time series with high autocorrelation, so that the
samples cannot be assumed as independent. This means that randomly
splitting the data into a train and test dataset will overpredict the
accuracy by far. With a time series, training should be done on historic
data to predict the future. This means that the training set must happen
in time prior to the test set, which has been done in this report for
the test evaluation as well as in the cross validation for parameter
tuning.
The Support Vector Regressor seems to be the model that performs the
best. However, none of the models seem to perform very well on this
dataset and the accuracy changes very much with the test size, which
means that the ranking between the models is very unreliable. The
dataset should be further examined and extended with additional features
to enable for a better model fit.
% Add a bibliography block to the postdoc


%!TEX root = ../thesis.tex
%*******************************************************************************
%*********************************** First Chapter *****************************
%*******************************************************************************

\chapter{Formulations of Einstein Field Equations}  %Title of the Second Chapter

\ifpdf
    \graphicspath{{Chapter1/Figs/PDF/}{Chapter1/Figs/}}
\else
    \graphicspath{{Chapter1/Figs/}}
\fi

%********************************** %First Section  **************************************
\section{Introduction to general relativity} %Section - 1.1
\label{section1.1}

\subsection{Einstein field equations} %Section - 1.1.1
\label{section1.1.1}

The Einstein field equations is given by
\begin{align} \label{eq:Einstein_eq}
    G_{\mu\nu} = 8 \pi T_{\mu\nu},
\end{align}
where $T_{\mu\nu}$ is the enery-momentum tensor and $G_{\mu\nu}$ is the Einstein tensor.
The Einstein tensor $G_{\mu\nu}$ is defined as
\begin{align}
    G_{\mu\nu} \coloneqq R_{\mu\nu} - \frac{1}{2} g_{\mu\nu} R,
\end{align}
where $R_{\mu\nu}$ is the Ricci tensor,
$R$ is the Ricci scalar
and $g_{\mu\nu}$ is the metric tensor.

%\subsection{Relativistic Star} %Section - 1.1.2
%\label{section1.1.2}

%********************************** %Second Section  *************************************
\section{The 3+1 decomposition of spacetime} %Section - 1.2
\label{section1.2}

Due to the complexity and nonlinearity of Einstein field equations, it is extremely difficult to obtain analytical solution even for the simplest dynamical evolution systems.
Therefore, the accurate discription of the such systems can only be derived through numerical simulation.
For this, we need to reformulate the Einstein equations as an initial-value problem or Cauchy problem.
In this chapter, we will introduction the Arnowitt-Deser-Misner (ADM) formulation, which is the one of the milestone of the 3+1 numerical relativity.
In particular, we will focus on the constrained evolution scheme for the Einstein equations.
For more comprehensive discussion of numerical relativity,
we refer readers to \cite{shibata2015numerical,baumgarte2010numerical,gourgoulhon20123+}.

\subsection{Foliation of spacetime} \label{section1.2.1}

In the 3+1 decomposition, the spacetime manifold $\mathcal{M}$ is foliated into a set of non-intersecting spacelike hypersurfaces $\Sigma_t$ parameterized by the coordinate time $t$ \cite{misner1973gravitation}.
We denote a future-directed timelike unit four-vector $n^\mu$ normal to the hypersurface $\Sigma_t$ (i.e. $n_{\mu} \propto \nabla_\mu t$).
The induced spacetime metric $\gamma_{\mu\nu}$ on each hypersurfuce can then be defined as
\begin{align}\label{eq:1.2.spatial}
    \gamma_{\mu\nu} \coloneqq g_{\mu\nu} + n_{\mu} n_{\nu}.
\end{align}
Thus, we can construct spatial projection tensor $\gamma^{\mu}{}_{\nu}$ and time projection tensor $N^{\mu}{}_{\nu}$ as
\begin{align}
    \gamma^{\mu}{}_{\nu} &\coloneqq \delta^{\mu}{}_{\nu} + n^{\mu} n_{\nu}, & N^{\mu}{}_{\nu} &\coloneqq - n^{\mu} n_{\nu},
\end{align}
which decompose any generic four-vector $U^\mu$ into spatial part $\gamma^{\mu}{}_{\nu}U^{\nu}$ and timelike part $N^{\mu}{}_{\nu}U^{\nu}$.
Therefore, we can decompose the timelike vector field
\begin{align}\label{eq:1.2.1.normal_decompose}
t^\mu = \alpha n^{\mu} + \beta^{\mu}
\end{align}
into two components as
\begin{align}
    \alpha &\coloneqq - t^\mu n_\mu, & \beta^{\mu} &\coloneqq t^{\nu} \gamma^{\mu}{}_{\nu},
\end{align}
where the lapse function $\alpha$ measures the physical proper time ($\alpha\Delta t$) between two neighboring spatial hypersurface $\Sigma_t$ and $\Sigma_{t+\Delta t}$
, and the shift vector $\beta^i$ measures the changes of spatial coordinates on $\Sigma_{t+\Delta t}$.\\
Here, we summarise several useful relations.
The timelike normal vector $n^\mu$ and its corresponding one-form $n_\mu$ can be expressed as
\begin{align} \label{eq:1.2.1.normal}
    n^\mu &= \frac{1}{\alpha}\left(1, \beta^i \right), & n_\mu &= \left(\alpha, \vec{0}, \right).
\end{align}
The generic line element in 3+1 decomposition is given by
\begin{align}
    ds^2 = - \left( \alpha^2 - \beta^i \beta_i \right) dt^2 + \beta_i dx^i dt + \gamma_{ij} dx^i dx^j
\end{align}
The covariant and contravariant components of the metric can be written as
\begin{align}\label{eq:1.2.1.g}
    g_{\mu\nu} &=
    \begin{pmatrix}
        - \alpha^2 + \beta^i \beta_i & \beta_j \\
        \beta_i & \gamma_{ij}
    \end{pmatrix}, &
    g^{\mu\nu} &=
    \begin{pmatrix}
        - \frac{1}{\alpha^2} & \beta^j \\
        \beta^i & \gamma^{ij}
    \end{pmatrix}.
\end{align}
From equation(\ref{eq:1.2.1.g}), we can conclude that
\begin{align}
    \sqrt{-g} = \alpha \sqrt{\gamma},
\end{align}
where $g \coloneqq \det{\left(g_{\mu\nu}\right)}$ and $\gamma \coloneqq \det{\left(\gamma_{ij}\right)}$.

\subsection{Derivative operator} \label{section1.2.2}
With the 3+1 decomposition, we can now construct the 3-dimensional covariant derivative $D_\alpha$ associated with $\gamma_{\mu\nu}$ by projecting the 4-dimensional covariant derivative $\nabla_\alpha$ onto $\Sigma_t$, which is given by
\begin{align}\label{eq:1.2.2.spatialD}
    D_{\alpha} T^{\mu_1 \mu_2 \dots}{}_{\nu_1 \nu_2 \dots} = \gamma_{\alpha}{}^{\beta}\gamma_{\rho_1}{}^{\mu_1} \gamma_{\rho_2}{}^{\mu_2} \dots \gamma_{\nu_1}{}^{\sigma_1} \gamma_{\nu_2}{}^{\sigma_2} \dots \nabla_{\beta} T^{\rho_1 \rho_2 \dots}{}_{\sigma_1 \sigma_2 \dots},
\end{align}
for arbitrary tensor $T^{\mu_1 \mu_2 \dots}{}_{\nu_1 \nu_2 \dots}$ on spatial hypersurface $\Sigma_t$.
Using equation(\ref{eq:1.2.2.spatialD}), it can be shown that the corvariant derivative of $\gamma_{\mu\nu}$ vanishes
\begin{align}
\begin{split}
    D_{\alpha} \gamma_{\mu\nu} &= \gamma_{\alpha}{}^{\beta} \gamma_{\rho}{}^{\mu} \gamma_{\nu}{}^{\sigma} \nabla_{\beta} \left(g_{\rho\sigma} + n_\rho n_\sigma \right) \\
    &= \gamma_{\alpha}{}^{\beta} \gamma_{\rho}{}^{\mu} \gamma_{\nu}{}^{\sigma} \left( n_\rho \nabla_\beta n_\sigma + n_\sigma \nabla_\beta n_\rho \right) = 0
\end{split}
\end{align}
The components of 3-dimensional connection coefficients $\Gamma^{\alpha}{}_{\mu\nu}$ in coordinate basis can be expressed as
\begin{align}\label{eq:3_connection}
    \Gamma^{\alpha}{}_{\mu\nu} &= \frac{1}{2} \gamma^{\alpha\beta} \left( \partial_{\nu}\gamma_{\beta\mu} + \partial_{\mu}\gamma_{\beta\nu} - \partial_{\beta}\gamma_{\mu\nu} \right).
\end{align}
Here, the upper left index ${}^{(4)}$ marks the 4-dimensional tensors while the unmarked one represents purely spatial 3-dimensional tensors.
Similarly, the 3-dimensional Riemann tensor $R^{\alpha}{}_{\beta\mu\nu}$ associated with $\gamma_{\mu\nu}$ is defined by requiring that
\begin{align}
    2 D_{[\nu} D_{\mu]} W_\beta &= W_\alpha R^\alpha{}_{\beta\mu\nu}, & R^{\alpha}{}_{\beta\mu\nu} n_\alpha &= 0,
\end{align}
which can be explicitly expressed in coordinate basis as
\begin{align}
    R^{\alpha}{}_{\beta\mu\nu} &= \partial_{\mu} \Gamma^{\alpha}{}_{\beta\nu} - \partial_{\nu} \Gamma^{\alpha}{}_{\beta\mu} + \Gamma^{\alpha}{}_{\mu\rho}\Gamma^{\rho}{}_{\beta\nu} - \Gamma^{\alpha}{}_{\nu\rho}\Gamma^{\rho}{}_{\beta\mu}.
\end{align}
The 3-dimensional Ricci tensor $R_{\mu\nu}$ and Ricci scalar $R$ are defined in a similar manner as their 4-dimensional counterparts
\begin{align}
     R_{\mu\nu} &\coloneqq  R^\alpha{}_{\mu\alpha\nu}, & R &\coloneqq  R^{\mu}{}_{\mu}.
\end{align}
Since $R^{\alpha}{}_{\beta\mu\nu}$ is purely spatial and can be computed by the spatial derivatives of the spatial metric alone,
it only contains about information about the curvature intrinsic to the hypersurface $\Sigma_t$,
but cannot contain all the information of ${}^{(4)} R^{\alpha}{}_{\beta\mu\nu}$ which includes time derivative of the 4-dimensional metric.
The missing information can be found in a purely spatial symmetric tensor called the extrinsic curvature $K_{\mu\nu}$.

\subsection{Extrinsic curvature} \label{section1.2.3}
The extrinsic curvature $K_{\mu\nu}$ is related to the time derivative of the spatial metric $\gamma_{\mu\nu}$.
Therefore, the spatial metric and extrinsic curvature $\left(\gamma_{\mu\nu}, K_{\mu\nu} \right)$ are equivalent to the positions and velocities in classical mechanics,
which describe the instantaneous state of the gravitational field.
It can be obtained by projecting of the gradient of the normal vector $\gamma_{\mu}{}^{\lambda}\gamma_{\nu}{}^{\rho} \nabla_{\lambda} n_{\rho}$ into the hypersurface $\Sigma_t$,
and then taking the negative expression of the symmetric part
\begin{align}\label{eq:1.2.3.K1}
\begin{split}
   K_{\mu\nu} \coloneqq& - \gamma_{\mu}{}^{\lambda}\gamma_{\nu}{}^{\rho} \nabla_{\lambda} n_{\rho} \\
   =& - \gamma_{\mu}{}^{\lambda} \left( \delta_{\nu}{}^{\rho} + n_{\nu} n^{\rho} \right) \nabla_{\lambda} n_{\rho} \\
   =& - \gamma_{\mu}{}^{\lambda} \nabla_{\lambda} n_{\nu},
\end{split}
\end{align}
where the identity $n^{\rho}\nabla_{\lambda} n_{\rho}=0$ is used. \\
We can also define an spatial acceleration $a_\nu$
\begin{align}
    a_\nu \coloneqq n^\mu \nabla_\mu n_\nu,
\end{align}
satisfying the identities
\begin{align}
    a_\nu = D_\nu \ln{\alpha},
\end{align}
to rewrite equation(\ref{eq:1.2.3.K1}) as
\begin{align}
    K_{\mu\nu} = - \nabla_\mu n_\nu - n_\mu a_\nu
\end{align}
Finally, we can write the extrinsic curvature $K_{\mu\nu}$ as the Lie derivative of the spatial metric along the local normal $n^\mu$
\begin{align}
    K_{\mu\nu} = - \frac{1}{2} \mathcal{L}_{n} \gamma_{\mu\nu}.
\end{align}
Using equation(\ref{eq:1.2.1.normal_decompose}), we can express the Lie derivative $\mathcal{L}_n$ as
\begin{align}\label{eq:normal_Lie}
    \mathcal{L}_n = \frac{1}{\alpha} \left( \mathcal{L}_t - \mathcal{L}_\beta \right),
\end{align}
and thus obtain the evolution equation for the spatial metric
\begin{align}\label{eq:g_evol}
    \mathcal{L}_t \gamma_{\mu\nu} = - 2\alpha K_{\mu\nu} + \mathcal{L}_\beta \gamma_{\mu\nu}.
\end{align}

\subsection{The Gauss, Codazzi and Ricci equations}
\label{section1.2.4}

To express the Einstein field equations in term of the spatial variables $(\gamma_{\mu\nu}, K_{\mu\nu})$ we defined previously,
we first need to relate 3-dimensional Riemann tensor $R^\alpha{}_{\beta\mu\nu}$ on $\Sigma_t$ to the 4-dimensional Riemann tensor ${}^{(4)}R^\alpha{}_{\beta\mu\nu}$ on $\mathcal{M}$,
The relation between $R^\alpha{}_{\beta\mu\nu}$ and the full spatial projection of ${}^{(4)}R^\alpha{}_{\beta\mu\nu}$ is given by the \textit{Gauss' equation}
\begin{align}\label{eq:Gauss}
    R_{\alpha\beta\mu\nu} + K_{\alpha\mu}K_{\beta\nu} - K_{\alpha\nu} K_{\beta\mu} = \gamma_{\alpha}{}^{\rho} \gamma_{\beta}{}^{\sigma} \gamma_{\mu}{}^{\lambda} \gamma_{\nu}{}^{\delta} {}^{(4)}R_{\rho\sigma\lambda\delta},
\end{align}
while the projection of ${}^{(4)}R^\alpha{}_{\beta\mu\nu}$ with one index projected in the normal direction is given by the \textit{Codazzi equation}
\begin{align}\label{eq:Codazzi}
    D_{\nu} K_{\mu\alpha} - D_{\mu} K_{\nu\alpha} = \gamma_{\mu}{}^{\rho} \gamma_{\nu}{}^{\sigma} \gamma_{\alpha}{}^{\lambda} n^{\delta} {}^{(4)}R_{\rho\sigma\lambda\delta}.
\end{align}
Finally, by projecting two indices of ${}^{(4)}R_{\rho\sigma\lambda\delta}$ in the normal direction,
we can relate it to the time derivative of $K_{\mu\nu}$
\begin{align}\label{eq:Ricci}
    \mathcal{L}_n K_{\mu\nu} = n^{\alpha} n^{\beta} \gamma_{\mu}{}^{\lambda} \gamma_{\nu}{}^{\delta} {}^{(4)}R_{\alpha\deta\beta\lambda} - \frac{1}{\alpha} D_{\mu} D_\nu \alpha - K_{\nu}{}^{\lambda}K_{\mu\lambda},
\end{align}
which is called the \textit{Ricci equation}.

\subsection{Constraint and evolution equations} %Section - 1.2.5
\label{section1.2.5}

Using the Gauss, Codazzi and Ricci equations,
the Einstein fields equations can be decomposed into a set of evolution equations and a set of constraint equations of $(\gamma_{\mu\nu}, K_{\mu\nu})$.
To begin with, we define the following matter quantities
\begin{align}
    S_{\mu\nu} \coloneqq& \gamma^{\alpha}{}_{\mu} \gamma^{\beta}{}_{\nu} T_{\alpha\beta}, \\
    S_\mu \coloneqq& - \gamma^{\alpha}{}_{\mu} n^{\beta} T_{\alpha\beta}, \\
    S \coloneqq& S^\mu{}_\mu, \\
    E \coloneqq& n^\alpha n^\beta T_{\alpha\beta},
\end{align}
which decompose the stress-energy tensor as
\begin{align}\label{eq:T_decompose}
    T_{\mu\nu} = E n_\mu n_\nu + S_\mu n_\nu + S_\nu n_\mu + S_{\mu\nu}.
\end{align}\\
By contracting the $\alpha,\mu$ indices in equation(\ref{eq:Gauss}), we can obtain
\begin{align}\label{eq:Gauss_1st}
    R_{\mu\nu} = \gamma_{\mu}{}^{\alpha}\gamma_{\nu}{}^{\beta} \left( {}^{(4)} R_{\alpha\beta} + n^\rho n^\sigma {}^{(4)}R_{\alpha\rho\beta\sigma} \right) + K_{\mu\lambda} K_\nu{}^{\lambda} - K_{\mu\nu} K,
\end{align}
where $K\coloneqq K^\mu{}_{\mu}$ is the trace of the extrinsic curvature,
called the \textit{mean curvature}.
Further contracting the $\mu, \nu$ indices in equation(\ref{eq:Gauss_1st}), the contracted Gauss' equation becomes
\begin{align}\label{eq:Gaussr_2nd}
    2 n^\mu n^\nu G_{\mu\nu} = R + K^2 - K_{\mu\nu} K^{\mu\nu},
\end{align}
Using the Einstein equation(\ref{eq:Einstein_eq}), we can obtain the \textit{Hamiltonian constraint}
\begin{align}
    R + K^2 - K_{\mu\nu} K^{\mu\nu} = 16\pi E.
\end{align}
Similarly, by contracting $\alpha, \nu$ indices in equation(\ref{eq:Codazzi}), the Codazzi equation yields
\begin{align}
    D_{\nu} K_{\mu}{}^{\nu} - D_\mu K = - 8\pi \gamma^{\alpha}{}_{\mu} n^{\beta} T_{\alpha\beta},
\end{align}
and thus obtain the \textit{momentum constrain equation}
\begin{align}
    D_{\nu} K_{\mu}{}^{\nu} - D_\mu K = 8 \pi S_{\mu}.
\end{align}\\
The Ricci equation (\ref{eq:Ricci}) can be rewritten using equation(\ref{eq:Gauss_1st}) to
\begin{align}
    \mathcal{L}_n K_{\mu\nu} = R_{\mu\nu} - \gamma_{\mu}{}^{\rho} \gamma_\nu{}^{\sigma} {}^{(4)} R_{\rho\sigma} - 2 K_{\mu\lambda} K_\nu{}^{\lambda} + K K_{\mu\nu} - \frac{1}{\alpha} D_\mu D_\nu \alpha.
\end{align}
Using the Einstein equations (\ref{eq:Einstein_eq})
\begin{align}
\begin{split}
    \gamma_{\mu}{}^{\rho} \gamma_\nu{}^{\sigma} {}^{(4)} R_{\rho\sigma} &= 8\pi \gamma_{\mu}{}^{\rho} \gamma_\nu{}^{\sigma} \left( T_{\rho\sigma} - \frac{1}{2}g_{\rho\sigma} T^\mu{}_\mu \right)\\
    &= 8\pi \left[S_{\mu\nu} - \frac{1}{2} \gamma_{\mu\nu} \left(S-E\right) \right]
\end{split}
\end{align}
and equation(\ref{eq:normal_Lie}), we can finally obtain the evolution equation for $K_{\mu\nu}$ as
\begin{align}\label{eq:K_evol}
    \mathcal{L}_t K_{\mu\nu} = - D_\mu D_\nu \alpha + \alpha \left(R_{\mu\nu} - 2K_{\mu\lambda} K_\nu{}^{\lambda} + K K_{\mu\nu} \right)
    - 8 \pi \alpha \left[ S_{\mu\nu} - \frac{1}{2}\gamma_{\mu\nu} \left(S-E\right) \right] + \mathcal{L}_\beta K_{\mu\nu}.
\end{align}

\subsection{The Arnowitt, Deser and Misner equations} %Section - 1.2.6
\label{section1.2.6}

The Lie derivative in the evolution equations (\ref{eq:g_evol}) and (\ref{eq:K_evol}) can be expressed in terms of coordinate basis as
\begin{align}
    \mathcal{L}_t K_{\mu\nu} &= \partial_t K_{\mu\nu} \\
    \mathcal{L}_\beta K_{\mu\nu} &= \beta^\lambda D_\lambda K_{\mu\nu} + K_{\mu\lambda} D_\nu \beta^\lambda + K_{\lambda\nu} D_\mu \beta^\lambda
\end{align}\\
As the result, the Einstein field equaitons (\ref{eq:Einstein_eq}) in the standard 3+1 decomposition can be decomposed into a set of constraint equations and evolution equation of $(\gamma_{ij}, K_{ij})$ in terms of coordinate basis,
which are referred to as the Arnowitt, Deser and Misner (ADM) equations \cite{amowitt1962dynamics,york1979kinematics}
\begin{flalign}
    & R + K^2 - K_{ij}K^{ij} = 16\pi E, && \text{(Hamiltonian constraint)} \label{eq:ADM_H_const}\\
    & D_j \left(K^{ij} - \gamma^{ij} K \right) = 8\pi S^i, && \text{(momentum constraint)} \label{eq:ADM_S_const}\\
    & \partial_t \gamma_{ij} = - 2 \alpha K_{ij} + D_i \beta_j + D_j \beta_i, && \text{(spatial metric evolution)} \label{eq:ADM_g_evol}\\
    &
    \begin{aligned}
    \partial_t K_{ij} =& - D_i D_j \alpha + \alpha \left(R_{ij} - 2 K_{ik} K_j{}^k + K K_{ij} \right) \\
    &- 8\pi \alpha \left[S_{ij} - \frac{1}{2}\gamma_{ij} \left(S-E \right) \right] \\
    &+ \beta^k D_k K_{ij} + K_{ik} D_j \beta^k + K_{kj} D_i \beta^k.
    \end{aligned} && \text{(extrinsic curvature evolution)} \label{eq:ADM_K_evol}
\end{flalign}

%********************************** % Third Section  *************************************
\section{Conformal Decomposition} %Section - 1.3
\label{section1.3}

The conformal decompostion factors out a scalar component from a spatial metric.
It was first developped for initial data problems in general relativity \cite{lichnerowicz1944integration,york1971gravitational,york1972role,york1973conformally},
and then used in reformulating evolution equations in the 3+1 formulation.
In this section, we will discuss the conformal decomposition of spatial metric and extrinsic curvature in numerical relativity.

\subsection{Conformal transformation of the spatial metric}
\label{section1.3.1}
We consider the conformal transformation of the spatial metric $\gamma_{ij}$ as
\begin{align}\label{eq:conformal_metric}
    \tilde{\gamma}_{ij} = \psi^{-4} \gamma_{ij},
\end{align}
where $\tilde{\gamma}_{ij}$ is the \textit{conformal metric} and $\psi$ is a positive scaling factor satisfying
\begin{align}\label{eq:scaling_factor}
    \psi &\coloneqq \det{\left( \frac{\gamma}{f} \right)}, & \gamma &\coloneqq \det{\left( \gamma_{ij} \right)}, & f &\coloneqq \det{\left( f_{ij} \right)}
\end{align}
for a time independent flat metric $f_{ij}$ (i.e. $\det{\left( \tilde{\gamma}_{ij} \right)} = f$ by construction).\\
Thus, the \textit{inverse conformal metric} is given by
\begin{align}\label{eq:conformal_metric_inv}
    \tilde{\gamma}^{ij} \coloneqq \psi^4 \gamma^{ij}.
\end{align}
Substituting the conformal transformation (\ref{eq:conformal_metric}) into equation(\ref{eq:3_connection}),
we can obtain the transformation law for 3-dimensional connection coefficient
\begin{align}
    \Gamma^{i}{}_{jk} = \tilde{\Gamma}^{i}{}_{jk} + 2 \left( \delta^i{}_j \tilde{D}_k \ln \psi + \delta^i{}_k \tilde{D}_j \ln \psi
    - \tilde{\gamma}_{jk} \tilde{\gamma}^{il} \tilde{D}_l \ln \psi \right).
\end{align}
From now on, we denote all objects associated with the conformal metric $\tilde{\gamma}^{ij}$ with a tilde symbol.
Similarly, the transformation for Ricci tensor and scalar curvature are given by
\begin{align}
\begin{split}
    R_{ij} =& \tilde{R}_{ij} - 2 \left( \tilde{D}_i \tilde{D}_j \ln \psi + \tilde{\gamma}_{ij} \tilde{\gamma}^{lm} \tilde{D}_l \tilde{D}_m \ln \psi \right)\\
    &+ 4 \left[ \left(\tilde{D}_i \ln \psi \right) \left( \tilde{D}_j \ln \psi \right)
    - \tilde{\gamma}_{ij} \tilde{\gamma}^{lm} \tilde{D}_l \left(\tilde{D}_l \ln \psi \right) \left( \tilde{D}_m \ln \psi \right) \right]
\end{split} \label{eq:conformal_ricci_tensor}\\
    R =& \psi^{-4} \tilde{R} - 8 \psi^{-5} \tilde{D}^2 \psi, \label{eq:conformal_ricci_scalar}
\end{align}
where $\tilde{D}^2 = \tilde{\gamma}^{ij} \tilde{D}_i \tilde{D}_j$ denotes the Laplace operator associated with $\tilde{\gamma}_{ij}$.
Therefore, using equation(\ref{eq:conformal_ricci_scalar}), the Hamiltonian constraint (\ref{eq:ADM_H_const}) becomes
\begin{align}
    8 \tilde{D}^2 \psi - \psi \tilde{R} - \psi^5 K^2 + \psi^2 K_{ij} K^{ij} = - 16 \pi \psi^5 E.
\end{align}

\subsection{Conformal transformation of the extrinsic curvature}
\label{section1.3.2}

\subsubsection{Traceless decomposition}
\label{section1.3.2.1}
Before we perform the conformal transformation to the extrinsic curvature $K_{ij}$, it is convenient to split $K_{ij}$ into the trace part
\begin{align}
    K \coloneqq \gamma^{ij} K_{ij},
\end{align}
and its traceless part
\begin{align}
    A_{ij} &\coloneqq K_{ij} - \frac{1}{3} \gamma_{ij} K, & \operatorname{tr}_{\gamma} A_{ij} &= \gamma^{ij} A_{ij} = 0.
\end{align}
Therefore, we can obtain the tracelss decomposition of the extrinsic curvature
\begin{align}
    K_{ij} &= A_{ij} + \frac{1}{3} \gamma_{ij} K, & K^{ij} &= A^{ij} + \frac{1}{3} \gamma^{ij} K.
\end{align}
The evolution equations of the spatial metric (\ref{eq:ADM_g_evol}) in conformal decomposition formulation can hence be written as
\begin{flalign}
    \partial_t \psi &= \beta^i \tilde{D}_i \psi - \frac{1}{6}\psi \left(\alpha K - \tilde{D}_i \beta^i \right), &&\text{(conformal factor evolution)} \label{eq:psi_evol} \\
    \partial_t \tilde{\gamma}_{ij} &= - 2\alpha \psi^{-4} A_{ij} + \tilde{\gamma}_{jk} \tilde{D}_i \beta^k + \tilde{\gamma}_{ik} \tilde{D}_j \beta^k - \frac{2}{3} \tilde{\gamma}_{ij} \tilde{D}_k \beta^k, &&\text{(conformal metric evolution)} \label{eq:con_g_evol_1}
\end{flalign}
and the constraint equations become
\begin{flalign}
    &\tilde{D}^2 \psi - \frac{1}{8} \psi \tilde{R} + \left( \frac{1}{8} A_{ij} A^{ij} - \frac{1}{12}K^2 + 2 \pi E \right) \psi^5 = 0,
    &&\text{(Hamiltonian constraint)} \label{eq:H_const_s} \\
    &\tilde{D}_j \left(\psi^{10} A^{ij} \right) - \frac{2}{3}\psi^6 \tilde{D}^i K = 8\pi \psi^{10} S^i.
    &&\text{(momentum constraint)} \label{eq:S_const_s}
\end{flalign}

\subsubsection{Conformal transformation of the traceless part}
\label{section1.3.2.2}
We consider the transformation
\begin{align}
    A^{ij} \coloneqq \psi^a \tilde{A}^{ij},
\end{align}
for some undetermined exponent $\alpha$.
Here, we discuss two natural choices of $a$: $a = -4$ and $a = -10$.

\subparagraph{“Time-evolution” scaling: $a=-4$.}
This choice of scaling was considered by Nakamura in 1994 \cite{nakamura19943d},
It comes naturally from the evolution equation of conformal metric (\ref{eq:con_g_evol_1}),
where the $\psi^{-4}A_{ij}$ term suggests the conformal transformation of $A_{ij}$ to have the same scaling factor as the conformal spatial metric (\ref{eq:conformal_metric_inv})
\begin{align}
    \tilde{A}^{ij} \coloneqq \psi^4 A^{ij},
\end{align}
where the indices of $\tilde{A}^{ij}$ and $\tilde{A}_{ij}$ are lowered and raised by the conformal metric $\tilde{\gamma}_{ij}$ and $\tilde{\gamma}^{ij}$ respectively
(i.e. $\tilde{A}_{ij} = \tilde{\gamma}_{il}\tilde{\gamma}_{jm}\tilde{A}^{lm} = \psi^{-4} A_{ij}$).
The evolution equations of conformal spatial metric therefore become
\begin{align}
    \partial_t \tilde{\gamma}_{ij} &= - 2\alpha \tilde{A}_{ij} + \tilde{\gamma}_{jk} \tilde{D}_i \beta^k + \tilde{\gamma}_{ik} \tilde{D}_j \beta^k - \frac{2}{3} \tilde{\gamma}_{ij} \tilde{D}_k \beta^k.
\end{align}
The Hamiltonian constraint and momentum constraint in this scaling is rewritten as
\begin{align}
    &\tilde{D}^2 \psi = \frac{1}{8} \psi \tilde{R} - \left( 2 \pi E - \frac{1}{12}K^2 + \frac{1}{8} \tilde{A}_{ij} \tilde{A}^{ij} \right) \psi^5,
    \label{eq:H_const_s4}\\
    &\tilde{D}_i \left(\psi^6 \tilde{A}^{ij} \right) - \frac{2}{3}\psi^6 \tilde{D}^i K = 8\pi \psi^{10} S^i.\label{eq:S_const_s4}
\end{align}

\subparagraph{“Momentum-constraint” scaling: $a=-10$.}
Another possible choice of scaling factor $a=-10$ originates from the momentum constraint equation (\ref{eq:S_const_s}),
which was first suggested by Lichnerowicz in 1944 \cite{lichnerowicz1944integration}.
we define
\begin{align}
    \hat{A}^{ij} \coloneqq \psi^{10} A^{ij},
\end{align}
and thus
\begin{align}
    \hat{A}_{ij} = \psi^{2} A_{ij}.
\end{align}
Here, we use hat symbol to separate the "momentum-constraint" scaling from the tilde symbol in "time-evolution" scaling.
These two scaling are related by
\begin{align}
    \hat{A}^{ij}&= \psi^6\tilde{A}^{ij}, &\hat{A}_{ij} &= \psi^6 \tilde{A}_{ij}, &\hat{A}_{ij} \hat{A}^{ij} &= \psi^{12} \tilde{A}_{ij} \tilde{A}^{ij}
\end{align}
Therefore, the constraint equations can be written as
\begin{align}
    &\tilde{D}^2 \psi = \frac{1}{8} \psi \tilde{R} - \left( 2\pi E - \frac{1}{12}K^2 \right) \psi^5 - \frac{1}{8} \hat{A}_{ij} \hat{A}^{ij} \psi^{-7},
    \label{eq:H_const_s10}\\
    &\tilde{D}_i \hat{A}^{ij} - \frac{2}{3}\psi^6 \tilde{D}^i K = 8\pi \psi^{10} S^i.\label{eq:S_const_s10}
\end{align}
Equation(\ref{eq:S_const_s10}) is known as \textit{Lichnerowicz equation}.
Although equation (\ref{eq:S_const_s4}) and equation (\ref{eq:S_const_s10}) are equivalent,
they have different mathematical properties if they are treated as a partial differential equation for $\psi$.
According to the maximal principle,
the local uniqueness of the solutions depends on the sign of the exponent of $\psi$ in the quadratic extrinsic curvature $A^2$ term
\cite{cordero2009improved,smarr1979sources,taylor1991partial,evans1997partial,protter2012maximum}.
Equation (\ref{eq:S_const_s4}) suffers from the mathematical nonuniqueness problems due to the positive exponent $(+5)$,
while the negative exponent $(-7)$ in equation (\ref{eq:S_const_s10}) guarantees the local uniquess of the solutions.

\subsection{Conformal transverse-traceless decomposition}
\label{section1.3.3}
Using the "momentum-constraint” scaling mentioned previously,
we can further decompose the symmetric, traceless tensor $\hat{A}^{ij}$ as
\begin{align}\label{eq:CTT}
    \hat{A}^{ij} = \hat{A}^{ij}_{TT} + \hat{A}^{ij}_{L},
\end{align}
where $\hat{A}^{ij}_{TT}$ is the transverse-traceless part which is divergenceless
\begin{align}
    \tilde{D}_j \hat{A}^{ij}_{L} = 0,
\end{align}
and $\hat{A}^{ij}_{L}$ is the longitudinal part satisfying
\begin{align}
    \hat{A}^{ij}_{L} = \tilde{D}^i X^j + \tilde{D}^j X^i - \frac{2}{3}\tilde{\gamma}^{ij} \tilde{D}_k X^k \equiv \left(\tilde{L} X \right)^{ij}.
\end{align}
The vector $X^i$ here is the vector potential
and $\tilde{L}$ is the \textit{longitudinal operator} or \textit{conformal Killing operator} associated with $\tilde{\gamma}$
which gives a symmetric, traceless tensor.
The divergence of $\hat{A}^{ij}$ becomes
\begin{align}\label{eq:vector_Lap}
    \tilde{D}_j \hat{A}^{ij} = \tilde{D}^2 X^i + \frac{1}{3} \tilde{D}^i \left( \tilde{D}_j X^j \right) + \tilde{R}^i{}_j X^j \equiv \tilde{\Delta}_{L},
\end{align}
where $\tilde{\Delta}_{L}$ is the \textit{vector Laplacian}.
Thus, the momentum constraint in the conformal transverse-traceless (CTT) decomposition yields
\begin{align}\label{eq:CTT_S_const}
    \tilde{\Delta}_L X^i - \frac{2}{3}\psi^6 \tilde{D}^i K = 8 \pi \psi^{10} S^i,
\end{align}
and the corresponding Hamiltonian constraint is the same as equation (\ref{eq:H_const_s10}).

%********************************** % Fourth Section  *************************************
\section{Gauge Condition}  %Section - 1.4
\label{section1.4}
In the 3+1 formulation of spacetime, the gauge freedom is preserved.
One can freely choose the lapse function $\alpha$ and shift vector $\beta^i$.
In this section, we introduce the \textit{maximal slicing} condition and \textit{generalized Dirac gauge},
which is used in the formulation of the constrained scheme in the next section.

\subsection{Maximal Slicing}
\label{section1.4.1}
By taking the trace of the evolution equation for extrinsic curvature (\ref{eq:ADM_K_evol}),
we can obtain an elliptic equation for the lapse $\alpha$
\begin{align}\label{eq:lapse_1}
    D^2 \alpha = - \partial_t K + \alpha \left[ K_{ij} K^{ij} + 4\pi\left(E+S\right) \right] + \beta^i D_i K.
\end{align}
One well-known choice to further simplify this equation is the \textit{maximal slicing} condition
\begin{align}\label{eq:max_slicing}
    K = 0 = \partial_t K,
\end{align}
which corresponds to the vanishing mean curvature in all hypersurface $\Sigma_t$.
This type of slicing was first introduced by Lichnerowicz \cite{lichnerowicz1944integration}
and then made popularized by York \cite{smarr1979sources,smarr1978radiation}.
Under this condition, the enclosed volume inside some hypersurface $\Sigma_t$ becomes maximal,
hence the name \textit{maximal slicing}.
With this choice of condition, equation (\ref{eq:lapse_1}) reduces to
\begin{align}\label{eq:lapse_2}
    D^2 \alpha = \alpha \left[ A_{ij} A^{ij} + 4\pi\left(E+S\right) \right],
\end{align}
which is independent of the shift $\beta^i$.
Alternatively, we can combine the conformally decomposed Hamiltonian equation (\ref{eq:H_const_s10}) to obtain
\begin{align}\label{eq:lapse_con}
    \tilde{D}^2 \left(\alpha \psi \right) = \alpha \psi \left[ \frac{7}{8} \psi^{-8} \hat{A}_{ij} \hat{A}^{ij} + \frac{1}{8} \tilde{R}
    + 2 \pi \psi^4 \left(E + 2 S \right) \right].
\end{align}
The \textit{maximal slicing} condition not only helps decouple the constraint equations,
but also has some nice physical properties:
it is a natural extension of Newtonian gravity and has singularity avoidance property.

\subsubsection{Natural generalization to Newtonian limit}
Consider the Newtonain limit of a weak and static gravitational field
\begin{align}
    \alpha &\approx 1 + \Phi, & \gamma_{ij} &\approx \left(1 + 2\Phi \right) f_{ij}, & K_{ij} &=0, & \text{for } \Phi &\ll 1,
\end{align}
where $\Phi$ is the Newtonian gravitational potential,
and non-relativistic matter
\begin{align}
    S &\ll E, & E &\approx \rho_0,
\end{align}
where $\rho_0$ is the proper rest mass energy density.
Equation (\ref{eq:lapse_2}) reduces to Poisson equation for the newtonian gravitational potential
\begin{align}
    \nabla^2 \Phi = 4\pi \rho_0.
\end{align}

\subsubsection{Singularity avoidance}
Another interesting property of maximal slicing is singularity avoidance.
Equation (\ref{eq:1.2.3.K1}) shows that under maximal slicing condition,
the normal observers move like irrotational and incompressible fluid elements
\begin{align}
    \nabla_\mu n^{\mu} = 0,
\end{align}
which implies that focusing of the timelike unit normal vector field is prohibited.
It can also be seen from equation (\ref{eq:ADM_g_evol}),
which yields the following continuity equation for volume element $\sqrt{\gamma}$ in maximal slicing condition
\begin{align}\label{eq:volume_evol}
    \partial_t \sqrt{\gamma} = \partial_i \left( \sqrt{\gamma} \beta^i \right).
\end{align}
This suggests that as long as a regular shift vector is chosen
and the initial condition for $\gamma_{\mu\nu}$ is regular,
$\gamma$ is regular forever.

\subsection{Generalized Dirac Gauge}
\label{section1.4.2}
The \textit{Dirac gauge} was first introduced by Dirac in 1959 \cite{dirac1959fixation},
and then generalized by the Meudon group \cite{bonazzola2004constrained}.
We define the \textit{generalized Dirac gauge} as
\begin{align}\label{eq:dirac_gauge_1}
    \mathcal{D}_j \tilde{\gamma}^{ij} = 0,
\end{align}
which fully specify the coordinates in the hypersurface $\Sigma_t$ including the initial one.
Here, $\mathcal{D}$ denotes the covariant derivative associated with the flat background metric $f_{ij}$ defined in equation (\ref{eq:scaling_factor}),
which relates $\tilde{D}$ by
\begin{align}
    \tilde{D}_k T^{i_1 \dots i_p}{}_{j_1 \dots j_q} = \mathcal{D}_k T^{i_1 \dots i_p}{}_{j_1 \dots j_q}
    + \sum_{r=1}^p \Delta^{i_r}{}_{lk} T^{i_1 \dots l \dots i_p}{}_{j_1 \dots j_q}
    + \sum_{r=1}^q \Delta^{l}{}_{j_r k} T^{i_1 \dots i_p}{}_{j_1 \dots l \dots j_q},
\end{align}
where $\Delta^{k}{}_{ij}$ is given by
\begin{align}
    \Delta^k{}_{ij} \coloneqq& \frac{1}{2} \tilde{\gamma}^{kl} \left( \mathcal{D}_i \tilde{\gamma}_{lj} + \mathcal{D}_j \tilde{\gamma}_{il}
    - \mathcal{D}_l \tilde{\gamma}_{ij} \right).
\end{align}
We can further define the potentials $h^{ij}$ as the deviation of the conformal metric from the flat fiducial metric
\begin{align}
    h^{ij} \coloneqq \tilde{\gamma}^{ij} - f^{ij}.
\end{align}
Thus, the generalized Dirac is equivalent to
\begin{align}
    \mathcal{D}_j h^{ij} = 0,
\end{align}
Under such gauge condition, the conformal Ricci tensor $\tilde{R}^{ij}$ is simplified drastically as
\begin{align}
    \tilde{R}^{ij} = \frac{1}{2} \mathcal{D}^2 h^{ij} + \tilde{R}^{ij}_{*},
\end{align}
where $\tilde{R}^{ij}_{*}$ is the quadratic part of $\tilde{R}^{ij}$
\begin{align}
    \tilde{R}^{ij}_{*} &\coloneqq \frac{1}{2} \biggl[ h^{kl} \mathcal{D}_k \mathcal{D}_l h^{ij} - \mathcal{D}_l h^{ik} \mathcal{D}_k h^{jl}
    - \tilde{\gamma}_{kl} \tilde{\gamma}^{mn} \mathcal{D}_m h^{ik} \mathcal{D}_n h^{jl} \\
    & + \tilde{\gamma}_{nl} \mathcal{D}_k h^{mn} \left( \tilde{\gamma}^{ik} \mathcal{D}_m h^{jl} + \tilde{\gamma}^{jk} \mathcal{D}_m h^{il} \right)
    + \frac{1}{2} \tilde{\gamma}^{ik} \tilde{\gamma}^{kl} \mathcal{D}_l h^{mn} \mathcal{D}_k \tilde{\gamma}_{mn} \biggr],
\end{align}
and $\mathcal{D}^2 = \mathcal{D}^i \mathcal{D}_i$ is the Laplacian operator associated with the flat metric with $\mathcal{D}^i \coloneqq f^{ij}\mathcal{D}_j$.
The curvature scalar $\tilde{R}$ of the conformal metric does not contain any second order derivative of $\tilde{\gamma}_{ij}$ thanks to the gauge condition
\begin{align}
    \tilde{R} = \frac{1}{4} \tilde{\gamma}^{kl} \mathcal{D}_k h^{ij} \mathcal{D}_l \tilde{\gamma}_{ij}
    - \frac{1}{2} \tilde{\gamma}^{kl} \mathcal{D}_k h^{ij} \mathcal{D}_j \tilde{\gamma}_{il}.
\end{align}
Note that the generalized gauge condition result in transverse-traceless (TT) gauge asymtotically,
which are well adapted to the treatment of gravitational radiation.

%********************************** % Fifth Section  *************************************
\section{Constrained scheme for the Einstein equations}  %Section - 1.5
\label{section1.5}
Although the ADM equations (\cref{eq:ADM_H_const,eq:ADM_S_const,eq:ADM_g_evol,eq:ADM_K_evol}) formulate the Einstein equations into a well-defined initial-value problem based on spacetime foliation,
it is known to be unsuitable for numerical simulation of singular spacetime due to the unbounded growth of numerical error (same for conformal decomposition formulation).
Several reformulations were developped to maintain stable evolutions.
Most of schemes such as BSSN \cite{shibata1995evolution,baumgarte1998numerical}, CCZ4 \cite{bona2003general}, Z4c \cite{bernuzzi2010constraint} schemes are based on free-evolution approach where the hyperbolic-type dynamical equations are evolved without enforcing the constraints.
The constraint equations are solved only to obtain the initial data and serve as an indicator for numerical errors during the simulation.
On the other hand, the fully constrained approach minimizes the hyperbolic-type evolution equations by solving the constraint equations at each time step.
Though the elliptic nature of the constraint equations makes it computationally costy to solve,
elliptic equations are more stable than hyperbolic equations,
and the constraint-violating modes appeared in the free-evolution scheme vanish by construction in fully constrained evolution.\\
With the efficient elliptic multigrid solvers developped,
our relativistic hydrodynamics code \texttt{Gmunu} employs the Isenberg–Wilson–Mathews (also known as conformal flatness condition) approximation to the general relativity
and the fully constrained formulation.
In this section, we introduce the formulations and implementations under the constrained scheme.

\subsection{Isenberg–Wilson–Mathews approximation}  %Section - 1.5.1
\label{section1.5.1}
The Isenberg–Wilson–Mathews approximation (IWM), also known as conformal flatness condition (CFC),
is a (gravitational-)waveless approximation to general relativity which was independently developped by
Isenberg in 1978 \cite{isenberg2008waveless} as well as Wilson and Mathews in 1989 \cite{wilson1989relativistic}.
In IWM, the spatial metric is approxiated to be conformally flat (hence the name conformal flatness condition)
\begin{align}
    \gamma_{ij} &= \psi^4 f_{ij}, &\text{or } &\text{equivalently } & \tilde{\gamma}_{ij} &= f_{ij},
\end{align}
under maximal slicing condition $K=0=\partial_t K$ (\cref{eq:max_slicing})
(i.e. $\partial_t \tilde{\gamma}_{ij} = 0$ and $\tilde{D}_i=\mathcal{D}_i$ by construction).
The equations for the conformal factor and extrinsic curvature can be obtained from equations (\ref{eq:psi_evol}) and (\ref{eq:con_g_evol_1}) respectively
\begin{align}
    \partial_t \psi &= \beta^i \mathcal{D}_i \psi + \frac{\psi}{6} \mathcal{D}_i \beta^i \\
    K_{ij} &= \frac{\psi^4}{2\alpha} \left(f_{jk} \mathcal{D}_i \beta^k + f_{ik} \mathcal{D}_j \beta^k - \frac{2}{3} f_{ij} \mathcal{D}_k \beta^k \right)
    \label{eq:K_CFC}.
\end{align}
The CFC approximation reduces the ADM equations in a set of coupled non-linear elliptic equations for $\psi$ (from \cref{eq:H_const_s4}), $\alpha$ (from \cref{eq:lapse_con}), and $\beta^i$ (from \cref{eq:S_const_s4})
\begin{align}
    & \mathcal{D}^2 \psi = - \left( 2\pi E + \frac{1}{8}K_{ij} K^{ij} \right) \psi^5, \\
    & \mathcal{D}^2 \left(\alpha \psi \right) = \alpha \psi^5 \left[ \frac{7}{8} K_{ij} K^{ij} + 2 \pi \left(E + 2 S \right) \right], \\
    & \Delta_L \beta^i = 16 \pi \alpha \psi^4 S^i - 2 \psi^{10} K^{ij} \mathcal{D}_j \left(\alpha \psi^{-6} \right),
\end{align}
where $\Delta_L \beta^i \coloneqq \mathcal{D}^2 \beta^i + \frac{1}{3} \mathcal{D}^i \mathcal{D}_j \beta^j$
is the \textit{vector Laplacian} (\cref{eq:vector_Lap}) associated with the flat metric $f_{ij}$.
Although the solutions $(\psi, \alpha, \beta^i)$ to the CFC system do not satisfy all the conformal 3+1 equations in general,
it is exact for spherically symmetric spacetime \cite{cordero2011maximal} and
correct at the 1-PN order in the post-Newtonian expansion of general relativity.
The CFC scheme has been successful in numerical simulation for various astrophysical simulation
\cite{dimmelmeier2002relativistic,oechslin2002conformally,saijo2004collapse,bauswein2012equation,bauswein2013systematics,bauswein2014revealing,muller2015dynamics,dimmelmeier2006non}
and obtained good approximation to full general relativity in axisymmetric rotating neutron stars
\cite{dimmelmeier2002relativistic,dimmelmeier2006non,cook1996testing}
and in rotating iron core collapses \cite{ott2007rotating}.

\subsubsection{Extended CFC scheme}
\label{section_XCFC}
Despite the success of CFC scheme in astrophysical simulation,
it suffers from the non-uniqueness issue as we discussed in section \ref{section1.3.2.2}.
A solution to this has been found \cite{cordero2009improved,saijo2004collapse,shibata2006merger},
which involves an extra elliptic equation of the vector potential from CTT decomposition (see section \ref{section1.3.3}).
The resultant scheme is called \textit{extended conformal flatness approximation} (XCFC),
and the metric can be solved by following
\begin{align}
    & \Delta_L X^i = 8\pi f^{ij} \left(S^{*}\right)_j, \label{eq:XCFC_X}\\
    & \mathcal{D}^2 \psi = - 2\pi E^{*} \psi^{-1} - \frac{1}{8} \psi^{-7}f_{il}f_{jm} \hat{A}^{lm} \hat{A}^{ij}, \label{eq:XCFC_psi}\\
    & \mathcal{D}^2 \left(\alpha \psi \right) = \left( \alpha \psi \right) \left[ 2\pi \left( E^{*} + 2 S^{*} \right) \psi^{-2}
    + \frac{7}{8} \psi^{-8} f_{il}f_{jm} \hat{A}^{lm} \hat{A}^{ij} \right], \label{eq:XCFC_alp}\\
    & \Delta_L \beta^i = 16 \pi \alpha \psi^{-6} f^{ij} \left(S^{*}\right)_{j} - 2 \hat{A}^{ij} \mathcal{D}_j \left(\alpha \psi^{-6} \right), \label{eq:XCFC_beta}
\end{align}
where the hydrodynamical conserved quantities are defined as
\begin{align}
    E^* &\coloneqq \psi^6 E, & S^* & \coloneqq \psi^6 S, & \left(S^*\right)_i &\coloneqq \psi^6 S_i,
\end{align}
and the extra vector elliptic equation (\ref{eq:XCFC_X}) comes from the momentum constraint (\cref{eq:CTT_S_const})
by taking CFC approximation and $\hat{A}^{ij}_{TT} \approx 0$ in CTT decomposition (\cref{eq:CTT}),
which gives
\begin{align}\label{eq:XCFC_A}
    \hat{A}^{ij} \approx \mathcal{D}^i X^j + \mathcal{D}^j X^i - \frac{2}{3} f^{ij} \mathcal{D}_k X^k \equiv \left(LX \right)^{ij}.
\end{align}
Unlike the coupled system in IWM approximation, the XCFC system is decoupled in a hierarchical way,
and hence guarantees local uniqueness.
Once the hydrodynamical conserved quantities are known,
the metric equations can be solved accordingly as follows
\begin{Step}
    \item Solve equation (\ref{eq:XCFC_X}) for the vector potential $X^i$ from the conserved variables $\left(S^*\right)_i$.
    \item Obtain $\hat{A}^{ij}$ from equation (\ref{eq:XCFC_A}).
    \item Solve equation (\ref{eq:XCFC_psi}) for the conformal factor $\psi$.
    \item Work out $S^*$ using conformal factor $\psi$.
    \item Solve equation (\ref{eq:XCFC_alp}) for the lapse function $\alpha$.
    \item Solve equation (\ref{eq:XCFC_beta}) for the shift vector $\beta^i$.
\end{Step}

\subsection{The Meudon-Valencia Fully Constrained Formulation}  %Section - 1.5.2
\label{section1.5.2}
The fully constrained formulation (FCF) was first proposed by the Meudon group \cite{bonazzola2004constrained},
and then later modified by the Valencia's group \cite{cordero2008mathematical,cordero2009improved,cordero2012gravitational}.
By choosing the maximal slcing condition (section \ref{section1.4.1}) and the generalized Dirac gauge (section \ref{section1.4.2}),
the conformal 3+1 decomposition can be recasted in a coupled elliptic-hyperbolic system,
where all the constraint equations are utilized to minimize the number of hyperbolic equations in the system.
Here, we summarize the gauge conditions and algebraic constraint for the scheme
\begin{flalign}
    &K \coloneqq \gamma_{ij} K^{ij} = 0, &&\text{(maximal slicing condition)} \label{eq:FCF_max_slicing}\\
    & \mathcal{D}_j h^{ij} = 0, &&\text{(generalized Dirac gauge)} \label{eq:FCF_dirac}\\
    & \det \tilde{\gamma}_{ij} = f, &&\text{(conformal decomposition)} \label{eq:FCF_conformal_g}\\
    & K^{ij} = \psi^{-10}\hat{A}^{ij}, \quad \hat{A}^{ij} = \hat{A}^{ij}_{TT} + \left(L X\right)^{ij}. &&\text{(conformal decomposition)} \label{eq:FCF_conformal_A}
\end{flalign}
Note that althought it would be more general to used the \textit{Killing operator} $\tilde{L}$ associated with $\tilde{\gamma}_{ij}$ in equation (\ref{eq:FCF_conformal_A}),
the \textit{Killing operator} $L$ associated with flat metric $f_{ij}$ is used since it is easier to handle technically.
Under such gauge conditions, the ADM equations are decomposed into a coupled hyperbolic-elliptic system.

\subsubsection{Hyperbolic sector}
The Valencia's group performed first-order reduction \cite{cordero2008mathematical} to the reduced FCF system \cite{bonazzola2004constrained} by introducing axuiliary variable
\begin{align}
    w^{ij}{}_k \coloneqq \mathcal{D}_k h^{ij},
\end{align}
with the corresponding gauge condition
\begin{align}\label{eq:FCF_conformal_w}
    w^{ij}{}_j = 0.
\end{align}
Thus, the hyperbolic sector in the FCF is recasted as a first-order system in $\left(h^{ij}, \hat{A}^{ij}, w^{ij}{}_k \right)$ as follows
\begin{flalign}
    &\partial_t h^{ij} = 2 \alpha \psi^{-6} \hat{A}^{ij} + \beta^k w^{ij}{}_k
    - \tilde{\gamma}^{ik} \mathcal{D}_k \beta^j - \tilde{\gamma}^{kj} \mathcal{D}_k \beta^i
    + \frac{2}{3}\tilde{\gamma}^{ij} \mathcal{D}_k \beta^k, \label{eq:FCF_h}\\
    &\begin{aligned}
        \partial_t \hat{A}^{ij} =& \mathcal{D}_k \left( \frac{1}{2}\alpha \psi^2 \tilde{\gamma}^{kl} w^{ij}{}_l
        + \beta^k \hat{A}^{ij} \right) - \hat{A}^{kj} \mathcal{D}_k \beta^i - \hat{A}^{ik} \mathcal{D}_k \beta^j
        + \frac{2}{3}\hat{A}^{ij} \mathcal{D}_k \beta^k
        + 2\alpha \psi^{-6} \tilde{\gamma}^{kl} \hat{A}^{ik} \hat{A}^{jl} \\
        &- 8 \pi \alpha \psi^6 \left( \psi^4 S^{ij} -\frac{1}{3}\tilde{\gamma}^{ij} S \right)
        + \alpha \psi^2 \left( \tilde{R}^{ij}_* - \frac{1}{3} \tilde{R} \right)
        + 8\alpha
        \left( \tilde{\gamma}^{ik} \tilde{\gamma}^{jl}  -\frac{1}{3} \tilde{\gamma}^{ij} \tilde{\gamma}^{kl} \right)
        \mathcal{D}_k \psi \mathcal{D}_l \psi \\
        & + 4 \psi
        \left( \tilde{\gamma}^{ik} \tilde{\gamma}^{jl} + \tilde{\gamma}^{il} \tilde{\gamma}^{jk} - \frac{2}{3} \tilde{\gamma}^{kl} \tilde{\gamma}^{ij}\right)
        \mathcal{D}_k \psi \mathcal{D}_l \alpha
        - \left( \tilde{\gamma}^{ik} \tilde{\gamma}^{jl} - \frac{1}{3} \tilde{\gamma}^{ij} \tilde{\gamma}^{kl} \right)
        \mathcal{D}_k \mathcal{D}_l \left(\alpha \psi^2 \right) \\
        &- \frac{1}{2} \left( \tilde{\gamma}^{ik} w^{lj}{}_k + \tilde{\gamma}^{lk} w^{il}{}_k \right) \mathcal{D}_l \left(\alpha \psi^2 \right),
    \end{aligned} \label{eq:FCF_A}\\
    &\partial_t w^{ij}{}_k = \mathcal{D}_k \left(2 \alpha \psi^{-6} \hat{A}^{ij} + \beta^k w^{ij}{}_k
    - \tilde{\gamma}^{ik} \mathcal{D}_k \beta^j - \tilde{\gamma}^{kj} \mathcal{D}_k \beta^i
    + \frac{2}{3}\tilde{\gamma}^{ij} \mathcal{D}_k \beta^k\right), \label{eq:FCF_w}
\end{flalign}
where $\tilde{R}^{ij}_*$ and $\tilde{R}$ defined in section \ref{section1.4.2}.
This evolution system is proved to be strongly hyperbolic \cite{cordero2008mathematical} under following conditions
\begin{align}
    \alpha &\neq 0, & \alpha^2 - \beta^i \beta_i &> 0,
\end{align}
and the characteristic speed is given by
\begin{align}
    \lambda^i_{\pm} = -\beta^i \pm \alpha\psi^{-2} \tilde{\gamma}^{ii}.
\end{align}
In Meudon-Valencia's approach, only the transverse-traceless (TT) part of the hyperbolic equations are evolved.
Each tensorial hyperbolic equation is reduced to two scalar equations under TT decomposition \cite{bonazzola2004constrained} and solved using spectral method,
and partially implicit Runge-Kutta methods (PIRK) is used to update $w^{ij}{}_k$ to maintain numerical stability \cite{cordero2012gravitational,cordero2012partially}.
To fulfill the constraint in equation (\ref{eq:FCF_conformal_g}), the trace part of $h^{ij}$ was calculated by the following iteration procedure:
\begin{Step}
    \item Calculate $h\coloneqq \det{\tilde{\gamma}^{ij}} - f$.
    \item Solve the Poisson equation
    \begin{align}\label{eq:FCF_g_trace}
        \mathcal{D}^2 \Phi = h.
    \end{align}
    \item Update $h^{ij}$ by $h^{ij}_{(new)} = h^{ij}_{(old)} + \frac{1}{2} \left( h f^{ij} - \mathcal{D}^i \mathcal{D}^j \Phi \right)$.
    \item Repeat step 1 to 3 until the $\det{\tilde{\gamma}^{ij}} = f$ is satisfied.
\end{Step}

\subsubsection{Elliptic sector}
The elliptic sector in the FCF scheme is given by
\begin{align}
    &\tilde{\gamma}^{kl} \mathcal{D}_k \mathcal{D}_l X^i + \frac{1}{3}\tilde{\gamma}^{ik}\mathcal{D}_k \mathcal{D}_l X^l
    + \Delta^i{}_{kl} \left( LX \right)^{kl} = 8\pi \tilde{\gamma}^{ij} \left( S^* \right)_j - \Delta^i{}_{kl} \hat{A}^{kl}_{TT}, \label{eq:FCF_X}\\
    & \tilde{\gamma}^{kl} \mathcal{D}_k \mathcal{D}_l \psi = - 2\pi E^* \psi^{-1}
    - \frac{1}{8} \psi^{-7} \tilde{\gamma}_{il} \tilde{\gamma}_{jm} \hat{A}^{lm} \hat{A}^{ij} + \frac{1}{8}\psi \tilde{R}, \label{eq:FCF_psi}\\
    & \tilde{\gamma}^{kl} \mathcal{D}_k \mathcal{D}_l \left( \alpha \psi \right) = \left(\alpha\psi\right)
    \left[ 2\pi\psi^{-2} \left(E^* + 2 S^* \right) + \frac{7}{8}\psi^{-8}\tilde{\gamma}_{il} \tilde{\gamma}_{jm} \hat{A}^{lm} \hat{A}^{ij}
    + \frac{\tilde{R}}{8}\right], \label{eq:FCF_alp} \\
    &\tilde{\gamma}^{kl} \mathcal{D}_k \mathcal{D}_l \beta^i + \frac{1}{3}\tilde{\gamma}^{ik}\mathcal{D}_k \mathcal{D}_l \beta^l =
    16 \pi \alpha \psi^{-6} \tilde{\gamma}^{ij} \left( S^* \right)_j + 2 \hat{A}^{ij} \mathcal{D}_j \left(\alpha \psi^{-6} \right)
    - 2 \alpha \psi^{-6} \Delta^i{}_{kl} \hat{A}^{kl}, \label{eq:FCF_beta}
\end{align}
which can be solved following the same routine as XCFC scheme (section \ref{section_XCFC}).
Note that the FCF scheme is a natural generalization of XCFC scheme
since it reduces to XCFC if the approximation $h^{ij} = \hat{A}^{ij}_{TT} = 0$ is made.

\subsubsection{passive FCF}
The elliptic sector in FCF scheme is technically more difficult to solve.
Therefore, the Valencia's group an approximation scheme based on FCF, called passive FCF \cite{cordero2012gravitational},
which neglected the backreaction of the GWs onto the dynamics of the system.
Unlike the XCFC which sets the gravitational radiation to zero,
the gravitational wave can be evolved in passive FCF scheme by keeping the hyperbolic sector in FCF scheme,
while solving the elliptic sector in XCFC scheme.

\subsection{The fully-constrained scheme in \texttt{Gmunu}}
\label{section1.5.3}
In \texttt{Gmunu}, the fully-constrained scheme is solved in a slightly different approach.
Instead of solving \cref{eq:FCF_h,eq:FCF_A,eq:FCF_w},
we omit the axuiliary variable $w^{ij}{}_k$ in order to avoid solving the gauge condition for $w^{ij}{}_k$ \ref{eq:FCF_conformal_w} and evolve the following hyperbolic equations for $\left(h^{ij}, A^{ij} \right)$
\begin{flalign}
    &\partial_t h^{ij} = 2 \alpha \psi^{-6} \hat{A}^{ij} + \beta^k \mathcal{D}_k h^{ij}
    - \tilde{\gamma}^{ik} \mathcal{D}_k \beta^j - \tilde{\gamma}^{kj} \mathcal{D}_k \beta^i
    + \frac{2}{3}\tilde{\gamma}^{ij} \mathcal{D}_k \beta^k, \label{eq:FCF_h_2}\\
    &\begin{aligned}
        \partial_t \hat{A}^{ij} =& \frac{1}{2} \alpha \psi^2 \tilde{\gamma}^{kl} \mathcal{D}_k \mathcal{D}_l h^{ij}{}
        + \beta^k \mathcal{D}_k \hat{A}^{ij} - \hat{A}^{kj} \mathcal{D}_k \beta^i - \hat{A}^{ik} \mathcal{D}_k \beta^j
        + \frac{5}{3}\hat{A}^{ij} \mathcal{D}_k \beta^k
        + 2\alpha \psi^{-6} \tilde{\gamma}^{kl} \hat{A}^{ik} \hat{A}^{jl} \\
        &- 8 \pi \alpha \psi^6 \left( \psi^4 S^{ij} -\frac{1}{3}\tilde{\gamma}^{ij} S \right)
        + \alpha \psi^2 \left( \tilde{R}^{ij}_* - \frac{1}{3} \tilde{R} \right)
        + 8\alpha
        \left( \tilde{\gamma}^{ik} \tilde{\gamma}^{jl}  -\frac{1}{3} \tilde{\gamma}^{ij} \tilde{\gamma}^{kl} \right)
        \mathcal{D}_k \psi \mathcal{D}_l \psi \\
        & + 4 \psi
        \left( \tilde{\gamma}^{ik} \tilde{\gamma}^{jl} + \tilde{\gamma}^{il} \tilde{\gamma}^{jk} - \frac{2}{3} \tilde{\gamma}^{kl} \tilde{\gamma}^{ij}\right)
        \mathcal{D}_k \psi \mathcal{D}_l \alpha
        - \left( \tilde{\gamma}^{ik} \tilde{\gamma}^{jl} - \frac{1}{3} \tilde{\gamma}^{ij} \tilde{\gamma}^{kl} \right)
        \mathcal{D}_k \mathcal{D}_l \left(\alpha \psi^2 \right) \\
        &- \frac{1}{2} \left( \tilde{\gamma}^{ik} \mathcal{D}_k h^{lj}+ \tilde{\gamma}^{lk} \mathcal{D}_k h^{il} - \tilde{\gamma}^{kl} \mathcal{D}_k h^{ij} \right)
        \mathcal{D}_l \left(\alpha \psi^2 \right),
    \end{aligned} \label{eq:FCF_A_2}\\
\end{flalign}
directly without performing TT composition.
Note that although the hyperbolic system is \textit{unconditionally unstable} if second-order explicit \textit{Runge-Kutta} (RK) method used,
it has shown to be numerically stable using fourth-order explicit RK method \cite{cordero2012partially,shibata2015numerical}.
In \texttt{Gmunu}, the hyperbolic sector in FCF scheme is evolving simulataneously with the hydrodynamical system using
fourth-order \textit{strong stability-preserving Runge-Kutta} (ssprk) methods.
For spatial derivative, fourth-order upwind finite difference is used for the advection terms \cite{shibata2015numerical}
(i.e. $\mathcal{D}_k h^{ij}$ in \cref{eq:FCF_h_2} and $\mathcal{D}_k \hat{A}^{ij}$ in \cref{eq:FCF_A_2}),
and fourth-order central finite difference is used for other derivative terms.\\
After the time integration is done,
we need to modify $\left(h^{ij}_{old}, \hat{A}^{ij}_{old}\right)$ so that the gauge conditions can be satisfied.
The generalized Dirac gauge condition is then enforced by \textit{elliptic divergence cleaning} method as follows
\begin{Step}
    \item Solve the \textit{vector Laplacian} equation
    \begin{align}
        \Delta_L W^i = \mathcal{D}_j h^{ij}_{(old)}.
    \end{align}
    \item Update $h^{ij}$ by
    \begin{align}
        h^{ij}_{(new)} = h^{ij}_{(old)} - \left( L W \right)^{ij}.
    \end{align}
\end{Step}
This treatment is inspired by the divergence cleaning of magnetic monopole in magnetohydrodynamics \cite{balsara2004comparison,teunissen2019geometric,balsara1998total}.
In \textit{Gmunu}, a fourth-order central finite difference scheme is used for $\mathcal{D}_j h^{ij}_{old}$,
and a second-order central finite difference scheme is used for $\Delta_L W^i$ and $\left( L W \right)^{ij}$.
To enforce the algebraic constraint (\ref{eq:FCF_conformal_g}),
we modify the trace part of $h^{ij}$ using the same routine described in section \ref{section1.5.2}.\\
For $\hat{A}^{ij}$, it can be modified by the following procedures:
\begin{Step}
    \item Obtain the traceless part of $\hat{A}^{ij}_{(old)}$ by
    \begin{align}
        \hat{A}^{ij}_{(1)} = \hat{A}^{ij}_{(old)} - \frac{1}{3} f^{ij} f_{kl} \hat{A}^{kl}_{(old)}.
    \end{align}
    \item Calculate the vector potential $X^i$ using momentum constraint
    \begin{align} \label{eq:FCF_X_2}
    &\tilde{\gamma}^{kl} \mathcal{D}_k \mathcal{D}_l X^i + \frac{1}{3}\tilde{\gamma}^{ik}\mathcal{D}_k \mathcal{D}_l X^l
    + \Delta^i{}_{kl} \left( LX \right)^{kl} = 8\pi \tilde{\gamma}^{ij} \left( S^* \right)_j
    - \Delta^i{}_{kl} \hat{A}^{kl}_{(1)} - \mathcal{D}_j \hat{A}^{ij}_{(1)}.
    \end{align}
    Note that differing from equation (\ref{eq:FCF_X}), $\hat{A}^{ij}_{(1)}$ is used on the right-hand-side instead of $\hat{A}^{ij}_{TT}$.
    Thus, the vector potential $X^i$ here is an additional longitudinal part for $\hat{A}^{ij}$ to satisfy the momentum constraint.
    \item Update $\hat{A}^{ij}$ by
    \begin{align}
        \hat{A}^{ij}_{(new)} = \hat{A}^{ij}_{(1)} + \left( L X \right)^{ij}.
    \end{align}
\end{Step}
The remaining unknowns $\left(\psi, \alpha, \beta^i\right)$ can then be solved accordingly by adopting the same procedure in section \ref{section1.5.2}.\\
Note that we follow the Meudon-Valencia approach and solve the metric variables in orthonormal basis.

\subsubsection{Boundary condition}
In \texttt{Gmunu}, we impose the following boundary conditions for the metric variables at the outermost boundary $(r=r_{max})$
\begin{align}
    \left.\frac{\partial \psi}{\partial r}\right|_{r=r_{max}} &= \frac{1-\psi}{r},
    &\left.\frac{\partial \alpha}{\partial r}\right|_{r=r_{max}} &= \frac{1-\alpha}{r}, \\
    \left.\frac{\partial \beta^i}{\partial r}\right|_{r=r_{max}} &= -\frac{\beta^i}{r},
    &\left.\frac{\partial X^i}{\partial r}\right|_{r=r_{max}} &= -\frac{X^i}{r},
    &\left.\frac{\partial W^i}{\partial r}\right|_{r=r_{max}} &= -\frac{W^i}{r}.
\end{align}
We assume that asymtotically $h^{ij}$ satisfies the linearized quadrupole wave equation \cite{teukolsky1982linearized}
\begin{align}
    &\frac{\partial h^{rr}}{\partial t} + \frac{\partial h^{rr}}{\partial r} + \frac{3 h^{rr}}{r} = 0, \\
    &\frac{\partial h^{r\theta}}{\partial t} + \frac{\partial h^{r\theta}}{\partial r} + \frac{2 h^{r\theta}}{r} = 0, \\
    &\frac{\partial h^{r\phi}}{\partial t} + \frac{\partial h^{r\phi}}{\partial r} + \frac{2 h^{r\phi}}{r} = 0, \\
    &\frac{\partial h^{\theta\theta}}{\partial t} + \frac{\partial h^{\theta\theta}}{\partial r} + \frac{h^{\theta\theta}}{r} = 0, \\
    &\frac{\partial h^{\theta\phi}}{\partial t} + \frac{\partial h^{\theta\phi}}{\partial r} + \frac{h^{\theta\phi}}{r} = 0, \\
    &\frac{\partial h^{\phi\phi}}{\partial t} + \frac{\partial h^{\phi\phi}}{\partial r} + \frac{h^{\phi\phi}}{r} = 0,
\end{align}
and similarly for $\hat{A}^{ij}$.
This boundary condition can be rewritten as \cite{shibata1995evolution}
\begin{align}
    Q(t,r) &= \left(1 - \frac{\Delta r}{r} \right)^n Q(t-\Delta t, r - \Delta r),
\end{align}
for $Q(t,r)$ in the Sommerfield form
\begin{align}
    &\frac{\partial Q}{\partial t} + \frac{\partial Q}{\partial r} + \frac{n Q}{r} = 0,
\end{align}
where $\Delta t$ is the time step, $\Delta r = \alpha \psi^-2 \Delta t$
and $Q(t-\Delta t, r - \Delta r)$ is obtained by the second-order interpolation from the nearby mesh points.


\section{Basics and Multiple Dispatch}
\label{JM:sec:basics}

There exist different ways to define functions in \text{Julia}. Similar to e.g. \text{Python} or \text{Matlab}, a simple Gaussian radial basis function $f : \mathbb{R} \times \mathbb{R} \mapsto \mathbb{R}$
can be implemented as follows

\lstinputlisting[language=Julia,firstline=1, lastline=8]{../scripts/HelloWorld.jl}

As we can see, we defined no input types for the function and called it with a Float64 and Int64 as arguments, resulting in a Float64 as the best intersection of both number types.
Changing the input type of the first argument to Float32 returns Float32, again using the intersection of the input data types. To see how the evaluation works, we will use

\lstinputlisting[language=Julia,firstline=10, lastline=10]{../scripts/HelloWorld.jl}

Which will evaluate the function and returns a lowered and type-inferred abstract syntax tree for the method

\begin{lstlisting}[language=Julia]
    CodeInfo(
        1 ─ %1 = Base.sitofp(Float64, y)::Float64
        │   %2 = Base.sub_float(x, %1)::Float64
        │   %3 = Base.mul_float(%2, %2)::Float64
        │   %4 = Base.neg_float(%3)::Float64
        │   %5 = invoke Main.exp(%4::Float64)::Float64
        └──      return %5
        ) => Float64
\end{lstlisting}

The above output contains two important informations: the intermediate representation (IR), indicated by the lines with a leading \%, passed on to the compiler and the type information
propagated through the function.
It first the value of $y$ is converted into a Float64 (\%1), the difference $x-y$ is computed (\%2), multiplied with itsself (\%3), negated (\%4) and mapped via the exponential function (\%5).
Entering different arguments also works out of the box. Using a pair of ComplexFloat64 and Float32
returns a complex-valued result, as can be expected.
Different representations as the one shown above can be accessed via {@code\_lowered}, @{code\_typed}, @{code\_lowered} and @{code\_native}. These return the IR, IR with type information, the code for the compiler and the machine code respectively.

\lstinputlisting[language=Julia,firstline=12, lastline=12]{../scripts/HelloWorld.jl}

The reason why this approach works is called multiple dispatch (MD) and a core design element of \textit{Julia}. Most prominent languages operate on
obect-oriented programming (OOP) or use functional programming\footnote{FP refers to purely functional programming in the scope of this work. In general modern languages using FP as a paradigm, like \textit{Closure}, tend to use MD.} (FP).
In FP, each function is defined uniquely by its name and stored in the global namespace. OOP stores methods related to objects in the namespace
of the corresponding object definition, allowing for more expressiveness and clarity in defining the functions.

Following \cite{JMKarpinski2019}, the expressiveness of a language can be defined as the number of different methods with the same name but different purposes depending on their arguments.
Consider the exponential function $exp : \mathbb{X} \mapsto \mathbb{X},~ \mathbb{X} \in \lbrace \mathbb{R}, \mathbb{C}, \dots \rbrace$. FP would define several methods by name for different
arguments, e.g. $exp_{\mathbb{R}}$, $exp_{\mathbb{C}}$. In OOP, the object itself is the dispatch argument, so a pseudo-code notation would result in $\mathbb{R}.exp$, $\mathbb{C}.exp$.
In MD, all input arguments are checked, hence $exp$ can be used and extended for all types it holds a definition for. These insights are summarized in Table \ref{JM:tab:ExpressivePow}, showing the proportional
growth of expressiveness in relation to their dispatch arguments. \\

\begin{table}
    \begin{tabular}{|l|l|l|l|} \hline
        & FP & OOP & MD \\ \hline
        Dispatch arguments & $\emptyset$ & $\lbrace x_1 \rbrace$ & $\lbrace x_1 , x_2, \dots, x_N \rbrace$ \\
        Expressive Order &  $\mathcal{O}\left(1\right)$ & $\mathcal{O}\left(\left|x_1\right|\right)$ &  $\mathcal{O}\left(\prod_{i=1}^N \left|x_i\right|\right)$ \\
        Expressive Power & const. & linear & exponential \\ \hline
    \end{tabular}
    \caption{Expressiveness of different programming paradigms}
    \label{JM:tab:ExpressivePow}
\end{table}

If a general function, e.g. $+$, is called in \textit{Julia}, the compiler automatically uses the right function definition based on the arguments.
This can be confirmed with

\begin{lstlisting}[language=Julia]
    methods(+, (Number,Number))
    # 40 methods for generic function "+":
    [1] +(x::T, y::T) where T<:Union{Int128, ..., UInt8} in Base at int.jl:87
    [2] +(c::Union{UInt16, UInt32, UInt64, UInt8}, x::BigInt) in Base.GMP at gmp.jl:528
    [3] +(c::Union{Int16, Int32, Int64, Int8}, x::BigInt) in Base.GMP at gmp.jl:534
    [4] +(c::Union{UInt16, UInt32, UInt64, UInt8}, x::BigFloat) in Base.MPFR at mpfr.jl:376
    [5] +(c::Union{Int16, Int32, Int64, Int8}, x::BigFloat) in Base.MPFR at mpfr.jl:384
    [6] +(c::Union{Float16, Float32, Float64}, x::BigFloat) in Base.MPFR at mpfr.jl:392
    ...
\end{lstlisting}

which returns all methods defined in the current workspace for the $+$ operator using two Number types as inputs. Number represents an abstract type spanning various number types, e.g. Float, Int, UInt, Complex.
Evaluating the following code block

\lstinputlisting[language=Julia,firstline=14, lastline=16]{../scripts/HelloWorld.jl}

returns the corresponding method used for computation and where it is defined.

\begin{lstlisting}[language=Julia]
    exp(x::T) where T<:Float32 in Base.Math at special/exp.jl:229
    exp(z::Complex) in Base at complex.jl:638
\end{lstlisting}

A key difference to OOP based programming is that no method definition has to explicitly know of the other, as long as it is unique in its dispatch arguments\footnote{An unwanted dispatch on an already defined method can result unstable behaviour and called \textit{type-piracy}}.
This allows developers to easily extend existing packages and functionalities, allowing excessive reuse of the codebase\footnote{A good example is given by \url{https://github.com/JuliaPlots/RecipesBase.jl}, which is used to define individual recipes used for plotting without explicitly depending on \textit{Plots.jl}}.
As a small example consider defining a new Number type and its corresponding $\exp$:

\lstinputlisting[language=Julia,firstline=19, lastline=27]{../scripts/HelloWorld.jl}

To make the function $f$ useable for vector operations, multiple dispatch can be leveraged as well:

\lstinputlisting[language=Julia,firstline=29, lastline=38]{../scripts/HelloWorld.jl}

Since both $\exp$ and \^~ are not defined for vectors, we use broadcasting to call the function on each element of the data structure individually. This is accomplished via the
. operator. Checking the available definitions of the function via

\lstinputlisting[language=Julia,firstline=40, lastline=40]{../scripts/HelloWorld.jl}

we can see that two definitions are present

\begin{lstlisting}[language=Julia]
    # 2 methods for generic function "f":
    [1] f(x::AbstractVector{T} where T, y::AbstractVector{T} where T) in Main at ./HelloWorld.jl:32
    [2] f(x, y) in Main at ./HelloWorld.jl:3
\end{lstlisting}

[1] is the definition we just added and [2] our original implementation from the beginning of this section, extending the function to be reused and avoiding different naming schemes.

\newpage


\chapter{Functions}
\emph{Functions} in ABS define names for parametrized data expressions.
A function in ABS is always side effect-free, which means that it cannot
manipulate the heap.

\begin{abssyntax}
\NT{FunctionDecl} \defn \TR{def}\ \TR{Type}\ \NT{Identifier}\ \OPTG{\TRS{<}\ \NT{TypeIdList}\ \TRS{>}}\ \TRS{(} \NT{ParamList} \TRS{)}\ \TRS{=}\
                 \NT{FunBody}\ \TRS{;}  \\
\NT{FunBody}      \defn \TR{builtin} ~|~ \NT{PureExp}\\
\NT{TypeIdList}   \defn \NT{TypeId}\ \MANYG{\TRS{,}\ \NT{TypeId}}
\end{abssyntax}

\begin{absexample}
def Int length(IntList list) =
  case list {
    Nil => 0;
    Cons(n, ls) => 1 + length(ls);
  };
\end{absexample}

\section{Parametric Functions}
\label{sec:parametric-functions}

\emph{Parametric Functions} allow to work with parametric data types in a
general way.  For example, given a list of any type, a parametric
function \absinline{head} can return the first element, regardless of its
type.  Parametric functions are defined like normal functions but have
an additional \texttt{type parameter} section inside angle brackets
(\texttt{< >}) after the function name.

\begin{absexample}
def A head<A>(List<A> list) =
  case list {
    Cons(x, xs) => x;
  };
\end{absexample}

\noindent
(Note that \absinline{head} is a partial function.)


\documentclass[twoside]{MATH77}
\usepackage{multicol}
\usepackage[fleqn,reqno,centertags]{amsmath}
\usepackage{moreverb}
\begin{document}
\begmath 16.1  Character-based Graphics --- One or More XY Graphs

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

\subsection{Purpose}

These subroutines produce an image in a character array that the user can
print to produce a printer plot of one or more {\em xy} data sets with
titles and numeric grid-line labels. The size of the image is user-specified.
SPRPL1/DPRPL1 will process a single {\em xy} data set, whereas SPRPL2/DPRPL2
will process multiple {\em xy} data sets.

\subsection{Usage}

\subsubsection{Usage to plot a single {\em xy} data set}

\paragraph{Program Prototype, Single Precision}

\begin{description}

\item[INTEGER] \ {\bf NP, NLINES, NCHARS, IERR}

\item[REAL] \ {\bf X}($\geq $NP){\bf , Y}($\geq $NP)

\item[CHARACTER*$n_1$] \ {\bf TITLE} \ [1 $\leq  n_1 \leq $ NCHARS]

\item[CHARACTER*$n_2$] \ {\bf XNAME} \ [1 $\leq n_2 \leq $ NCHARS]

\item[CHARACTER*$n_3$] \ {\bf YNAME} \ [1 $\leq n_3 \leq $ NLINES]

\item[CHARACTER*$n_4$] \ {\bf IMAGE}($\geq $NLINES)\\ $[n_4 \geq $ NCHARS]

\end{description}

Assign values to all arguments except IMAGE() and IERR.

\begin{center}
\fbox{\begin{tabular}{@{\bf }c@{}}
CALL SPRPL1 (X, Y, NP, TITLE, XNAME,\rule{6pt}{0pt}\\
YNAME, NLINES, NCHARS, IMAGE, IERR)\\
\end{tabular}}
\end{center}

The printer plot image is returned in IMAGE() and the termination status in
IERR.

\paragraph{Argument Definitions}

\begin{description}

\item[X(), Y()] \ [in] Arrays of $(x$, $y)$ coordinate pairs defining the curve
to be plotted.

\item[NP] \ [in] Number of $(x$, $y)$ points to be plotted.

\item[TITLE] \ [in] Character string to be placed above the plot frame as a
title for the graph.

\item[XNAME] \ [in] Character string to be placed below the plot frame to
identify the abscissa variable.

\item[YNAME] \ [in] Character string to be placed in a vertical column to the
left of the plot frame to identify the ordinate variable.

\item[NLINES] \ [in] Number of lines of a plot image to be built in IMAGE().
The array IMAGE() must be dimensioned at least NLINES.

\item[NCHARS] \ [in] Number of character positions to be used in each line in
building the plot image in IMAGE(). The declared character length of each
element of IMAGE() must be at least NCHARS.

\item[IMAGE()] \ [out] Character array in which the printer plot image is
built. The image will use NLINES positions in the vertical direction and
NCHARS positions in the horizontal direction.

\item[IERR] \ [out] Termination status indicator.
\begin{itemize}
\item[0] \ No errors.
\item[1] \ NCHARS is too small.
\item[2] \ NLINES is too small.
\end{itemize}
\end{description}

\subsubsection{Usage to plot multiple {\em xy} data sets}

\paragraph{Program Prototype, Single Precision}

\begin{description}

\item[INTEGER] \ {\bf IDIM, KC, NR, JX}($\geq $KC){\bf , JY}($\geq $KC){\bf,
NP}($\geq $KC)

\item[INTEGER] \ {\bf NLINES, NCHARS, IERR}

\item[REAL] \ {\bf XY}(IDIM, $m)$\ ${\displaystyle [m \geq \max_{1 \leq k \leq
\text{KC}} \{\text{JX}(k), \text{JY}(k)\}}$]

\item[CHARACTER*1] \ {\bf SYMBOL}($\geq $KC)

\item[CHARACTER*$n_1$] \ {\bf TITLE} \ [1 $\leq n_1 \leq $ NCHARS]

\item[CHARACTER*$n_2$] \ {\bf XNAME} \ [1 $\leq n_2 \leq $ NCHARS]

\item[CHARACTER*$n_3$] \ {\bf YNAME} \ [1 $\leq n_3 \leq $ NLINES]

\item[CHARACTER*$n_4$] \ {\bf IMAGE}($\geq $NLINES)\\
$[n_4 \geq $ NCHARS]

\end{description}

Assign values to all arguments except IMAGE() and IERR.

\begin{center}
\fbox{\begin{tabular}{@{\bf }c@{}}
CALL SPRPL2 (XY, IDIM, KC, JX, JY, NP,\\
SYMBOL, TITLE, XNAME, YNAME,\\
NLINES, NCHARS, IMAGE, IERR)\\
\end{tabular}}
\end{center}

The printer plot image is returned in IMAGE() and the termination status in
IERR.

\paragraph{Argument Definitions}

\begin{description}

\item[XY(,)] \ [in] Array of values from which $(x,\ y)$ coordinates of points
to be placed will be obtained under control of the parameters JX(), JY(),
and NP().

\item[IDIM] \ [in] Dimension of the first subscript in the XY array. Require
IDIM ${\displaystyle \geq \max_{1 \leq k \leq \text{KC}}\{\text{NP}(k)\}}$.

\item[KC] \ [in] Number of {\em xy} sets to be plotted. If KC $\leq$ 0
the subroutine will return taking no action.

\item[JX()] \ [in] JX($k)$ specifies the column (second subscript) of XY(,)
to be used as the $x$ coordinates for the $k^{th}$ {\em xy} set.

\item[JY()] \ [in] JY($k)$ specifies the column (second subscript) of XY(,)
to be used as the $y$ coordinates for the $k^{th}$ {\em xy} set.

\item[NP()] \ [in] NP($k)$ specifies the number of {\em xy} pairs from XY(,)
in the $k^{th}$ set to be plotted.

\item[SYMBOL()] \ [in] SYMBOL$(k)$ is the single character to be used for
point-plotting the $k^{th}$ data set.

\item[TITLE,]{\bf XNAME, YNAME, NLINES, NCHARS,\newline
IMAGE, IERR} \ Same as in Section B.1 above.

\end{description}

\subsubsection{Modifications for Double Precision}

Change the names SPRPL1 and SPRPL2 to DPRPL1 and DPRPL2, respectively, and
change the REAL declarations to DOUBLE PRECISION.

\subsection{Examples and Remarks}

It is permissible, and generally most convenient, to give the arguments
TITLE, XNAME, and YNAME as character literals directly in the CALL
statement. We suggest that no leading or trailing blanks be included in
these strings, since each of these strings will be centered in the image
based on its length.

The program DRSPRPL1 and its output ODSPRPL1 illustrate the use of SPRPL1 to
obtain printer-plots in two different resolutions. The first plot uses
NLINES = 45 and NCHARS = 110, producing a plot that can be displayed on
8.5 inch wide paper using compressed printing, $i.e.$, 16.67 characters per
inch. The second plot uses NLINES = 22 and NCHARS = 79, producing a plot
that can be displayed on the $25 \times 80$ character display frequently
used with personal computers. Similarly the use of SPRPL2 is illustrated by
the program DRSPRPL2 and its output ODSPRPL2.

\subsection{Functional Description}

The subroutine first scans the given {\em xy} data to determine maximum and
minimum values. It then determines end-values for the $x$-axis and a
subdivision of the $x$-axis into~3 to~10 equal-length subintervals, such
that the values at the ends and subdivision points will be representable in
decimal with a small number of nonzero digits, and the span of the $x$-axis
will encompass the given $x$ data. This same process is applied to the $y$
data.

The subroutine establishes integer values, {\em top}, {\em bottom},
{\em left}, and {\em right}, such that the plot grid will extend vertically
from index {\em top} to index {\em bottom} in the IMAGE() array, inclusive
of the top and bottom grid lines, and horizontally from character position
{\em left} to {\em right}, inclusive of the left and right grid lines. These
values will satisfy 1 $\leq$ {\em top} $<$ {\em bottom} $\leq  \text{NLINES}
- 1,$ and $1 <$ {\em left} $<$ {\em right} = NCHARS $-$ 1.  If TITLE is
nonblank, it will be copied into IMAGE(1) and {\em top} is set to~2,
otherwise {\em top} = 1. If XNAME is nonblank, it will be copied into
IMAGE(NLINES) and {\em bottom} is set to NLINES $-$ 2, otherwise {\em bottom}
= NLINES $-$ 1. {\em left} is set large enough to allow for YNAME, if
nonblank, to be placed vertically at the left edge of the plot image, for
the numeric $y$-axis labels to be positioned to the left of the plot grid,
and for the leftmost numeric $x$-axis label to extend partially to the left
of the plot grid. The width of the numeric $x$-axis labels, and $y$-axis
labels are data-dependent.

For minimal useful resolution one should probably arrange to have
({\em bottom} $-$ {\em top}) $\geq $ 20 and ({\em right} $-$ {\em left})
$\geq 20$, however the subroutine imposes the less stringent requirement
that these extents each be at least~10. The subroutine abandons the effort
and returns with IERR $\neq 0$ if either of these extents is less than~10.

It is possible that there will not be enough space to place a numeric label
below each subdivision point of the $x$-axis. The subroutine first places
one centered under the left end of the $x$-axis. This is assured to be
possible by the way {\em left} is defined. It next attempts to place one for
the right end of the $x$-axis, right justified in the available space. It then
sequentially tries to place labels centered under the second, third,
etc., $x$-axis subdivision points. It is acceptable if not all $x$-axis labels
can be placed.

\subsection{Error Procedures and Restrictions}

If the character variable TITLE or XNAME has length greater than NCHARS,
only the first NCHARS characters are placed in the image. If YNAME has
length greater than NLINES, only the first NLINES characters are placed in
the image.

This subroutine requires at least enough space for the plot grid boundary
indices, defined above in Section D, to satisfy ({\em bottom} $-$
{\em top}) $\geq 10$ and ({\em right} $-$ {\em left}) $\geq 10$. If this is not
satisfied the subroutine abandons the image-building effort, issues an error
message using the error message package of Chapter~19.2 at error
level 0, and returns with IERR = 1 or~2.

\subsection{Supporting Information}

The source language is ANSI Fortran~77.  At Release~4.0 of MATH77 the
subroutines of this Chapter were introduced and previous similar but
less general subroutines PRPL1 and PRPL2 were deleted.

Based on 1967 code by C. L. Lawson, and J.\ Hatfield, JPL.

Current version by C. L. Lawson, 1992.

\pagebreak

\begin{tabular}{@{\bf}l@{\hspace{5pt}}l}
\bf Entry & \hspace{.35in} {\bf Required Files}\vspace{2pt} \\
DPRPL1 & \parbox[t]{2.7in}{\hyphenpenalty10000 \raggedright
DPRPL1, DPRPL3, ERFIN, ERMSG, IERM1, IERV1\rule[-5pt]{0pt}{8pt}}\\
DPRPL2 & \parbox[t]{2.7in}{\hyphenpenalty10000 \raggedright
DPRPL2, DPRPL3, ERFIN, ERMSG, IERM1, IERV1\rule[-5pt]{0pt}{8pt}}\\
\end{tabular}

\begin{tabular}{@{\bf}l@{\hspace{5pt}}l}
\bf Entry & \hspace{.35in} {\bf Required Files}\vspace{2pt} \\
SPRPL1 & \parbox[t]{2.7in}{\hyphenpenalty10000 \raggedright
ERFIN, ERMSG, IERM1, IERV1, SPRPL1, SPRPL3\rule[-5pt]{0pt}{8pt}}\\
SPRPL2 & \parbox[t]{2.7in}{\hyphenpenalty10000 \raggedright
ERFIN, ERMSG, IERM1, IERV1, SPRPL2, SPRPL3}\\
\end{tabular}

\begcode

\medskip\

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

\centerline{\bf \large DRSPRPL1}\vspace{10pt}
\lstinputlisting{\codeloc{sprpl1}}

\newpage
{\scriptsize
\centerline{\bf \large ODSPRPL1}\vspace{10pt}
\lstset{language={}}
\hspace{-1.6in}\vbox{
{\ttfamily
\lstinputlisting{\outputloc{sprpl1}}
}
}
\newpage
\lstset{language=[77]Fortran,showstringspaces=false}
\lstset{xleftmargin=.8in}
\enlargethispage*{10pt}
\centerline{\bf \large DRSPRPL2}\vspace{5pt}
\lstinputlisting{\codeloc{sprpl2}}
\newpage
{\scriptsize
\centerline{\bf \large ODSPRPL2}\vspace{10pt}
\hspace{-1.6in}\vbox{
{\ttfamily
\lstinputlisting{\outputloc{sprpl2}}
}
}
\end{document}


%% This is an evolving article style
%% steeling ideas from different places

\documentclass[12pt,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[linktocpage,colorlinks,urlcolor=blue,pdfstartview=FitH]{hyperref}

\newcommand{\boldsymbol}[1]{\mbox{\boldmath $#1$}}
\newcommand{\N}{\mbox{$I\!\!N$}}
\newcommand{\Z}{\mbox{$Z\!\!\!Z$}}
\newcommand{\Q}{\mbox{$I\:\!\!\!\!\!Q$}}
\newcommand{\R}{\mbox{$I\!\!R$}}

\makeindex
\makeatletter
\makeatother

\begin{document}

\title{Calculating the Fisher Information Matrix \\
for Parameter Fitting}

\author{Stefan Hoops\\
 Virginia Bioinformatics Institute - 0477\\
 Virginia Tech\\
 Bioinformatics Facility I\\
 Blacksburg, VA 24061 \\
 USA \\
 \href{mailto:Stefan Hoops <shoops@vt.edu>}{shoops@vt.edu}}

\date{2005-11-11}

\maketitle
\begin{abstract}
The \href{http://planetmath.org/encyclopedia/FisherInformationMatrix.html}
{Fisher Information Matrix} $\boldsymbol{I}$ is a measure for how much
information is known about a parameter set $\boldsymbol{\theta}$.  The
\href{http://planetmath.org/encyclopedia/CovarianceMatrix.html}
{covariance matrix} $C$ of the parameter set is bound by the
Cram\'er-Rao inequality $\boldsymbol{C} \ge \boldsymbol{I}^{-1}$ from
below. This allows us to judge the quality of the fitted parameter
set.
\end{abstract}

\section{Calculating the Fisher Information Matrix}

Let $\boldsymbol{X} \in \R^{n}$ be a vector denoting the $n$
measurements we intend to fit with a model depending on $p$ parameters
denoted by $\boldsymbol{\theta} \in \R^{p}$. For our model we assume
that the value $X_k$ is given by a normal distribution
$\boldsymbol{\emph{N}}(\mu_k, \sigma_k^2)$. The mean value $\mu_k$
must obviously depend on the parameter set $\boldsymbol{\theta}$. Whereas
the variance $\sigma_i^2$ is not influenced by the
parameters and we assume that $\sigma_k^2 = 1/2$ for all $n$
measurements. This leads us to the
\href{http://planetmath.org/encyclopedia/Distribution.html}
{probability density function} for
$X_k$
%
\begin{eqnarray}\label{PDF}
p(X_k|\boldsymbol{\theta}) =
 \frac{1}{\sqrt{\pi}}
 \exp\left(-(X_k - \mu_k(\boldsymbol{\theta}))^2\right)
\end{eqnarray}
%
which gives rise to the
\href{http://planetmath.org/encyclopedia/LikelihoodFunction.html}
{likelihood function}
%
\begin{eqnarray}\label{likelyhood}
L(\boldsymbol{\theta}|\boldsymbol{X}) =
 \pi^{-\frac{n}{2}}
 \exp\left(- \sum_{k=0}^{n} (X_k - \mu_k(\boldsymbol{\theta}))^2\right)
\end{eqnarray}
%
and the more convenient log likelihood function
%
\begin{eqnarray}\label{loglikelyhood}
l(\boldsymbol{\theta}|\boldsymbol{X}) =
 - \frac{n}{2}\ln(\pi)
 - \sum_{k=0}^{n}(X_k - \mu_k(\boldsymbol{\theta}))^2
\end{eqnarray}
%
The Fisher Information Matrix $\boldsymbol{I}$ is defined by
\begin{eqnarray}\label{Fisher}
\boldsymbol{I}_{i, j}(\boldsymbol{\theta})) =
\mbox{\bf E}
\left(
-\frac{\partial^2 \, l(\boldsymbol{\theta}|\boldsymbol{X})}
{\partial \theta_i \; \partial \theta_j}
\right)
\end{eqnarray}
where {\bf E} denotes the
\href{http://planetmath.org/encyclopedia/ExpectedValue.html}
{expectation value} and $i$ and $j$ are in
$1, \ldots, p$.
%
\begin{eqnarray}
\boldsymbol{I}_{i, j}(\boldsymbol{\theta}))
& = &
\mbox{\bf E}
\left(
-\frac{\partial}
{\partial \theta_i}
\left(
\frac{\partial \, l(\boldsymbol{\theta}|\boldsymbol{X})}
{\partial \theta_j}
\right)
\right)\\
& = &
\mbox{\bf E}
\left(
-2 \frac{\partial}
{\partial \theta_i}
\sum_{k=0}^{n}(X_k - \mu_k(\boldsymbol{\theta}))
\frac{\mu_k(\boldsymbol{\theta})}{\partial \theta_j}
\right)\\
& = &
\mbox{\bf E}
\left(
2 \sum_{k=0}^{n}
\frac{\mu_k(\boldsymbol{\theta})}{\partial \theta_i}
\frac{\mu_k(\boldsymbol{\theta})}{\partial \theta_j}
- 2
\sum_{k=0}^{n}
(X_k - \mu_k(\boldsymbol{\theta}))
\frac{\partial^2 \, \mu_k(\boldsymbol{\theta})}
{\partial \theta_i \; \partial \theta_j}
\right)\\
& = &
2 \sum_{k=0}^{n}
\frac{\mu_k(\boldsymbol{\theta})}{\partial \theta_i}
\frac{\mu_k(\boldsymbol{\theta})}{\partial \theta_j}
\end{eqnarray}
%
In the last equality we made use of the fact that the expectation
value of $X_k$ is $\mu_k(\boldsymbol{\theta})$.

\end{document}


\subsection{Memory organization}

CPU can address up to $2^{24}$ words, whole memory space is linear. Everything
is in one memory space, there is nothing like IO space, program space, data
space. MARK II CPU following Von Neumann scheme, so program and also data is in
one space. Peripherals and IO devices should be mapped there too.

There are two instruction for working with memory. One is LD for reading from
memory, and second is ST for writing into memory. Both instruction can use
absolute addressing mode (address is part of instruction) or indirect
addressing with register (address is stored in register).

\subsubsection{Stack}

Stack is used for storing returning address when calling subroutines or
interrupts. It grow from up to down. So, you should set SP at end of ram.

You can also use stack for storing your variables/registers etc. There is two
special functions for that.

\begin{itemize}
    \item \textbf{PUSH} - store data into stack and decrement SP
    \item \textbf{POP} - take data from stack and increment SP
\end{itemize}