\documentclass{article}
\usepackage[minionint,mathlf,textlf]{MinionPro} % To gussy up a bit
\usepackage[margin=1in]{geometry}
\usepackage{graphicx} % For .eps inclusion
%\usepackage{indentfirst} % Controls indentation
\usepackage[compact]{titlesec} % For regulating spacing before section titles
\usepackage{adjustbox} % For vertically-aligned side-by-side minipages
\usepackage{array, mathrsfs, mathrsfs, mhchem, amsmath} % For centering of tabulars with text-wrapping columns
\usepackage{hyper ref}

\newcommand{\Lapl}{\mathscr{L}}

\pagenumbering{gobble}
\setlength\parindent{0 cm}
\begin{document}
\large

\section*{Introduction to LTI systems}

Imagine a system as a black box to which we can supply an input $x(t)$ and measure an output, $y(t)$. [Draw a block diagram.] To describe how the system works, we would like to find a mathematical representation for the relationship between $x(t)$ and $y(t)$. You can imagine how we might approach this experimentally, by supplying simple inputs like pulses, step functions, or ramps and measuring the resulting output timecourse. \\

It would make our life much easier if we could make a few simplifying assumptions about the system. For example, it would be great if we got the same output every time we supply the same input: this system property is called \textit{time invariance} and its utility is probably clear. It would also be handy if the system is \textit{linear}, i.e., once we have determined the outputs $y_1(t)$ and $y_2(t)$ for two inputs $x_1(t)$ and $x_2(t)$, then we should be able to predict that the output for $ax_1(t) + bx_2(t)$ is  $ay_1(t) + by_2(t)$. Why is this second property so useful?\\

Recall that the Dirac delta distribution $d(t)$ is defined to have integral unity and the properties:
\[ \delta(t)=\begin{cases}
    \infty, & t = 0\\
    0, & t \neq 0
  \end{cases} \]

Any input function $x(t)$ can be represented as a time-offset combination of (Dirac) delta distributions. So if we know the system's response to a delta distribution input, and the system is linear, then we can predict the system's output for any input! The response to the Dirac delta distribution input deserves its own name -- the \textit{impulse response function} -- and can be used to fully describe a linear, time-invariant (LTI) system.

\section*{Introduction to negative feedback}

Many biological processes have evolved within the context of stable internal conditions. The cyanobacterial clock we studied earlier assumed, for example, that there would be a generous supply of ATP with which to phosphorylate each substrate, that the pH would permit the proteins to stay folded, and many other implicit requirements which could only be considered reasonable because of the cell's active efforts to maintain consistent internal conditions despite a variable environment -- a process called homeostasis. Biological systems designed to maintain some variable at a constant value are thus essential for permitting all of the other qualities of life.\\

Most such systems share a quality in common: the system's output is monitored and used to regulate the system's activity through negative feedback. Why? [Audience response.] Here is how we would draw the corresponding block diagram. Notice that we consider this feedback to be combined with the input \textit{before} it enters the block: in this way, the system represented by the block remains linear and time-invariant. More generally, some processing might be done to the output signal before it is fed back [draw in another box]. For example, we will soon compare the value of responding proportionally to the output, to the derivative of the output, and to the integral of the output. At the moment, however, we need to discuss how to calculate what the system output will be.

%As an example, consider the biosynthesis pathway that converts threonine to isoleucine. A Goldilocks concentration of isoleucine is needed: making too much is potentially poisonous and limits threonine availability; making too little limits protein synthesis. Regulation is achieved through allosteric inhibition of the first enzyme in the pathway by isoleucine: when the isoleucine concentration gets high enough, no more isoleucine is made. What type of feedback is this? [Accept student input. Then, discuss how the block diagram for this negative feedback would be drawn.]

\section*{Convolution}

Consider first a system with no feedback and suppose that we have determine the impulse response function, $h(t)$ (recall that this is the system's response to a DDD input). What is the system's output $y(t)$ for an arbitrary input $x(t)$?

Suppose as an example that we would like to calculate $y(5)$, i.e. the output at time $t=5$ seconds. Imagine breaking the input down into small``bins" in the range 0 to 5 seconds. We will calculate how input from each bin contributes to the output at $t=5$.

Consider the bin centered at $\tau$ ($0 \leq \tau \leq t$). Since the bins are small, we can think of the input in each bin as instantaneous, and represent it by a multiple of the delta function centered a $\tau$: $x(\tau)\delta(t-\tau)$. The impulse response function tells us that the contribution from this bin to the output at time $t$ will be $x(\tau)h(t-\tau)$. If we sum up the contributions from all bins,

\[ y(t) = \int_0^t x(\tau) \, h(t - \tau) \, d\tau  = x(t) \ast h(t) \]

This type of integral is a convolution of $x$ and $h$ (represented by the $\ast$ symbol here). Similarly, for our system with (unmodified) negative feedback:

\[ y(t) = \int_0^t \left[ x(\tau) - y(\tau) \right] \, h(t - \tau) \, d\tau  = \left[ x(t) - y(t) \right] \ast h(t) \]

Notice that $y(t)$ occurs on both sides of the equation -- it could be challenging to compute if not for a method we now introduce, called the Laplace transform.

\section*{Laplace transforms}

The Laplace transform of a real function $f(t)$ defined for $t > 0$ is:

\[ \Lapl \left[ f(t) \right] \triangleq \hat{f}(s) = \int_0^{\infty} \exp \left(-st \right) \, f(t) \, dt\]

The result of the transform is a function of $s$, a variable in frequency space (inverse time).  An inverse Laplace transform also exists, but is difficult to implement; usually we just look up $f(t)$ for $\hat{f}(s)$, and even $\hat{f}(s)$ for $f(t)$, in a reference table to save time However, here is one example of how the calculation is performed. Suppose the original function is:

\[  f(t)=\begin{cases}
    e^{- \alpha t}, & t \geq 0\\
    0, & t < 0
  \end{cases} \]

In this case we can plug in to the definition and integrate:

\begin{eqnarray*}
\Lapl \left[ f(t) \right]  & = & \int_0^{\infty} e^{-s t} e^{- \alpha t}\, dt\\
& = & - \frac{1}{s + \alpha} \left.  e^{-(s + \alpha)t} \right|_0^{\infty}\\
& = &  \frac{1}{s + \alpha}
\end{eqnarray*}

This particular Laplace transform is worth memorizing because exponentially-decaying responses are commmon in systems analysis.\\

Laplace transforms convert derivatives and integrals into algebraic expressions. For example, suppose we would like to calculate the Laplace transform of $df/dt$. We make use of integration by parts:

\[ \int_0^{\infty} u \, dv = \left. uv \right|_0^{\infty} - \int_0^{\infty} v \, du \]

Plugging in with  $dv = \frac{df}{dt} \, dt$ and $u = e^{-st}$,

\begin{eqnarray*}
\Lapl \left[ \frac{d\, f}{dt} \right]  & = & \int_0^{\infty} e^{-s t} \frac{d\, f}{dt} \, dt\\
& = & \left. e^{-s t} f(t) \right|_0^{\infty} + s \int_0^{\infty} f(t) e^{-st} \, dt\\
& = &  -f(0) + s \hat{f}(s)
\end{eqnarray*}

Likewise, it is easy to show that:

\[ \Lapl \left[ \int_0^{\infty} f(t) \, dt \right] = \frac{\hat{f}(s)}{s} \]

This makes it easy to find solutions to systems of differential equations, since we can ``eliminate" variables in frequency space through substitution. The Laplace transform also works miracles on convolutions:

\[ \Lapl \left[x(t) \ast h(t) \right] = \hat{x}(s) \hat{h}(s) \]

which will turn out to be very helpful when calculating the system's output. When we begin on Tuesday, we'll use these properties to examine how simple systems with negative feedback behave.

%\section*{Application:analysis of open loop systems}
%
%Consider a signaling cascade where the abundance of an input signaling molecule, $a(t)$, influences the abundance of an output signaling molecule, $c(t)$, via an intermediate, $b(t)$. Specifically we assume
%
%\begin{eqnarray*}
%\frac{db}{dt} & = & k_a a -  \gamma_b b\\
%\frac{dc}{dt} & = & k_b b - \gamma_c c\\
%\end{eqnarray*}
%
%This might be applicable if $b$ and $c$ are continuously subject to degradation and are produced enzymatically within the linear range of their respective enzymes. We would like to find an expression for $c(t)$ given an input $a(t)$. We begin by using the fact that the Laplace operator is linear, and the identity described above, to take the Laplace transform of both equaions:
%
%\begin{eqnarray*}
%s \hat{b}(s) - b(0) & = & k_a \hat{a}(s)  - \gamma_b\hat{b}(s)\\
%s \hat{c}(s) - c(0) & = & k_b \hat{b}(s) - \gamma_c \hat{c}(s)
%\end{eqnarray*}
%
%Now, we simply solve for $\hat{c}(s)$ by rearrangement:
%
%\begin{eqnarray*}
%\hat{c}(s) & = & \frac{1}{s+\gamma_c} \left[ k_b \hat{b}(s) + c(0) \right]\\
%& = & \frac{1}{s+\gamma_c} \left[ \frac{k_b}{s+\gamma_b} \left( k_a \hat{a}(s) + b(0) \right) + c(0) \right]\\
%& = & \frac{k_a k_b \hat{a}(s)}{\left( s + \gamma_b \right) \left( s + \gamma_c \right)} + \frac{k_b b(0)}{\left( s + \gamma_b \right) \left( s + \gamma_c \right)} + \frac{c(0)}{s + \gamma_c} = G(s) \hat{a}(s) + \textrm{ initial condition terms}
%\end{eqnarray*}
%
%Notice that this expression has two parts: one is proportional to the input, and the other depends only on the initial conditions. We have introduced the notation $G(s)$ for the \textit{transfer function}, which is the ratio between the transforms of the output and input in the special case where initial values are zero. We are primarily interested in the input response, so will ignore the initial condition terms here to simply the algebra (a full solution would employ the same techniques used below.) Therefore we are interested in findining
%
%\[ c(t) \approx \Lapl^{-1} \left[ G(s) \hat{a}(s) \right] = \Lapl^{-1} \left[ \frac{k_a k_b \hat{a}(s)}{\left( s + \gamma_b \right) \left( s + \gamma_c \right)} \right]  \]
%
%Let's suppose that our input function $a(t)$ is a unit step function at time zero; then, according to a table of Laplace transforms, $\hat{a}(s) = 1/s$, so we need to calculate:
%
% \[ c(t) =  k_a k_b \, \Lapl^{-1} \left[ \frac{1}{s \left( s + \gamma_b \right) \left( s + \gamma_c \right)} \right] =  \frac{x}{s} + \frac{y}{s + \gamma_b} + \frac{z}{s + \gamma_c} \]
%
%for some constants $x, y, z$ (assuming the denominators are distinct). Once we find the constants, we can easily handle each term in the inverse Laplace transform because we already know that
%
%\[ \Lapl \left[ e^{-\alpha t} \right] = \frac{1}{s+\alpha} \implies \Lapl^{-1} \left[ \frac{1}{s+\alpha}\right] = e^{-\alpha t} \]
%
%Using partial fractions, we find that:
%
%\begin{eqnarray*}
%c(t) & = & k_a k_b \, \Lapl^{-1} \left[ \frac{1}{s\gamma_b \gamma_c } - \frac{1}{\gamma_b (s + \gamma_b)(\gamma_c - \gamma_b)} - \frac{1}{\gamma_c(s + \gamma_c)(\gamma_b - \gamma_c)} \right]\\
%& = & \frac{k_a k_b}{\gamma_b \gamma_c} \left( 1 - \frac{\gamma_c e^{-\gamma_b t}}{\gamma_c - \gamma_b} - \frac{\gamma_b e^{-\gamma_c t}}{\gamma_b - \gamma_c} \right)
%\end{eqnarray*}
%
%This result may be underwhelming since we can see that at long times, $c(t) = k_ak_b/\gamma_b\gamma_c$, which is the same result we could have reached by just setting all of the derivatives equal to zero. We will see however that the same approach applied to control systems with feedback can give surprising results.

\end{document}

lectures/Lecture 13 - Simple Negative Feedback Loop; Nyquist Criterion for Stability/lecture anatomy of a control loop.tex


\section{Results}
In the following, we present an evaluation of the predictors discussed in section \cref{sec:metadata}.

\begin{table}
\centering
\begin{tabular}{| l | *{5}{c|}}
																				\cline{1-2}
valet		& 1																\\	\cline{1-3}
serviteur	& 0.367	& 1 													\\	\cline{1-4}
domestique	& 0.116	& 0.072 	& 1											\\	\cline{1-5}
p\^atissier	& 0.148	& 0.087		& 0.087			& 1							\\ 	\cline{1-6}
cuisinier 	& 0.211	& 0.156 	& 0.078			& 0.567			& 1			\\	\hline
 			& valet &serviteur	& domestique	&p\^atissier	& cuisiner	\\	\hline
\end{tabular}
\caption{Cosine distance for given word vectors using pre-trained word2vec model, with skip-gram architecture and dim=700.}
\label{tab:word_sim}
\end{table}

\subsection{Profession predictor}
In order to evaluate the precision of this predictor, we decided on utilizing the numerical representations of word embeddings to get a measure out of it, since the multiple possible outcomes made it impossible to qualify it as a classification. We wanted to be able to take semantic similarity into account. Word embeddings can provide this, to a certain extent.

The pre-computed model we use is trained using the skip-gram model, which performs better than a continuous bag-of-words model for semantic similarities \cite{mikolov2013efficient}. The vectors are 700-dimensional and were computed on 1.6 billion words from French web domains

In effect this means we're able to get a numeric similarity between two words (or job-titles) by getting the cosine distance between their vector representations. We compare an extracted title with our hand-labeled title, and thus get a similarity score. This measure should be taken with a pinch of salt however, since the similarities weren't extensively tested on our job corpus. In \cref{tab:word_sim}, we see that the two highest scores are for the pairs `valet'-`serviteur' and `cuisinier'-`p\^atissier', which is as one would expect. However `domestique' has a surprisingly low similarity with both `valet' and `serviteur', which are semantically similar. Since the model uses PoS tags (i.e. `domestique\_n' to indicate it's a noun) to avoid ambiguity, this isn't due to confusion with its adjective form.

\begin{figure}
\centering
\includegraphics[width=.8\textwidth]{fig/count_vs_prox_bonheur.png}
\caption{Count vs Proximity predictor scores on \textit{Au Bonheur des Dames} characters. Points with score 1 are an exact match between two words. Characters are ordered by decreasing occurrence count. \textit{Note}: plots for other books are generally similar.}
\label{fig:count_vs_prox}
\end{figure}

The job predictor returns the 5 top guesses for a $c_i$'s job. In \cref{fig:count_vs_prox}, we show the result of the `count' and `proximity' predictors. In some cases, the job labels for the characters contain more than one possibility, which is why some characters have more points in the graph than others. The figure shows that the `count' predictor is far more present in the exact matches with the label, and `proximity' points are more pertinent when used for more minor characters.

\begin{table}
\centering
\begin{tabular}{| l | *{5}{c|}}
\hline
& \multicolumn{5}{ |c| }{Rank} \\ \cline{2-6}
					& 0		& 1 	&2 		& 3		& 4		\\ \hline
Individual ratio	& \textbf{0.41}	& 0.22	& 0.1	& 0.09	& 0.05	\\ \hline
Cumulative ratio	& 0.41	& 0.55	& 0.61	& 0.68	& 0.71	\\ \hline

\end{tabular}
\caption{Perfect match ratio for different ranks. The full character-set has 108 characters. The individual ratio is the ratio for only the given rank, and the cumulative is the ratio up until and including the given rank.}
\label{tab:match_ratio}
\end{table}

