\section*{Appendix}
\addcontentsline{toc}{section}{Appendix}
\renewcommand{\thesubsection}{\Alph{subsection}}
\setcounter{subsection}{0}

% Proof source: https://archive.cnx.org/contents/48100338-6af8-4c8b-afed-e15fd821cae6@5/discrete-time-markov-chains-state-classifications

\subsection{Proof of null recurrent chain}
\label{sec:proof-null-recurrent}

\begin{figure}[!b]
	\centering
	\includegraphics[width=0.6\textwidth]{appendix/mcmc-null-recurrent}
	\caption[Null recurrent Markov chain]{An example for a null recurrent Markov chain. It was introduced in figure \ref{fig:recurrent} as an example of a null recurrent Markov chain.}
	\label{fig:null-recurrent}
\end{figure}

In section \ref{sec:markov-properties} several properties of a Markov chain were introduced. An example of a \emph{null recurrent} Markov chain was given in figure \ref{fig:recurrent}. The null recurrent property of that chain will be proven in this appendix section. As a reminder the chain is shown again in figure \ref{fig:null-recurrent}. Also remind the definition of the random variable $T_{x_i}$ in equation \eqref{eq:first-comeback}, which is the number of steps necessary to come back to state $x_i$ for the \emph{first time}. A state is recurrent if $\Pb(T_{x_i} < \infty) = 1$, which corresponds to equation \eqref{eq:recurrent} and null recurrent if $\E[T_i] = \infty$, which was defined in \eqref{eq:first-comeback-expect} and the following.

First, a homogen Markov chain is assumed and an infinite state space $S = \{x_1, x_2, x_3, x_4, ...\} = \{A, B, C, D, ...\}$ is given. $\Pb(T_{x_i} = t)$ will be denoted by $q_{x_i}^t$. It is the probability to come back to state $x_i$ for the first time after $t$ steps. Therefore, starting from state $A$, the probability to come back to state $A$ in only one step is

\begin{equation}
q_A^1 = \Pb(T_A = 1) = \Pb(X_1 = A | X_0 = A) = p_{AA} = 0.
\end{equation}

Since $A$ has no self-loop, it is impossible to come back to $A$ in just one step. For two steps, a non-zero probability exists:

\begin{equation}
\begin{split}
q_A^2 &= \Pb(T_A = 2)\\
&= \Pb(X_1 = B | X_0 = A) \cdot \Pb(X_2 = A | X_1 = B)\\
&= p_{AB} \cdot p_{BA} = 1 \cdot \frac{1}{2} = \frac{1}{2}
\end{split}
\end{equation}

Results are similar for $t=3$, $t=4$ and $t=5$ steps:

\begin{subequations}
\begin{equation}
q_A^3 = p_{AB} \cdot p_{BC} \cdot p_{CA} = 1 \cdot \frac{1}{2} \cdot \frac{1}{3} = \frac{1}{6}
\end{equation}
\begin{equation}
q_A^4 = p_{AB} \cdot p_{BC} \cdot p_{CD} \cdot p_{DA} = 1 \cdot \frac{1}{\cancel{2}} \cdot \frac{\cancel{2}}{3} \cdot \frac{1}{4} = \frac{1}{3} \cdot \frac{1}{4} = \frac{1}{12}
\end{equation}
\begin{equation}
q_A^5 = p_{AB} \cdot p_{BC} \cdot p_{CD} \cdot p_{DE} \cdot p_{EA} = 1 \cdot \frac{1}{\cancel{2}} \cdot \frac{\cancel{2}}{\cancel{3}} \cdot \frac{\cancel{3}}{4} \cdot \frac{1}{5} = \frac{1}{4} \cdot \frac{1}{5} = \frac{1}{20}
\end{equation}
\end{subequations}

It can easily be seen that $q_A^t$ follows a specific rule, namely

\begin{equation}
q_A^t = \frac{1}{t-1} \frac{1}{t},
\end{equation}

for all $t>1$. Note that it does not hold for $t=1$.

Using this rule, the probability to come back to state $A$ can be obtained by

\begin{equation}
\begin{split}
\Pb(T_A < \infty) &= \sum_{t=1}^\infty \Pb(T_A = t) = \sum_{t=1}^\infty q_A^t\\
&= 0 + \sum_{t=2}^\infty \frac{1}{t-1} \frac{1}{t} = \sum_{t=1}^\infty \frac{1}{t} \frac{1}{t+1}.
\end{split}
\end{equation}

With induction it can be shown that

\begin{equation}
\Pb(T_A < \infty) = \sum_{t=1}^\infty \frac{1}{t} \frac{1}{t+1} = \lim_{n \to\infty} \frac{n-1}{n} = 1.
\end{equation}

Hence, equation \eqref{eq:recurrent} is fulfilled and state $A$ is recurrent. It remains to show that the state is also null recurrent. In order to verify this, the expectation value can be calculated using

\begin{equation}
\begin{split}
\E[T_A] &= \sum_{t=1}^\infty t \cdot \Pb(T_A = t)\\
&= 0 + \sum_{t=2}^\infty t \cdot \frac{1}{t-1} \frac{1}{t} = \sum_{t=2}^\infty \frac{1}{t-1} = \sum_{t=1}^\infty \frac{1}{t} = \infty,
\end{split}
\end{equation}

where the last step follows from the harmonic series. It was possible to show that the expected number of steps, necessary to come back to state $A$ for the first time, are infinite. Equation \eqref{eq:first-comeback-expect} is fulfilled and state $A$ is null recurrent.

\hfill$\square$

\newpage

\subsection{Testing phase with STDP}
\label{sec:appendix:stdp}

\begin{figure}[!b]
    \centering
    \begin{subfigure}{0.48\textwidth}
    	\centering
        \includegraphics[width=\textwidth]{appendix/stdp_with_test_traces_distances}
        \caption{}
        \label{fig:stdp-with-trace}
    \end{subfigure}
    \hfill
    \begin{subfigure}{0.48\textwidth}
    	\centering
        \includegraphics[width=\textwidth]{appendix/stdp_with_performance_distances}
        \caption{}
        \label{fig:stdp-with-perf}
    \end{subfigure}
    \begin{subfigure}{0.48\textwidth}
    	\centering
        \includegraphics[width=\textwidth]{appendix/stdp_without_test_traces_distances}
        \caption{}
        \label{fig:stdp-without-test}
    \end{subfigure}
    \hfill
    \begin{subfigure}{0.48\textwidth}
    	\centering
        \includegraphics[width=\textwidth]{appendix/stdp_without_performance_distances}
        \caption{}
        \label{fig:stdp-without-perf}
    \end{subfigure}
    \caption[Performance with and without STDP in testing phase]{Performance with and without \acs{stdp} in testing phase. \textbf{a)} shows that the error increases quite fast in the testing phase with \acs{stdp}, compared to \textbf{c)}, where \acs{stdp} was switched off. \textbf{b)} and \textbf{d)} shows the performance at the end of the testing phase for both cases. As the error and the standard error is higher in the case with \acs{stdp}, the differences between the models are mainly maintained. Note that the testing phase was extended to $T_\test = 200,000$ steps and that the $y$-axis of the plots is fixed to $0.08$ for comparison. Error bars indicate standard errors.}
    \label{fig:stdp-with-without}
\end{figure}

The \acf{stdp} is responsible for the dynamics in the weights. It was applied while training to adjust the weights with respect to the time-dependent input patterns. Afterwards, while no-plastic training and while testing, \acs{stdp} was switched off in order to sustain the learned structure. In results, e.g. in figure \ref{fig:mc1-test_traces-transition}, it was shown that the static structure in the testing phase results in a constant performance. If \acs{stdp} is active in testing phase and, therefore, weights are further adapted, spontaneous activity should lead to random changes in the weights, which will increasingly occur independent from the initial Markov chain transitions. Subsequently, the stored state transitions should decay. The testing phase was extended to $T_\test = 200,000$ steps to be able to observe the process for a longer time and the model series II from figure \ref{fig:mc2-models} was used with $5$ models.

Figure \ref{fig:stdp-with-trace} shows that the network `forgets' the stored information and the effect seems to be stronger for those Markov models, where errors were initially higher. The results can be compared to figure \ref{fig:stdp-without-test}, where also $T_\test = 200,000$ were simulated, but with \acs{stdp} switched off, as it was done in all previous simulations. The error increases quickly in the beginning and seems to maintain at a specific level. Interestingly, the differences between the models remain over the whole $200,000$ steps. Finally, figures \ref{fig:stdp-with-perf} and \ref{fig:stdp-without-perf} show the performance for both cases at the end of the testing phase. Those plots support the prior analysis. As the error and the standard error is higher in the simulation with \acs{stdp}, compared to the simulation without it, the differences between the models are basically maintained.

\newpage

\subsection{No-plastic training}
\label{sec:appendix:noplastic}

The length of the no-plastic training phase, which was introduced in section \ref{sec:train}, should have no influence on the performance. Its objective is to classify the current state of the network, when only spontaneous activity is in the network. Even if the input is still active in the no-plastic training phase, the main training effect should come from the plastic training phase, when the network adjusts the weights using \acs{stdp} and input is given for a long time of $T_\plastic = 50,000$ steps in most cases.

The number of steps in the no-plastic training phase $T_\noplastic$ was varied for model series II from figure \ref{fig:mc2-models} with $5$ models. As can be seen in figure \ref{fig:noplastic}, there is no influence on the performance of the models. The performance is independent from the number of no-plastic training steps. There are some slight differences in model $1$, but they are not significant ($p > 0.05$). Note that it is not possible to set the number of training steps below the number of steps to compare with. That actually means that necessarily $T_\noplastic > \tilde{T}_{\text{compare}}$, as already discussed in the methods section.

\begin{figure}[!b]
	\centering
	\includegraphics[width=0.85\textwidth]{appendix/noplastic_train}
	\caption[Influence of the length of the no-plastic training phase]{Influence of the length of the no-plastic training phase $T_\noplastic$. The parameter was chosen between $T_\noplastic = 10,000$ and $T_\noplastic = 90,000$. The length of the no-plastic training phase does not influence the performance of the models.}
	\label{fig:noplastic}
\end{figure}

\clearpage

\subsection{Hamming classification}
\label{sec:appendix:hamming}

\begin{figure}[p]
    \centering
    \begin{subfigure}{0.48\textwidth}
    	\centering
        \includegraphics[width=\textwidth]{appendix/hamming_freqs_model1}
        \caption{Model $1$}
        \label{fig:ham-freq-1}
    \end{subfigure}
    \hfill
    \begin{subfigure}{0.48\textwidth}
    	\centering
        \includegraphics[width=\textwidth]{appendix/hamming_freqs_model2}
        \caption{Model $2$}
        \label{fig:ham-freq-2}
    \end{subfigure}
    \begin{subfigure}{0.48\textwidth}
    	\centering
        \includegraphics[width=\textwidth]{appendix/hamming_freqs_model3}
        \caption{Model $3$}
        \label{fig:ham-freq-3}
    \end{subfigure}
    \hfill
    \begin{subfigure}{0.48\textwidth}
    	\centering
        \includegraphics[width=\textwidth]{appendix/hamming_freqs_model3}
        \caption{Model $4$}
        \label{fig:ham-freq-4}
    \end{subfigure}
    \begin{subfigure}{0.48\textwidth}
    	\centering
        \includegraphics[width=\textwidth]{appendix/hamming_freqs_model5}
        \caption{Model $5$}
        \label{fig:ham-freq-5}
    \end{subfigure}
    \caption[Histograms of minimum hamming distances for 5 models]{Histograms of minimum hamming distances for 5 models. The minimum hamming distances are normally distributed. The variances of the minimum hamming distances decrease if training is increased. The mean also decreases, as long as state $A$ is not to unlikely. Furthermore, the mean decreases if state $A$ is more and more equally connected to the other states and the states in the model becomes more regular.}
    \label{fig:ham-freqs}
\end{figure}

The purpose of this section is to evaluate the classification mechanism, based on the hamming distance. The systematic model series II was used for evaluation,, shown in figure \ref{fig:mc2-models} in results. The series was realized with $5$ models. The hamming distance calculation was introduced in section \ref{sec:state-classification}. In a first step, histograms were plotted, showing the frequencies of the smallest hamming distances for every step in the testing phase, where any testing phase step was compared with all comparison steps from the no-plastic testing phase. Results are shown in figure \ref{fig:ham-freqs}. There are three notable effects:

\begin{figure}[!t]
    \centering
    \begin{subfigure}{0.48\textwidth}
    	\centering
        \includegraphics[width=\textwidth]{appendix/hamming_distances_training_steps_with_thresholds}
        \caption{}
        \label{fig:ham-thesholds}
    \end{subfigure}
    \hfill
    \begin{subfigure}{0.48\textwidth}
    	\centering
        \includegraphics[width=\textwidth]{appendix/hamming_distances_training_steps_hamming}
        \caption{}
        \label{fig:ham-training-hamming}
    \end{subfigure}
    \caption[Performance results associated with hamming distances]{Performance results associated with hamming distances. In \textbf{a)} thresholds of $20,22,24$ and $26$ were applied. If the minimum hamming distance exceeded that threshold, the current pattern was classified as `unknown'. In the legend they are represented with the transparent lines for each model. They are compared to the default case, were no threshold was applied. In that case the threshold is infinity. It is represented by the opaque line for each model. In figure \textbf{b)}, the mean minimum hamming distance was calculated and divided by the maximum possible hamming distance $N^E$. The relative mean hamming distance can be used as a performance measure. Differences between the models are present and a training effect occurs. But since this measure is very robust and, therefore, effects are very small compared to the transition error, this performance measure was not used.}
    \label{fig:ham-thraining}