The results in \cref{fig:count_vs_prox} are encouraging, seeing as a majority of the characters (in this book, but also others) have an exact match between one its job-labels and at least one among the top 5 predictions. As an additional step, we look at the percentage of characters with exact matches in each of the 5 ranks in \cref{tab:match_ratio}. These were achieved using the `aggregate' predictor on the full book, with constant increments (c.f. figures below).

\begin{figure}
\centering
\includegraphics[width=.6\textwidth]{fig/rank_cpa.png}
\caption{Mean of all book and character scores grouped by 'rank' of prediction. Here the plots are of the `count', `proximity' and `aggregate' (first two combined) predictors. The bars represent the confidence interval for the point estimate.}
\label{fig:rank_cpa}
\end{figure}

To get an understanding of how the different guesses perform, in order, we plot the mean of all similarity scores (all books, all characters) grouped by the rank they were predicted in, in \cref{fig:rank_cpa}. The `aggregate' predictor is a combination of the other two, but with a higher weight given to the `count' predictor. We can see that it scores slightly higher than the `count' predictor for its first predictions.

\begin{figure}
\centering
\includegraphics[width=.6\textwidth]{fig/job_params.png}
\caption{A comparison of the different parameters for the job predictor. `full' indicates the prediction was made based on observations from the whole book, whereas `exposition' focuses only on the $k$ first occurrences (here $\max(\frac{1}{10}L_i, 10)$, where $L_i$ is the length of $c_i$'s document). `decreasing' indicates that the weight of the contributions of each occurrence decreases (by rate seen in \cref{sec:metadata}) with occurrences later in $c_i$'s document.}
\label{fig:job_params}
\end{figure}

The effect of the different parameters of the job predictor are shown in \cref{fig:job_params}. We can see that the best similarity score on rank 0 and 1 is achieved with the `full-constant' parameter, but for ranks 2, 3 and 4 it's the `exposition-constant' that is on top. It seems working with the full range of data available in a characters document is generally preferable.

Both \cref{fig:rank_cpa} and \cref{fig:job_params} were created with approx 3000 data points, split evenly between the 5 `rank' categories. There are 108 distinct characters among them, taken from the 5 different books described in \cref{ssec:data}. Given the limited nature of this data, we should take the results presented above as indicators, but not entirely deterministic. The precision of these evaluations would benefit from more labeled books, and a system of expert reviewers for the labels.

The results above seem to work in favour of hypotheses 1 and 2 discussed in \cref{sec:metadata}. On the one hand, the result is slightly better when using a proximity score, and we also work with a constrained window size (maximum 5 sentences, with character occurrence at center), which performs better than larger sizes. This indicates there is an information gain from looking at and weighting the data close to the character higher, as hypothesis 1 stipulates.

On the other, the predictor using only `exposition' occurrences (initial $\frac{1}{10}$th of total) has a performance very close to that of the `full' occurrences. Given that these occurrences are much fewer in number, and thus provide much less data overall, one can see that a lot of the metadata we're looking for will presumably be found within an exposition phase, as hypothesis 2 stipulates (first $k$ occurrences is called the `exposition' here).

\subsection{Gender predictor}
The evaluation of the gender predictor is more straightforward, since it is taken as a 2-class classification, i.e. we want to predict when a character is female. All characters were labeled with either a `m' (for male), `f' (for female) or `-' (for unknown) tag. The latter was given in cases where there wasn't a clear answer, for example when the predicted character name was used interchangeably for different family members (mother, father, children), or for animals of unknown gender. These characters were ignored in the classification metrics given below.

We provide the results for different feature generation schemes that we used, i.e. either all character $c_i$'s occurrences are taken, or only the ones where $c_i$ appears alone (filtered document). The accuracy, precision, recall and f-score metrics are shown in \cref{tab:gender_metrics}. Overall, the best performance is achieved when using the weighted features from the whole character documents. This is by a small margin however, so can't be considered conclusive. In part this is due to the greedy labeling of the name-gender predictor, since without it, there is a bigger gap in the ratio of guessed data points (approx. $7\%$) between the `solo' and `full' data.

This failing of the `solo' data seems to be an argument against our 3rd hypothesis in \cref{sec:metadata}, but can also be attributed to the fewness of data in our character documents, and the general nature of the extracted features (i.e. only small percentage of sentences will get positive or negative score off these features).

\begin{table}
\centering
\begin{tabular}{| >{\bf}l || *{5}{c|}}
\hline
		& Accuracy & Precision	& Recall & F-score & Known ratio\\ \hline \hline
GFNW	& 0.873 & 0.758 & 0.979	& 0.854	& 0.83 	\\ \hline
GSNW	& 0.878	& 0.793	& 0.938	& 0.859	& 0.81	\\ \hline
GFW		& 0.88	& 0.767	& 0.978	& 0.859	& 0.83 \\ \hline
GSW		& 0.869	& 0.779 & 0.938 & 0.851	& 0.81 \\ \hline

\end{tabular}
\caption{Comparison of different features and weights used on the gender prediction task.`G' is for gender, `F' means we used the full data, as opposed to `S' (for solo), where we worked only with sentences where the character occurs alone. `NW' means the scores are non-weighted, and `W' means they are weighted, with weights approximated from a logistic regression. The column 'Known ratio' indicates the ratio of data points for which the predictor was able to make a guess.}
\label{tab:gender_metrics}
\end{table}

We show the distribution of predicted and true labels in \cref{fig:gender}.
Interestingly, we see in \cref{fig:gender_dist} that the predictor tends to output more `female' labels than there are true data points of that category, and the opposite for the `male' category. We remarked on the problematic case of the neutral `il' in \cref{sssec:gender}. These results show that the bias even tends towards the opposite direction. This can be attributed to the efficiency of the multi-feature predictor, in that each feature contributes only a fraction of the result score. Additionally, the pronoun feature was shown to be less efficient and thus given a smaller weight than the other features.