\end{figure}

\begin{itemize}
\item A Kolmogorov-Smirnov test was performed, showing that all minimum hamming distances are normally distributed ($p > 0.05$).
\item The more the model contains less probable states (model $1$ has fewest transition probability to state $A$, model $5$ is equal for every state), the higher is the mean of the minimum hamming distances in tendency.
\item The more the network was trained, the lower is the variance and the mean of the minimum hamming distances in tendency. This effect is stronger for models with states which occur with similar probabilities.
\end{itemize}

Furthermore, it was checked if the classification method has an influence on the performance. In section \ref{sec:state-classification} a parallel to the $k$-nearest neighbor algorithm with $k=1$ was drawn. The classification mechanism does only search for the one activity pattern which is closest. The hamming distance could be the same for activity patterns that belong to different Markov states. In that case, the algorithm just chooses the first one. It would be possible to apply a threshold which classifies states as `unknown' if the minimum hamming distance is too high. That is the case, if the state in the network is not very clear. It was checked if such a stricter rule, using a threshold, influences the behavior. Figure \ref{fig:ham-thesholds} shows that  this is not the case. The transparent lines show the performance of different thresholds. The opaque line represents a threshold of infinity, which equals no threshold at all, and therefore represents the algorithm which was used by default. If a threshold is applied, its performance seems to be very similar to the performance of the infinite threshold. Hence, the original algorithm seems to be very robust.

Finally, the relative mean hamming distance was calculated. The minimum hamming distances were averaged and divided by the maximum possible hamming distance $N^E$ in order to provide another performance measure. The better the model is learned, the lower should be the minimum hamming distance. Indeed, figure \ref{fig:ham-training-hamming} shows that the relative mean hamming distance behaves similar to the other performance measures. But the differences between the models and the decrease in performance, due to training, seems to be very low. Therefore, the relative mean hamming distance is not an appropriate performance measure. On the other hand, it shows again that the hamming distance is very robust between the models and regarding more or less training.

\newpage

\subsection{Models close to equal probabilities}
\label{sec:appendix:close}

In most cases, the `equal' model, where the probability of all available connections is $0.5$, was outstanding in performance. There was a drop between this model and the very next model, e.g. in figure \ref{fig:mc2-performance-distance}, \ref{fig:mc3-performance-distance} or \ref{fig:mc6-performance-distance} in the results section. In this section, starting from the `equal' model, the probabilities were varied in very small steps to be able to observe the behavior for very small changes. For evaluation, the model series II from figure \ref{fig:mc2-models} was adapted to a series which is shown in figure \ref{fig:mc2b-models}. This series was applied with $76$ steps between the left and right model. Therefore, the probabilities were changed in very small steps.

\begin{figure}[!h]
	\centering
	\includegraphics[width=0.85\textwidth]{appendix/mc2b_models}
	\caption[Model series close to equal probabilities]{Model series close to equal probabilities. This series is adapted from the model series II in figure \ref{fig:mc2-models}, where the starting probability is already chosen more close to the `equal' model. This series was divided into $76$ steps with very small probability changes.}
	\label{fig:mc2b-models}
\end{figure}

The results are shown in figure \ref{fig:mc2b-performance}. Starting from the right, were all probabilities are equal, the error starts to increase very fast. Small changes seem to influence the performance more strongly if the models are close to the `equal' model. The performance change of the models on the left side is small. Therefore, those models seem to be more robust to changes of the probabilities. Whereas the models on the right are very sensitive to changes of the probabilities.

\begin{figure}[p]
	\centering
	\includegraphics[width=0.85\textwidth]{appendix/mc2b_performance_distances}
	\caption[Performance of model series close to equal probabilities]{Performance of model series close to equal probabilities. $76$ models were applied and the probabilities were changed in very small steps. The network is sensitive to changes around the `equal' model (last model on the right) and becomes more robust towards the more unequal models (right to left).}
	\label{fig:mc2b-performance}
\end{figure}

\clearpage

\subsection{IP learning rate}
\label{sec:appendix:eta}

The \acs{ip} mechanism was suggested to explain the performance differences of the different input patterns, sampled from the Markov chains. The \acl{ip} rule is build with three parameters, introduced in equation \eqref{eq:hip-ind} in methods. $\bar H^\IP$ and $\sigma^\IP$ were already tested in section \ref{sec:ip-hyp} in results, but the impact of the learning rate parameter $\eta_\IP$ remains to be checked. The model series II from figure \ref{fig:mc2-models} was used and applied with $5$ models.

Figure \ref{fig:eta-small} shows that a very small $\eta_\IP = 0.0002$ increases the burn-in time in the testing phase. The network needs a long time until it finds a stable performance. If the parameter is very high, like in figure \ref{fig:eta-huge}, where $\eta_\IP = 0.002$, the performance starts to be stable after the first few steps in testing phase. This also happens for the default case with $\eta_\IP = 0.001$, shown in figure \ref{fig:eta-norm}.

\begin{figure}[!b]
    \centering
    \begin{subfigure}{0.48\textwidth}
    	\centering
        \includegraphics[width=\textwidth]{appendix/etaip_test_traces_distances_smallhip}
        \caption{$\eta_\IP = 0.0002$}
        \label{fig:eta-small}
    \end{subfigure}
    \hfill
    \begin{subfigure}{0.48\textwidth}
    	\centering
        \includegraphics[width=\textwidth]{appendix/etaip_test_traces_distances_hugehip}
        \caption{$\eta_\IP = 0.002$}
        \label{fig:eta-huge}
    \end{subfigure}
    \begin{subfigure}{0.48\textwidth}
    	\centering
        \includegraphics[width=\textwidth]{appendix/etaip_test_traces_distances}
        \caption{$\eta_\IP = 0.001$ (default)}
        \label{fig:eta-norm}
    \end{subfigure}
    \caption[Influence of the IP learning rate]{Influence of the \acs{ip} learning rate $\eta_\IP$ on the burn-in time in the beginning of the testing phase.}
    \label{fig:eta-ip}
\end{figure}

\clearpage

\subsection{Network connectivity}
\label{sec:appendix:connectivity}

As already mentioned at the end of results section \ref{sec:ip-hyp}, probably the connectivity could influence the performance, beside the \acl{ip}. The connectivity is defined by the number of connections of every neuron, which equals the number of weights with $w_{ij} > 0$ or --- under a biological perspective --- the number of synapses. Initially, every neuron is connected with $\rho = 0.1 \hat{=} 10\%$ of the other neurons. Since $N^E = 200$, every neuron has $\lambda^W = \rho \cdot N^E = 20$ synapses or weights greater zero.

\begin{figure}[!b]
    \centering
    \begin{subfigure}{0.48\textwidth}
    	\centering
        \includegraphics[width=\textwidth]{appendix/connectivity_plastic}
        \caption{Plastic reservoir ($T_\plastic = 50,000$)}
        \label{fig:connectivity-plastic}
    \end{subfigure}
    \hfill
    \begin{subfigure}{0.48\textwidth}
    	\centering
        \includegraphics[width=\textwidth]{appendix/connectivity_static}
        \caption{Static reservoir ($T_\plastic = 0$)}
        \label{fig:connectivity-static}
    \end{subfigure}
    \caption[Variation of connectivity]{Variation of connectivity $\rho$. The left plot shows results for a plastic reservoir and the right plot for a static reservoir. For both holds that the more sparse the network is connected, the better the performance. Furthermore, the plastic reservoir outperforms the static reservoir network.}
    \label{fig:connectivity}
\end{figure}

\textcite{lazar2009sorn} showed in their appendix that the connectivity influences the performance of the network. In particular, they concluded that if the network is too dense, the activity `explodes'. To replicate the results in a context of Markov chain sampled input, model series II from figure \ref{fig:mc2-models} was divided into $5$ models. The results for different values of $\rho$ are shown in figure \ref{fig:connectivity}. On the left side the results for a \acs{sorn} with $T_\plastic = 50,000$ steps show that the performance is similar for $\rho \le 0.1$ and increases for $\rho > 0.1$. On the left side, a static reservoir is shown with $T_\plastic = 0$ steps. In that case, performance is increasing if $\rho$ increases. For $T_\plastic = 50,000$ steps and $\rho= 0.3$ the static reservoir network has very low performance in representing model $3$ and model $4$. \textcite{lazar2009sorn} suggested that this behavior is due to seizure-like bursts in the network, due to the high connectivity. Comparing both plots, a sparse connectivity increases the performance for both networks, plastic and static. Furthermore, the plastic network outperforms the static reservoir network. Both findings are in line with previous findings from \textcite{lazar2009sorn}.


\chapter{Image Embedding}
\label{ch:image-embedding}

Every data set so far came in the matrix (tabular) form: objects (say, tissue samples, students, flowers) were described by row vectors representing a number of features. Not all the data is like this; think about collections of text articles, nucleotide sequences, voice recordings or images. \marginnote{This depiction of deep learning network was borrowed from \url{http://www.amax.com/blog/?p=804}}It would be great if we could represent them in the same matrix format we have used so far. We would turn collections of, say, images, into matrices and explore them with the familiar prediction or clustering techniques.

\begin{wrapfigure}{o}{1.0\textwidth}
    \includegraphics[scale=0.5]{blog_deeplearning.jpg}
    \label{fig:deep-learning}
\end{wrapfigure}

Until very recently, finding useful representation of complex objects such as images was a real pain. Now, technology called deep learning is used to develop models that transform complex objects to vectors of numbers.

Consider images. When we, humans, see an image, our neural networks go from pixels, to spots, to patches, and to some higher order representations like squares, triangles, frames, all the way to representation of complex objects. Artificial neural networks used for deep learning emulate these through layers of computational units (essentially, logistic regression models and some other stuff we will ignore here). If we put an image to an input of such a network and collect the outputs from the higher levels, we get vectors containing an abstraction of the image. This is called embedding.

\begin{wrapfigure}{o}{0.8\textwidth}
    \includegraphics[scale=0.6]{workflow-embedding.png}
    \label{fig:embedding}
\end{wrapfigure}

Deep learning requires a lot of data (thousands, possibly millions of data instances) and processing power to prepare the network. We will use one which is already prepared. Even so, embedding takes time, so Orange doesn't do it locally but uses a server invoked through the \widget{Image Embedding} widget.

\newpage

Image embedding describes the images with a set of 2048 features appended to the table with meta features of images.

\begin{figure*}[h]
    \centering
    \includegraphics[scale=0.45]{data-table.png}
    \caption{$\;$}
\end{figure*}

We have no idea what these features are,\marginnote{Images are available at \url{http://file.biolab.si/images/domestic-animals.zip}} except that they represent some higher-abstraction concepts in the deep neural network (ok, this is not very helpful in terms of interpretation). Yet, we have just described images with vectors that we can compare and measure their similarities and distances. Distances? Right, we could do clustering. Let's cluster the images of animals and see what happens.

\begin{figure*}[h]
    \centering
    \includegraphics[scale=0.6]{workflow-clustering.png}
    \caption{$\;$}
\end{figure*}

To recap: in the workflow above we have loaded the images from the local disk, turned them into numbers, computed the distance matrix containing distances between all pairs of images, used the distances for hierarchical clustering, and displayed the images that correspond to the selected branch of the dendrogram in the \widget{Image Viewer}. We used cosine similarity to assess the distances (simply because the dendrogram looked better than with the Euclidean distance).

\begin{marginfigure}
    \centering
    \includegraphics[scale=0.6]{distances.png}
    \caption{$\;$}
\end{marginfigure}

\newpage

Even the lecturers of this course were surprised at the result. Beautiful!

\begin{figure*}[h!]
    \centering
    \newcommand{\hierclust}{\includegraphics[scale=0.45]{hier-clustering.png}}
    \newcommand{\imageview}{\includegraphics[scale=0.45]{image-viewer.png}}
    \infinitewidthbox{
    \stackinset{r}{-0.35\linewidth}{t}{+0.45\linewidth}{\imageview}{\hierclust}\hspace{6cm}
    }
\end{figure*}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright (c) 2003-2018 by The University of Queensland
% http://www.uq.edu.au
%
% Primary Business: Queensland, Australia
% Licensed under the Apache License, version 2.0
% http://www.apache.org/licenses/LICENSE-2.0
%
% Development until 2012 by Earth Systems Science Computational Center (ESSCC)
% Development 2012-2013 by School of Earth Sciences
% Development from 2014 by Centre for Geoscience Computing (GeoComp)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Linear Magnetic Intensity Inversion}\label{sec:forward magnetic intensity}
An alternative target for then inversion is the intensity anomaly of the magnetic flux
density. In this case the difference $b$ of the length of the total flux
density $B^{tot}=B^b+B$ to the back ground flux density $B^b$~\index{magnetic flux density}:
\begin{equation}\label{ref:IMAG:EQU:0}
b=\|B^{tot}\| -\|B^{b}\|
\end{equation}
where is the Euclean norm is defined as
\begin{equation}\label{ref:IMAG:EQU:1}
\|B\| =  \sqrt{B_i B_i}
\end{equation}
and we use the notations of the previous section~\ref{sec:forward magnetic}.
We have
\begin{equation}\label{ref:IMAG:EQU:1b}
\|B^{tot}\|^2 = \|B^{b}\|^2 + 2 B^{b}_i B_i + \|B\|^2 \approx  \|B^{b}\|^2 + 2 B^{b}_i B_i
\end{equation}
where the term $\|B\|^2$ of the anomaly can is assumed to be neglagable.
This gives
\begin{equation}\label{ref:IMAG:EQU:1bb}
\|B^{tot}\|  = \|B^{b}\| \sqrt{1 + \frac{2 B^{b}_i B_i}{\|B^{b}\|^2}} \approx  \|B^{b}\| \left(1 + \frac{B^{b}_i B_i}{\|B^{b}\|^2} \right)
\end{equation}
and therefore
\begin{equation}\label{ref:IMAG:EQU:0b}
b= \frac{B^{b}_i B_i}{\|B^{b}\|}  = \hat{B}^{b}_i B_i \mbox{ with } \hat{B}^{b}_i = \frac{B^b_i}{\|B^{b}\|}
\end{equation}
If $b^{(s)}_i$ is the measurement of the magnetic flux density intensity anomaly for
survey $s$ and $\omega^{(s)}$ is a weighting factor the data defect
$J^{mag}(k)$ in the notation of Chapter~\ref{chapter:ref:inversion cost function} is given as
\begin{equation}\label{ref:IMAG:EQU:9}
J^{mag}(k) = \frac{1}{2}\sum_{s} \int_{\Omega} \left( \omega^{(s)} \cdot ( \hat{B}^{b}_i B_i - b^{(s)} )\right)^2 dx
\end{equation}

The cost function kernel\index{cost function!kernel} is given as
\begin{equation}\label{ref:IMAG:EQU:10}
K^{mag}(\psi_{,i},k) = \frac{1}{2}\sum_{s} \left( \omega^{(s)} \cdot (k \cdot  \|B^{b}\|  -  \hat{B}^{b}_i \psi_{,i} - b^{(s)}) \right)^2
\end{equation}
Notice that if magnetic flux density is measured in air one can ignore the
$k\cdot B^b_i$ as the susceptibility is zero.

In practice the magnetic flux density intensity $b^{(s)}$ is measured
with a standard error deviation $\sigma^{(s)}$ at certain locations in the domain.
In this case one sets the weighting
factors $\omega^{(s)}$ as
\begin{equation}\label{ref:IMAG:EQU:11}
\omega^{(s)}
= \left\{
\begin{array}{lcl}
f \cdot  \frac{f}{\sigma^{(s)}} & & \mbox{data are available} \\
& \mbox{ where } & \\
0 & & \mbox{ otherwise } \\
\end{array}
\right.
\end{equation}
With the objective to control the
gradient of the cost function the scaling factor $f$ is chosen in the way that
\begin{equation}\label{ref:IMAG:EQU:12}
\sum_{s} \int_{\Omega} ( \omega^{(s)}_i B^{(s)}_i )
 \cdot ( \omega^{(s)}_j \frac{1}{L_j} ) \cdot L^2 \cdot
( B^b_n \frac{1}{L_n} )
 \cdot k' \;
 dx =\alpha
\end{equation}
where $\alpha$ defines a scaling factor which is typically set to one and $L$ is defined by equation~(\ref{ref:EQU:REG:6b}).
$k'$ is considering the
derivative of the density with respect to the level set function.

\subsection{Usage}

\begin{classdesc}{MagneticIntensityModel}{domain, w, b, background_field,
        \optional{, fixPotentialAtBottom=False},
        \optional{, tol=1e-8},
}
opens a magnetic forward model over the \Domain \member{domain} with
weighting factors \member{w} ($=\omega^{(s)}$) and measured magnetic flux
density anomalies \member{b} ($=b^{(s)}$).
The weighting factors and the  measured magnetic flux density anomalies must be scalars.
\member{background_field} defines the background magnetic flux density $B^b$
as a vector with north, east and vertical components.
\member{tol} sets the tolerance for the solution of the PDE~(\ref{ref:MAG:EQU:8}).
If \member{fixPotentialAtBottom} is set to  \True, the magnetic potential
at the bottom is set to zero in addition to the potential on the top.
\member{coordinates} set the reference coordinate system to be used. By the default the
Cartesian coordinate system is used.
\end{classdesc}

\begin{methoddesc}[MagneticModel]{rescaleWeights}{
        \optional{scale=1.}
 \optional{k_scale=1.}}
rescale the weighting factors such condition~(\ref{ref:IMAG:EQU:12}) holds where
\member{scale} sets the scale $\alpha$
and \member{k_scale} sets $k'$. This method should be called before any inversion is started
in order to make sure that all components of the cost function are appropriately scaled.
\end{methoddesc}

\subsection{Gradient Calculation}
This section briefly explains how the gradient
$\frac{\partial J^{mag}}{\partial k}$ of the cost function $J^{mag}$ with
respect to the susceptibility $k$ is calculated.  We follow the concept as outlined in section~\ref{chapter:ref:inversion cost function:gradient}.

The magnetic potential $\psi$ from PDE~(\ref{ref:MAG:EQU:8}) is solved in weak form:
\begin{equation}\label{ref:IMAG:EQU:201}
\int_{\Omega} q_{,i} \psi_{,i} \; dx  = \int_{\Omega}  k \cdot q_{,i}  B^r_i \; dx
\end{equation}
for all $q$ with $q=0$ on $\Gamma_{0}$.
In the following we set $\Psi[k]=\psi$ for a given susceptibility $k$ as
solution of the variational problem~(\ref{ref:MAG:EQU:201}).
If $\Gamma_{k}$ denotes the region of the domain where the susceptibility is
known and for a given direction $p$ with $p=0$ on $\Gamma_{k}$ one has
\begin{equation}\label{ref:IMAG:EQU:201aa}
\int_{\Omega}   \frac{\partial J^{mag}}{\partial k} \cdot p \; dx  = \int_{\Omega}
\sum_{s}
\omega^{(s)} \; \left(b^{(s)} - k \cdot  \|B^{b}\|  +  \hat{B}^{b}_i \psi_{,i}  \right)
\cdot \omega^{(s)} \; \left(\hat{B}^{b}_i \Psi[p]_{,i} - p \cdot  \|B^{b}\| \right) \; dx
\end{equation}
With
\begin{equation}\label{ref:IMAG:EQU:202c}
Y_i[\psi]=   \sum_{s}
(\omega^{(s)})^2
\left(b^{(s)} - k \cdot  \|B^{b}\|  +  \hat{B}^{b}_i \psi_{,i} \right) \hat{B}^{b}_i
\end{equation}
this is written as
\begin{equation}\label{ref:IMAG:EQU:202cc}
\int_{\Omega}   \frac{\partial J^{mag}}{\partial k} \cdot p \;  dx  = \int_{\Omega}
(Y_i[\psi] \Psi[p]_{,i} -p \cdot Y_i[\psi]B^b_i)   \; dx
\end{equation}
We then set adjoint function $Y^*[\psi]$ as the solution of the equation
\begin{equation}\label{ref:IMAG:EQU:202d}
\int_{\Omega} r_{,i} Y^*[\psi]_{,i} \; dx  =  \int_{\Omega} r_{,i} Y_i[\psi]  \; dx  \mbox{ for all } r \mbox{ with } r=0 \mbox{ on } \Gamma_{0}
\end{equation}
with $Y^*[\psi]=0$ on $\Gamma_{0}$. With $r=\Psi[p]$ we get
\begin{equation}\label{ref:IMAG:EQU:202dd}
\int_{\Omega} \Psi[p]_{,i} Y^*[\psi]_{,i} \; dx  =  \int_{\Omega} \Psi[p]_{,i} Y_i[\psi]  \; dx
\end{equation}
and from Equation~(\ref{ref:IMAG:EQU:201}) with $q=Y^*[\psi]$ we get
\begin{equation}\label{ref:IMAG:EQU:20e}
\int_{\Omega} Y^*[\psi]_{,i}  \Psi[p]_{,i} \; dx  = \int_{\Omega}  p \cdot Y^*[\psi]_{,i}  B^r_i \; dx
\end{equation}
which leads to
\begin{equation}\label{ref:IMAG:EQU:20ee}
\int_{\Omega} \Psi[p]_{,i} ,Y_i[\psi]  \; dx  = \int_{\Omega}  p \cdot Y^*[\psi]_{,i}  B^r_i \; dx
\end{equation}
and finally
\begin{equation}\label{ref:IMAG:EQU:201a}
\int_{\Omega}   \frac{\partial J^{mag}}{\partial k} \cdot p \;  dx  = \int_{\Omega}
p \cdot (Y^*[\psi]_{,i}  B^r_i - Y_i[\psi] B^b_i) \; dx
\end{equation}
or
\begin{equation}\label{ref:IMAG:EQU:201b}
\frac{\partial J^{mag}}{\partial k} = Y^*[\psi]_{,i}  B^r_i - Y_i[\psi] B^b_i
\end{equation}

\subsection{Geodetic Coordinates}
Not supported yet.


\documentclass[11pt]{article}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{fancyhdr}
\usepackage{tikz-qtree}
\usepackage{enumerate}
\usepackage{graphicx}

% margins
\usepackage[vmargin=1in,hmargin=1.5in]{geometry}

% Config
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\ass}{2}
\newcommand{\name}{Connor Taffe}
\newcommand{\tno}{3742} % last 4 digits of T number.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\title{
	$A_{\ass}$ \\
	{\large Assignment \ass\\
	CS 3482; Professor Tang}
}
\author{
	\name. T no. \tno
}

\pagestyle{fancy}
\rhead{Homework \ass}
\lhead{{\name}. T no. \tno}

\begin{document}
\maketitle

{\bf Notice}: I have used a format for binary number addition where extraneous places are shown when they would illustrate the generation of a $C_{\text{in}}$ bit. For example, a one bit adder might be accompanied by an example expression such as the following:

	\[
		1.1_2 + 0.1_2 = 10_2
	\]

	The topmost bit of the rightmost number in the expression is the $C_{\text{out}}$ value, and the lowest bit is the $S$ (sum) for the current bit addition. The lower bit in the operands is only shown to illustrate that a carry ($C_{\text{in}}$) bit was generated on some previous addition.

\section{Single-bit full adder}

\begin{enumerate}[(a)]
	\item{
	Show the truth table of $C$ (carry) and S(sum) of single-bit adder with input $X$, $Y$ and $C_{\text{in}}$ (carry-in) simulating the single-bit binary arithmetic addition.

		The truth table of $C$ (carry) is as follows in figure \ref{fig:1a}. C is the carry bit, so it is true if $XY$ is true ($1_2+1_2=10_2$) or if $(X \oplus Y)C_{\text{in}}$ is true ($1.1_2+0.1_2=10_2$).

		The truth table of $S$ (sum) is illustrated in the same figure. It can be seen that the sum bit is only on if $CXYC_{\text{in}} + C'(X+Y+C_{\text{in}})$ is true. This last statment is purely observational. This is because a two bits ($1_2+1_2=10_2$) rolls over to the next place (generates carry without sum bit), but three bits ($1.1_2+1.1_2=11_2$) rolls over and leaves one behind (generates carry with sum bit), and one ($0_2+1_2=1_2$) does not roll over (generates no carry, but sum bit).

		\begin{table}[h]
		\centering
		\begin{tabular}{lllll}
			$X$ & $Y$ & $C_{\text{in}}$ & $C$ & $S$ \\ \hline
			0 & 0 & 0 & 0 & 0 \\
			0 & 0 & 1 & 0 & 1 \\
			0 & 1 & 0 & 0 & 1 \\
			0 & 1 & 1 & 1 & 0 \\
			1 & 0 & 0 & 0 & 1 \\
			1 & 0 & 1 & 1 & 0 \\
			1 & 1 & 0 & 1 & 0 \\
			1 & 1 & 1 & 1 & 1 \\
		\end{tabular}
		\caption{\label{fig:1a} Truth table for $C$ and $S$ in single-bit full adder.}
		\end{table}
	}
	\item{
		Show the sum of min-term expression of $C$ and $S$.

		The minterms of $C$ are as follows:
		\[
			C_{\sum_{\text{minterm}}} = X'YC_{\text{in}} + XY'C_{\text{in}} + XYC_{\text{in}}' + XYC_\text{in}
		\]
		As we can see more clearly, two bits must be set (first three min-terms) to rollover, or all three bits (last min-term) to generate a carry and a sum.

		The minterms of $S$ are as follows:
		\[
			S_{\sum_{\text{minterm}}} = X'Y'C_{\text{in}} + X'YC_{\text{in}}' + XY'C_{\text{in}}' + XYC_\text{in}
		\]
		As we can see more clearly, only one bit can be set (first three min-terms), or three bits can be set (last min-term) for a sum bit to be on.
	}
	\item{
		Implement the single-bit full adder on LogicWorks using the following Boolean expressions:
		\[
			C = XY + XC_{\text{in}} + YC_{\text{in}}
		\]
		\[
			S = X \oplus Y \oplus C_{\text{in}}
		\]

		For illustrative purposes, here follows the parse trees of the above boolean expressions (figures \ref{fig:1c}, \ref{fig:1c2}). They can be used to show the structure of the resulting logic circuit.
		\begin{figure}[h]
			\centering
			\Tree [.$+$ [.$*$ $X$ $Y$ ] [.$*$ $X$ $C_{\text{in}}$ ] [.$*$ $Y$ $C_\text{in}$ ] ]
		\caption{\label{fig:1c} Parse tree of boolean expression for $C$.}
		\end{figure}

		\begin{figure}[h]
			\centering
			\Tree [.$\oplus$ $X$ $Y$ $C_{\text{in}}$ ]
		\caption{\label{fig:1c2} Parse tree of boolean expression for $S$.}
		\end{figure}

		Figure \ref{fig:1cc} shows the LogicWorks circuit implementation and figure \ref{fig:1ct} shows the testing of the circuit. The testing shows that the circuit is properly functioning for each of 8 inputs. It correlates to the truth table in figure \ref{fig:1a}. In the first column, $X=0,Y=0,C_{\text{in}}=0$, and $S=0,C=0$ which correlates with the truth table. The second column shows $X=0,Y=1,C_{\text{in}}=0$, and $S=1,C=0$, which correlates with the truth table. The remaining columns also correlate with the truth table, as $S$ is true only if one or three of the inputs are true, and $C$ is true only if two or three of the inputs are true, which is the same as was discussed above.

		\begin{figure}[h]
			\centering
			\includegraphics[width=300pt]{1c}
			\caption{\label{fig:1cc} LogicWorks circuit implementation.}
		\end{figure}

		\begin{figure}[h]
			\centering
			\includegraphics[width=200pt]{1t}
			\caption{\label{fig:1ct} Testing of circuit.}
		\end{figure}
	}
	\item{
	Pack your single-bit full adder and name it as {\tt fa-1}. Show the testing of your packaged single-bit full adder.

	The LogicWorks circuit is shown in figure \ref{fig:1dc}, while the testing is shown in figure \ref{fig:1dt}. The $C_{\text{in}}$, $X$, and $Y$ inputs are tested in the same order as the previous test, and we can see that it has the exact same output for $S$ and $C$. Since we have established that the output for the previous testing was correct, this packaged circuit must also be correct.

		\begin{figure}[h]
			\centering
			\includegraphics[width=200pt]{1pc}
			\caption{\label{fig:1dc} LogicWorks circuit implementation.}
		\end{figure}

		\begin{figure}[h]
			\centering
			\includegraphics[width=200pt]{1pt}
			\caption{\label{fig:1dt} Testing of circuit.}
		\end{figure}
	}
\end{enumerate}

\section{Ripple carry binary adder}

\begin{enumerate}[(a)]
	\item{
		Implement a 4-bit ripple carry binary adder with inputs $A_{3\text{-}0}$, $B_{3\text{-}0}$ and $C_{\text{in}}$ and outputs $S_{3\text{-}0}$ and $C_{\text{out}}$, using the singe-bit full adder you built in the previous question. Show three test cases to demonstrate that your adder works correctly (You need to do binary add yourself and then show that your adder delivers the correct result, for each of the three input cases).

		The three cases for testing are as follows:
		\begin{enumerate}[1.]
			\item{
				\[
					1010.1_2 + 1100.1_2 = 10111_2
				\]
				\[
					C_{\text{in}} = 1,
					A_0 = 0, A_1 = 1, A_2 = 0, A_3 = 1,
					B_0 = 0, B_1 = 0, B_2 = 1, B_3 = 1,
				\]
				\[
					S_0 = 1, S_1 = 1, S_2 = 1, S_3 = 0, C_{\text{out}} = 1
				\]

				Testing shown in figure \ref{fig:2atc}.

				\begin{figure}[h]
					\centering
					\includegraphics[width=150pt]{2at1}
					\caption{\label{fig:2atc} LogicWorks circuit test 1.}
				\end{figure}
			}
			\item{
				\[
					1010.0_2 + 0100.1_2 = 01110_2
				\]
				\[
					C_{\text{in}} = 0,
					A_0 = 0, A_1 = 1, A_2 = 0, A_3 = 1,
					B_0 = 0, B_1 = 0, B_2 = 1, B_3 = 0,
				\]
				\[
					S_0 = 0, S_1 = 1, S_2 = 1, S_3 = 1, C_{\text{out}} = 0
				\]

				Testing shown in figure \ref{fig:2atc1}.

				\begin{figure}[h]
					\centering
					\includegraphics[width=150pt]{2at2}
					\caption{\label{fig:2atc1} LogicWorks circuit test 2.}
				\end{figure}
			}
			\item{
				\[
					0000.1_2 + 1111.1_2 = 10000_2
				\]
				\[
					C_{\text{in}} = 1,
					A_0 = 0, A_1 = 0, A_2 = 0, A_3 = 0,
					B_0 = 1, B_1 = 1, B_2 = 1, B_3 = 1,
				\]
				\[
					S_0 = 0, S_1 = 0, S_2 = 0, S_3 = 0, C_{\text{out}} = 1
				\]

				Testing shown in figure \ref{fig:2atc2}.

				\begin{figure}[h]
					\centering
					\includegraphics[width=150pt]{2at3}
					\caption{\label{fig:2atc2} LogicWorks circuit test 3.}
				\end{figure}
			}
		\end{enumerate}
	}
	\item{
		Figures \ref{fig:2btc}, \ref{fig:2btc1}, \ref{fig:2btc2} depict testing of the packaged circuit correlating to the above tests.

		\begin{figure}[h]
			\centering
			\includegraphics[width=200pt]{2pt1}
			\caption{\label{fig:2btc} LogicWorks circuit test 1.}
		\end{figure}
		\begin{figure}[h]
			\centering
			\includegraphics[width=200pt]{2pt2}
			\caption{\label{fig:2btc1} LogicWorks circuit test 1.}
		\end{figure}
		\begin{figure}[h]
			\centering
			\includegraphics[width=200pt]{2pt3}
			\caption{\label{fig:2btc2} LogicWorks circuit test 1.}
		\end{figure}
	}
	\item{
		Test the longest propagation delays of your {\tt RP Adder-4} from the inputs to $C_{\text{out}}$ and $S_3$ (the highest bit of the sum) by setting $A_{3\text{-}0}$ and $B_{3\text{−}0}$ to make their sum to be 1111 and connecting $C_{\text{in}}$ to a clock.

		The circuit is shown in figure \ref{fig:2cc} and the output is shown in figure \ref{fig:2ct}. The testing shows a 1ns delay between $C_{\text{in}}$ and $S_0$, and a 2ns delay between $S_0$ and the next subcircuit ($S_1$), which continues between subcircuits. The delay between the last subcircuit ($S_3$) and its carry $C_{\text{out}}$ is 1ns. This totals 8ns. This is because each circuit has a 1ns delay between its $C_{\text{in}}$ input and its $S$ output, and an additional 1ns (2ns total) between its input and its carry output ($C$).

		Since this circuit is a ripple adder, each single-bit adder depends on the carry from the last single-bit adder. This leads to a 2ns delay for each additional bit. This type of circuit is $O(n)$ concerning gate delay (gates are operations) where $n$ is bits of the number.

		\begin{enumerate}[i.]
			\item{
				Figure \ref{fig:2cc} shows the testing circuit.
			}
			\item {
				Figure \ref{fig:2ct} shows the waveform of the testing circuit with $C_{\text{in}}$ as a reference line.
			}
			\item{
				The dalay from $C_{\text{in}}$ to $C_{\text{out}}$ is 8ns. The dalay from $C_{\text{in}}$ to $C_{\text{out}}$ is 7ns. The reason this differs by one nanosecond is that the carry ($C$) bit takes 2ns to compute while the $S$ bit takes only 1ns for each subcircuit. This is because the carry ($C$) bit is calculated with two gates in a row ($*$ then $+$), while the $S$ bit is calculated with a single gate ($\oplus$).

				The overall delay is caused by the dependency chain of each subsequent bit adder on the last carry bit output. Thusly this circuit is $O(n)$ operations (gate operations), meaning it scales in number of operations over time by the number of bits. The delay is $D_t = \sum\limits_{i=0}^n di$ where $d$ is the delay of each single-bit addition, in this case 2ns, $D_t$ is the total delay, and $n$ is the number of bits.
			}
		\end{enumerate}

		\begin{figure}[h]
			\centering
			\includegraphics[width=200pt]{2pct}
			\caption{\label{fig:2cc} LogicWorks circuit delay test.}
		\end{figure}

		\begin{figure}[h]
			\centering
			\includegraphics[width=200pt]{2ptt}
			\caption{\label{fig:2ct} Output showing delay.}
		\end{figure}
	}
\end{enumerate}

\section{Single-bit full adder with $p$ (carry propagation) and $g$ (carry generation) outputs.}

\begin{enumerate}[(a)]
	\item{
	Show the truth tables of $g$ (carry generation) and $p$ (carry propagation) of single-bit adder as functions of input $X$ and $Y$ (They do not depend on $C_{\text{in}}$).

		The truth table is shown in figure \ref{fig:3a}.

		\begin{table}[h]
		\centering
		\begin{tabular}{llll}
			$X$ & $Y$ & $g$ & $p$ \\ \hline
			0 & 0 & 0 & 0 \\
			0 & 1 & 0 & 1 \\
			1 & 0 & 0 & 1 \\
			1 & 1 & 1 & 0 \\
		\end{tabular}
		\caption{\label{fig:3a} Truth table for $g$ and $p$ for a single bit adder.}
		\end{table}
	}
	\item{
		Implement and pack the single-bit full adder with $g$ and $p$ outputs on LogicWorks. Show the testing of your packaged single-bit full adder with $g$ and $p$ outputs. (You need to test and show all 8 input cases.)

		Figure \ref{fig:3bc} shows the testing circuit for the packaged Single-bit full adder with $p$ (carry propagation) and $g$ (carry generation) outputs.

		Figure \ref{fig:3bt} shows the testing. As you can see $S$ is only on if one of the inputs $X$, $Y$, or $C_{\text{in}}$ is set or all are set, which is the same as the original single-bit adder, so it is correct. $p$ is correct because it should be on when either $X$ or $Y$ is on, but not both, and it is. $g$ is correct because it should be on if both $X$ and $Y$ are on, and it is. Thusly we can conclude that this single-bit adder with $p$ (carry propogation) and $g$ (carry generation) is correct. This shows all eight test cases are correct.

		\begin{figure}[h]
			\centering
			\includegraphics[width=200pt]{3pc}
			\caption{\label{fig:3bc} LogicWorks circuit.}
		\end{figure}

		\begin{figure}[h]
			\centering
			\includegraphics[width=200pt]{3pt}
			\caption{\label{fig:3bt} Waveform test.}
		\end{figure}
	}
\end{enumerate}

\section{4-bit carry look-ahead unit ({\tt LA-4})}

\begin{enumerate}[(a)]
	\item{
		Derive the Boolean expressions for carries $c1, \ldots, c4$ as functions of $g0, \ldots, g3$, $p0, \ldots, p3$, and $c0$.

		The formula for a carry bit is $C=g+pC_{\text{in}}$. For the first bit, carry in is given, and for the others, carry in is generated recersively based on the formula.
		\[
			C_1 = g_0+p_0C_0
		\]
		\[
			C_2 = g_1+p_1C_1 = g_1+p_1(g_0+p_0C_0)
		\]
		\[
			C_3 = g_2+p_2C_2 = g_2+p_2(g_1+p_1C_1) = g_2+p_2(g_1+p_1(g_0+p_0C_0))
		\]
		\[
			C_4 = g_3+p_3C_3 = g_3+p_3(g_2+p_2C_2) = g_3+p_3(g_2+p_2(g_1+p_1C_1)) = g_3+p_3(g_2+p_2(g_1+p_1(g_0+p_0C_0)))
		\]

		These can be simplified using the distributive property to derive:
		\[
			C_1 = g_0+p_0C_0
		\]
		\[
			C_2 = g_1 + p_1(g_0+p_0C_0) = g_1 + p_1g_0 + p_1p_0C_0
		\]
		\[
			C_3 = g_2+p_2(g_1+p_1g_0 + p_1p_0C_0) =  g_2 + p_2g_1 + p_2p_1g_0 + p_2p_1p_0C_0
		\]
		\[
			C_4 = g_3+p_3(g_2 + p_2g_1 + p_2p_1g_0 + p_2p_1p_0C_0) = g_3 + p_3g_2 + p_3p_2g_1 + p_3p_2p_1g_0 + p_3p_2p_1p_0C_0
		\]

		This second way is better because it is the sum of min-terms approach that we know can reduce gate dalays to a mamimum of 3.
	}
	\item{
		Derive the Boolean expressions for block carry generation $G$ and block carry propagation $P$ as functions of $g0, \ldots, g3$ and $p0, \ldots, p3$.

		The formula for $G$ and $P$ is $C_4=G+PC_0$, so using the $C_4$ derived in the previous step, we can see the following values for $G$ and $P$:
		\[
			G = g_3 + p_3g_2 + p_3p_2g_1 + p_3p_2p_1g_0
		\]
		\[
			P = p_3p_2p_1p_0
		\]
	}
	\item{
		Implement and pack the {\tt LA-4} unit in LogicWorks. Show the internal circuit of the unit.

		The circuit can be seen in figure \ref{fig:4c}.

		\begin{figure}[h]
			\centering
			\includegraphics[width=200pt]{4c}
			\caption{\label{fig:4c} LogicWorks circuit implementation.}
		\end{figure}
	}
	\item{
		Show the testing of $c2$ of the {\tt LA-4}.

		Figure \ref{fig:4dc} shows the circuit in testing setup.

		Figure \ref{fig:4dt} shows the testing output wavelengths for all 32 applicable input combinations. $C_2 = g_1 + p_1(g_0+p_0C_0)$, so we can confirm the correctness of the circuit by showing that each value of $C_2$ is because $g_1$ or $p_1$ and either $g_0$ or $p_0$ and $C_0$. We can see for the first half when $C_0$ is off, that $C_2$ is off while $g_1$ and $p_1$ are off, and then turns on while $g_1$ is on. When $g_1$ is next off, $C_2$ reflects $g_0$ as $p_0$s value is of no importance whilst $C_0$ is off. It continues to follow the formula for the remainder of the wavelength and we can confirm it is correct.

		\begin{figure}[h]
			\centering
			\includegraphics[width=200pt]{4ct}
			\caption{\label{fig:4dc} LogicWorks circuit implementation.}
		\end{figure}
		\begin{figure}[h]
			\centering
			\includegraphics[width=200pt]{4t}
			\caption{\label{fig:4dt} Wavelength recording.}
		\end{figure}
	}
\end{enumerate}

\section{4-bit carry look-ahead adder}

\begin{enumerate}[(a)]
	\item{
		Implement the 4-bit carry look-ahead adder with inputs $A_{3\text{-}0}$ , $B_{3\text{-}0}$ and $C_{\text{in}}$ and outputs $S_{3\text{-}0}$, $C_{\text{out}}$, $G$ and $P$. Show the internal circuit of the adder.

		Figure \ref{fig:5ac} shows the internal circuit of the adder.

		\begin{figure}[h]
			\centering
			\includegraphics[width=200pt]{5c}
			\caption{\label{fig:5ac} LogicWorks circuit implementation.}
		\end{figure}
	}
	\item{
		Pack the 4-bit carry look-ahead and name it as {\tt Adder-4}. Show three test cases to demonstrate that your adder works correctly.

		The three cases for testing are as follows:
		\begin{enumerate}[1.]
			\item{
				\[
					1010.1_2 + 1100.1_2 = 10111_2
				\]
				\[
					C_{\text{in}} = 1,
					X_0 = 0, X_1 = 1, X_2 = 0, X_3 = 1,
					Y_0 = 0, Y_1 = 0, Y_2 = 1, Y_3 = 1,
				\]
				\[
					S_0 = 1, S_1 = 1, S_2 = 1, S_3 = 0, C_{\text{out}} = 1
				\]

				Testing shown in figure \ref{fig:5t}.

				\begin{figure}[h]
					\centering
					\includegraphics[width=150pt]{5t}
					\caption{\label{fig:5t} LogicWorks circuit test 1.}
				\end{figure}
			}
			\item{
				\[
					1010.0_2 + 0100.1_2 = 01110_2
				\]
				\[
					C_{\text{in}} = 0,
					X_0 = 0, X_1 = 1, X_2 = 0, X_3 = 1,
					Y_0 = 0, Y_1 = 0, Y_2 = 1, Y_3 = 0,
				\]
				\[
					S_0 = 0, S_1 = 1, S_2 = 1, S_3 = 1, C_{\text{out}} = 0
				\]

				Testing shown in figure \ref{fig:5t1}.

				\begin{figure}[h]
					\centering
					\includegraphics[width=150pt]{5t1}
					\caption{\label{fig:5t1} LogicWorks circuit test 2.}
				\end{figure}
			}
			\item{
				\[
					0000.1_2 + 1111.1_2 = 10000_2
				\]
				\[
					C_{\text{in}} = 1,
					X_0 = 0, X_1 = 0, X_2 = 0, X_3 = 0,
					Y_0 = 1, Y_1 = 1, Y_2 = 1, Y_3 = 1,
				\]
				\[
					S_0 = 0, S_1 = 0, S_2 = 0, S_3 = 0, C_{\text{out}} = 1
				\]

				Testing shown in figure \ref{fig:5t2}.

				\begin{figure}[h]
					\centering
					\includegraphics[width=150pt]{5t2}
					\caption{\label{fig:5t2} LogicWorks circuit test 2.}
				\end{figure}
			}
		\end{enumerate}
	}
	\item{
		Test the longest propagation delays of your carry look-ahead Adder-4 from the inputs to $C_{\text{out}}$ and $S_3$ (the highest bit of the sum) by setting $A_{3 \text{−} 0}$ and $B_{3 \text{−} 0}$ to make their sum to be 1111 and connecting $C_{\text{in}}$ to a clock.

		\begin{enumerate}[i.]
			\item{
				 Show your testing circuit.

				Figure \ref{fig:5dtc} depicts the circuit.

				\begin{figure}[h]
					\centering
					\includegraphics[width=150pt]{5dtc}
					\caption{\label{fig:5dtc} LogicWorks circuit test 2.}
				\end{figure}
			}
			\item{
			Show the waveforms of the inputs and outputs with the rising edges of $C_{\text{in}}$ as reference lines.

				Shown in figure \ref{fig:5dt}.

				\begin{figure}[h]
					\centering
					\includegraphics[width=150pt]{5dt}
					\caption{\label{fig:5dt} Wavelength}
				\end{figure}
			}
			\item{
				Show the propagation delays from $C_{\text{in}}$ to $C_{\text{out}}$ and $S_3$. Explain why these delays are such as you observed.

				The propogation delay from $C_{\text{in}}$ to $C_{\text{out}}$ is 3ns, while from $C_{\text{in}}$ to $S_3$ is 3ns. This is because the new way of calculating carry bits with the look-ahead unit does not depend on the previous cascading carry and is thusly $O(1)$ for $n$ bits. The $S$ takes an additional 1ns because it must wait for the cary bit to come back from the look-ahead.
			}
		\end{enumerate}
	}
\end{enumerate}

\end{document}


\chapter{Bose-Einstein condensation and Diffusion Monte Carlo}\label{chap:advancedqmc}
\abstract{We discuss how to perform diffusion Monte Carlo calculations for systems of bosons}

\section{Diffusion Monte Carlo}

The DMC method belongs to a larger class of methods often called
\emph{projector} Monte Carlo. As the name indicates, this is a general
class of methods based on taking projections in Hilbert space.

%From a given superposition $\Psi$ of eigenfunctions of $\op H$, we
%will project out the desired one:
%\bdm
%\Psi = \sum_i c_i \phi_i \to \phi_k
%\edm

Consider a system governed by a Hamiltonian $\op H$. Its stationary
eigenfunctions are then given by
\bdm
\op H\phi_i = \epsilon_i\phi_i
\edm
DMC is a method of projecting out the $\phi_i$ from $\Psi$ with the
lowest energy. Most often, and in our case particularly, we are
interested in the ground state. But just as with the variational
principle used by VMC, if we let $\Psi$ fulfill a certain mathematical
symmetry, the projected $\phi_k$ will be the state of lowest energy
with that given symmetry.

In contrast to VMC, which relies on the variational principle, DMC does not directly depend on any a
priori choice of wave function that ultimately restricts the quality
of the result. Thus, DMC can in principle produce the exact ground
state of our system, at least within the statistical limits of the
algorithm.

The procedure of projecting out the component state of $\Psi$ with the
lowest energy is based on operating on $\Psi$ with the special
evolution operator $\exp(-\op Ht)$
\bdm
e^{(-\op Ht)}\Psi(\vec x) = \sum_i c_i
\exp(-\epsilon_it)\phi_i(\vec x)
\edm
This is just the formal solution of the special equation:
\be
-\frac{\partial}{\partial t}\Psi(\vec x, t) =
\op H \Psi(\vec x, t)
\label{eq:SE_imaginary_time}
\ee
which resembles the time dependent Schr\"odinger equation as if it
were transformed to imaginary time $it\to t$. Recall that the formal
solution of the time dependent Schr\"odinger equation is just
\bdm
\Psi(\vec x, t) = e^{-\frac{i}{\hbar}\op Ht}\,\Psi(\vec x) =
\sum_i c_i e^{-\frac{i}{\hbar}\epsilon_it}\,\phi_i(\vec x)
\edm
As we let $t\to\infty$, the exponential makes all the eigenstates with
negative energy blow up while the ones with positive energy vanish. To
control this effect we introduce a constant energy shift
$E_{\mathrm{T}}$, called a \emph{trial energy}, to the potential term
of $\op H$. This shift does, of course, not change any relevant physical
properties of our system since it is generally independent of the
choice of the zero point of the energy. The effect on the projection
operation becomes
\be
\Psi(\vec x, t) =
e^{-(\op H - E_{\mathrm{T}})t}\Psi(\vec x) = \sum_i c_i
e^{-(\epsilon_i-E_{\mathrm{T}})t}\phi_i(\vec x)
\label{eq:projector_on_Psi}
\ee
Consider the ideal situation of letting $E_{\mathrm{T}}$ equal exactly
$\epsilon_0$, resulting in
\bdm
\Psi(\vec x, t) =
e^{-(\op H - E_{\mathrm{T}})t}\Psi(\vec x) =
c_0\phi_0 + \sum_{i>0}c_i\phi_i(\vec x)e^{-(\epsilon_i-\epsilon_0)t}
\edm
Since $\epsilon_i > \epsilon_0$ for $i \neq 0$, all the remaining
exponents become negative. In the limit $t\to\infty$, the
contributions from excited states must obviously vanish, so that
propagating $\Psi$ according to Eq.~(\ref{eq:SE_imaginary_time})
gives
\bdm
\lim_{t\to\infty} e^{-(\op H - \epsilon_0)t}\Psi(\vec x) =
c_0\phi_0
\edm
thus projecting out the ground state.

Without even considering how to do the time propagation in practice,
the formulas already indicate to us that approaching the problem first
with VMC can help produce an initial $\Psi$ close to $\phi_0$ and,
more importantly, a trial energy $E_{\mathrm{T}}$ being an upper bound
to the true ground state energy $\epsilon_0$. Hopefully
$E_{\mathrm{T}}$ is close enough to $\epsilon_0$ to be smaller than the
first excited energy. Inserting such a $E_{\mathrm{T}}$ into
Eq.~(\ref{eq:projector_on_Psi}) while letting $t\to\infty$ will make all
the excited states collapse while the ground state blows up and
dominates because of the positive exponent in the coefficient.

From this consideration we also see that the evolution operator is not
unitary. The norm of $\Psi$ is not necessarily conserved with time.
Depending on the value of $E_{\mathrm{T}}$ it may grow without limit
or go to zero. Only in the case of $E_{\mathrm{T}}=\epsilon_0$ the
state tends to a constant. This proposes a method of determining the
ground state energy by adjusting $E_{\mathrm{T}}$ dynamically during
time propagation so that the state stays constant.

Writing out the imaginary time Schr\"odinger equation,
Eq.~(\ref{eq:SE_imaginary_time}), including the energy offset
$E_\mathrm{T}$, we get
\bea
\frac{\partial}{\partial t}\Psi(\vec x, t) &=&
-\op K \Psi(\vec x, t) -
(\op V(\vec x) - E_\mathrm{T})\Psi(\vec x, t)\nonumber\\
&=&
\frac{\hbar^2}{2m}\nabla^2 \Psi(\vec x, t) -
(\op V(\vec x) - E_\mathrm{T})\Psi(\vec x, t)
\label{eq:SE_imaginary_time_expanded}
\eea
where $\op K$ and $\op V$ is the kinetic and potential energy
operator, respectively. We see that this is of the form of an extended
diffusion equation. We can therefore consider the wave function $\Psi$
as a probability distribution evolving according to this equation.
This greatly contrasts the usual quantum mechanical interpretation of
$|\Psi|^2$ being the actual probability density function (PDF). We
will see that the approach poses some potentially serious problems
when the wave function $\Psi$ we seek has nodes and is partially
negative and possibly complex. But to illustrate the main mechanisms
of the method we will at the moment focus on the simple cases of
bosonic ground states which usually are strictly positive and real.

In simple terms, the job consists of representing the initial state
$\Psi$ by a collection of walkers, much the same way as in VMC, and
letting them evolve in time as a controlled diffusion process governed
by Eq.~(\ref{eq:SE_imaginary_time_expanded}). Interpreting the
rhs.~terms of Eq.~(\ref{eq:SE_imaginary_time_expanded}), we see that
the first term is a standard diffusion term with a diffusion constant
of
\be
D\equiv\frac{\hbar^2}{2m}
\label{eq:diffusion_constant}
\ee
The second term is called a \emph{branching term}. When positive, it
induces a growth of the number of walkers and a decay if it is negative.

Before we expand on how to carry out DMC in practice, it may be
helpful to consider an analytically exact approach by focusing on the
Green's function corresponding to the time evolution of the wave function.
The approach is called
\emph{Green's function Monte Carlo} (GFMC) and shares its main ideas
with the DMC method. Using Dirac's bracket notation, we start over by
substituting the initial wave function $\Psi(\vec x)$ with its
corresponding state ket $|\Psi\rangle$ and let the special evolution
operator work on $|\Psi\rangle$
\bdm
|\Psi\rangle_t = e^{-(\op H - E_{\mathrm{T}})t}|\Psi\rangle,
\edm
Now we switch to position representation:
\bdm
\Psi(\vec x, t) =
\overlap{\vec x}{\Psi}_t =
\bracket{\vec x}{e^{-(\op H - E_{\mathrm{T}})t}}{\Psi} =
\int\bracket{\vec x}{e^{-(\op H - E_{\mathrm{T}})t}}{\vec x^\prime}
\overlap{\vec x^\prime}{\Psi}d\vec x^\prime
\edm
where we have just inserted a completeness relation,
$1=\int\projection{\vec x^\prime}{\vec x^\prime}\,d\vec x^\prime$.
Defining the Green's function for this case
\bdm
G(\vec x,\vec x^\prime,t) \equiv
\bracket{\vec x}{e^{-(\op H - E_{\mathrm{T}})t}}{\vec x^\prime} =
\bracket{\vec x}{e^{-(\op K + \op V - E_{\mathrm{T}})t}}
{\vec x^\prime}
\edm
we get:
\be
\Psi(\vec x, t) =
\int G(\vec x,\vec x^\prime,t)\Psi(\vec x^\prime)d\vec x^\prime
\label{eq:greens_function_propag}
\ee
Calculating the Green's function $G$ would be greatly simplified if we
could split it into separate factors for each of the terms $\op K$ and
$(\op V- E_\mathrm{T})$ of the Hamiltonian $\op H$, as with the
following factorization
\bdm
e^{\op A + \op B} = e^{\op A}\,e^{\op B}
\edm
However, such a factorization requires that the operators $\op A$ and
$\op B$ commute, $[A,B]=0$. Unfortunately, this is not the case for
the terms $\op K$ and $\op V$ of the Hamiltonian. But, by expanding
the exponential of each part, using a descendent of the so called
Baker-Campbell-Hausdorff formula
\bdm
e^{\op A}e^{\op B}=e^{\op A+\op B}e^{\frac{1}{2}[\op A,\op B]}
\edm
we get that:
\bdm
e^{-(\op H-E_{\mathrm{T}})t} = e^{-(\op K+\op V-E_{\mathrm{T}})t} =
e^{-\op K t}e^{-(\op V-E_{\mathrm{T}}) t} + \bigO(t^2)
\edm
It is also possible to make approximations to higher orders of $t$, but
we will here keep to the simple first order case. As $t\to 0$, the error
term disappears and the simple factorized form becomes exact. Thus, an
approximation of the form
\bdm
e^{-(\op H-E_{\mathrm{T}})t}\approx
e^{-\op K t}e^{-(\op V-E_{\mathrm{T}}) t}
\edm
is only good for small $t$ and is readily called a \emph{short time
  approximation}. The Green's function can by this be approximated as
follows
\beaN
G(\vec x,\vec x^\prime,t) &=&
\bracket{\vec x}{e^{-(\op H-E_{\mathrm{T}})t}}{\vec x^\prime}\\
&=&
\bracket{\vec x}{e^{-\op K t}\,e^{-(\op V-E_{\mathrm{T}}) t}}
{\vec x^\prime} + \bigO(t^2)\\
&=&
\int\bracket{\vec x}{e^{-\op K t}}{\vec x^{\prime\prime}}\,
\bracket{\vec x^{\prime\prime}}{e^{-(\op V-E_{\mathrm{T}}) t}}
{\vec x^\prime}\,d\vec x^{\prime\prime} + \bigO(t^2)\\
&=&
\int G_K(\vec x,\vec x^{\prime\prime},t)\,
G_V(\vec x^{\prime\prime},\vec x^\prime,t)
\,d\vec x^{\prime\prime} + \bigO(t^2)
\eeaN
For the kinetic energy part, $G_K$, we get
\beaN
G_K(\vec x,\vec x^{\prime\prime},t) &=&
\bracket{\vec x}{e^{-\op K t}}{\vec x^{\prime\prime}}\\
&=&
\frac{1}{(2\pi)^{3N}}\int
\overlap{\vec x}{\vec k}e^{-Dk^2t}
\overlap{\vec k}{\vec x^{\prime\prime}}\,d\vec k\\
&=&
\frac{1}{(2\pi)^{3N}}\int
e^{-i\vec k\vec x}e^{-Dk^2t}
e^{i\vec k\vec x^{\prime\prime}}\,d\vec k\\
&=&
\frac{1}{(4\pi Dt)^{3N/2}}\,
e^{-(\vec x^{\prime\prime}-\vec x)^2/4Dt}
\eeaN
The constant $D$ is still the same diffusion constant in
Eq.~(\ref{eq:diffusion_constant}). The part related to the potential,
$G_V$, is simpler, since it contains a local operator only dependent
on $\vec x$
\bdm
G_V(\vec x^{\prime\prime},\vec x^\prime,t) =
e^{-(V(\vec x^\prime)-E_{\mathrm{T}})t}
\delta(\vec x^\prime-\vec x^{\prime\prime})
\edm
Putting these two parts together and carrying out the integral over
$\vec x^{\prime\prime}$ is simplified by the delta function of
$G_V$. Ignoring the normalization constant of $G_K$ we get
\be
G(\vec x,\vec x^\prime,t) =
e^{-(\vec x^\prime-\vec x)^2/4Dt}\,
e^{(E_\mathrm{T}-V(\vec x^\prime))t}+\bigO(t^2)
\label{eq:greens_func_short_time}
\ee

At this point, the GFMC method would pursue the problem by explicitly
evaluating the Green's function integral of
Eq.~(\ref{eq:greens_function_propag}) with a suitable
approximation. We, on the other hand, are now ready to interpret the
diffusion process controlled by
Eq.~(\ref{eq:SE_imaginary_time_expanded}) in terms of the short time
approximated Green's function. Our wave function $\Psi(\vec x)$ is
represented by a set of random walkers, so the integral over $G(\vec
x,\vec x^\prime,t)\Psi(\vec x^\prime)$ expresses the probability of a
walker ending up at $\vec x$ given the initial configuration of
walkers $\Psi(\vec x^\prime)$.  Calculating the integral corresponds
to one iteration of the DMC algorithm (to be described in detail later
on). Operationally this has a different effect for each of the two
exponential factors of $G$.

The first factor expresses the probability for a walker to move from
position $\vec x$ to $\vec x^\prime$. Since this clearly is just a
Gaussian of $\vec x$ around $\vec x^\prime$, we can simply generate
new positions as a simple diffusion process
\bdm
\vec x = \vec x^\prime + \chi
\edm
where $\chi$ is a Gaussian pseudo-random number with mean equal zero
and variance equal $2Dt$. The second factor, the branching term, is
only dependent on $\vec x^\prime$ and can be interpreted as the rate
of growth of random walkers at each position $\vec x^\prime$. The
short time approximation permits us to conduct the two processes,
diffusion and branching separately, as long as the time step $t$ is
kept small.

Even though this approach, after a large enough number of iterations,
should yield a distribution of walkers corresponding to the exact
ground state of $\op H$, the method is not efficient. In particular, a
serious problem arises when our system is governed by an unbounded
potential, like a Coulomb potential typical for interactions between
electrons or a parametrized nucleon-nucleon central potential
with a hard central core. The branching
exponential may diverge giving a huge production of new random walkers
that may be difficult to handle numerically. Also the fluctuations
become very large making statistical estimates of physical quantities
inaccurate.

Another problem is that there is actually no simple way of calculating
a mean energy estimate from the set of walkers alone. The mean energy
is not only the most essential result of the algorithm, we also need
it to be able to adjust the trial energy $E_\mathrm{T}$ dynamically
throughout the DMC calculation.

For these reasons, and others that will become apparent, we introduce
so called importance sampling by biasing the combined
branching-diffusion process with a trial wave function
$\Psi_\mathrm{T}$ which hopefully imitates the exact solution well.
The technical contents of this will be made clear shortly.

\subsection{Importance Sampling}

Let us
introduce a time independent trial wave function $\Psi_\mathrm{T}(\vec
x)$. We define the new quantity
\bdm
f(\vec x, t) \equiv \Psi_\mathrm{T}(\vec x)\,\Psi(\vec x, t)
\edm
Now by inserting $\Psi=f/\Psi_\mathrm{T}$ into
Eq.~(\ref{eq:SE_imaginary_time_expanded}) we get a slightly more
complicated equation in terms of $f(\vec x,t)$
\be
\frac{\partial f(\vec x, t)}{\partial t} =
D\nabla^2 f(\vec x, t)-D\vec\nabla(\vec F(\vec x)f(\vec x, t))-
(E_{\mathrm{L}}(\vec x)-E_{\mathrm{T}})f(\vec x, t)
\label{eq:SE_imaginary_time_expanded_imp}
\ee
with the constant $D$ defined as in
Eq.~(\ref{eq:diffusion_constant}). Notice that the
rhs.~consists of three terms. By the same line of thought as before
we now recognize the first term as the familiar diffusion term, acting
on $f$ instead of $\Psi$. The last term, similar in form to the
potential term, is our new branching term, also acting on $f$. The
quantity $E_\mathrm{L}(\vec x)$ is just the local energy with respect
to $\Psi_{\mathrm{T}}$, defined in the same manner as in the variational Monte Carlo procedure
\bdm
E_{\mathrm{L}} \equiv
\frac{1}{\Psi_\mathrm{T}}\op H\Psi_\mathrm{T}
\edm
The vector quantity $\vec F(\vec x)$ in the unfamiliar middle term is
the drift velocity as we know it from the Fokker-Planck formalism we
used to improve the Metropolis algorithm
\be
\vec F(\vec x)\equiv
\frac{2}{\Psi_\mathrm{T}}\vec\nabla\Psi_\mathrm{T}
\label{eq:drift_velocity_DMC}
\ee
Actually, the two first terms on the rhs.~of
Eq.~(\ref{eq:SE_imaginary_time_expanded_imp}) can equivalently be
expressed as the familiar Fokker-Planck drift-diffusion on the rhs.~of
Eq.~(\ref{eq:fokker-planck}).

Eq.~(\ref{eq:SE_imaginary_time_expanded_imp}) motivates us to let the
set of random walkers represent $f$ instead of $\Psi$. A typical first
order short time approximation of the corresponding Green's function
is
\bea
G(\vec x,\vec x^\prime,t) &=&
\frac{1}{(4\pi Dt)^{3N/2}}\,
e^{-(\vec x-\vec x^\prime-Dt\vec F(\vec x^\prime))^2/4Dt}\,\,
e^{-((E_\mathrm{L}(\vec x)+E_\mathrm{L}(\vec
  x^\prime))/2-E_\mathrm{T})t}\nonumber\\&+&
\vphantom{\frac{1}{1}}\bigO(t^2)
\label{eq:greens_func_short_time_imp}
\eea
We see that the Green's function above
consists of two factors. The first one is similar to the Gaussian in
Eq.~(\ref{eq:greens_func_short_time}). But now we have in addition a
drift term displacing the mean of the Gaussian by $Dt\vec F(\vec
x^\prime)$. Notice that this factor of the Green's function is
practically identical to the transition proposition rule introduced by
the Fokker-Planck formalism to improve the Metropolis algorithm
(see Eq.~(\ref{eq:omega_drift_diffusion})). We can therefore use the same
drift-diffusion formalism for the first factor in the above Green's
function. Recall that if a walker is initially at position $\vec
x^\prime$, the new position $\vec x$ is calculated as follows (see
Eq.~(\ref{eq:drift_diffusion_proposition}))
\be
\vec x = \vec x^\prime + \chi +
D\vec F(\vec x^\prime) t
\label{eq:drift_diffusion_prop_DMC}
\ee
where $\chi$ is again a Gaussian pseudo-random number with mean equal
zero and variance equal $2Dt$ while $D\vec F(\vec x^\prime) t$ gives a
drift in the direction that $\Psi_\mathrm{T}$ increases. The size of the time step
$t$ biased the final outcome of the Fokker-Planck algorithm of the
drifted diffusion. A desirable diffusion was reached only as $t\to 0$
for each iteration. Also in the present application to DMC, this bias
must be taken into account. In the Metropolis algorithm, the
rejection mechanism took care of it. So we may use the same approach
here. After calculating a new position with
Eq.~(\ref{eq:drift_diffusion_prop_DMC}), we accept it according to the
acceptance matrix
\be
  A(\vec x ,\, \vec x^\prime,\, t) =
  \textrm{min}\left[1\textrm{, }
  \frac{G_K(\vec x^\prime, \vec x)}
  {G_K(\vec x, \vec x^\prime)}
  \frac{|\Psi_\mathrm{T}(\vec x)|^2}
       {|\Psi_\mathrm{T}(\vec x^\prime)|^2}\right]
  \label{eq:acceptance_DMC}
\ee
where $G_K$ is the kinetic part of the Green's function, the part
related to the diffusion process. If we do not wish to do such a
Metropolis test, we may alternatively conduct separate calculations
for a set of different time steps $t$ and extrapolate the results to
$t=0$.

The second factor of Eq.~(\ref{eq:greens_func_short_time_imp}) plays
the same role as the branching term of
Eq.~(\ref{eq:greens_func_short_time}). But the potential $V$ is
replaced by an expression dependent on the local energy,
\bdm
\frac{E_\mathrm{L}(\vec x)+E_\mathrm{L}(\vec x^\prime)}{2}-
E_\mathrm{T}
\edm

The new branching term gives a greatly reduced branching effect
compared to the one in Eq.~(\ref{eq:greens_func_short_time}).
Particularly, in the limit of $\Psi_\mathrm{T} = \phi_0$ and
$E_\mathrm{T}=\epsilon_0$ (exactly equal the ground state of $\op H$),
the local energy is constant, giving equal branching everywhere, or in
effect, no branching at all. Thus we can in general expect the number
of walkers to fluctuate less and we certainly avoid uncontrollable
growth. In addition, the branching favors the areas of the
configuration space that give the lowest local energy, i.e.~the local
energy closest to the true ground state energy. Furthermore, the drifted
diffusion pushes the walkers towards the desirable areas. Thus the
whole DMC process is conducted more efficiently.

Finally, the introduction of the trial wave function $\Psi_\mathrm{T}$
makes it possible to evaluate an estimate of the mean energy given the
distribution of the walkers. Instead of calculating the typical mean
energy
\bdm
\frac{\int\Psi^\ast\op H\Psi d\vec x}
{\int\Psi^\ast\Psi d\vec x}
\edm
we calculate the so called \emph{mixed estimator}
\be
\mean{E}_\mathrm{mixed} =
\frac{\int\Psi_\mathrm{T}\op H\Psi d\vec x}
{\int\Psi_\mathrm{T}\Psi d\vec x}
\label{eq:mixed_estim}
\ee
As the DMC method approaches the exact result $\Psi=\phi_0$, the mixed
estimator becomes
\bdm
\mean{E}_\mathrm{mixed} =
\frac{\int\Psi_\mathrm{T}\,\epsilon_0\,\Psi d\vec x}
{\int\Psi_\mathrm{T}\Psi d\vec x} =
\frac{\epsilon_0\int\Psi_\mathrm{T}\Psi d\vec x}
{\int\Psi_\mathrm{T}\Psi d\vec x} =
\epsilon_0
\edm
so that the estimate indeed becomes correct.  Because of the
hermiticity of $\op H$ we can rewrite the mixed estimator of
Eq.~(\ref{eq:mixed_estim}) as follows
\be
\mean{E}_\mathrm{mixed} =
\frac{\int\Psi\op H\Psi_\mathrm{T} d\vec x}
{\int\Psi_\mathrm{T}\Psi d\vec x} =
\frac{\int\Psi_\mathrm{T}\Psi\,\frac{1}{\Psi_\mathrm{T}}
\op H\Psi_\mathrm{T}\,d\vec x}
{\int\Psi_\mathrm{T}\Psi d\vec x}=
\frac{\int E_\mathrm{L}f(\vec x) d\vec x}
{\int f(\vec x) d\vec x}
\label{eq:mixed_estim_Elocal}
\ee
Since the walkers represent $f$ we just need to average the local
energy $E_\mathrm{L}$ over the set of walkers.

This energy estimator allows us to calculate relatively easily the mean
energy on the distribution of walkers so that we can update the trial
energy $E_{\mathrm{T}}$ dynamically as the algorithm proceeds. As
the trial energy gets better and better, the algorithm will hopefully
stabilize on the exact result within the limits of statistical
fluctuations imposed by the local energy and our choice of
$\Psi_\mathrm{T}$.

As we know, a good choice of $\Psi_\mathrm{T}$ reduces the
fluctuations of the local energy $E_\mathrm{L}$. Now we see that this
also makes the estimation of the mean energy
in Eq.~(\ref{eq:mixed_estim_Elocal}) more efficient since the same
number of points (walkers) gives a smaller variance, thus pinpointing
the energy more exactly.

Importance sampling makes it also to some extent easier to deal with
wave functions that are not positive definite, like fermionic states
whose wave function have nodes. What happens is that the nodes of the
function $f$ are tied by the nodes of the trial wave function
$\Psi_\mathrm{T}$. Therefore it is necessary for $\Psi_\mathrm{T}$ to
have a node configuration that best reproduces the physical properties
of the exact wave function. Operationally, the node surfaces of
$\Psi_\mathrm{T}$ become impenetrable walls to the walkers in the
sense that the drift velocity $\vec F$ in the vicinity of such a
surface increases in a direction away from it pushing any walker away,
preventing it from crossing the nodal surfaces of $\Psi_\mathrm{T}$.
The approach is called a \emph{fixed node approximation}.

From all these deliberations on importance sampling we should by now
understand the importance of the trial wave function being as close to
the exact solution as possible. We therefore rely heavily on simpler
methods like VMC that do not necessarily solve the problem exactly,
but are easier to handle computationally and are much less sensitive
to initial conditions.

%\subsection{A Summary of the Algorithm}
%In preparation for spring 2010.

\section{Bose-Einstein Condensation in Atoms}

 The spectacular demonstration of Bose-Einstein condensation (BEC) in gases of
 alkali atoms $^{87}$Rb, $^{23}$Na, $^7$Li confined in magnetic
 traps \cite{anderson95,davis95,bradley95} has led to an explosion of interest in
 confined Bose systems. Of interest is the fraction of condensed atoms, the
 nature of the condensate, the excitations above the condensate, the atomic
 density in the trap as a function of Temperature and the critical temperature of BEC,
 $T_c$. The extensive progress made up to early 1999 is reviewed by Dalfovo et
 al.\cite{dalfovo1999}.

 A key feature of the trapped alkali and atomic hydrogen systems is that they are
 dilute. The characteristic dimensions of a typical trap for $^{87}$Rb is
 $a_{h0}=\left( {\hbar}/{m\omega_\perp}\right)^\frac{1}{2}=1-2 \times 10^4$
 \AA\ (Ref.~\cite{anderson95}). The interaction between $^{87}$Rb atoms can be well represented
 by its s-wave scattering length, $a_{Rb}$. This scattering length lies in the
 range $85 < a_{Rb} < 140 a_0$ where $a_0 = 0.5292$ \AA\ is the Bohr radius.
 The definite value $a_{Rb} = 100 a_0$ is usually selected and
 for calculations the definite ratio of atom size to trap size
 $a_{Rb}/a_{h0} = 4.33 \times 10^{-3}$
 is usually chosen \cite{dalfovo1999}. A typical $^{87}$Rb atom
 density in the trap is $n \simeq 10^{12}- 10^{14}$ atoms/cm$^3$ giving an
 inter-atom spacing $\ell \simeq 10^4$ \AA. Thus the effective atom size is small
 compared to both the trap size and the inter-atom spacing, the condition
 for diluteness ($na^3_{Rb} \simeq 10^{-6}$ where $n = N/V$ is the number
 density). In this limit,
 although the interaction is important, dilute gas approximations such as the
 Bogoliubov theory \cite{bogo1958}, valid for small $na^3$ and large
 condensate fraction $n_0 = N_0/N$, describe the system well. Also, since most
 of the atoms are in the condensate (except near $T_c$), the Gross-Pitaevskii
 equation \cite{gross1961,pita1961}
for the condensate describes the whole gas
 well. Effects of atoms excited above the condensate have been incorporated
 within the Popov approximation \cite{hutchinson97}.

Most theoretical studies of Bose-Einstein condensates (BEC)
in gases of alkali atoms confined in magnetic or optical traps
have been conducted in the framework of the
Gross-Pitaevskii (GP) equation \cite{gross1961,pita1961}.
The key point for the validity of this description is the
dilute condition of these systems, i.e., the average distance between
the atoms is much larger than the range of the inter-atomic interaction. In
this situation the physics is dominated by two-body collisions,
well described in terms of the $s$-wave scattering length
$a$.  The crucial parameter defining the condition for diluteness is the
gas parameter $x({\bf r})= n({\bf r}) a^3$, where $n({\bf r})$ is the
local density of the system. For low values of the average gas
parameter $x_{av}\le 10^{-3}$, the mean field Gross-Pitaevskii
equation does an excellent job (see for example
Ref.~\cite{dalfovo1999} for a review).
However, in recent
experiments, the local gas parameter may well exceed this value due to
the possibility of tuning the scattering length in the presence of a
Feshbach resonance \cite{cornish00}.

Under such circumstances it is unavoidable to test the accuracy of
the GP equation by performing microscopic calculations. If we consider cases
where the gas parameter has been driven to a region were one
can still have a universal regime, i.e., that the specific shape of
the potential is unimportant, we may attempt to describe the system as dilute
hard spheres whose diameter coincides with the scattering length.
However, the value of $x$ is such that the
calculation of the energy of the uniform hard-sphere Bose gas would
require to take into account the second term in the low-density
expansion \cite{fetter} of the energy density
\begin{equation}
  \frac {E}{V} = \frac {2 \pi n^2 a \hbar^2}{m}
  \left [ 1 + \frac {128}{15} \left ( \frac {n a^3}{\pi} \right)^{1/2}
          + \cdots \right ],
\label{low-ex}
\end{equation}
where $m$ is the mass of the atoms treated as hard spheres.
For the case of uniform systems, the validity of this expansion has been
carefully studied using Diffusion Monte Carlo \cite{boro99} and
Hyper-Netted-Chain techniques \cite{mazz03}.

The energy functional associated with the GP theory is obtained
within the framework of  the local-density approximation (LDA)
by keeping only the first
term in the low-density expansion of Eq.~(\ref{low-ex})

\begin{equation}
  E_{\mathrm{GP}} [\Psi] = \int d{\bf r} \left [ \frac {\hbar^2 }{2m} \mid \nabla
  \Psi({\bf r}) \mid^2 + V_{\mathrm{trap}}({\bf r})\mid \Psi \mid ^2+ \frac {2 \pi
  \hbar^2 a }{m}\mid \Psi \mid ^4 \right ],
\label{func1}
\end{equation}

where
\begin{equation}
  V_{\mathrm{trap}}({\bf r}) = \frac {1}{2} m (\omega_{\bot}^2 x^2
  + \omega_{\bot}^2 y^2 +\omega_{z}^2 z^2 )
\label{trap}
\end{equation}
is the confining potential defined by the two angular frequencies
$\omega_{\bot}$ and $\omega_{z}$.
The condensate
wave function $\Psi$ is
normalized to the total number of particles.

By performing a functional variation of $E_{\mathrm{GP}}[\Psi]$ with respect
to $\Psi^*$ one finds the corresponding Euler-Lagrange equation,
known as the Gross-Pitaevskii (GP) equation
\begin{equation}
  \left [ - \frac {\hbar^2}{2m} \nabla^2 + V_{\mathrm{trap}}({\bf r}) +
   \frac{4\pi\hbar^2 a}{m} \mid \Psi \mid^2 \right ]\Psi=\mu\Psi ,
\label{gp1}
\end{equation}
where $\mu$ is the chemical potential, which accounts for the conservation
of the number of particles. Within the
LDA framework, the next step
is to include into the energy functional of Eq.~(\ref{func1})
the next term of the low density expansion of Eq.~(\ref{low-ex}).
The functional variation gives then rise to the so-called
modified GP equation (MGP) \cite{fabro99}

\begin{equation}
  \left [ - \frac {\hbar^2}{2m} \nabla^2 + V_{\mathrm{trap}}({\bf r})+\frac {4 \pi \hbar^2 a}{m} \mid \Psi \mid^2
    \left (1 + \frac {32 a^{3/2}}{3 \pi^{1/2}} \mid \Psi\mid \right)
    \right ] \Psi =  \mu \Psi .
\label{gp2}
\end{equation}

The MGP corrections have been estimated in  Ref.~\cite{fabro99} in a cylindrical
condensate in the range of the scattering lengths and trap parameters
from the first JILA experiments with Feshbach resonances. These experiments took
advantage of the  presence of a Feshbach resonance in the collision of two
$^{85}$Rb atoms to tune their scattering length \cite{cornish00}.
Fully microscopic calculations using  a hard-spheres interaction have
also been performed in the framework of Variational and Diffusion Monte
Carlo methods \cite{dubois2001,glyde2002,glyde2003,blume1}.

\section{Exercises}
\begin{prob}
%\subsection*{Project 17.1: Bose-Einstein condensation of atoms}

 The aim of this project is to use the Variational Monte
 Carlo (VMC) method and evaluate
 the ground state energy of
 a trapped, hard sphere Bose gas for different numbers of particles
 with a specific
 trial wave function. See Ref.~\cite{abinitio} for a discussion of VMC.

 This wave function is used
 to study the sensitivity of condensate and
 non-condensate properties to the hard sphere radius and the number
 of particles.
 The trap we will use is  a spherical (S) or
 an elliptical (E) harmonic trap in three dimensions given by
  \begin{equation}
 V_{ext}({\bf r}) =
 \Bigg\{
 \begin{array}{ll}
	 \frac{1}{2}m\omega_{ho}^2r^2 & (S)\\
 \strut
	 \frac{1}{2}m[\omega_{ho}^2(x^2+y^2) + \omega_z^2z^2] & (E)
 \label{trap_eqn}
 \end{array}
 \end{equation}
 where (S) stands for symmetric and
 \begin{equation}
     H = \sum_i^N \left(
	 \frac{-\hbar^2}{2m}
	 { \bigtriangledown }_{i}^2 +
	 V_{ext}({\bf{r}}_i)\right)  +
	 \sum_{i<j}^{N} V_{int}({\bf{r}}_i,{\bf{r}}_j),
 \end{equation}
 as the two-body Hamiltonian of the system.
 Here $\omega_{ho}^2$ defines the trap potential strength.  In the case of the
 elliptical trap, $V_{ext}(x,y,z)$, $\omega_{ho}=\omega_{\perp}$ is the trap frequency
 in the perpendicular or $xy$ plane and $\omega_z$ the frequency in the $z$
 direction.
 The mean square vibrational amplitude of a single boson at $T=0K$ in the
 trap (\ref{trap_eqn}) is $<x^2>=(\hbar/2m\omega_{ho})$ so that
 $a_{ho} \equiv (\hbar/m\omega_{ho})^{\frac{1}{2}}$ defines the
 characteristic length
 of the trap.  The ratio of the frequencies is denoted
 $\lambda=\omega_z/\omega_{\perp}$ leading to a ratio of the
 trap lengths
 $(a_{\perp}/a_z)=(\omega_z/\omega_{\perp})^{\frac{1}{2}} = \sqrt{\lambda}$.

 We represent the inter boson interaction by a pairwise, hard core potential
 \begin{equation}
 V_{int}(|{\bf r}_i-{\bf r}_j|) =  \Bigg\{
 \begin{array}{ll}
	 \infty & {|{\bf r}_i-{\bf r}_j|} \leq {a}\\
	 0 & {|{\bf r}_i-{\bf r}_j|} > {a}
 \end{array}
 \end{equation}
 where ${a}$ is the hard core diameter of the bosons.  Clearly, $V_{int}(|{\bf r}_i-{\bf r}_j|)$
 is zero if the bosons are separated by a distance $|{\bf r}_i-{\bf r}_j|$ greater than $a$ but
 infinite if they attempt to come within a distance $|{\bf r}_i-{\bf r}_j| \leq a$.

 Our trial wave function for the ground state with $N$ atoms is given by
 \be
 \Psi_T({\bf R})=\Psi_T({\bf r}_1, {\bf r}_2, \dots {\bf r}_N,\alpha,\beta)=\prod_i g(\alpha,\beta,{\bf r}_i)\prod_{i<j}f(a,|{\bf r}_i-{\bf r}_j|),
 \label{eq:trialwf}
 \ee
 where $\alpha$ and $\beta$ are variational parameters. The single-particle wave function is proportional
 to the harmonic oscillator function for the ground state, i.e.,
 \be
    g(\alpha,\beta,{\bf r}_i)= \exp{[-\alpha(x_i^2+y_i^2+\beta z_i^2)]}.
 \ee
 For spherical traps we have $\beta = 1$ and for non-interacting bosons ($a=0$) we have
 $\alpha = 1/2a_{ho}^2$.
 The correlation wave function is
 \be
    f(a,|{\bf r}_i-{\bf r}_j|)=\Bigg\{
 \begin{array}{ll}
	 0 & {|{\bf r}_i-{\bf r}_j|} \leq {a}\\
	 (1-\frac{a}{|{\bf r}_i-{\bf r}_j|}) & {|{\bf r}_i-{\bf r}_j|} > {a}.
 \end{array}
 \ee

 \begin{enumerate}
 \item[a)] Find analytic expressions for the local energy
 \be
    E_L({\bf R})=\frac{1}{\Psi_T({\bf R})}H\Psi_T({\bf R}),
    \label{eq:locale}
 \ee
 for the above
 trial wave function of Eq.~(\ref{eq:trialwf}).
 Compute also the analytic expression for the drift force to be used in importance sampling
 \be
   F = \frac{2\nabla \Psi_T}{\Psi_T}.
 \ee

The tricky part is to find an analytic expressions for the derivative of the trial wave function
\[
   \frac{1}{\Psi_T({\bf R})}\sum_i^{N}\nabla_i^2\Psi_T({\bf R}),
\]
for the above
trial wave function of Eq.~(\ref{eq:trialwf}).
We rewrite
\[
\Psi_T({\bf R})=\Psi_T({\bf r}_1, {\bf r}_2, \dots {\bf r}_N,\alpha,\beta)=\prod_i g(\alpha,\beta,{\bf r}_i)\prod_{i<j}f(a,|{\bf r}_i-{\bf r}_j|),
\]
as
\[
\Psi_T({\bf R})=\prod_i g(\alpha,\beta,{\bf r}_i)e^{\sum_{i<j}u(r_{ij})}
\]
where we have defined $r_{ij}=|{\bf r}_i-{\bf r}_j|$
and
\[
   f(r_{ij})= e^{\sum_{i<j}u(r_{ij})},
\]
and in our case
\[
    g(\alpha,\beta,{\bf r}_i) = e^{-\alpha(x_i^2+y_i^2+z_i^2)}= \phi({\bf r}_i).
\]

The first derivative becomes
\[
  \nabla_k\Psi_T({\bf R}) = \nabla_k\phi({\bf r}_k)\left[\prod_{i\ne k}\phi({\bf r}_i)\right]e^{\sum_{i<j}u(r_{ij})}+
\prod_i\phi({\bf r}_i)e^{\sum_{i<j}u(r_{ij})}\sum_{j\ne k}\nabla_k u(r_{ij})
\]
We leave it as an exercise for the reader to find the expression for the sceond derivative.
The final expression is
\[
   \frac{1}{\Psi_T({\bf R})}\nabla_k^2\Psi_T({\bf R})=
   \frac{\nabla_k^2\phi({\bf r}_k)}{\phi({\bf r}_k)}+
\frac{\nabla_k\phi({\bf r}_k)}{\phi({\bf r}_k)}\left(\sum_{j\ne k}\frac{{\bf r}_k}{r_k}u'(r_{ij})\right)+
\]
\[
\sum_{ij\ne k}\frac{({\bf r}_k-{\bf r}_i)({\bf r}_k-{\bf r}_j)}{r_{ki}r_{kj}}u'(r_{ki})u'(r_{kj})+
\sum_{j\ne k}\left( u''(r_{kj})+\frac{2}{r_{kj}}u'(r_{kj})\right)
\]
You need to get the analytic expression for this expression using the harmonic oscillator wave functions
and the correlation term defined in the project.

 \item[b)] Write a Variational Monte Carlo program which uses standard Metropolis sampling
 and compute the ground state energy
 of a spherical harmonic oscillator ($\beta = 1$) with no interaction.
 Use natural units and make an analysis of your calculations using both the analytic expression for the
 local energy and a numerical calculation of the kinetic energy using numerical derivation.
 Compare the CPU time difference.  You should also  parallelize your code.
 The only variational parameter is $\alpha$. Perform these calculations for $N=10$,
 $100$ and $500$ atoms. Compare your results with the exact answer.

 \item[c)] We turn now to the elliptic trap with a hard core interaction.
 We fix, as in Refs.~\cite{dubois2001,nilsen2005} $a/a_{ho}=0.0043$. Introduce lengths in units
 of $a_{ho}$, $r\rightarrow r/a_{ho}$ and energy in units of $\hbar\omega_{ho}$.
 Show then that the original Hamiltonian can be rewritten as
 \be
    H=\sum_{i=1}^N\frac{1}{2}\left(-\nabla^2_i+x_i^2+y_i^2+\gamma^2z_i^2\right)+\sum_{i<j}V_{int}(|{\bf r}_i-{\bf r}_j|).
 \ee
 What is the expression for $\gamma$?
 Choose the initial value for $\beta=\gamma = 2.82843$ and set up a VMC program
 which computes the ground state energy using the trial wave function of Eq.~(\ref{eq:trialwf}).
 using only $\alpha$ as variational parameter.
 Use standard Metropolis sampling and vary the parameter $\alpha$ in order to find a
 minimum. Perform the calculations for $N=10,50$ and $N=100$ and compare your results to those from the ideal case in the previous exercise.
In actual calculations employing e.g., the Metropolis algorithm,
all moves are recast into the chosen simulation cell with
periodic boundary conditions. To carry out consistently the Metropolis moves,
it has to be assumed that the correlation function has a range shorter than
$L/2$. Then, to decide if a move of a single particle is accepted or not,
only the set of particles contained in a sphere of radius $L/2$ centered at the
referred particle have to be considered.

\item[d)] We repeat exercise c), but now we replace the brute force Metropolis algorithm with
importance sampling based on the Fokker-Planck and the Langevin equations.
Discuss your results and comment on eventual differences between importance sampling and brute force sampling.

Your code should reproduce the results of Refs.~\cite{dubois2001,nilsen2005}.

\end{enumerate}

\end{prob}