\begin{figure}
\centering
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\linewidth]{fig/gender_dist.png}
\caption{Distribution of gender predictions and true labels.}
\label{fig:gender_dist}
\end{subfigure}
\hspace{1em}
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\linewidth]{fig/gender_error.png}
\caption{TP, TN, FP and FN rates for the gender predictions (`f' is said to be positive).}
\label{fig:gender_error}
\end{subfigure}
\caption{Gender predictor metrics.}
\label{fig:gender}
\end{figure}

What we're doing here can be considered a no-go, by ML standards. However, since we're using only these `hand-generated' features, and they are designed to adhere to as general standards as possible, the chance of overfitting is minimal. On top of this, we're using the weights generated by the model merely to confirm suspicions that we already had about each feature's importance.

For example, the score measuring specific pronouns in the window with $c_i$ is error-prone by design. The pronouns `il' and `elle' are among the most frequent words in the French language. The scores of specific titles or articles immediately preceding a $c_i$ occurrence is far more precise, and thus also less prone to error (or noise). It's safe to assume that these last two will have a higher weight than the first. This was confirmed by the weights given by our models.

As a sanity-check, we generated predictions on some unused books during training of the weights, and verified that results are similar to the ones we obtained in \cref{tab:gender_metrics} . Usually, they were a few percent lower, i.e. for \textit{Nana}, by Zola (66 characters), we get an accuracy of $82.1\%$, precision, recall and f-score of $75.8\%, 88\%, 81.5\%$ respectively and a known ratio of $0.848$.

By the nature of our features (specific word types or words occurring in window with $c_i$), about $20\%$ of data points remain undecided (neutral). A quick look at these characters indicates that none of these play a major role within the book, so we can assume this is due to a lack of data.

\begin{figure}
\centering
  \includegraphics[width=0.6\textwidth]{fig/sent_prop.png}
  \caption{Mean proportions of positive, negative and neutral sentences for reduced character documents. Here the mean for all characters are shown.}
  \label{fig:sent_prop}
\end{figure}

\subsection{Sentiment predictor}
The results of the sentiment predictor on the characters is meaningful mainly for major characters. The API used returns the result `neutral' for most sentences it receives (c.f. \cref{fig:sent_prop}. So for a small number of sentences, we will have only a handful that indicate any sentiment, according to the NLTK tool we use. This may be due to a justifiably conservative predicting scheme on the part of the text classifier, however it has as a consequence that we're unable to extract a truthful understanding around the sentiment pertaining to a character in a novel, which is often associated with hundreds of sentences, and a wide range of polar descriptions.

Some characters with obvious polarities associated with them (i.e. Mrs Aouada, from \textit{Le Tour du Monde en 80 Jours} should be positive, Hutin from \textit{Au Bonheur des Dames} should be negative) are predicted with the wrong or no polarity (c.f. \cref{tab:full_vs_red}).

As mentioned in \cref{sssec:sentiment}, we compared the extracted NLTK sentiment metrics with the LIWC \cite{liwc2015} `emopos' and `emoneg' variables, gotten on the full character documents for the top 5 characters in each of our 5 books. The results were proportionally similar (almost identical) when computed on the same filtered sentences we used for the NLTK sentiment score and the raw sentence, which is an indicator of the efficiency of the filtering. In this way, we were able to provide less words, i.e. a less computationally intense operation, while achieving as effective results.

We expected similar results, since both methods are dictionary based. However there seems to be less variability in the LIWC results, as shown for the characters in \cref{tab:full_vs_red}. All characters tested have higher positive emotion variable values than the negative, but there are some telling differences in the ratio between them. For example `MrsAouda' has a significantly higher pos-to-neg ratio than `Bourdoncle'. This is also reflected in the NLTK values extracted.

With additional resources, less limited access to the NLTK text sentiment classification API, we could have compromised less. In order to truly evaluate such a result, as we did for the `gender' predictor, we would need access to expert-reviewed labels for a set of books. Associated sentiment is too ambiguous a notion for us to make a decision about the less than obvious characters. We also didn't intend for this predictor to answer a precise question about a character's sentiment throughout a narrative, but rather to understand sentiment associated with a character like a bubble surrounding his or her actions.

\begin{table}
\centerfloat
\begin{tabular}{| l | l || *{6}{c|}}
\hline
& Doc size & Pos & Neg	& Neut & LIWC-pos & LIWC-neg & Count	\\ \hline \hline
\multirow{2}{*}{Denise} & reduced & 0.059 & 0.059 & \bf 0.882 & & & 51 \\ \cline{2-8}
& full & \bf 0.074 & 0.049 & 0.877	& 5.99 & 3.88 & 511 	\\ \hline

\multirow{2}{*}{Hutin} & reduced & 0.0	& 0.0 & \bf 1.00 & & & 12 \\ \cline{2-8}
& full & 0.032 & 0.032 & \bf 0.935	& 4.46 & 3.38 & 124	\\ \hline

\multirow{2}{*}{Bourdoncle}	& reduced & 0.0	& 0.0 & \bf 1.0 & & & 11 \\ \cline{2-8}
	& full & \bf 0.085 & 0.043 & 0.872 & 5.09 & 4.04 & 117 \\ \hline

\multirow{2}{*}{MrsAouda} & reduced	& 0.083	& \bf 0.167	&  0.88 & & &  12 \\ \cline{2-8}
	& full & \bf 0.062 & 0.039 & 0.899 & 6.47 & 2.60 & 129 \\ \hline

\end{tabular}

\caption{Performance of the sentiment predictor on some main characters. A character is said to be positive if it has a higher ratio than the negative, and vice-versa. The LIWC scores are given as they were retrieved, without any processing, so should be compared among themselves only, to get an idea of the proportion of pos-to-neg. `Count' contains the total occurrence count of the character.}
\label{tab:full_vs_red}
\end{table}

\vspace{3em}

%%%% PLOT MEAN JOB PREDICTIONS FOR PHILEASFOGG MFOGG AND FOGG AND THEN ALL THREE AGGREGATED > COST OF AMBIGUITY


%% LyX 2.0.6 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english, 12pt]{article}
 \usepackage{geometry}
 \geometry{
 letterpaper,
 left=1in,
 right=1in,
 top=1in,
 bottom=1in,
 bindingoffset=0mm
 }

\usepackage{natbib}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{hyperref}
\hypersetup{%
        pdftitle={A Concise Representation Shunn's Two-Dimensional Variable-Density MMS Solutions},
        pdfauthor={Tony Saad},
        pdfsubject={Pressure projection, variable density, variable-density, reacting flows},
        pdfkeywords={Pressure projection, variable density, variable-density, reacting flows},
        pdfview=FitH,
        pdfborder=0 0 0,        % make all links invisible, so the pdf looks good when printed
        pdffitwindow=true,      % window fit to page when opened
        pdfstartview={FitH},    % fits the width of the page to the window
        pdfnewwindow=true,      % links in new window
        bookmarksnumbered=true,
        breaklinks=true,%
        colorlinks=true, %% to produce a black & white document, use "false"
        urlcolor=darkblue, % used to be darkblue % color of external links (magenta)
        filecolor=darkblue, % used to be darkblue % color of file links
        citecolor=blue, % used to be black % color of text links to bibliography
        linkcolor=blue} % used to be black % color of internal links

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amstext}

\usepackage{times}
\usepackage{txfonts}

%\usepackage{txfonts}

\usepackage{babel}
\usepackage{cleveref}
\crefformat{equation}{Equation (#2#1#3)} % this is to remove the space...
\Crefname{equation}{Equation}{Equations}
\crefformat{equation}{(#2#1#3)}
\crefname{equation}{}{}

\crefformat{section}{\S#2#1#3}
\crefformat{subsection}{\S#2#1#3}
%\crefname{subsection}{\S}{\S}
\Crefname{section}{Section}{Sections}
\Crefname{subsection}{Section}{Sections}

\crefname{figure}{figure}{figures}
\Crefname{figure}{Figure}{Figures}

\begin{document}

\title{A Concise Representation Shunn's Two-Dimensional Variable-Density MMS Solutions}

\author{Tony Saad}

\maketitle

For all the solutions presented in this document, we use a simple mixing model for two streams given by
\begin{equation}
\frac{1}{\rho} =\frac{1-f}{{\rho_0}}+\frac{f}{{\rho_1}}
\end{equation}
where the mixture fraction $f$ is transported via
\begin{equation}
\frac{\partial \rho f}{\partial t} + \nabla\cdot\mathbf{u}\rho f = \nabla \rho \Gamma \cdot \nabla f + R_f
\end{equation}

This document simplifies the presentation and implementation of two
important variable density analytical solutions using the MMS approach.
Both can be found in \cite{shunn_moin2012}.

\section{Corrugated-Front MMS}
For this problem, we set
\begin{equation}
\hat{x} = u_f t - x + a \cos[k (v_f t - y)];
\end{equation}
\begin{equation}
f = \frac{1 + \tanh(b \hat{x} e^{-w t})}{1 + \tfrac{\rho0}{\rho1} + (1 + \tfrac{\rho0}{\rho1})\tanh(b \hat{x} e^{-w t})}
\end{equation}
\begin{equation}
u = \frac{\rho_1 - \rho_0}{\rho}\left\{-\omega \hat{x} + \frac{ \omega \hat{x} - u_f}{\exp\left[2 b \hat{x} \exp(-\omega t)\right] + 1 } + \frac{\omega \ln\left[\exp(2b\hat{x} \exp(-\omega t) + 1)\right]}{2 b \exp(-\omega t)}\right\}
%u := (r1 - r0)/\rho*(-w xh + (w xh - uf)/(
%     Exp[2 b xh Exp[-w t]] + 1) + (w Log[Exp[2 b xh Exp[-w t]] + 1])/(
%     2 b Exp[-w t]));
\end{equation}
\begin{equation}
v = v_f
\end{equation}
The continuity equation does not require a source term. The mixture fraction equation requires the addition of a source term. Let
\begin{align*}
s_0 & = e^{t w}; \\
s_1 & = u_f t - x + a \cos[k (v_f t - y)]; \\
s_2 & = e^{2 b s_1/s_0}
%s2 := E^((2 b s1)/s0);
\end{align*}

\begin{align*}
R_f = & \frac{r_0 r_1 s_2}{s_0^2 (r_0 + r_1 s_2)^3} \times \\
      & \left \{-4 A b^2 r_0 - 2 a^2 A b^2 k^2 r_0 + 4 A b^2 r_1 s_2 +
 2 a^2 A b^2 k^2 r_1 s_2 + 2 b r_0 r_1 s_0 u_f \right. \\
      & + 2 b r_1^2 s_0 s_2 u_f -2 b r_0^2 s_0 t u_f w - 2 b r_0 r_1 s_0 s_2 t u_f w + 2 b r_0^2 s_0 w x \\
      &+ 2 b r_0 r_1 s_0 s_2 w x +2 a b s_0 (r_0 + r_1 s_2) (A k^2 - r_0 w) \cos[k (t v_f - y)] \\
      &+
 2 a^2 A b^2 k^2 (r_0 - r_1 s_2) \cos[2 k (t v_f - y)] +r_0^2 s_0^2 w \ln[1 + s_2] \\
 & - r_0 r_1 s_0^2 w \ln(1 + s_2) +r_0 r_1 s_0^2 s_2 w \ln(1 + s_2) \\
 & \left . - r_1^2 s_0^2 s_2 w \ln(1 + s_2)\right\}
\end{align*}

\section{Oscillating MMS}
For this periodic problem, we set
\begin{align*}
\hat{x} = & x - u_f t \\
\hat{y} = & y - \varv_f t \\
\bar{x} = & \pi k \hat{x} \\
\bar{y} = & \pi k \hat{y} \\
\bar{t} = & \pi \omega t
\end{align*}

\begin{equation}
	f = \frac{\sin (\bar{x} ) \sin (\bar{y}) \cos (\bar{t}) + 1}
	         {\left(1-\frac{\rho_0}{\rho_1}\right) \sin (\bar{x}) \sin (\bar{y}) \cos (\bar{t})+\left(1 + \frac{{\rho_0}}{{\rho_1}}\right)};
\end{equation}

\begin{equation}
\rho u=\left(\frac{-\omega}{4 k}\right)({\rho_1}-{\rho_0}) \cos (\bar{x}) \sin (\bar{y}) \sin (\bar{t})
\end{equation}

\begin{equation}
\rho \varv= \left(\frac{-\omega}{4 k}\right)({\rho_1}-{\rho_0}) \sin (\bar{x}) \cos (\bar{y}) \sin (\bar{t})
\end{equation}
The source term for the continuity equation is
\begin{equation}
R_\rho=\frac{1}{2} \pi  k ({\rho_0}-{\rho_1}) \cos (\bar{t}) \left[ {u_f} \cos (\bar{x}) \sin (\bar{y})+{\varv_f} \sin (\bar{x}) \cos (\bar{y})\right]
\end{equation}
so that
\begin{equation}
\frac{\partial \rho}{\partial t} + \nabla\cdot\rho\mathbf{u} = R_\rho
\end{equation}
The source term for the mixture fraction is given by $R_f$ such that

\begin{align*}
&s_0  = \cos(\pi \omega t),\\
&s_1  = \sin(\pi \omega t),\\
&s_2  = \cos(k \pi x),\\
&s_3  = \sin(k \pi x),\\
&s_4  = \cos(k \pi y),\\
&s_5  = \sin(k \pi y), \\
&s_6  = \sin[k \pi (x -t u_f)], \\
&s_7  = \sin[k \pi (y -t \varv_f)], \\
&s_8 = \cos[k \pi (x -t u_f)], \\
&s_9 = \cos[k \pi (y -t \varv_f)], \\
&s_{10} = \rho_0 + \rho_1, \\
&s_{11} = \rho_0 - \rho_1 \\
& A \equiv \rho \Gamma = \text{constant}
\end{align*}

\begin{align*}
R_f  = & -\frac{\pi  \rho_1}{4 (s_{10} - s_0 s_6 s_7 s_{11} )^3}\times \\
       &\left\{
       16 A k^2 \pi \rho_0 s_0^2 s_9^2 s_{11} s_6^2 \right. \\
& - 16 A k^2 \pi \rho_0 s_0 s_{10} s_6 s_7
  + 16 A k^2 \pi \rho_0 s_0^2 s_8^2 s_{11} s_7^2 \\
& + 16 A k^2 \pi \rho_0 s_0^2 s_{11} s_6^2 s_7^2
  + 2 k s_0 s_8 s_{10}^3 s_7 u_f \\
& - 6 k \rho_0^2 s_0^2 s_8 s_{11} s_6 s_7^2 u_f
  - 12 k \rho_0 \rho_1 s_0^2 s_8 s_{11} s_6 s_7^2 u_f \\
& - 6 k \rho_1^2 s_0^2 s_8 s_{11} s_6 s_7^2 u_f
  + 6 k s_0^3 s_8 s_{10} s_{11}^2 s_6^2 s_7^3 u_f \\
& - 2 k s_0^4 s_8 s_{11}^3 s_6^3 s_7^4 u_f
  + 2 k s_0 s_9 s_{10}^3 s_6 \varv_f \\
& - 6 k \rho_0^2 s_0^2 s_9 s_{11} s_6^2 s_7 \varv_f
  - 12 k \rho_0 \rho_1 s_0^2 s_9 s_{11} s_6^2 s_7 \varv_f \\
& - 6 k \rho_1^2 s_0^2 s_9 s_{11} s_6^2 s_7 \varv_f
  + 6 k s_0^3 s_9 s_{10} s_{11}^2 s_6^3 s_7^2 \varv_f \\
& - 2 k s_0^4 s_9 s_{11}^3 s_6^4 s_7^3 \varv_f
  - 2 \rho_0 s_0 s_1 s_9^2 s_{10} s_{11} s_6^2 w \\
& + 4 \rho_0 s_1 s_{10}^2 s_6 s_7 w
  + 2 \rho_0 s_0^2 s_1 s_9^2 s_{11}^2 s_6^3 s_7 w \\
& - 5 \rho_0 s_0 s_1 s_{10} s_{11} s_7^2 w
  + 3 \rho_0 s_0 s_1 s_8^2 s_{10} s_{11} s_7^2 w \\
& - 3 \rho_0 s_0 s_1 s_{10} s_{11} s_6^2 s_7^2 w
  + 2 \rho_0 s_0^2 s_1 s_8^2 s_{11}^2 s_6 s_7^3 w \\
& + 4 \rho_0^2 s_0^2 s_1 s_{11} s_6^3 s_7^3 w
 \left. - 4 \rho_0 \rho_1 s_0^2 s_1 s_{11} s_6^3 s_7^3 w \right\}
%       &  \left \{ k (\rho_0-\rho_1) \cos ^2(\bar{t}) \left(-s_0 -s_1 + s_2 + s_3 + s_4 - s_5 - s_6\right) \right.\\
%	  & + k (\rho_0+\rho_1) \cos (\bar{t}) \left( s_7 + s_8 \right) \\
%	  & + k (\rho_0-\rho_1)^2 \sin ^2(\bar{x}) \sin ^2(\bar{y}) \cos ^3(\bar{t}) (u_f \cos (\bar{x}) \sin (\bar{y})+\varv_f \sin (\bar{x}) \cos (\bar{y})) \\
%	  &\left. +\frac{1}{2} \rho_0 w  \left[s_7      +\sin (\bar{y})  \left(s_8 + s_{11}\right) \right] \right\}
\end{align*}

%\notice{shunn_verification_2012}

\bibliographystyle{apalike}
\bibliography{varden-mms}
\nocite{*}
\end{document}


%\documentclass[UTF8]{ctexart} % use larger type; default would be 10pt
\documentclass[a4paper]{article}
\usepackage{../mqc}

\title{\textbf{Modern Quantum Chemistry, Szabo \& Ostlund}\\HW}
\author{wsr
\vspace{5pt}\\
}
\date{\today} % Activate to display a given date or no date (if empty),
         % otherwise the current date is printed

\begin{document}
% \boldmath

\maketitle

\tableofcontents

\newpage

\setcounter{section}{4}
\section{Pair and Coupled-pair Theories}
\subsection{The Independent Electron Pair Approximation}
\ex{5.1}
\subex{a.}
\begin{align}
{^1 E}_{\corr}(\text{FO}) &= \dfrac{|\Braket{1\bar{1}||2\bar{2}}|^2}{\varepsilon_1 + \varepsilon_1 - \varepsilon_2 - \varepsilon_2} \notag\\
&= \dfrac{\abs{\Braket{1\bar{1}|2\bar{2}} - \Braket{1\bar{1}|\bar{2} 2}}^2}{2\varepsilon_1 - 2\varepsilon_2} \notag\\
&= \dfrac{\abs{[12|\bar{1}\bar{2}] - [1\bar{2}|\bar{1} 2]}^2}{2\varepsilon_1 - 2\varepsilon_2} \notag\\
&= \dfrac{K_{12}^2}{2(\varepsilon_1 - \varepsilon_2)}
\end{align}
\subex{b.}
\begin{align}
{^1 E}_{\corr} &= \Delta - \Delta\sqrt{1 + \dfrac{K_{12}^2}{\Delta^2}} \notag\\
&= \Delta - \Delta\qty(1 + \dfrac{K_{12}^2}{2\Delta^2}) \notag\\
&= - \dfrac{K_{12}^2}{2\Delta}) \notag\\
&\approx \dfrac{K_{12}^2}{2(\varepsilon_1 - \varepsilon_2)}
\end{align}

\ex{5.2}
From Eq. 5.9a and 5.9b in the textbook, we get
\begin{align}
\sum_{t<u} c_{1_i\bar{1}_i}^{tu} \Braket{\Psi_0 | \sH | \Psi_{1_i\bar{1}_i}^{tu}} &= e_{1_i\bar{1}_i} \\
\Braket{\Psi_{1_i\bar{1}_i}^{rs} | \sH | \Psi_0} + \sum_{t<u} \Braket{\Psi_{1_i\bar{1}_i}^{rs} | \sH - E_0 | \Psi_{1_i\bar{1}_i}^{tu}} c_{1_i\bar{1}_i}^{tu}  &= e_{1_i\bar{1}_i} c_{1_i\bar{1}_i}^{rs}
\end{align}
$ \therefore $
\begin{align}
c_{1_i\bar{1}_i}^{2_i\bar{2}_i} \Braket{\Psi_0 | \sH | \Psi_{1_i\bar{1}_i}^{2_i\bar{2}_i}} &= e_{1_i\bar{1}_i} \label{5.2a}\\
\Braket{\Psi_{1_i\bar{1}_i}^{2_i\bar{2}_i} | \sH | \Psi_0} + \sum_{t<u} \Braket{\Psi_{1_i\bar{1}_i}^{2_i\bar{2}_i} | \sH - E_0 | \Psi_{1_i\bar{1}_i}^{tu}} c_{1_i\bar{1}_i}^{tu}  &= e_{1_i\bar{1}_i} c_{1_i\bar{1}_i}^{2_i\bar{2}_i}   \label{5.2b}
\end{align}
$ \eqref{5.2a} $ gives
\begin{align}
K_{12} c_{1_i\bar{1}_i}^{2_i\bar{2}_i} = e_{1_i\bar{1}_i}
\end{align}
$ \eqref{5.2b} $ gives
\begin{align}
K_{12} + \sum_{jk} \Braket{\Psi_{1_i\bar{1}_i}^{2_i\bar{2}_i} | \sH - E_0 | \Psi_{1_i\bar{1}_i}^{2_j\bar{2}_k}} c_{1_i\bar{1}_i}^{2_j\bar{2}_k}  &= e_{1_i\bar{1}_i} c_{1_i\bar{1}_i}^{2_i\bar{2}_i}
\end{align}
Since
\begin{align}
\Braket{\Psi_{1_i\bar{1}_i}^{2_i\bar{2}_i} | \sH - E_0 | \Psi_{1_i\bar{1}_i}^{2_j\bar{2}_k}} c_{1_i\bar{1}_i}^{2_j\bar{2}_k} = \left\{
\mqty{2\Delta & j=k=i\\
0 & j=k\neq i\\
0 & i=j=\neq k}
\right.
\end{align}
we have
\begin{align}
K_{12} + 2\Delta c_{1_i\bar{1}_i}^{2_i\bar{2}_i}  &= e_{1_i\bar{1}_i} c_{1_i\bar{1}_i}^{2_i\bar{2}_i}
\end{align}

\ex{5.3}
\begin{align}
{^2 E}_{\corr}(\text{FO}) &= \sum_i \dfrac{\abs{\Braket{1_i\bar{1}_i||2_i\bar{2}_i}}^2}{\varepsilon_1 + \varepsilon_1 - \varepsilon_2 - \varepsilon_2} \notag\\
&= 2\times \dfrac{K_{12}^2}{2(\varepsilon_1 - \varepsilon_2)} \notag\\
&= \dfrac{K_{12}^2}{(\varepsilon_1 - \varepsilon_2)}
\end{align}

\subsubsection{Invariance under Unitary Transformations: An Example}
\ex{5.4}
\begin{align}
\ket{a\bar{a} b\bar{b}} &= 2^{-1/2} \qty(\ket{1_1\bar{a} b\bar{b}} + \ket{1_2\bar{a} b\bar{b}}) \notag\\
&= 2^{-1} \qty(\ket{1_1\bar{1}_1 b\bar{b}} + \ket{1_1\bar{1}_2 b\bar{b}}  + \ket{1_2\bar{1}_1 b\bar{b}} + \ket{1_2\bar{1}_2 b\bar{b}}) \notag\\
&= 2^{-2} (
\ket{1_1\bar{1}_1 1_1\bar{1}_1} - \ket{1_1\bar{1}_1 1_1\bar{1}_2} - \ket{1_1\bar{1}_1 1_2\bar{1}_1} + \ket{1_1\bar{1}_1 1_2\bar{1}_2} \notag\\
&{}\quad + \ket{1_1\bar{1}_2 1_1\bar{1}_1} - \ket{1_1\bar{1}_2 1_1\bar{1}_2} - \ket{1_1\bar{1}_2 1_2\bar{1}_1} + \ket{1_1\bar{1}_2 1_2\bar{1}_2} \notag\\
&{}\quad + \ket{1_2\bar{1}_1 1_1\bar{1}_1} - \ket{1_2\bar{1}_1 1_1\bar{1}_2} - \ket{1_2\bar{1}_1 1_2\bar{1}_1} + \ket{1_2\bar{1}_1 1_2\bar{1}_2} \notag\\
&{}\quad + \ket{1_2\bar{1}_2 1_1\bar{1}_1} - \ket{1_2\bar{1}_2 1_1\bar{1}_2} - \ket{1_2\bar{1}_2 1_2\bar{1}_1} + \ket{1_2\bar{1}_2 1_2\bar{1}_2}
) \notag\\
&= 2^{-2} (
2\ket{1_1\bar{1}_1 1_1\bar{1}_1}   + 2\ket{1_1\bar{1}_1 1_2\bar{1}_2}
- 2\ket{1_1\bar{1}_2 1_1\bar{1}_2} - 2\ket{1_1\bar{1}_2 1_2\bar{1}_1}
) \notag\\
&= 2^{-2} ( 2\ket{1_1\bar{1}_1 1_2\bar{1}_2} - 2\ket{1_1 \bar{1}_1 1_2\bar{1}_2}  ) \notag\\
&= \ket{1_1\bar{1}_1 1_2\bar{1}_2}
\end{align}

\ex{5.5}
\begin{align}
\Braket{\Psi_0 | \sH | \Psi_{a\bar{a}}^{**}} &= 2^{-1/2}\qty(\Braket{\Psi_0 | \sH | \Psi_{a\bar{a}}^{r\bar{r}}} + \Braket{\Psi_0 | \sH | \Psi_{a\bar{a}}^{s\bar{s}}}) \notag\\
&= 2^{-1/2}\qty(2\times \dfrac{1}{2}K_{12} ) \notag\\
&= 2^{-1/2} K_{12}
\end{align}
\begin{align}
\Braket{\Psi_{a\bar{a}}^{**} | \sH - E_0 | \Psi_{a\bar{a}}^{**}} &= 2^{-1} (\Braket{\Psi_{a\bar{a}}^{r\bar{r}} | \sH - E_0 | \Psi_{a\bar{a}}^{r\bar{r}}}
+ \Braket{\Psi_{a\bar{a}}^{r\bar{r}} | \sH - E_0 | \Psi_{a\bar{a}}^{s\bar{s}}} \notag\\
&{}\quad
+ \Braket{\Psi_{a\bar{a}}^{s\bar{s}} | \sH - E_0 | \Psi_{a\bar{a}}^{r\bar{r}}}
+ \Braket{\Psi_{a\bar{a}}^{s\bar{s}} | \sH - E_0 | \Psi_{a\bar{a}}^{s\bar{s}}}) \notag\\
&= 2^{-1} \Bigg[ \qty(2h_{11} + 2h_{22} + \dfrac{1}{2}J_{11} + \dfrac{1}{2}J_{22} + 2J_{12} - K_{12}) - (4h_{11} + 2J_{11}) \notag\\
&{}\qquad + \dfrac{1}{2}J_{22} + \dfrac{1}{2}J_{22} \notag\\
&{}\qquad + \qty(2h_{11} + 2h_{22} + \dfrac{1}{2}J_{11} + \dfrac{1}{2}J_{22} + 2J_{12} - K_{12}) - (4h_{11} + 2J_{11})
 \Bigg] \notag\\
&= 2^{-1} \qty(-2h_{11} + 2h_{22} - \dfrac{3}{2}J_{11} + J_{22} + 2J_{12} - K_{12})\times 2 \notag\\
&= -2h_{11} + 2h_{22} - \dfrac{3}{2}J_{11} + J_{22} + 2J_{12} - K_{12}
\end{align}
Since
\begin{equation}\label{key}
\varepsilon_2 - \varepsilon_1 = h_{22} - h_{11} + 2J_{12} - K_{12} - J_{11}
\end{equation}
we have
\begin{align}
\Braket{\Psi_{a\bar{a}}^{**} | \sH - E_0 | \Psi_{a\bar{a}}^{**}} &= 2(\varepsilon_2 - \varepsilon_1) - 2J_{12} + K_{12} + \dfrac{1}{2}J_{11} + J_{22}
\end{align}

\ex{5.6}
Since
\begin{equation}\label{key}
\ket{\Psi_{a\bar{b}}^{**}} = 2^{-1/2} (\ket{\Psi_{a\bar{b}}^{r\bar{s}}} + \ket{\Psi_{a\bar{b}}^{s\bar{r}}})
\end{equation}
\begin{align}
\Braket{\Psi_0 | \sH | \Psi_{a\bar{b}}^{**}} &= 2^{-1/2}\qty(\Braket{\Psi_0 | \sH | \Psi_{a\bar{b}}^{r\bar{s}}} + \Braket{\Psi_0 | \sH | \Psi_{a\bar{b}}^{s\bar{r}}}) \notag\\
&= 2^{-1/2}\qty(\Braket{a\bar{b}||r\bar{s}} + \Braket{a\bar{b}||s\bar{r}} ) \notag\\
&= 2^{-1/2} \qty((ar|bs) + (as|br)) \notag\\
&= 2^{-1/2} K_{12}
\end{align}
\begin{align}
\Braket{\Psi_{a\bar{b}}^{**} | \sH - E_0 | \Psi_{a\bar{b}}^{**}} &= 2^{-1} (\Braket{\Psi_{a\bar{b}}^{r\bar{s}} | \sH - E_0 | \Psi_{a\bar{b}}^{r\bar{s}}}
+ \Braket{\Psi_{a\bar{b}}^{r\bar{s}} | \sH - E_0 | \Psi_{a\bar{b}}^{s\bar{r}}} \notag\\
&{}\quad
+ \Braket{\Psi_{a\bar{b}}^{s\bar{r}} | \sH - E_0 | \Psi_{a\bar{b}}^{r\bar{s}}}
+ \Braket{\Psi_{a\bar{b}}^{s\bar{r}} | \sH - E_0 | \Psi_{a\bar{b}}^{s\bar{r}}}) \notag\\
&= 2^{-1} \Bigg[ \qty(2h_{11} + 2h_{22} + \dfrac{1}{2}J_{11} + \dfrac{1}{2}J_{22} + 2J_{12} - K_{12}) - (4h_{11} + 2J_{11}) \notag\\
&{}\qquad + \dfrac{1}{2}J_{22} + \dfrac{1}{2}J_{22} \notag\\
&{}\qquad + \qty(2h_{11} + 2h_{22} + \dfrac{1}{2}J_{11} + \dfrac{1}{2}J_{22} + 2J_{12} - K_{12}) - (4h_{11} + 2J_{11})
\Bigg] \notag\\
&= ... \notag\\
&= 2(\varepsilon_2 - \varepsilon_1) - 2J_{12} + K_{12} + \dfrac{1}{2}J_{11} + J_{22} \equiv 2\Delta'
\end{align}
Thus the equations determining $ e_{a\bar{b}} $ are identical to that of $ e_{a\bar{a}} $. Similarly, $ e_{\bar{a}b} $ shares the same equations with them.\\
$ \therefore\; e_{a\bar{b}} = e_{\bar{a}b} = e_{a\bar{a}}$.

\ex{5.7}
\subex{a.}
As shown in Ex 5.5, 5.6
\begin{align}
\Braket{\Psi_0 | \sH | \Psi_{a\bar{a}}^{**}}
= \Braket{\Psi_0 | \sH | \Psi_{a\bar{b}}^{**}}
= \Braket{\Psi_0 | \sH | \Psi_{\bar{a}b}^{**}} = 2^{-1/2}K_{12}
\end{align}
\begin{align}
\Braket{\Psi_{a\bar{a}}^{**} | \sH - E_0 | \Psi_{a\bar{a}}^{**}}
= \Braket{\Psi_{a\bar{b}}^{**} | \sH - E_0 | \Psi_{a\bar{b}}^{**}}
= \Braket{\Psi_{\bar{a}b}^{**} | \sH - E_0 | \Psi_{\bar{a}b}^{**}} = 2\Delta'
\end{align}
Similarly, we get
\begin{align}
\Braket{\Psi_0 | \sH | \Psi_{b\bar{b}}^{**}} = 2^{-1/2}K_{12}
\end{align}
\begin{align}
\Braket{\Psi_{b\bar{b}}^{**} | \sH - E_0 | \Psi_{b\bar{b}}^{**}}
 = 2\Delta'
\end{align}
For the rest,
\begin{align}
\Braket{\Psi_{a\bar{a}}^{**} | \sH - E_0 | \Psi_{b\bar{b}}^{**}}
&= 2^{-1} (\Braket{\Psi_{a\bar{a}}^{r\bar{r}} | \sH - E_0 | \Psi_{b\bar{b}}^{r\bar{r}}}
+ \Braket{\Psi_{a\bar{a}}^{r\bar{r}} | \sH - E_0 | \Psi_{b\bar{b}}^{s\bar{s}}} \notag\\
&{}\quad
+ \Braket{\Psi_{a\bar{a}}^{s\bar{s}} | \sH - E_0 | \Psi_{b\bar{b}}^{r\bar{r}}}
+ \Braket{\Psi_{a\bar{a}}^{s\bar{s}} | \sH - E_0 | \Psi_{b\bar{b}}^{s\bar{s}}}) \notag\\
&= 2^{-1} \qty[
\Braket{b\bar{b} || a\bar{a}}
+ 0 + 0 + \Braket{b\bar{b} || a\bar{a}}
] \notag\\
&= (ab|ab) \notag\\
&= \dfrac{1}{2}J_{11}
\end{align}
\begin{align}
\Braket{\Psi_{a\bar{a}}^{**} | \sH - E_0 | \Psi_{a\bar{b}}^{**}}
&= 2^{-1} (\Braket{\Psi_{a\bar{a}}^{r\bar{r}} | \sH - E_0 | \Psi_{a\bar{b}}^{r\bar{s}}}
+ \Braket{\Psi_{a\bar{a}}^{r\bar{r}} | \sH - E_0 | \Psi_{a\bar{b}}^{s\bar{r}}} \notag\\
&{}\quad
+ \Braket{\Psi_{a\bar{a}}^{s\bar{s}} | \sH - E_0 | \Psi_{a\bar{b}}^{r\bar{s}}}
+ \Braket{\Psi_{a\bar{a}}^{s\bar{s}} | \sH - E_0 | \Psi_{a\bar{b}}^{s\bar{r}}}) \notag\\
&= 2^{-1} \qty[
\Braket{\bar{r}\bar{b} || \bar{a}\bar{s}}
- \Braket{r\bar{b} || s\bar{a}} + \Braket{s\bar{b} || r\bar{a}} - \Braket{\bar{s}\bar{b} || \bar{a}\bar{r}}
] \notag\\
&= 2^{-1}[(ra|bs) - (rs|ba) - (rs|ba) - (sr|ba) + (sa|br) - (sr|ba) ] \notag\\
&= 2^{-1}[(ra|bs) + (sa|br) - 4(ab|sr) ] \notag\\
&= 2^{-1}\qty[2\times \dfrac{1}{2}K_{12} - 4\times \dfrac{1}{2}J_{12}] \notag\\
&= \dfrac{1}{2} K_{12} - J_{12}
\end{align}
Similarly, we get
\begin{align}
\Braket{\Psi_{a\bar{b}}^{**} | \sH - E_0 | \Psi_{\bar{a}b}^{**}} = \dfrac{1}{2}J_{11}
\end{align}
\begin{align}
\Braket{\Psi_{a\bar{a}}^{**} | \sH - E_0 | \Psi_{\bar{a}b}^{**}} = \Braket{\Psi_{b\bar{b}}^{**} | \sH - E_0 | \Psi_{a\bar{b}}^{**}} = \Braket{\Psi_{b\bar{b}}^{**} | \sH - E_0 | \Psi_{\bar{a}b}^{**}} = \dfrac{1}{2}K_{12} - J_{12}
\end{align}
thus the DCI equation is
\begin{equation}\label{key}
\mqty(0 & 2^{-1/2}K_{12} & 2^{-1/2}K_{12} & 2^{-1/2}K_{12} & 2^{-1/2}K_{12} \\
2^{-1/2}K_{12} & 2\Delta' & \tfrac{1}{2}J_{11} & \tfrac{1}{2}K_{12} - J_{12} & \tfrac{1}{2}K_{12} - J_{12} \\
2^{-1/2}K_{12} & \tfrac{1}{2}J_{11} & 2\Delta' & \tfrac{1}{2}K_{12} - J_{12} & \tfrac{1}{2}K_{12} - J_{12} \\
2^{-1/2}K_{12} & \tfrac{1}{2}K_{12} - J_{12} & \tfrac{1}{2}K_{12} - J_{12} & 2\Delta' &\tfrac{1}{2}J_{11} \\
2^{-1/2}K_{12} & \tfrac{1}{2}K_{12} - J_{12} & \tfrac{1}{2}K_{12} - J_{12} & \tfrac{1}{2}J_{11} & 2\Delta' )
\mqty(1\\ c_1\\ c_2\\ c_3\\ c_4) = {^2 E}_{\corr}(\text{DCI})
\mqty(1\\ c_1\\ c_2\\ c_3\\ c_4)
\end{equation}

\subex{b.}
By solving the DCI equation above (see \code{5-7.nb}), we get
\begin{align}
{^2 E}_{\corr}(\text{DCI}) &= \dfrac{2\Delta' + \tfrac{1}{2}J_{11} + 2(\tfrac{1}{2}K_{12} - J_{12}) - \sqrt{16(2^{-1/2}K_{12})^2 + [2\Delta' + \tfrac{1}{2}J_{11} + 2(\tfrac{1}{2}K_{12} - J_{12})]^2}}{2} \notag\\
%&=
\end{align}
and
\begin{align}
c_1 = c_2 = c_3 = c_4 = \dfrac{2\Delta' + \tfrac{1}{2}J_{11} + 2(\tfrac{1}{2}K_{12} - J_{12}) + \sqrt{16(2^{-1/2}K_{12})^2 + [2\Delta' + \tfrac{1}{2}J_{11} + 2(\tfrac{1}{2}K_{12} - J_{12})]^2}}{8\times 2^{-1/2}K_{12}}
\end{align}
Since
\begin{align}
2\Delta' = 2(\varepsilon_2 - \varepsilon_1) - 2J_{12} + K_{12} + \dfrac{1}{2}J_{11} + J_{22} \\
2\Delta = 2(\varepsilon_2 - \varepsilon_1) + J_{11} + J_{22} - 4J_{12} + 2K_{12}
\end{align}
we have
\begin{equation}\label{key}
2\Delta = 2\Delta' + \dfrac{1}{2}J_{11} - 2J_{12} + K_{12}
\end{equation}
$ \therefore $
\begin{align}
{^2 E}_{\corr}(\text{DCI}) &= \dfrac{2\Delta - \sqrt{8K_{12}^2 + (2\Delta)^2}}{2} \notag\\
&= \Delta - \sqrt{2K_{12}^2 + \Delta^2}
\end{align}
\begin{align}
c_1 = c_2 = c_3 = c_4  &= \dfrac{2\Delta + \sqrt{8K_{12}^2 + (2\Delta)^2}}{4\sqrt{2}K_{12}} \notag\\
&= \dfrac{\Delta + \sqrt{2K_{12}^2 + \Delta^2}}{2\sqrt{2}K_{12}}
\end{align}

\ex{5.8}
\begin{align}
E_{\corr}(\text{FO}) &= \sum_{A<B}\sum_{R<S} \dfrac{\abs{\Braket{AB||RS}}^2}{\varepsilon_A + \varepsilon_B - \varepsilon_R - \varepsilon_S} \notag\\
&= \dfrac{\abs{\Braket{a\bar{a}||r\bar{r}}}^2 + \abs{\Braket{a\bar{a}||r\bar{s}}}^2 + \abs{\Braket{a\bar{a}||s\bar{r}}}^2 + \abs{\Braket{a\bar{a}||s\bar{s}}}^2}{\varepsilon_1 + \varepsilon_1 - \varepsilon_2 - \varepsilon_2} %\notag\\
%&{}\quad
+ \dfrac{\abs{\Braket{a\bar{b}||r\bar{r}}}^2 + \abs{\Braket{a\bar{b}||r\bar{s}}}^2 + \abs{\Braket{a\bar{b}||s\bar{r}}}^2 + \abs{\Braket{a\bar{b}||s\bar{s}}}^2}{\varepsilon_1 + \varepsilon_1 - \varepsilon_2 - \varepsilon_2} \notag\\
&{}\quad + \dfrac{\abs{\Braket{b\bar{a}||r\bar{r}}}^2 + \abs{\Braket{b\bar{a}||r\bar{s}}}^2 + \abs{\Braket{b\bar{a}||s\bar{r}}}^2 + \abs{\Braket{b\bar{a}||s\bar{s}}}^2}{\varepsilon_1 + \varepsilon_1 - \varepsilon_2 - \varepsilon_2} %\notag\\
%&{}\quad
+ \dfrac{\abs{\Braket{b\bar{b}||r\bar{r}}}^2 + \abs{\Braket{b\bar{b}||r\bar{s}}}^2 + \abs{\Braket{b\bar{b}||s\bar{r}}}^2 + \abs{\Braket{b\bar{b}||s\bar{s}}}^2}{\varepsilon_1 + \varepsilon_1 - \varepsilon_2 - \varepsilon_2} \notag\\
&= \dfrac{\abs{(ar|ar)}^2 + \abs{(ar|as)}^2 + \abs{(as|ar)}^2 + \abs{(as|as)}^2}{2(\varepsilon_1 - \varepsilon_2)}
+ \dfrac{\abs{(ar|br)}^2 + \abs{(ar|bs)}^2 + \abs{(as|br)}^2 + \abs{(as|bs)}^2}{2(\varepsilon_1 - \varepsilon_2)} \notag\\
&{}\quad + \dfrac{\abs{(br|ar)}^2 + \abs{(br|as)}^2 + \abs{(bs|ar)}^2 + \abs{(bs|as)}^2}{2(\varepsilon_1 - \varepsilon_2)}
+ \dfrac{\abs{(br|br)}^2 + \abs{(br|bs)}^2 + \abs{(bs|br)}^2 + \abs{(bs|bs)}^2}{2(\varepsilon_1 - \varepsilon_2)} \notag\\
&= \dfrac{\abs{\tfrac{1}{2}K_{12}}^2 + 0 + 0 + \abs{\tfrac{1}{2}K_{12}}^2}{2(\varepsilon_1 - \varepsilon_2)}
+ \dfrac{0 + \abs{\tfrac{1}{2}K_{12}}^2 + \abs{\tfrac{1}{2}K_{12}}^2 + 0}{2(\varepsilon_1 - \varepsilon_2)} \notag\\
&{}\quad + \dfrac{0 + 0 + \abs{\tfrac{1}{2}K_{12}}^2 + \abs{\tfrac{1}{2}K_{12}}^2}{2(\varepsilon_1 - \varepsilon_2)}
+ \dfrac{\abs{\tfrac{1}{2}K_{12}}^2 + 0 + 0 + \abs{\tfrac{1}{2}K_{12}}^2}{2(\varepsilon_1 - \varepsilon_2)} \notag\\
&= \dfrac{2K_{12}^2 }{2(\varepsilon_1 - \varepsilon_2)}
\end{align}

\ex{5.9}
\subex{a.}
\begin{align}
{^2 }E_{\corr}(\text{EN(L)})
%&= -\sum_{a<b} \sum_{r<s} \dfrac{\abs{\Braket{\Psi_0|\sH|\Psi_{ab}^{rs}}}^2}{\Braket{\Psi_{ab}^{rs} | \sH - E_0 | \Psi_{ab}^{rs}}} \notag\\
&= -\dfrac{\abs{\Braket{\Psi_0|\sH|\Psi_{1_1\bar{1}_1}^{2_1\bar{2}_1}}}^2 }{\Braket{\Psi_{1_1\bar{1}_1}^{2_1\bar{2}_1} | \sH - E_0 | \Psi_{1_1\bar{1}_1}^{2_1\bar{2}_1}}}
- \dfrac{\abs{\Braket{\Psi_0|\sH|\Psi_{1_1\bar{1}_1}^{2_1\bar{2}_1}}}^2 }{\Braket{\Psi_{1_1\bar{1}_1}^{2_1\bar{2}_1} | \sH - E_0 | \Psi_{1_1\bar{1}_1}^{2_1\bar{2}_1}}} \notag\\
&= -\dfrac{K_{12}^2}{2\Delta}\times 2 \notag\\
&= -\dfrac{K_{12}^2}{\Delta}
\end{align}
\subex{b.}
\begin{align}
{^2 }E_{\corr}(\text{EN(D)}) &= e_{a\bar{a}} + e_{b\bar{b}} + e_{a\bar{b}} + e_{\bar{a}b} \notag\\
&= 2e_{a\bar{a}} + 2e_{a\bar{b}} \notag\\
&= -2\dfrac{\abs{\Braket{\Psi_0|\sH|\Psi_{a\bar{a}}^{**}}}^2 }{\Braket{\Psi_{a\bar{a}}^{**} | \sH-E_0 | \Psi_{a\bar{a}}^{**}}}
- 2\dfrac{\abs{\Braket{\Psi_0|\sH|\Psi_{a\bar{b}}^{**}}}^2 }{\Braket{\Psi_{a\bar{b}}^{**} | \sH - E_0 | \Psi_{a\bar{b}}^{**}}}
\notag\\
&= -2\dfrac{\abs{2^{-1/2}K_{12}}^2}{2\Delta'} -2\dfrac{\abs{2^{-1/2}K_{12}}^2}{2\Delta'} \notag\\
&= -\dfrac{K_{12}^2}{2\Delta'}\times 2 \notag\\
&= -\dfrac{K_{12}^2}{\Delta'}
\end{align}
\subex{c.}
\begin{align}
{^2 }E_{\corr}^{\text{singlet}}(\text{EN(D)}) &= e_{a\bar{a}} + e_{b\bar{b}} + e_{ab}^{\text{singlet}} \notag\\
&= -\dfrac{K_{12}^2}{2\Delta'} -\dfrac{\abs{\Braket{\Psi_0|\sH| ^B\Psi_{ab}^{rs}}}^2 }{\Braket{ ^B\Psi_{ab}^{rs} | \sH-E_0 | ^B\Psi_{ab}^{rs}}}  \notag\\
&= -\dfrac{K_{12}^2}{2\Delta'} -\dfrac{K_{12}^2}{2\Delta''}
\end{align}
\subex{d.}
\begin{align}
{^2 }E_{\corr}(\text{EN(L)}) &= -0.04168 \\
{^2 }E_{\corr}(\text{EN(D)}) &= -0.02755 \\
{^2 }E_{\corr}^{\text{singlet}}(\text{EN(D)}) &= -0.02585
\end{align}
thus EN pairs is not invariant to unitary transformations.

\ex{5.10}
From Ex 5.7,
\begin{align}
\Braket{\Psi_0 | \sH | \Psi_{a\bar{a}}^{**}} &= \Braket{\Psi_0 | \sH | \Psi_{b\bar{b}}^{**}} = 2^{-1/2}K_{12} \\
\Braket{\Psi_{a\bar{a}}^{**} | \sH-E_0 | \Psi_{a\bar{a}}^{**}} &= \Braket{\Psi_{b\bar{b}}^{**} | \sH-E_0 | \Psi_{b\bar{b}}^{**}} = 2\Delta' \\
\Braket{\Psi_{a\bar{a}}^{**} | \sH-E_0 | \Psi_{b\bar{b}}^{**}} &= \dfrac{1}{2}J_{11}
\end{align}
From Eq 5.42 in the textbook,
\begin{align}
\Braket{\Psi_0 | \sH | {^B}\Psi_{ab}^{rs}} &= K_{12} \\
\Braket{{^B}\Psi_{ab}^{rs} | \sH-E_0 | {^B}\Psi_{ab}^{rs}} &= 2\Delta''
\end{align}
and
\begin{align}
\Braket{\Psi_{a\bar{a}}^{**} | \sH | {^B}\Psi_{ab}^{rs}} &= 2^{-3/2}\Braket{\Psi_{a\bar{a}}^{r\bar{r}} + \Psi_{a\bar{a}}^{s\bar{s}} | \sH | \Psi_{\bar{a}b}^{\bar{s}r} + \Psi_{\bar{a}b}^{\bar{r}s} + \Psi_{a\bar{b}}^{r\bar{s}} + \Psi_{a\bar{b}}^{s\bar{r}} } \notag\\
&= 2^{-3/2} \qty(
-\Braket{\bar{r}b||\bar{s}a} + \Braket{rb||as}
+ \Braket{\bar{r}\bar{b}||\bar{a}\bar{s}} - \Braket{r\bar{b}||s\bar{a}}
+ \Braket{sb||ar} - \Braket{\bar{s}b||\bar{r}a}
- \Braket{s\bar{b}||r\bar{a}} + \Braket{\bar{s}\bar{b}||\bar{a}\bar{r}}
) \notag\\
&= 2^{-3/2} \qty( -8(rs|ba) + 2(ra|bs) + 2(sa|br) ) \notag\\
&= 2^{-3/2} \qty( -8\times \dfrac{1}{2}J_{12} + 4\times\dfrac{1}{2} K_{12}) \notag\\
&= 2^{-1/2} \qty( K_{12} - 2J_{12} )
\end{align}
similarly,
\begin{equation}\label{key}
\Braket{\Psi_{b\bar{b}}^{**} | \sH | {^B}\Psi_{ab}^{rs}} = 2^{-1/2} \qty( \times K_{12} - 2J_{12} )
\end{equation}
thus the DCI equation is
\begin{equation}\label{key}
\mqty( 0 & 2^{-1/2}K_{12} & 2^{-1/2}K_{12} & K_{12} \\
2^{-1/2}K_{12} & 2\Delta' & \dfrac{1}{2}J_{11} & 2^{-1/2} \qty( K_{12} - 2J_{12})\\
2^{-1/2}K_{12} & \dfrac{1}{2}J_{11} & 2\Delta' & 2^{-1/2} \qty(K_{12} - 2J_{12})\\
K_{12} & 2^{-1/2} \qty( K_{12} - 2J_{12} ) & 2^{-1/2} \qty( K_{12} - 2J_{12} ) & 2\Delta'' ) \mqty(1\\ c_1 \\ c_2 \\ c_3)
= {^2}E_{\corr}(\text{DCI}) \mqty(1\\ c_1 \\ c_2 \\ c_3)
\end{equation}
by solving the DCI equation,
\begin{align}
{^2}E_{\corr}(\text{DCI}) = \Delta - \sqrt{\Delta^2 + 2K_{12}^2}
\end{align}

\subsubsection{Some Illustrative Calculations}

\subsection{Coupled-pair Theories}
\subsubsection{The Coupled-cluster Approximation}

\subsubsection{The Cluster Expansion of the Wave Function}
\ex{5.11}
Eq. 5.49 gives
\begin{align}
\ket{\Phi_0} &= \ket{1_1 \bar{1}_1 1_2 \bar{1}_2}
+ c_{1_1 \bar{1}_1}^{2_1 \bar{2}_1} \ket{2_1\bar{2}_1 1_2\bar{1}_2}
+ c_{1_2 \bar{1}_2}^{2_2 \bar{2}_2} \ket{1_1\bar{1}_1 2_2\bar{2}_2}
+ c_{1_1 \bar{1}_1 1_2 \bar{1}_2}^{2_1 \bar{2}_1 2_2 \bar{2}_2} \ket{2_1\bar{2}_1 2_2\bar{2}_2} \notag\\
&= \qty[1
+ c_{1_1 \bar{1}_1}^{2_1 \bar{2}_1} a^\dagger_{2_1}a^\dagger_{\bar{2}_1} a_{\bar{1}_1}a_{1_1}
+ c_{1_2 \bar{1}_2}^{2_2 \bar{2}_2} a^\dagger_{2_2}a^\dagger_{\bar{2}_2} a_{\bar{1}_2}a_{1_2}
+ c_{1_1 \bar{1}_1 1_2 \bar{1}_2}^{2_1 \bar{2}_1 2_2 \bar{2}_2} a^\dagger_{2_1}a^\dagger_{\bar{2}_1}a^\dagger_{2_2}a^\dagger_{\bar{2}_2} a_{\bar{1}_2}a_{1_2}a_{\bar{1}_1}a_{1_1} ] \ket{1_1\bar{1}_1 1_2\bar{1}_2} %\notag\\
\end{align}
while
\begin{align}
& \quad \exp(c_{1_1 \bar{1}_1}^{2_1 \bar{2}_1} a^\dagger_{2_1}a^\dagger_{\bar{2}_1} a_{\bar{1}_1}a_{1_1} + c_{1_2 \bar{1}_2}^{2_2 \bar{2}_2} a^\dagger_{2_2}a^\dagger_{\bar{2}_2} a_{\bar{1}_2}a_{1_2}
) \ket{1_1 \bar{1}_1 1_2 \bar{1}_2} \notag\\
&= \qty[ 1
+ \qty(c_{1_1 \bar{1}_1}^{2_1 \bar{2}_1} a^\dagger_{2_1}a^\dagger_{\bar{2}_1} a_{\bar{1}_1}a_{1_1} + c_{1_2 \bar{1}_2}^{2_2 \bar{2}_2} a^\dagger_{2_2}a^\dagger_{\bar{2}_2} a_{\bar{1}_2}a_{1_2})
+ \qty(c_{1_1 \bar{1}_1}^{2_1 \bar{2}_1} a^\dagger_{2_1}a^\dagger_{\bar{2}_1} a_{\bar{1}_1}a_{1_1} + c_{1_2 \bar{1}_2}^{2_2 \bar{2}_2} a^\dagger_{2_2}a^\dagger_{\bar{2}_2} a_{\bar{1}_2}a_{1_2})^2 + \cdots
] \ket{1_1 \bar{1}_1 1_2 \bar{1}_2} %\notag\\
%&=
\end{align}
since we cannot annihilate or create any orbital twice, the terms over 3rd power must be zero, thus
\begin{align}
& \quad \exp(c_{1_1 \bar{1}_1}^{2_1 \bar{2}_1} a^\dagger_{2_1}a^\dagger_{\bar{2}_1} a_{\bar{1}_1}a_{1_1} + c_{1_2 \bar{1}_2}^{2_2 \bar{2}_2} a^\dagger_{2_2}a^\dagger_{\bar{2}_2} a_{\bar{1}_2}a_{1_2}
) \ket{1_1 \bar{1}_1 1_2 \bar{1}_2} \notag\\
&= \qty[ 1
+ \qty(c_{1_1 \bar{1}_1}^{2_1 \bar{2}_1} a^\dagger_{2_1}a^\dagger_{\bar{2}_1} a_{\bar{1}_1}a_{1_1} + c_{1_2 \bar{1}_2}^{2_2 \bar{2}_2} a^\dagger_{2_2}a^\dagger_{\bar{2}_2} a_{\bar{1}_2}a_{1_2})
+ \qty(c_{1_1 \bar{1}_1}^{2_1 \bar{2}_1} a^\dagger_{2_1}a^\dagger_{\bar{2}_1} a_{\bar{1}_1}a_{1_1} + c_{1_2 \bar{1}_2}^{2_2 \bar{2}_2} a^\dagger_{2_2}a^\dagger_{\bar{2}_2} a_{\bar{1}_2}a_{1_2})^2
] \ket{1_1 \bar{1}_1 1_2 \bar{1}_2} \notag\\
&= \left[ 1
+ \qty(c_{1_1 \bar{1}_1}^{2_1 \bar{2}_1} a^\dagger_{2_1}a^\dagger_{\bar{2}_1} a_{\bar{1}_1}a_{1_1} + c_{1_2 \bar{1}_2}^{2_2 \bar{2}_2} a^\dagger_{2_2}a^\dagger_{\bar{2}_2} a_{\bar{1}_2}a_{1_2})
  + \qty(c_{1_1 \bar{1}_1}^{2_1 \bar{2}_1} a^\dagger_{2_1}a^\dagger_{\bar{2}_1} a_{\bar{1}_1}a_{1_1})^2
  + \qty(c_{1_2 \bar{1}_2}^{2_2 \bar{2}_2} a^\dagger_{2_2}a^\dagger_{\bar{2}_2} a_{\bar{1}_2}a_{1_2})^2 \right. \notag\\
&{} \qquad \left.
  + c_{1_1 \bar{1}_1}^{2_1 \bar{2}_1}c_{1_2 \bar{1}_2}^{2_2 \bar{2}_2} a^\dagger_{2_1}a^\dagger_{\bar{2}_1} a^\dagger_{2_2}a^\dagger_{\bar{2}_2} a_{\bar{1}_1}a_{1_1}  a_{\bar{1}_2}a_{1_2}
\right] \ket{1_1 \bar{1}_1 1_2 \bar{1}_2} \notag\\
&= \qty[1
+ c_{1_1 \bar{1}_1}^{2_1 \bar{2}_1} a^\dagger_{2_1}a^\dagger_{\bar{2}_1} a_{\bar{1}_1}a_{1_1}
+ c_{1_2 \bar{1}_2}^{2_2 \bar{2}_2} a^\dagger_{2_2}a^\dagger_{\bar{2}_2} a_{\bar{1}_2}a_{1_2}
+ c_{1_1 \bar{1}_1}^{2_1 \bar{2}_1}c_{1_2 \bar{1}_2}^{2_2 \bar{2}_2} a^\dagger_{2_1}a^\dagger_{\bar{2}_1} a^\dagger_{2_2}a^\dagger_{\bar{2}_2} a_{\bar{1}_1}a_{1_1}  a_{\bar{1}_2}a_{1_2}
] \ket{1_1 \bar{1}_1 1_2 \bar{1}_2} \notag\\
&= \qty[1
+ c_{1_1 \bar{1}_1}^{2_1 \bar{2}_1} a^\dagger_{2_1}a^\dagger_{\bar{2}_1} a_{\bar{1}_1}a_{1_1}
+ c_{1_2 \bar{1}_2}^{2_2 \bar{2}_2} a^\dagger_{2_2}a^\dagger_{\bar{2}_2} a_{\bar{1}_2}a_{1_2}
+ c_{1_1 \bar{1}_1 1_2 \bar{1}_2}^{2_1 \bar{2}_1 2_2 \bar{2}_2}  a^\dagger_{2_1}a^\dagger_{\bar{2}_1} a^\dagger_{2_2}a^\dagger_{\bar{2}_2} a_{\bar{1}_1}a_{1_1}  a_{\bar{1}_2}a_{1_2}
] \ket{1_1 \bar{1}_1 1_2 \bar{1}_2}
\end{align}

\subsubsection{Linear CCA and the Coupled-Electron Pair Approximation}
\ex{5.12}
\subex{a.}
The diagonal elements of $ \vb{D} $ is
\begin{align}
\vb{D}_{rasb, rasb} &= \Braket{\Psi_{ab}^{rs} | \sH - E_0 | \Psi_{ab}^{rs}} %\notag\\
%&= \Braket{\Psi_{ab}^{rs} | \sH | \Psi_{ab}^{rs}} - E_0 \notag\\
%&= h_{rr} + h_{ss} - h_{aa} - h_{bb} +
\end{align}
thus
\begin{align}
E_{\corr} &= -\vb{B}^\dagger \vb{D}^{-1} \vb{B} \notag\\
&= - \sum_{a<b}\sum_{r<s}\dfrac{\Braket{\Psi_0 | \sH | \Psi_{ab}^{rs}}^\dagger \Braket{\Psi_0 | \sH | \Psi_{ab}^{rs}} }{\Braket{\Psi_{ab}^{rs} | \sH - E_0 | \Psi_{ab}^{rs}}} \notag\\
&= - \sum_{a<b}\sum_{r<s}\dfrac{\abs{\Braket{\Psi_0 | \sH | \Psi_{ab}^{rs}}}^2 }{\Braket{\Psi_{ab}^{rs} | \sH - E_0 | \Psi_{ab}^{rs}}}
\end{align}
which matches Eq. 5.15 and 5.16.
\subex{b.}
localized orbitals:\\
From Ex 4.12, we get
\begin{align}
\vb{B} = \mqty( K_{12} \\ K_{12} )
\end{align}
\begin{align}
\vb{D} =
\mqty( 2\Delta & 0  \\
0 & 2\Delta )
\end{align}
thus
\begin{align}
E_{\corr}(\text{L-CCA(L)}) &= -\vb{B}^\dagger \vb{D}^{-1} \vb{B} \notag\\
&= -\dfrac{K_{12}^2}{\Delta}
\end{align}
delocalized orbitals:\\
From Ex 5.7, we get
\begin{align}
\vb{B} = \mqty(2^{-1/2}K_{12} \\ 2^{-1/2}K_{12} \\ 2^{-1/2}K_{12} \\ 2^{-1/2}K_{12})
\end{align}
\begin{align}
\vb{D} =
\mqty( 2\Delta' & \tfrac{1}{2}J_{11} & \tfrac{1}{2}K_{12} - J_{12} & \tfrac{1}{2}K_{12} - J_{12} \\
\tfrac{1}{2}J_{11} & 2\Delta' & \tfrac{1}{2}K_{12} - J_{12} & \tfrac{1}{2}K_{12} - J_{12} \\
\tfrac{1}{2}K_{12} - J_{12} & \tfrac{1}{2}K_{12} - J_{12} & 2\Delta' &\tfrac{1}{2}J_{11} \\
\tfrac{1}{2}K_{12} - J_{12} & \tfrac{1}{2}K_{12} - J_{12} & \tfrac{1}{2}J_{11} & 2\Delta' )
\end{align}
thus
\begin{align}
E_{\corr}(\text{L-CCA(D)}) &= -\vb{B}^\dagger \vb{D}^{-1} \vb{B} \notag\\
&= -\dfrac{K_{12}^2}{\Delta}
\end{align}

\subsubsection{Some Illustrative Calculations}

\subsection{Many-electron Theories with Single Particle Hamiltonians}
\ex{5.13}
\begin{equation}\label{key}
C = \dfrac{-H_{11} + H_{22} - \sqrt{H_{11}^2 + 4H_{12}H_{21} - 2H_{11}H_{22} + H_{22}^2}}{2H_{12}}
\end{equation}
\begin{align}\label{key}
\varepsilon_1 &= H_{11} + H_{12}C \notag\\
&= H_{11} + \dfrac{-H_{11} + H_{22} - \sqrt{H_{11}^2 + 4H_{12}H_{21} - 2H_{11}H_{22} + H_{22}^2}}{2} \notag\\
&=  \dfrac{H_{11} + H_{22} - \sqrt{H_{11}^2 + 4H_{12}H_{21} - 2H_{11}H_{22} + H_{22}^2}}{2}
\end{align}
while the eigenvalues of the matrix is
\begin{equation}\label{key}
\dfrac{H_{11} + H_{22} \pm \sqrt{H_{11}^2 + 4H_{12}H_{21} - 2H_{11}H_{22} + H_{22}^2}}{2}
\end{equation}

\subsubsection{The Relaxation Energy via CI, IEPA, CEPA and CCA}
%\paragraph{1. Full CI}
\ex{5.14}
\subex{a.}
\begin{align}
\Braket{\Psi_0 | \sH | \Psi_b^s} &= \Braket{\Psi_0 | \sum_i [h_0(i) + v(i)] | \Psi_b^s} \notag\\
&= v_{bs}
\end{align}
\subex{b.}
Similarly
\begin{align}
\Braket{\Psi_a^r | \sH | \Psi_0} = v_{ra}
\end{align}
\subex{c.}
\begin{align}
\Braket{\Psi_a^r | \sH - E_0 | \Psi_b^s}
&= \Braket{\Psi_a^r | \sH | \Psi_b^s} - E_0\Braket{\Psi_a^r | \Psi_b^s} \notag\\
&= \left\{\mqty{
	0 + 0 & a\neq b, r\neq s\\
	v_{rs} + 0 & a=b, r\neq s\\
	-v_{ba} + 0 & a\neq b, r=s\\
	E_0 + \varepsilon_r^{(0)} + v_{rr} - \varepsilon_a^{(0)} - v_{aa} - E_0 & a=b, r=s
}\right. \notag\\
&= \left\{\mqty{
	0  & a\neq b, r\neq s\\
	v_{rs}  & a=b, r\neq s\\
	-v_{ba}  & a\neq b, r=s\\
	\varepsilon_r^{(0)} + v_{rr} - \varepsilon_a^{(0)} - v_{aa} & a=b, r=s
}\right.
\end{align}
\subex{d.}
Since we cannot create or annihilate an orbital twice,
\begin{align}
\Braket{\Psi_a^r | \sH - E_0 | \Psi_{ab}^{rs}} =
\left\{\mqty{
	v_{bs} & a\neq b, r\neq s\\
	0 & \text{otherwise}
}\right.
\end{align}

%\paragraph{2. SCI}

%\paragraph{3. IEPA}

%\paragraph{4. CCA}

%\paragraph{5. L-CCA}

%\paragraph{6. CEPA}

\ex{5.15}
\subex{a.}
\begin{align}
\Ket{\Phi_0} &=
a_1b_1\cdot 0 + a_1 b_2 \ket{\chi_1^{(0)}\chi_2^{(0)}}
+ a_1 b_3\ket{\chi_1^{(0)}\chi_3^{(0)}} + a_1 b_4\ket{\chi_1^{(0)}\chi_4^{(0)}}
\notag\\
&\quad{} + a_2 b_1\ket{\chi_2^{(0)}\chi_1^{(0)}} + a_2 b_2\cdot 0
+ a_2 b_3\ket{\chi_2^{(0)}\chi_3^{(0)}} + a_2 b_4\ket{\chi_2^{(0)}\chi_4^{(0)}}
\notag\\
&\quad{}
+ a_3 b_1\ket{\chi_3^{(0)}\chi_1^{(0)}} + a_3 b_2\ket{\chi_3^{(0)}\chi_2^{(0)}}
+ a_3 b_3\cdot 0 + a_3 b_4\ket{\chi_3^{(0)}\chi_4^{(0)}}
\notag\\
&\quad{}
+ a_4 b_1\ket{\chi_4^{(0)}\chi_1^{(0)}} + a_4 b_2\ket{\chi_4^{(0)}\chi_2^{(0)}}
+ a_4 b_3\ket{\chi_4^{(0)}\chi_3^{(0)}} + a_4 b_4\cdot 0
\notag\\
&= (a_1 b_2 - a_2 b_1) \ket{\chi_1^{(0)}\chi_2^{(0)}}
+ (a_1 b_3 - a_3 b_1)\ket{\chi_1^{(0)}\chi_3^{(0)}}
+ (a_1 b_4 - a_4 b_1)\ket{\chi_1^{(0)}\chi_4^{(0)}} \notag\\
&\quad{}
- (a_2 b_3 - a_3 b_2)\ket{\chi_3^{(0)}\chi_2^{(0)}}
- (a_2 b_4 - a_4 b_2)\ket{\chi_4^{(0)}\chi_2^{(0)}}
+ (a_3 b_4 - a_4 b_3)\ket{\chi_3^{(0)}\chi_4^{(0)}}
\end{align}
thus, with intermediate normalization
\begin{align}
\Ket{\Phi_0} &= \ket{\Psi_0}
+ \dfrac{a_1 b_3 - a_3 b_1}{a_1 b_2 - a_2 b_1}\ket{\Psi_2^3}
+ \dfrac{a_1 b_4 - a_4 b_1}{a_1 b_2 - a_2 b_1}\ket{\Psi_2^4} \notag\\
&\quad{}
- \dfrac{a_2 b_3 - a_3 b_2}{a_1 b_2 - a_2 b_1}\ket{\Psi_1^3}
- \dfrac{a_2 b_4 - a_4 b_2}{a_1 b_2 - a_2 b_1}\ket{\Psi_1^4}
+ \dfrac{a_3 b_4 - a_4 b_3}{a_1 b_2 - a_2 b_1}\ket{\Psi_{12}^{34}}
\end{align}
\begin{align}
c_1^3 c_2^4 - c_1^4 c_2^3 &= -\dfrac{a_2 b_3 - a_3 b_2}{a_1 b_2 - a_2 b_1}\dfrac{a_1 b_4 - a_4 b_1}{a_1 b_2 - a_2 b_1} + \dfrac{a_2 b_4 - a_4 b_2}{a_1 b_2 - a_2 b_1}\dfrac{a_1 b_3 - a_3 b_1}{a_1 b_2 - a_2 b_1} \notag\\
&= \dfrac{a_2a_4b_1b_3 + a_1a_3b_2b_4 - a_2a_3b_1b_4 - a_1a_4b_2b_3}{(a_1 b_2 - a_2 b_1)^2} \notag\\
&= \dfrac{(a_1b_2 - a_2b_1)(a_3b_4-a_4b_3) }{(a_1 b_2 - a_2 b_1)^2} \notag\\
&= \dfrac{a_3b_4-a_4b_3 }{a_1 b_2 - a_2 b_1} \notag\\
&= c_{12}^{34}
\end{align}
\subex{b.}
\begin{align}
\vb{U}_{AA}^{-1} = \dfrac{1}{\det(\vb{U}_{AA})} \mqty(b_2 & -b_1\\ -a_2 & a_1)
\end{align}
\begin{align}
(\vb{U}_{BA} \vb{U}_{AA}^{-1})_{11}
&= \dfrac{1}{\det(\vb{U}_{AA})} (a_3 b_2 - b_3 a_2) \notag\\
&= -\dfrac{a_2 b_3 - a_3 b_2}{a_1 b_2 - a_2 b_1} \notag\\
&= c_1^3
\end{align}

\subsubsection{The Resonance Energy of Polyenes in H\"uckel Theory}
\ex{5.16}
\begin{align}
\vb{H} =
\mqty(\alpha & \beta & 0 & 0 & 0 & \beta\\
      \beta & \alpha & \beta & 0 & 0 & 0 \\
      0 & \beta & \alpha & \beta & 0 & 0 \\
      0 & 0 & \beta & \alpha & \beta & 0 \\
      0 & 0 & 0 & \beta & \alpha & \beta \\
      \beta & 0 & 0 & 0 & \beta & \alpha \\
      )
\end{align}
the eigenvalues are
\begin{equation}\label{key}
\alpha - 2\beta, \alpha - \beta, \alpha - \beta, \alpha + \beta, \alpha + \beta, \alpha + 2\beta
\end{equation}
while from Eq. 5.131, we get
\begin{align}
\varepsilon_i = \alpha + 2\beta\cos\dfrac{\pi i}{3} \quad (i=0,\pm 1, \pm 2, 3)
\end{align}
i.e.
\begin{equation}\label{key}
\{\varepsilon_i\} = \{\alpha+2\beta, \alpha + \beta, \alpha + \beta, \alpha - \beta, \alpha - \beta, \alpha - 2\beta, \}
\end{equation}
which is identical to those eigenvalues.

The total energy is
\begin{align}
\mathscr{E}_0 &= 2(\alpha+2\beta + \alpha+\beta + \alpha+\beta)\\
&= 6\alpha + 8\beta
\end{align}
which agrees with Eq. 5.132.

\ex{5.17}
For Eq. 5.139
\begin{align}
\Braket{i|j} &= \dfrac{1}{2}\qty(\bra{\phi_{2i-1}} + \bra{\phi_{2i}}) \qty(\ket{\phi_{2j-1}} + \ket{\phi_{2j}}) \notag\\
&= \dfrac{1}{2}\qty(\delta_{2i-1,2j-1} + 0 + 0 + \delta_{2i,2j}) \notag\\
&= \dfrac{1}{2}\qty(\delta_{i,j} + \delta_{i,j}) \notag\\
&= \delta_{i,j}
\end{align}
$ \Braket{i^*|j^*} $ is similar.
\begin{align}
\Braket{i|j^*} &= \dfrac{1}{2}\qty(\bra{\phi_{2i-1}} + \bra{\phi_{2i}}) \qty(\ket{\phi_{2j-1}} - \ket{\phi_{2j}}) \notag\\
&= \dfrac{1}{2}\qty(\delta_{2i-1,2j-1} - 0 + 0 - \delta_{2i,2j}) \notag\\
&= \dfrac{1}{2}\qty(\delta_{i,j} - \delta_{i,j}) \notag\\
&= 0
\end{align}

For Eq. 5.140
\begin{align}
\Braket{i | h_{\eff} | i} &= \dfrac{1}{2}\qty(\bra{\phi_{2i-1}} + \bra{\phi_{2i}}) h_{\eff} \qty(\ket{\phi_{2i-1}} + \ket{\phi_{2i}}) \notag\\
&= \dfrac{1}{2} (\alpha + \beta + \beta + \alpha) \notag\\
&= \alpha + \beta
\end{align}
\begin{align}
\Braket{i^* | h_{\eff} | i^*} &= \dfrac{1}{2}\qty(\bra{\phi_{2i-1}} - \bra{\phi_{2i}}) h_{\eff} \qty(\ket{\phi_{2i-1}} - \ket{\phi_{2i}}) \notag\\
&= \dfrac{1}{2} (\alpha - \beta - \beta + \alpha) \notag\\
&= \alpha - \beta
\end{align}
\begin{align}
\Braket{i | h_{\eff} | i\pm 1} &= \dfrac{1}{2}\qty(\bra{\phi_{2i-1}} + \bra{\phi_{2i}}) h_{\eff} \qty(\ket{\phi_{2i-1\pm 2}} + \ket{\phi_{2i\pm 2}}) \notag\\
&= \left\{
\mqty{\dfrac{1}{2} (0 + 0 + \beta + 0) \qquad +  \\ ~\\
	  \dfrac{1}{2} (0 + \beta + 0 + 0) \qquad -
}\right. \notag\\
&= \beta/2
\end{align}
\begin{align}
\Braket{i^* | h_{\eff} | (i\pm 1)^*} &= \dfrac{1}{2} \qty(\bra{\phi_{2i-1}} - \bra{\phi_{2i}}) h_{\eff} \qty(\ket{\phi_{2i-1\pm 2}} - \ket{\phi_{2i\pm 2}}) \notag\\
&= \left\{
\mqty{\dfrac{1}{2} (0 - 0 - \beta + 0) \qquad +  \\ ~\\
	\dfrac{1}{2} (0 - \beta - 0 + 0) \qquad -
}\right. \notag\\
&= -\beta/2
\end{align}
\begin{align}
\Braket{i | h_{\eff} | (i\pm 1)^*} &= \dfrac{1}{2}\qty(\bra{\phi_{2i-1}} + \bra{\phi_{2i}}) h_{\eff} \qty(\ket{\phi_{2i-1\pm 2}} - \ket{\phi_{2i\pm 2}}) \notag\\
&= \left\{
\mqty{\dfrac{1}{2} (0 - 0 + \beta - 0) \qquad +  \\ ~\\
	\dfrac{1}{2} (0 - \beta + 0 - 0) \qquad -
}\right. \notag\\
&= \pm\beta/2
\end{align}

\ex{5.18}
\begin{align}
\Braket{\Psi_0 | \sH | \overset{*}{1}} &= 2^{-1/2} \Braket{\Psi_0 | \sH | \Psi_1^{2*} - \Psi_1^{3*}} \notag\\
&= 2^{-1/2}[\beta/2 - (-\beta/2)] \notag\\
&= 2^{-1/2}\beta
\end{align}
\begin{align}
\Braket{ \overset{*}{1} | \sH - E_0 | \overset{*}{1}} &= \dfrac{1}{2} \Braket{\Psi_1^{2*} - \Psi_1^{3*} | \sH - E_0 | \Psi_1^{2*} - \Psi_1^{3*}}
\notag\\
&= \dfrac{1}{2} \qty[
\Braket{\Psi_1^{2*} - \Psi_1^{3*} | \sH | \Psi_1^{2*} - \Psi_1^{3*}}
- \Braket{\Psi_1^{2*} - \Psi_1^{3*} | E_0 | \Psi_1^{2*} - \Psi_1^{3*}}
] \notag\\
&= \dfrac{1}{2} \qty[ 2(\alpha-\beta) - 2(-\beta/2) - 2E_0] \notag\\
&= \alpha - \beta/2 - E_0 \notag\\
&= -\dfrac{3}{2}\beta
\end{align}
thus
\begin{align}
2^{-1/2}\beta c &= e_1 \\
2^{-1/2}\beta -\dfrac{3}{2}\beta c &= e_1 c
\end{align}
the solutions are
\begin{equation}\label{key}
c = \dfrac{-3 \pm \sqrt{17}}{2\sqrt{2}} \qquad
e_1 = \dfrac{-3 \pm\sqrt{17}}{4}\beta
\end{equation}
and we take
\begin{equation}\label{key}
e_1 = \dfrac{-3 + \sqrt{17}}{4}\beta
\end{equation}

\ex{5.19}
\subex{a)}
\begin{align}
\ket{\Psi_1} = \ket{\Psi_0} + c_1\ket{\Psi_1^{1*}} + c_2\ket{\Psi_1^{2*}} + \cdots + c_n\ket{\Psi_1^{n*}}
\end{align}
Since
\begin{align}
\Braket{\Psi_0 | \sH | \Psi_1^{1*} } &= 0\\
\Braket{\Psi_0 | \sH | \Psi_1^{2*} } &= \beta/2 \\
\Braket{\Psi_0 | \sH | \Psi_1^{j*} } &= 0 \qquad (1<j<n)\\
\Braket{\Psi_0 | \sH | \Psi_1^{n*} } &= -\beta/2
\end{align}
thus,
\begin{align}
\ket{\Psi_1} = \ket{\Psi_0} + c\Ket{ \overset{*}{1}}
\end{align}
\begin{equation}\label{key}
\Ket{ \overset{*}{1}} = 2^{-1/2} \qty(\Ket{\Psi_1^{2*} } - \Ket{\Psi_1^{n*} })
\end{equation}
As before, we get
\begin{align}
\Braket{\Psi_0 | \sH | \overset{*}{1}} %&= 2^{-1/2} \Braket{\Psi_0 | \sH | \Psi_1^{2*} - \Psi_1^{3*}} \notag\\
%&= 2^{-1/2}[\beta/2 - (-\beta/2)] \notag\\
&= 2^{-1/2}\beta
\end{align}
but
\begin{align}
\Braket{ \overset{*}{1} | \sH - E_0 | \overset{*}{1}}
%&= \dfrac{1}{2} \Braket{\Psi_1^{2*} - \Psi_1^{n*} | \sH - E_0 | \Psi_1^{2*} - \Psi_1^{n*}}
%\notag\\
&= \dfrac{1}{2} \qty[
\Braket{\Psi_1^{2*} - \Psi_1^{3*} | \sH | \Psi_1^{2*} - \Psi_1^{3*}}
- \Braket{\Psi_1^{2*} - \Psi_1^{3*} | E_0 | \Psi_1^{2*} - \Psi_1^{3*}}
] \notag\\
&= \dfrac{1}{2} \qty[ 2(\alpha-\beta) - 2\times 0 - 2E_0] \notag\\
&= \alpha - \beta - E_0 \notag\\
&= -2\beta
\end{align}
thus
\begin{equation}\label{key}
e_1 = \qty(-1 + \dfrac{\sqrt{6}}{2})\beta
\end{equation}
\begin{align}\label{key}
E_R(\text{IEPA}) &= Ne_1 \notag\\
&= \qty(-1 + \dfrac{\sqrt{6}}{2})N\beta \notag\\
&= 0.2247 N\beta
\end{align}

\subex{b)}
As $ N=10 $,
\begin{align}
\ket{\Psi_1} = \ket{\Psi_0} + c_1\ket{\Psi_1^{1*}} + c_2\ket{\Psi_1^{2*}} + c_3\ket{\Psi_1^{3*}} + + c_4\ket{\Psi_1^{4*}} + c_5\ket{\Psi_1^{5*}}
\end{align}
As before, let
\begin{equation}\label{key}
\Ket{\overset{*}{1}} = 2^{-1/2}\qty(\ket{\Psi_1^{1*}} - \ket{\Psi_1^{5*}})
\end{equation}
\begin{equation}\label{key}
\ket{\Psi_1} = \ket{\Psi_0} + c_1\Ket{\overset{*}{1}} + c_3\ket{\Psi_1^{3*}} + + c_4\ket{\Psi_1^{4*}}
\end{equation}
then the "particle" equations will be
\begin{align}
\Braket{\Psi_0 | \sH | \overset{*}{1}} c_1 + \Braket{\Psi_0 | \sH | \Psi_1^{3*}}c_3 + \Braket{\Psi_0 | \sH | \Psi_1^{4*}}c_4 &= e_1 \\
\Braket{\overset{*}{1} | \sH | \Psi_0}
+ \Braket{\overset{*}{1} | \sH | \Psi_1^{3*}}c_3
+ \Braket{\overset{*}{1} | \sH | \Psi_1^{4*}}c_4
+ \Braket{\overset{*}{1} | \sH-E_0 | \overset{*}{1}}c_1 &= e_1 c_1 \\
\Braket{\Psi_1^{3*} | \sH | \Psi_0}
+ \Braket{\Psi_1^{3*} | \sH | \overset{*}{1}}c_1
+ \Braket{\Psi_1^{3*} | \sH | \Psi_1^{4*}}c_4
+ \Braket{\Psi_1^{3*} | \sH-E_0 | \Psi_1^{3*}}c_3 &= e_1 c_3 \\
\Braket{\Psi_1^{4*} | \sH | \Psi_0}
+ \Braket{\Psi_1^{4*} | \sH | \overset{*}{1}}c_1
+ \Braket{\Psi_1^{4*} | \sH | \Psi_1^{3*}}c_3
+ \Braket{\Psi_1^{4*} | \sH-E_0 | \Psi_1^{4*}}c_4 &= e_1 c_4
\end{align}
where
\begin{align}
\Braket{\Psi_0 | \sH | \overset{*}{1}} = 2^{-1/2}\beta \\
\Braket{\Psi_0 | \sH | \Psi_1^{3*}} = 0\\
\Braket{\Psi_0 | \sH | \Psi_1^{4*}} = 0
\end{align}
\begin{align}
\Braket{\overset{*}{1} | \sH-E_0 | \overset{*}{1}} = -2\beta
\end{align}
\begin{align}
\Braket{\Psi_1^{3*} | \sH-E_0 | \Psi_1^{3*}} = \Braket{\Psi_1^{4*} | \sH-E_0 | \Psi_1^{4*}} = \alpha - \beta - E_0 = -2\beta
\end{align}
\begin{align}
\Braket{\overset{*}{1} | \sH | \Psi_1^{3*}} &= 2^{-1/2}\qty[\Braket{\Psi_1^{2*} | \sH | \Psi_1^{3*}} - \Braket{\Psi_1^{5*} | \sH | \Psi_1^{3*}}] \notag\\
&= 2^{-1/2}(-\beta/2)
\end{align}
\begin{align}
\Braket{\overset{*}{1} | \sH | \Psi_1^{4*}} &= 2^{-1/2}\qty[\Braket{\Psi_1^{2*} | \sH | \Psi_1^{4*}} - \Braket{\Psi_1^{5*} | \sH | \Psi_1^{4*}}] \notag\\
&= 2^{-1/2} (\beta/2)
\end{align}
\begin{align}
\Braket{\Psi_1^{3*} | \sH | \Psi_1^{4*}}
&= -\beta/2
\end{align}
thus
\begin{align}
2^{-1/2}\beta c_1 &= e_1 \\
2^{-1/2}\beta + 2^{-1/2}(-\beta/2) c_3 + 2^{-1/2}(\beta/2) c_4 + (-2\beta) c_1 &= e_1 c_1\\
2^{-1/2}(-\beta/2) c_1 + (-\beta/2) c_4 + (-2\beta) c_3 = e_1 c_3\\
2^{-1/2} (\beta/2) c_1 + (-\beta/2) c_3 + (-2\beta) c_4 = e_1 c_4
\end{align}
or
\begin{align}
\mqty(0 & 2^{-1/2}\beta & 0 & 0\\
      2^{-1/2}\beta & -2\beta & 2^{-1/2}(-\beta/2) & 2^{-1/2}(\beta/2)\\
      0 & 2^{-1/2}(-\beta/2) & -2\beta & -\beta/2\\
      0 & 2^{-1/2}(\beta/2) & -\beta/2 & -2\beta)
\mqty(1 \\ c_1 \\ c_3 \\ c_4)
= e_1 \mqty(1 \\ c_1 \\ c_3 \\ c_4)
\end{align}
the eigenvalues are
\begin{equation}\label{key}
-\dfrac{5}{2}\beta \;\text{ or roots of }\;
(2e_1/\beta)^3 + 7(2e_1/\beta)^2 + 9(2e_1/\beta) - 6 = 0
\end{equation}
rearrange the cubic equation, we get
\begin{align}
4e_1^3 + 14\beta e_1^2 + 9\beta^2 e_1 - 3\beta^3 = 0
\end{align}
\begin{equation}\label{key}
e_1 = -2.4627\beta, -1.2760\beta, 0.2387\beta
\end{equation}
so we take
\begin{equation}\label{key}
e_1 = 0.2387\beta
\end{equation}

\ex{5.20}
\begin{align}
\Braket{\overset{*}{1} | \sH | \overset{*}{2}}
&= \dfrac{1}{2} \Braket{\Psi_1^{2*} - \Psi_1^{3*} | \sH | \Psi_2^{3*} - \Psi_2^{1*}} \notag\\
&= -\dfrac{1}{2} \Braket{\Psi_1^{3*} | \sH | \Psi_2^{3*} } \notag\\
&= -\dfrac{1}{2} (-1)\Braket{2 | h_{\eff} | 1} \notag\\
&= -\dfrac{1}{2} (-1)\beta/2 \notag\\
&= \beta/4
\end{align}
\begin{align}
\Braket{\overset{*}{1} | \sH | \overset{*}{3}}
&= \dfrac{1}{2} \Braket{\Psi_1^{2*} - \Psi_1^{3*} | \sH | \Psi_3^{1*} - \Psi_3^{2*}} \notag\\
&= -\dfrac{1}{2} \Braket{\Psi_1^{2*} | \sH | \Psi_3^{2*} } \notag\\
&= -\dfrac{1}{2} (-1)\beta/2 \notag\\
&= \beta/4
\end{align}
\begin{align}
\Braket{\overset{*}{2} | \sH | \overset{*}{3}}
&= \dfrac{1}{2} \Braket{\Psi_2^{3*} - \Psi_2^{1*} | \sH | \Psi_3^{1*} - \Psi_3^{2*}} \notag\\
&= -\dfrac{1}{2} \Braket{\Psi_2^{1*} | \sH | \Psi_3^{1*} } \notag\\
&= -\dfrac{1}{2} (-1)\beta/2 \notag\\
&= \beta/4
\end{align}
For SCI,
\begin{equation}\label{key}
\sum_{bs} v_{bs} c_b^s = E_R(\text{SCI})
\end{equation}
\begin{equation}\label{key}
v_{ra} + (\varepsilon_r^{(0)} + v_{rr})c_a^r + \sum_s v_{rs}c_a^s - (\varepsilon_a^{(0)} + v_{aa})c_a^r - \sum_b v_{ba}c_b^r = E_R(\text{SCI}) c_a^r
\end{equation}
thus
\begin{align}
6c\Braket{\overset{*}{i} | \sH | \Psi_0} &= E_R(\text{SCI}) \\
\Braket{\overset{*}{i} | \sH | \Psi_0}
+ c\Braket{\overset{*}{i} | \sH-E_0 | \overset{*}{i}}
+ \sum_{j\neq i} c\Braket{\overset{*}{j} | \sH | \overset{*}{i}}
%- \sum_{j\neq i} c\Braket{\overset{*}{j} | \sH | \overset{*}{i}}
&= E_R(\text{SCI}) c
\end{align}
i.e.
\begin{align}
6c\times 2^{-1/2}\beta &= E_R(\text{SCI}) \\
2^{-1/2}\beta + c\qty(-\dfrac{3}{2}\beta + 2\times \beta/4)
&= E_R(\text{SCI}) c
\end{align}
$ \therefore $
\begin{align}
6c\times 2^{-1/2}\beta &= E_R(\text{SCI}) \\
2^{-1/2}\beta - c\beta &= E_R(\text{SCI}) c
\end{align}
the solutions are
\begin{equation}\label{key}
E_R(\text{SCI}) = \dfrac{-1\pm\sqrt{13}}{2}\beta
\end{equation}
we take
\begin{equation}\label{key}
E_R(\text{SCI}) = \dfrac{-1+\sqrt{13}}{2}\beta
\end{equation}

\ex{5.21}
It's clear that
\begin{equation}\label{key}
\Braket{\Psi_0 | \sH |\overset{*}{i}} = 2^{-1/2}\beta
\end{equation}
while
\begin{align}
\Braket{\overset{*}{i} | \sH-E_0 | \overset{*}{j}}
&= \Braket{\overset{*}{i} | \sH | \overset{*}{j}} - E_0\delta_{ij} \notag\\
&= \Braket{\Psi_i^{(i+1)*} - \Psi_i^{(i-1)*} | \sH | \Psi_j^{(j+1)*} - \Psi_j^{(j-1)*}} - E_0\delta_{ij} %\notag\\
\end{align}
If $ i=j $,
\begin{align}
\Braket{\overset{*}{i} | \sH-E_0 | \overset{*}{j}}
%&= \Braket{\overset{*}{i} | \sH | \overset{*}{j}} - E_0\delta_{ij} \notag\\
&= \dfrac{1}{2}\Braket{\Psi_i^{(i+1)*} - \Psi_i^{(i-1)*} | \sH | \Psi_i^{(i+1)*} - \Psi_i^{(i-1)*}} - E_0 \notag\\
%%% See 5.19
&= \dfrac{1}{2}\times 2 (\alpha-\beta) - E_0 \notag\\
&= -2\beta
\end{align}
else,
\begin{align}
\Braket{\overset{*}{i} | \sH-E_0 | \overset{*}{j}}
%&= \Braket{\overset{*}{i} | \sH | \overset{*}{j}} - E_0\delta_{ij} \notag\\
&= \dfrac{1}{2}\Braket{\Psi_i^{(i+1)*} - \Psi_i^{(i-1)*} | \sH | \Psi_j^{(j+1)*} - \Psi_j^{(j-1)*}} \notag\\
&= - \dfrac{1}{2}\Braket{\Psi_i^{(i+1)*} | \sH |  \Psi_j^{(j-1)*}}
- \dfrac{1}{2}\Braket{\Psi_i^{(i-1)*} | \sH |  \Psi_j^{(j+1)*}} \notag\\
&= 0
\end{align}
thus
\begin{equation}\label{key}
\Braket{\overset{*}{i} | \sH-E_0 | \overset{*}{j}} = -2\beta \delta_{ij}
\end{equation}
Similar to Ex. 5.20, the SCI equations are
\begin{align}
Nc\times 2^{-1/2}\beta &= E_R(\text{SCI}) \\
2^{-1/2}\beta + c(-2\beta + 0) &= E_R(\text{SCI})c
\end{align}
$ \therefore $
\begin{equation}\label{key}
E_R(\text{SCI}) = \dfrac{-2 + \sqrt{2N + 4}}{2}\beta
= \qty[\sqrt{1+N/2} - 1] \beta
\end{equation}

\end{document}


\documentclass{article}

\title{Title of my document}
\date{2013-09-01}
\author{John Doe}

\usepackage{amsmath}

\begin{document}

\maketitle
\pagenumbering{gobble}
\newpage
\pagenumbering{arabic}
\begin{equation*}
  f(x) = x^2
\end{equation*}

\section{First}
section 1 text
\subsection{First1.1}
\subsubsection{Second1.1}

\paragraph{P1}
\subparagraph{P1.1}

\newpage
%\pagenumbering{arabic}
\section{Second}
section 2 text

\begin{equation*}
  1 + 2 = 3
\end{equation*}

\begin{equation*}
  1 = 3 - 2
\end{equation*}

\begin{align*}
  1 + 2 &= 3\\
  1 &= 3 - 2
\end{align*}

\end{document}


\section{Backflow wavefunctions}

\label{sec:backflow}

One can perturb the nodal surface of a single-Slater/multi-Slater wavefunction through use of a backflow transformation.  Specifically, if we have an antisymmetric function $D(\mathbf{x}_{0\uparrow},\cdots,\mathbf{x}_{N\uparrow}, \mathbf{x}_{0\downarrow},\cdots,\mathbf{x}_{N\downarrow})$, and if $i_\alpha$ is the $i$-th particle of species type $\alpha$, then the backflow transformation works by making the coordinate transformation $\mathbf{x}_{i_\alpha} \to \mathbf{x}'_{i_\alpha}$ and evaluating $D$ at these new ``quasiparticle" coordinates.  QMCPACK currently supports quasiparticle transformations given by

\begin{equation}\label{backflowdef}
\mathbf{x}'_{i_\alpha}=\mathbf{x}_{i_\alpha}+\sum_{\alpha \leq \beta} \sum_{i_\alpha \neq j_\beta} \eta^{\alpha\beta}(|\mathbf{x}_{i_\alpha}-\mathbf{x}_{j_\beta}|)(\mathbf{x}_{i_\alpha}-\mathbf{x}_{j_\beta})\:.
\end{equation}

Here, $\eta^{\alpha\beta}(|\mathbf{x}_{i_\alpha}-\mathbf{x}_{j_\beta}|)$ is a radially symmetric backflow transformation between species $\alpha$ and $\beta$.  In QMCPACK, particle $i_\alpha$ is known as the ``target" particle and $j_\beta$ is known as the ``source."  The main types of transformations are so-called one-body terms, which are between an electron and an ion $\eta^{eI}(|\mathbf{x}_{i_e}-\mathbf{x}_{j_I}|)$ and two-body terms.  Two-body terms are distinguished as those between like and opposite spin electrons:  $\eta^{e(\uparrow)e(\uparrow)}(|\mathbf{x}_{i_e(\uparrow)}-\mathbf{x}_{j_e(\uparrow)}|)$ and  $\eta^{e(\uparrow)e(\downarrow)}(|\mathbf{x}_{i_e(\uparrow)}-\mathbf{x}_{j_e(\downarrow)}|)$.  Henceforth, we will assume that $\eta^{e(\uparrow)e(\uparrow)}=\eta^{e(\downarrow)e(\downarrow)}$.

In the following, we explain how to describe general terms such as Eq.~\ref{backflowdef} in a QMCPACK XML file.  For specificity, we will consider a particle set consisting of H and He (in that order).  This ordering will be important when we build the XML file, so you can find this out either through your specific declaration of <particleset>, by looking at the hdf5 file in the case of plane waves, or by looking at the QMCPACK output file in the section labeled ``Summary of QMC systems."
\subsection{Input Specifications}
All backflow declarations occur within a single \ixml{<backflow> ... </backflow>} block.  Backflow transformations occur in \ixml{<transformation>} blocks and have the following input parameters:

\begin{table}[h]
\begin{center}
\begin{tabular}{l c c c l }
\hline
\multicolumn{5}{l}{Transformation element} \\
\hline
\bfseries Name & \bfseries Datatype & \bfseries Values & \bfseries Defaults  & \bfseries Description \\
\hline
name & Text &  & (Required) & Unique name for this Jastrow function. \\
type & Text & ``e-I" & (Required) & Define a one-body backflow transformation. \\
        &          & ``e-e" & & Define a two-body backflow transformation. \\
function & Text & B-spline & (Required) & B-spline type transformation (no other types supported). \\
source & Text &  &  & ``e" if two body, ion particle set if one body.\\
  \hline
\end{tabular}
%\end{tabular*}
\end{center}
\end{table}

Just like one- and two-body jastrows, parameterization of the backflow transformations are specified within the \ixml{<transformation>} blocks by  \ixml{<correlation>} blocks.  Please refer to Section~\ref{sec:onebodyjastrowspline} for more information.

\subsection{Example Use Case}
Having specified the general form, we present a general example of one-body and two-body backflow transformations in a hydrogen-helium mixture.  The hydrogen and helium ions have independent backflow transformations, as do the like and unlike-spin two-body terms.  One caveat is in order:  ionic backflow transformations must be listed in the order they appear in the particle set.  If in our example, helium is listed first and hydrogen is listed second, the following example would be correct.  However, switching backflow declaration to hydrogen first then helium, will result in an error.  Outside of this, declaration of one-body blocks and two-body blocks are not sensitive to ordering.

\begin{lstlisting}[style=QMCPXML]
<backflow>
<!--The One-Body term with independent e-He and e-H terms. IN THAT ORDER -->
<transformation name="eIonB" type="e-I" function="Bspline" source="ion0">
    <correlation cusp="0.0" size="8" type="shortrange" init="no" elementType="He" rcut="3.0">
        <coefficients id="eHeC" type="Array" optimize="yes">
            0 0 0 0 0 0 0 0
        </coefficients>
    </correlation>
    <correlation cusp="0.0" size="8" type="shortrange" init="no" elementType="H" rcut="3.0">
        <coefficients id="eHC" type="Array" optimize="yes">
            0 0 0 0 0 0 0 0
        </coefficients>
    </correlation>
</transformation>

<!--The Two-Body Term with Like and Unlike Spins -->
<transformation name="eeB" type="e-e" function="Bspline" >
    <correlation cusp="0.0" size="7" type="shortrange" init="no" speciesA="u" speciesB="u" rcut="1.2">
        <coefficients id="uuB1" type="Array" optimize="yes">
            0 0 0 0 0 0 0
        </coefficients>
    </correlation>
    <correlation cusp="0.0" size="7" type="shortrange" init="no" speciesA="d" speciesB="u" rcut="1.2">
        <coefficients id="udB1" type="Array" optimize="yes">
            0 0 0 0 0 0 0
        </coefficients>
    </correlation>
</transformation>
</backflow>
\end{lstlisting}

Currently, backflow works only with single-Slater determinant wavefunctions.  When a backflow transformation has been declared, it should be placed within the \ixml{<determinantset>} block, but outside of the \ixml{<slaterdeterminant>} blocks, like so:

\begin{lstlisting}[style=QMCPXML]
<determinantset ... >
    <!--basis set declarations go here, if there are any -->

    <backflow>
        <transformation ...>
          <!--Here is where one and two-body terms are defined -->
         </transformation>
     </backflow>

     <slaterdeterminant>
         <!--Usual determinant definitions -->
     </slaterdeterminant>
 </determinantset>
\end{lstlisting}

\subsection{Optimization Tips}
Backflow is notoriously difficult to optimize---it is extremely nonlinear in the variational parameters and moves the nodal surface around.  As such, it is likely that a full Jastrow+Backflow optimization with all parameters initialized to zero might not converge in a reasonable time.  If you are experiencing this problem, the following pointers are suggested (in no particular order).

\subsubsection{Get a good starting guess for $\Psi_T$:}

\begin{enumerate}
\item Try optimizing the Jastrow first without backflow.
\item Freeze the Jastrow parameters, introduce only the e-e terms in the backflow transformation, and optimize these parameters.
\item Freeze the e-e backflow parameters, and then optimize the e-I terms.
  \begin{itemize}
    \item If difficulty is encountered here, try optimizing each species independently.
  \end{itemize}
\item Unfreeze all Jastrow, e-e backflow, and e-I backflow parameters, and reoptimize.

\end{enumerate}

\subsubsection{Optimizing Backflow Terms}

It is possible that the previous prescription might grind to a halt in steps 2 or 3 with the inability to optimize the e-e or e-I backflow transformation independently, especially if it is initialized to zero.  One way to get around this is to build a good starting guess for the e-e or e-I backflow terms iteratively as follows:

\begin{enumerate}
\item Start off with a small number of knots initialized to zero.  Set $r_{cut}$ to be small (much smaller than an interatomic distance).
\item Optimize the backflow function.
\item If this works, slowly increase $r_{cut}$ and/or the number of knots.
\item Repeat steps 2 and 3 until there is no noticeable change in energy or variance of $\Psi_T$.
\end{enumerate}

\subsubsection{Tweaking the Optimization Run}

The following modifications are worth a try in the optimization block:

\begin{itemize}
\item Try setting ``useDrift" to ``no."  This eliminates the use of wavefunction gradients and force biasing in the VMC algorithm.  This could be an issue for poorly optimized wavefunctions with pathological gradients.
\item Try increasing ``exp0" in the optimization block.  Larger values of exp0 cause the search directions to more closely follow those predicted by steepest-descent than those by the linear method.
\end{itemize}

Note that the new adaptive shift optimizer has not yet been tried with backflow wavefunctions. It should perform better than the older optimizers, but a considered optimization process is still recommended.


\subsubsection{Influence of Window Size Determination} \label{influence_of_window_size_determination}
92 different simulations have been tested that use $\eta$DTW with a Sakoe-Chiba band of size 36\% depending on the
input time series length and \textit{HAveD} as threshold determination. \textit{Ave}, \textit{Max}, \textit{Mid} and
\textit{Min} as window size determination each have respectively 23 different simulations. Figure
\ref{fig:window_size_result} illustrates the distribution of the four subsets. It is clearly visible that the
\textit{Mid} window size determination reaches the best $Precision_{\mu}$, $Recall_{\mu}$ and $F_{1}score_{\mu}$
values in the experiment. The \textit{Ave} window size determination achieves also much better performance as
\textit{Max} and \textit{Min}.

\begin{figure}[H]
    \begin{center}
        \resizebox {\textwidth} {!} {
            \begin{tabular}{cc}
                \resizebox {!} {\height} {
                    \begin{tikzpicture}
                        \begin{axis}[
                            legend pos=north west,
                            xmin=0.5,
                            xmax=1,
                            ymin=0.2,
                            ymax=0.7,
                            width=\axisdefaultwidth,
                            height=\axisdefaultwidth,
                            xlabel=$Precision_{\mu}$,
                            ylabel=$Recall_{\mu}$,
                            samples=100]
                            \addplot[blue, only marks, mark size=1] table {../data/fig/window_size_result/ave.dat};
                            \addlegendentry{Ave}
                            \addplot[red, only marks, mark size=1] table {../data/fig/window_size_result/max.dat};
                            \addlegendentry{Max}
                            \addplot[green, only marks, mark size=1] table {../data/fig/window_size_result/mid.dat};
                            \addlegendentry{Mid}
                            \addplot[violet, only marks, mark size=1] table {../data/fig/window_size_result/min.dat};
                            \addlegendentry{Min}
                            \addplot[gray, domain=0.16:1] {(0.3 * x) / (2 * x - 0.3)};
                            \addplot[gray, domain=0.21:1] {(0.4 * x) / (2 * x - 0.4)};
                            \addplot[gray, domain=0.26:1] {(0.5 * x) / (2 * x - 0.5)};
                            \addplot[gray, domain=0.31:1] {(0.6 * x) / (2 * x - 0.6)};
                            \addplot[gray, domain=0.36:1] {(0.7 * x) / (2 * x - 0.7)};
                            \addplot[gray, domain=0.41:1] {(0.8 * x) / (2 * x - 0.8)};
                        \end{axis}
                    \end{tikzpicture}
                } &
                \resizebox {!} {\height} {
                    \begin{tikzpicture}
                        \begin{axis}[
                            xmin=0,
                            xmax=1,
                            ymin=0,
                            ymax=1,
                            width=\axisdefaultwidth,
                            height=\axisdefaultwidth,
                            xlabel=$Precision_{\mu}$,
                            ylabel=$Recall_{\mu}$,
                            samples=100]
                            \addplot[blue, only marks, mark size=1] table {../data/fig/window_size_result/ave.dat};
                            \addplot[red, only marks, mark size=1] table {../data/fig/window_size_result/max.dat};
                            \addplot[green, only marks, mark size=1] table {../data/fig/window_size_result/mid.dat};
                            \addplot[violet, only marks, mark size=1] table {../data/fig/window_size_result/min.dat};
                            \addplot[gray, domain=0.051:1] {(0.1 * x) / (2 * x - 0.1)};
                            \addplot[gray, domain=0.11:1] {(0.2 * x) / (2 * x - 0.2)};
                            \addplot[gray, domain=0.16:1] {(0.3 * x) / (2 * x - 0.3)};
                            \addplot[gray, domain=0.21:1] {(0.4 * x) / (2 * x - 0.4)};
                            \addplot[gray, domain=0.26:1] {(0.5 * x) / (2 * x - 0.5)};
                            \addplot[gray, domain=0.31:1] {(0.6 * x) / (2 * x - 0.6)};
                            \addplot[gray, domain=0.36:1] {(0.7 * x) / (2 * x - 0.7)};
                            \addplot[gray, domain=0.41:1] {(0.8 * x) / (2 * x - 0.8)};
                            \addplot[gray, domain=0.46:1] {(0.9 * x) / (2 * x - 0.9)};
                        \end{axis}
                    \end{tikzpicture}
                }
            \end{tabular}
        }
    \end{center}
    \caption{$Precision_{\mu}$ and $Recall_{\mu}$ of all simulations that use $\eta$DTW with a Sakoe-Chiba band of size
    36\% depending on the input time series length and \textit{HAveD} as threshold determination, separated
    by the used window size determination. The left plot is a zoomed version of the right plot. Gray lines are
    illustrating the distribution of $F_{1}score_{\mu}$ in $\frac{1}{10}$ steps.}
    \label{fig:window_size_result}
\end{figure}


\subsubsection{Spline form}
\label{sec:onebodyjastrowspline}

The one-body spline Jastrow function is the most commonly used one-body Jastrow for solids. This form
was first described and used in \cite{EslerKimCeperleyShulenburger2012}.
Here $u_{ab}$ is an interpolating 1D B-spline (tricublc spline on a linear grid) between zero distance and $r_{cut}$. In 3D periodic systems
the default cutoff distance is the Wigner Seitz cell radius. For other periodicities, including isolated
molecules, the $r_{cut}$ must be specified. The cusp can be set.   $r_i$
and $R_I$ are most commonly the electron and ion positions, but any particlesets that can provide the
needed centers can be used.

\paragraph{Input specification}
\begin{table}[h]
\begin{center}
\begin{tabular}{l c c c l }
\hline
\multicolumn{5}{l}{Correlation element} \\
\hline
\bfseries Name & \bfseries Datatype & \bfseries Values & \bfseries Defaults & \bfseries Description \\
\hline
ElementType & Text & Name & See below & Classical particle target  \\
SpeciesA & Text & Name & See below & Classical particle target \\
SpeciesB & Text & Name & See below & Quantum species target \\
Size & Integer & $> 0$ & (Required) & Number of coefficients \\
Rcut & Real & $> 0$ & See below & Distance at which the correlation goes to 0 \\
Cusp & Real & $\ge 0$ & 0 & Value for use in Kato cusp condition \\
Spin & Text & Yes or no & No & Spin-dependent Jastrow factor \\
\hline
\multicolumn{5}{l}{Elements}\\ \hline
& Coefficients & & & \\ \hline
\multicolumn{5}{l}{Contents}\\ \hline
& (None)  & & &  \\ \hline
\end{tabular}
%\end{tabular*}
\end{center}
\end{table}

Additional information:

 \begin{itemize}
 \item \ixml{elementType, speciesA, speciesB, spin}.  For a spin-independent Jastrow factor (spin = ``no''),
elementType should be the name of the group of ions in the classical particleset to which the quantum
particles should be correlated.  For a spin-dependent Jastrow factor (spin = ``yes''), set speciesA to the
group name in the classical particleset and speciesB to the group name in the quantum particleset.
 \item \ixml{rcut}. The cutoff distance for the function in atomic units (bohr).
For 3D fully periodic systems, this parameter is optional, and a default of the Wigner
Seitz cell radius is used. Otherwise this parameter is required.
 \item \ixml{cusp}. The one-body Jastrow factor can be used to make the wavefunction
satisfy the electron-ion cusp condition\cite{kato}.  In this case, the derivative of the Jastrow
factor as the electron approaches the nucleus will be given by
\begin{equation}
\left(\frac{\partial J}{\partial r_{iI}}\right)_{r_{iI} = 0} = -Z .
\end{equation}
Note that if the antisymmetric part of the wavefunction satisfies the electron-ion cusp
condition (for instance by using single-particle orbitals that respect the cusp condition)
or if a nondivergent pseudopotential is used, the Jastrow should be cuspless at the
nucleus and this value should be kept at its default of 0.
 \end{itemize}

\begin{table}[h]
\begin{center}
\begin{tabular}{l c c c l }
\hline
\multicolumn{5}{l}{Coefficients element} \\
\hline
\bfseries Name & \bfseries Datatype & \bfseries Values & \bfseries Defaults & \bfseries Description \\
\hline
Id & Text & & (Required) & Unique identifier \\
Type & Text & Array & (Required) & \\
Optimize & Text & Yes or no & Yes & if no, values are fixed in optimizations \\
\hline
\multicolumn{5}{l}{Elements}\\ \hline
(None) & & & \\ \hline
\multicolumn{5}{l}{Contents}\\ \hline
 (No name) & Real array & & Zeros & Jastrow coefficients \\ \hline
\end{tabular}
%\end{tabular*}
\end{center}
\end{table}

\paragraph{Example use cases}
\label{sec:1bjsplineexamples}

Specify a spin-independent function with four parameters. Because rcut  is not
specified, the default cutoff of the Wigner Seitz cell radius is used; this
Jastrow must be used with a 3D periodic system such as a bulk solid. The name of
the particleset holding the ionic positions is ``i."
\begin{lstlisting}[style=QMCPXML]
<jastrow name="J1" type="One-Body" function="Bspline" print="yes" source="i">
 <correlation elementType="C" cusp="0.0" size="4">
   <coefficients id="C" type="Array"> 0  0  0  0  </coefficients>
 </correlation>
</jastrow>
\end{lstlisting}

Specify a spin-dependent function with seven up-spin and seven down-spin parameters.
The cutoff distance is set to 6 atomic units.  Note here that the particleset holding
the ions is labeled as ion0 rather than ``i,'' as in the other example.  Also in this case,
the ion is lithium with a coulomb potential, so the cusp condition is satisfied by
setting cusp=``d."
\begin{lstlisting}[style=QMCPXML]
<jastrow name="J1" type="One-Body" function="Bspline" source="ion0" spin="yes">
  <correlation speciesA="Li" speciesB="u" size="7" rcut="6">
    <coefficients id="eLiu" cusp="3.0" type="Array">
    0.0 0.0 0.0 0.0 0.0 0.0 0.0
    </coefficients>
  </correlation>
  <correlation speciesA="C" speciesB="d" size="7" rcut="6">
    <coefficients id="eLid" cusp="3.0" type="Array">
    0.0 0.0 0.0 0.0 0.0 0.0 0.0
    </coefficients>
  </correlation>
</jastrow>
\end{lstlisting}


%
%$Id: airseaIntro.tex,v 1.2 2005-07-06 14:11:27 kbk Exp $
%

\section{Air--Sea interaction \label{sec:airseaIntro}}

\subsection{Introduction}

This module provides the surface forcing for GOTM. For all dynamic
equations, surface boundary conditions need to be specified.  For the
momentum equations described in \sect{sec:uequation} and
\sect{sec:vequation}, these are the surface momentum fluxes $\tau_x^s$ and
$\tau_y^s$ in N\,m$^{-2}$. For the temperature
equation described in \sect{sec:temperature}, it is the total surface heat flux,
\begin{equation}
  Q_{tot}=Q_E+Q_H+Q_B
\end{equation}
in W\,m$^{-2}$ that has to be determined\footnote{Note, that $Q_{tot}$
has to be divided by the mean density and the specific heat capacity
to be used as a boundary condition in \eq{TEq}, since this equation is
formulated in terms of the temperature, and the the internal
energy}. The total surface heat flux $Q_{tot}$ is calculated as the
sum of the latent heat flux $Q_E$, the sensible heat flux $Q_H$, and
the long wave back radiation $Q_B$.  In contrast to the total surface
heat flux $Q_{tot}$, the net short wave radiation at the surface,
$I_0$, is not used as a boundary condition but as a source of heat, as
calculated by means of equation \eq{Iz}, see \cite{PaulsonSimpson77}.
For the salinity equation described in \sect{sec:salinity}, the fresh
water fluxes at the surface are given by the difference
of the evaporation and the
precipitation, $p_e$, given in m\,s$^{-1}$, see also the surface boundary
condition for salinity, \eq{S_sbc}.
The way how boundary conditions for the
transport equations of turbulent quantities are derived, is discussed
in \sect{sec:turbulenceIntro}.

There are basically two ways of calculating the surface heat and
momentum fluxes implemented into GOTM. They are either prescribed (as
constant values or to be read in from files) or calculated on the
basis of standard meteorological data which have to be read in from
files. The necessary parameters are
the wind velocity vector at 10 m height in m\,s$^{-1}$,
the sea surface temperature (SST in Celsius),
air temperature in Celsius), air humidity (either as relative humidity
in \%, as wet bulb temperature or as dew point
temperature in Celsius) and air pressure (in hectopascal), each at 2 m height
above the sea surface, and
the wind velocity vector at 10 m height in m\,s$^{-1}$.
Instead of the observed SST,
also the SST from the model may be used.  For the calculation of these
fluxes, the bulk formulae of \cite{Kondo75} or \cite{Fairalletal96}
are used.