\documentclass[12pt,twoside]{article}
\usepackage{amsmath}
\usepackage[pdftex]{graphicx}
\usepackage{pstricks}

\renewcommand{\baselinestretch}{1.2}
\setlength{\topmargin}{-0.2in}
\setlength{\textwidth}{6in}
\setlength{\textheight}{8.5in}
\setlength{\oddsidemargin}{0.25in}
\setlength{\evensidemargin}{0.25in}
\raggedbottom

\newcommand{\bra}[1]{\left\langle #1 \right|}
\newcommand{\ket}[1]{\left|#1\right\rangle}
\newcommand{\braket}[2]{\left\langle#1 |  #2\right\rangle}
\newcommand{\rd}[1]{\mathop{\mathrm{d}#1}}

% This is a hack for getting Eq. 15 to fit on a single line
\DeclareMathSizes{12}{12}{9}{7}

\title{An Iterative Technique for Solving the $N$-electron Hamiltonian: The Hartree-Fock method}
\author{\colorbox{black}{Tony Hyun Kim}} 
\date{} 

\begin{document}

\maketitle
\pagestyle{myheadings}
\markboth{\colorbox{black}{Kim}}{An Iterative Technique for Solving the $N$-electron Hamiltonian}
\thispagestyle{empty}
\begin{abstract}
	\noindent	The problem of electron motion in an arbitrary field of nuclei is an important quantum mechanical problem finding applications in many diverse fields. From the variational principle we derive a procedure, called the Hartree-Fock (HF) approximation, to obtain the many-particle wavefunction describing such a system. Here, the central physical concept is that of electron indistinguishability: while the antisymmetry requirement greatly complexifies our task, it also offers a symmetry that we can exploit. After obtaining the HF equations, we then formulate the procedure in a way suited for practical implementation on a computer by introducing a set of spatial basis functions. An example implementation is provided, allowing for calculations on the simplest heteronuclear structure: the helium hydride ion. We conclude with a discussion of deriving physical information from the HF solution.
\end{abstract}

\section{Introduction}

In this paper I will introduce the theory and the techniques to solve for the approximate ground state of the \emph{electronic Hamiltonian}:
\begin{equation}
	H = -\frac{1}{2} \sum_{i=1}^N \nabla_i^2 - \sum_{i=1}^N \sum_{A=1}^M \frac{Z_A}{r_{Ai}} + \sum_{i=1}^N \sum_{j>i}^N \frac{1}{r_{ij}}, \ \ \ \ r_{ij} = |\vec{r}_i-\vec{r}_j|
	\label{eqn:elec_h}
\end{equation}
which describes the motion of $N$ electrons (indexed by $i$ and $j$) in the field of $M$ nuclei (indexed by $A$). The coordinate system, as well as the fully-expanded Hamiltonian, is explicitly illustrated for $N = M = 2$ in Figure \ref{fig:mol_coord}. Although we perform the analysis in dimensionless form, the physical lengths and energies can be readily obtained by multiplying by the scale factors $a_0 = 5.3\times 10^{-11}$m and $\epsilon_a = 27.21$eV respectively.

\begin{figure}[ht]
	\begin{center}
		\includegraphics[scale=0.5]{mol_coord.png}
	\end{center}
	\caption{\label{fig:mol_coord}The coordinate system corresponding to Eq. \ref{eqn:elec_h} for $N=M=2$. The \hspace*{18.5 mm} Hamiltonian is: $H = -\frac{1}{2}\nabla_1^2 -\frac{1}{2}\nabla_2^2 + \frac{Z_{A}}{r_{1A}} + \frac{Z_{B}}{r_{1B}} + \frac{Z_{A}}{r_{2A}} + \frac{Z_{B}}{r_{2B}}+\frac{1}{r_{12}}$}
\end{figure}

The above Hamiltonian and the system it represents are of profound importance for many areas of study even beyond physics. In particular, it is the theoretical basis for quantum chemistry, a field in which one derives from first principles a wealth of chemical facts, including quantities of practical modern interest such as structures of molecules and mechanisms of reactions. All of this is possible without relying on empirical parameters beyond $a_0$ and $\epsilon_a$. Accordingly, this paper culminates with a computer implementation to solve for the ground state of the helium hydride ion. I then report the computed equilibrium HeH$^+$ bond length, the vibrational frequency, and present the three-dimensional electronic distribution function, all of which are useful parameters in characterizing a substance. (All numerical results presented in this paper were obtained from my own implementations. The appendix describes how to access these programs.)

Our method, called the \emph{Hartree-Fock (HF) approximation} or the \emph{self-consistent field (SCF)}, iteratively treats each of the electrons of the $N$-particle wavefunction in sequence, in a one-by-one manner. We begin exploring such an iteration scheme by analyzing the simplest two-electron system, the He atom.

\subsection{Hartree iteration on the helium atom}

It is well-known that the difficulty in obtaining the two-electron wavefunction $\Psi(\vec{r}_1,\vec{r}_2)$ from the helium Hamiltonian originates from the Coulombic interaction term between electrons 1 and 2. In fact, when one simply ignores this interaction, the two-particle Schr\"odinger equation is satisfied by a product wavefunction, $\Psi(\vec{r}_1,\vec{r}_2) = \psi_a(\vec{r}_1) \psi_b(\vec{r}_2)$, where $\psi_i$ are the scaled single particle states obtained from the hydrogen atom. (Don't worry! We will say a word about the antisymmetry requirement shortly.)

With this background, we then follow the suggestion of the numerical analyst D.R. Hartree, who in the 1920's proposed that the many-electron wavefunction can still be expressed as a product of two single-particle states, even in the presence of mutual repulsion. In other words, we will now simply take for granted the functional form $\Psi(\vec{r}_1,\vec{r}_2) = \psi_a(\vec{r}_1) \psi_b(\vec{r}_2)$, but without yet specifying $\psi_{a,b}$.

Given this trial wavefunction, Hartree's iterative method describes how to determine the single-particle states $\psi_{a,b}$. Again, ``iteration'' implies that the algorithm analyzes each electron one at a time. 

As a starting point, consider the doubly-charged helium nucleus stripped of both electrons. In assigning a wavefunction to the first electron around this nucleus, the relevant potential is clearly $V_{nucl} = -2/r_1$, for which we have available an analytic form of the ground-state eigenfunction: call this $\psi_a^{(0)}$. The potential and the initial wavefunction of electron 1 are shown in Figure \ref{fig:hartree_iter}(a).

\begin{figure}[ht]
	\begin{center}
		\includegraphics[scale=0.5]{hartree_iter.png}
	\end{center}
	\caption{\label{fig:hartree_iter}Single-particle wavefunctions and relevant potentials for each electron.}
\end{figure}

We then move on to electron 2. Recalling that $|\psi_a(\vec{r}_1)|^2$ represents the spatial probability distribution of electron 1, it is plausible to associate a repulsive potential $V_{ee}$ due to the corresponding charge density, $\rho_a = e |\psi_a(\vec{r}_1)|^2$. Therefore, the Schr\"odinger equation (SE) for electron 2 will involve the electron-electron potential $V_{ee}$ in addition to $V_{nucl}$. In our dimensionless units, the fundamental charge $e$ is not necessary to convert between spatial and charge distributions. The electrostatic potential energy of the electron-electron interaction can then be obtained as:
\begin{equation}
	V_{ee}(\vec{r}_2; \psi_a) = \int d^3r_1 \frac{1}{r_{12}} \rho_a(\vec{r}_1) = \int d^3r_1 \frac{1}{r_{12}} |\psi_a(\vec{r}_1)|^2
	\label{eqn:ee_repulsion}
\end{equation}
where $r_{12} = |\vec{r}_1 - \vec{r}_2|$. The notation for $V_{ee}$ explicitly indicates its dependence on $\psi_a$. The numerical solution for electron 2's wavefunction $\psi_b$, in the effective potential $V_{ee}+V_{nucl}$, is shown in Figure \ref{fig:hartree_iter}(b). 

Returning to electron 1, it is now possible to utilize $\psi_b$ to similarly calculate $V_{ee}(\vec{r}_1;\psi_b)$. The new SE is solved, yielding $\psi_a^{(1)}(\vec{r}_1)$. The process is repeated, alternating between the two electrons, until the sequences of functions $\left\{\psi_a^{(i)}\right\}$ and $\left\{\psi_b^{(i)}\right\}$ converge within some desired precision. Formally, we are solving the equations:
\begin{eqnarray}
	\left[-\frac{1}{2}\nabla_1^2+V_{nucl}(\vec{r}_1)+V_{ee}(\vec{r}_1;\psi_b)\right]\psi_a(\vec{r}_1) = E_a \psi_a(\vec{r}_1)\\
	\left[-\frac{1}{2}\nabla_2^2+V_{nucl}(\vec{r}_2)+V_{ee}(\vec{r}_2;\psi_a)\right]\psi_b(\vec{r}_2) = E_b \psi_b(\vec{r}_2)
	\label{eqns:hartree_iteration}
\end{eqnarray}
in an iterative fashion. Note however, that it is not \emph{a priori} necessary that Eqs. 3 and 4 are solved in this way. Instead, the essential result of the Hartree procedure is the reduction of the many-body Hamiltonian (Eq. \ref{eqn:elec_h}) to several single-particle Hamiltonians (Eqs. 3 and 4). On the other hand, due to the coupling through $V_{ee}$, a direct solution to the above set of nonlinear Schr\"odinger equations is prohibitably difficult. In virtually every implementation, the resulting equations are numerically solved by fixed point iteration, in the way we have illustrated.

As with any iterative scheme, convergence and stability of solution are important concerns. However, in this paper I shy away from such issues, blissfully expecting all of my computations to converge without problem. Furthermore, recall that eigenvalue problems generally admit multiple solutions with different (energy) eigenvalues. Since we are interested in the ground state of the many-particle wavefunction, we seek the set of functions $(\psi_a,\psi_b)$ that satisfies Eqs. 3 and 4 with the lowest associated energies. Having noted these complications, Hartree's method then gives an algorithm for producing multi-electron wavefunctions of the form $\Psi(\vec{r}_1,\vec{r}_2)=\psi_a(\vec{r}_1)\psi_b(\vec{r}_2)$, valid for Hamiltonians involving electron-electron repulsion as in Eq. \ref{eqn:elec_h}.

\subsection{Shortcomings of the above iteration scheme}

Thus far, I have given an uncritical exposition of the \emph{Hartree method}. I now outline three of its inadequacies. The remainder of the paper is organized around each of their resolution.

\begin{enumerate}
	\item The Hartree method ignores the antisymmetry requirement for the many electron wavefunction. In Section 2, we will rectify this by introducing the Hartree-Fock (HF) approximation, which takes as its trial wavefunction $\Psi$ a Slater determinant.\footnote{It might appear that an easier alternative is to antisymmetrize the single-particle states arising from the Hartree method. However plausible, this approach is not rigorously justified. A sounder approach is to assume, from the beginning, a trial wavefunction that properly takes into account the antisymmetry requirement. See point 2 above.}
	\item Beyond heuristic arguments, it is not clear how the conversion from the many-body Hamiltonian to several single-particle Hamiltonians can be rigorously justified from the principles of QM. We show in Section 3 that the HF approximation is an advanced application of the variational principle.
	\item In general, numerical integration of the Schr\"odinger equation in coordinate-space is difficult. Speaking from personal experience, obtaining a bound-state wavefunction involves a careful choice of integration bounds, and fine-tuning of several numerical knobs. For practical purposes, we seek a more robust approach that is applicable to a wider range of inputs. In Section 4, a mathematical technique is introduced that converts the integro-differential equations of HF into a matrix equation, which are more tractable, and are actually how Hamiltonian solvers are implemented in practice.
\end{enumerate}
To summarize, our immediate task is then to derive from the $N$-particle Hamiltonian (Eq. \ref{eqn:elec_h}), $N$ single-particle Schr\"odinger equations, analogous to Eqs. 3 and 4, that take into account the proper Fermi statistics.

\section{Slater determinant wavefunctions}

The defining property of the Hartree-Fock (HF) approximation, as an improvement on the Hartree method, is that the trial wavefunction $\Psi$ is chosen to be a Slater determinant of mutually orthonormal single-particle states. Of course, the motivation arises from the fact that the mathematical properties of a determinant trivially satisfy the antisymmetry requirement.

However, recall that an electron has a spin degree of freedom in addition to its spatial coordinates. In fact, the antisymmetry requirement applies to an exchange of both spatial and spin coordinates, whereas we dealt solely with space in our previous discussion of the Hartree iteration. Hence, we must now augment our previous notation to explicitly incorporate spin.

We use $\vec{x}_i$ to denote the complete set of coordinates associated with the $i$-th electron, comprised of the spatial $\vec{r}_i$ and spin $w_i=\pm\frac{1}{2}$ parts. Throughout this paper, the single particle state will be expressed in various forms as deemed convenient:
\begin{equation}
	\ket{m} = \chi_m(\vec{x}_i) = \chi_m(i) = \psi_m(\vec{r}_i) \otimes \ket{w_i} = \psi_m(\vec{r}_i)\ket{w_i}
	\label{eqn:sp_state}
\end{equation}
The first form is useful when we wish to emphasize the state, rather than the electron index. In the last two expressions, the complete state $\chi_m(\vec{x}_i)$ (``spin orbital'' in chemistry parlance) is separated into its spatial $\psi_m(\vec{r}_i)$ and spin $\ket{w_i}$ parts.

With this convention, the trial determinantal wavefunction may be written:
\begin{eqnarray}
	\Psi(\vec{x}_1,\vec{x}_2,...,\vec{x}_N) &=& \frac{1}{\sqrt{N!}} 
		\left|
			\begin{array}{cccc}
				\chi_1(\vec{x}_1) & \chi_2(\vec{x}_1) & \ldots & \chi_N(\vec{x}_1) \\
				\chi_1(\vec{x}_2) & \chi_2(\vec{x}_2) & \ldots & \chi_N(\vec{x}_2) \\
				\vdots            & \vdots            &        & \vdots            \\
				\chi_1(\vec{x}_N) & \chi_2(\vec{x}_N) & \ldots & \chi_N(\vec{x}_N) \\
			\end{array}
		\right|\\
		&=& \frac{1}{\sqrt{N!}} \sum_{n=1}^{N!}(-1)^{p_n}P_n\left\{\chi_1(1)\chi_2(2)\ldots\chi_N(N)\right\}
\end{eqnarray}
In Eq. 7, the index $n$ runs over all $N!$ permutations of the $N$ single particle states. The quantity $p_n$ takes on $0$ or $1$ depending on whether the permutation $P_n$ is even or odd, respectively. An even (odd) permutation is one that can be formed by an even (odd) number of exchanges of two elements. (Such minimal exchanges are called transpositions.) We may regard the action of $P_n$ as permuting the electron indices, so that if $P_2$ is the transposition of 1 and 2, then
\begin{equation*}
	P_2\left\{\chi_1(1)\chi_2(2)\chi_3(3)\ldots\chi_N(N)\right\} = \chi_1(2)\chi_2(1)\chi_3(3)\ldots\chi_N(N)
\end{equation*}
and $(-1)^{p_2} = -1$ by definition.

\subsection{Matrix elements involving determinantal wavefunctions}

The Slater determinant state is fundamental to the HF theory. We have also previously hinted at the connection between the Hartree-Fock method and the variational principle. As one might expect, the bridge between the two is the energy expectation $\bra{\Psi}H\ket{\Psi}$ of a Slater determinant state $\Psi$.

Our task in computing $\bra{\Psi}H\ket{\Psi}$ is made simpler by recognizing the ``one- and two-electron'' structure of the electronic Hamiltonian, and by using the \emph{indistinguishability} of electrons to take advantage of that structure. Begin by writing Eq. \ref{eqn:elec_h} as
\begin{eqnarray}
	H &=& \sum_{i=1}^N \left(-\frac{1}{2}\nabla_i^2-\sum_{A=1}^M \frac{Z_A}{r_{iA}}\right) + \sum_{i=1}^N \sum_{j>i}^N\frac{1}{r_{ij}}\nonumber\\
	  &=& \sum_{i=1}^N h_1(i) + \sum_{i=1}^N \sum_{j>i}^N h_2(i,j)
\end{eqnarray}
Here, we have identified the \emph{one-electron operator} $h_1(i) = -\frac{1}{2}\nabla_i^2-\sum_{A=1}^M Z_A/r_{iA}$ (of the $i$-th electron) and the \emph{two-electron operator} $h_2(i,j) = r_{ij}^{-1}$ (involving electrons $i$ and $j$). The terminology corresponds to the fact that only one and two sets of electron coordinates are involved in the matrix elements of $h_1(i)$ and $h_2(i,j)$ respectively. In particular, $h_1(i)$ is also termed the \emph{core-Hamiltonian} of the $i$-th electron, describing its kinetic and potential energy in the field of the nuclei.

\subsubsection{One-electron integrals}

We now show explicitly that $\bra{\Psi}h_1(i)\ket{\Psi}$ reduces to an integral over a single electron coordinate. Consider $i = 1$. Expanding $\Psi$ as given in Eq. 7,
\begin{eqnarray*}
	\bra{\Psi}h_1(1)\ket{\Psi} &=& \frac{1}{N!} \sum_i^{N!} \sum_j^{N!} (-1)^{p_i} (-1)^{p_j} \int d\vec{x}_1d\vec{x}_2\ldots d\vec{x}_N\\
	&\times& P_i\left\{\chi_1^{*}(1)\chi_2^{*}(2)\ldots\chi_N^{*}(N)\right\}h_1(1)P_j\left\{\chi_1(1)\chi_2(2)\ldots\chi_N(N)\right\}
\end{eqnarray*}

Since the single particle states are chosen to be orthonormal, the above expression is zero unless electrons $2$, $3$,$\ldots$,$N$ occupy the same spin orbitals in the $i$-th permutation as in the $j$-th permutation. (Recall that $h_1(1)$ depends only on the coordinates of electron 1. The other electrons ``go right through'' $h_1(1)$.) This condition is equivalent to the two permutations being identical. In such a case, the sums over $i$ and $j$ can be accounted for by a single index, and $(-1)^{p_i}(-1)^{p_j} = (-1)^{p_i}(-1)^{p_i} = 1$, yielding:
\begin{eqnarray*}
	\bra{\Psi}h_1(1)\ket{\Psi} &=& \frac{1}{N!} \sum_i^{N!} \int d\vec{x}_1d\vec{x}_2\ldots d\vec{x}_N\\
	&\times& P_i\left\{\chi_1^{*}(1)\chi_2^{*}(2)\ldots\chi_N^{*}(N)\right\}h_1(1)P_i\left\{\chi_1(1)\chi_2(2)\ldots\chi_N(N)\right\}
\end{eqnarray*}														

Now note that in the sum over the $N!$ permutations, electron 1 occupies each spin orbital $\chi_m$, $(N-1)!$ times. This follows since there are $(N-1)!$ ways to arrange electrons $2$, $3$, $\ldots$, $N$, after having fixed the orbital of electron 1. In conclusion, $\bra{\Psi}h_1(1)\ket{\Psi}$ can be expressed as:
\begin{eqnarray}
	\bra{\Psi}h_1(1)\ket{\Psi} &=& \frac{(N-1)!}{N!} \sum_{m=1}^N \int d\vec{x}_1\chi_m^{*}(\vec{x}_1)h_1(1)\chi_m(\vec{x_1})\nonumber\\
														 &=& \frac{1}{N} \sum_{m=1}^N \bra{m}h_1(1)\ket{m}
\end{eqnarray}
where the sum is over the single-particle states.

So, we find that the core-energy of electron 1 is an average of the expected core-energy of every single-particle state that comprises the determinant. This is a direct consequence of the indistinguishability of electrons: because we have applied the proper statistics to describe the many-particle wavefunction (i.e. a Slater determinant), it does not make sense to assign an electron into a distinguishable combination of the single-particle states. Instead, every electron must occupy each single-particle state in an exactly identical way! (And hence Eq. 9.)

Given the indistinguishability of the electrons, it is then clear that $h_1(i) = h_1(j)$ for every $i, j$. We can thus conclude:
\begin{equation}
	\bra{\Psi}\sum_{i=1}^N h_1(i)\ket{\Psi} = \sum_{m=1}^N \bra{m}h_1(1)\ket{m}
	\label{eqn:1e_integral}
\end{equation}
Conventionally, the integration variable of the one-electron integral is taken to be $\vec{x}_1$.

\subsubsection{Two-electron integrals}

This time, we exploit indistinguishability from the beginning, and write
\begin{equation}
	\bra{\Psi}\sum_{i=1}^N \sum_{j>i}^N h_2(i,j) \ket{\Psi} = 
		\left(
			\begin{array}{c}
			 N \\
			 2 \\
			\end{array}
		\right) \bra{\Psi}h_2(1,2)\ket{\Psi} = \frac{N(N-1)}{2}\bra{\Psi}h_2(1,2)\ket{\Psi}
	\label{eqn:2e_integral1}
\end{equation}
This is valid since any pair of electrons will have identical $\bra{\Psi}h_2(i,j)\ket{\Psi}$ according to indistinguishability. Furthermore, the double sum accounts for all of the unique pairs among $N$ electrons, of which there are $N(N-1)/2$.

Proceeding as before, we obtain:
\begin{eqnarray*}
	\frac{N(N-1)}{2}\bra{\Psi}h_2(1,2)\ket{\Psi} &=& \frac{1}{2(N-2)!} \sum_i^{N!} \sum_j^{N!} (-1)^{p_i} (-1)^{p_j} \int d\vec{x}_1d\vec{x}_2\ldots d\vec{x}_N\\
	&\times& P_i\left\{\chi_1^{*}(1)\chi_2^{*}(2)\ldots\chi_N^{*}(N)\right\}h_2(1,2)P_j\left\{\chi_1(1)\chi_2(2)\ldots\chi_N(N)\right\}
\end{eqnarray*}

However, unlike the one-electron case, the orthogonality of single-particle states only stipulates that electrons $3$, $4$, $\ldots$, $N$ be assigned the same spin orbital by permutations $P_i$ and $P_j$. With fixed $P_i$, there are actually two possible choices for $P_j$ that satisfy this constraint: $P_j$ can either be identical to $P_i$, or be the composition of $P_i$ and the transposition of electrons 1 and 2 (which we have previously called $P_2$). In the latter case, note that $(-1)^{p_i}(-1)^{p_j} =(-1)^{p_i}(-1)^{p_i+p_2}= -1$. 

In the sums over $N!$ permutations, electrons 1 and 2 will occupy any two different spin orbitals $\chi_m$ and $\chi_n$, $(N-2)!$ times. (For each pair, there are $(N-2)!$ ways to permute the other $N-2$ electrons among the $N-2$ remaining states.) Hence,
\begin{eqnarray*}
	\frac{N(N-1)}{2}\bra{\Psi}h_2(1,2)\ket{\Psi} &=& \frac{1}{2(N-2)!} (N-2)! \sum_{m=1}^{N} \sum_{n\neq m}^N \int d\vec{x}_1 d\vec{x}_2\\
	&\times& \chi_m^{*}(1)\chi_n^{*}(2)h(1,2)\left[\chi_m(1)\chi_n(2) - \chi_m(2)\chi_n(1)\right]\\
	&=& \frac{1}{2} \sum_{m=1}^{N} \sum_{n\neq m}^N \bra{mn}h_2(1,2)\ket{mn} - \bra{mn}h_2(1,2)\ket{nm}
\end{eqnarray*}

As a final modification, note that $\bra{mn}h_2(1,2)\ket{mn} - \bra{mn}h_2(1,2)\ket{nm}$ vanishes when $n = m$, so we can eliminate the restriction on the inner sum to conclude:
\begin{equation}
	\frac{N(N-1)}{2}\bra{\Psi}h_2(1,2)\ket{\Psi} = \frac{1}{2} \sum_{m=1}^{N} \sum_{n=1}^N \bra{mn}h_2(1,2)\ket{mn} - \bra{mn}h_2(1,2)\ket{nm}
\end{equation}
Referring back to Eq. 8, we have then finished the task of computing $\bra{\Psi}H\ket{\Psi}$:
\begin{eqnarray}
	\bra{\Psi}H\ket{\Psi} &=& \bra{\Psi}\sum_{i=1}^N h_1\ket{\Psi} + \bra{\Psi}\sum_{i=1}^N \sum_{j>i}^N h_2\ket{\Psi}\nonumber\\
												&=& \sum_{m=1}^N \bra{m}h_1\ket{m} + \frac{1}{2} \sum_{m=1}^{N} \sum_{n=1}^N \bra{mn}h_2\ket{mn} - \bra{mn}h_2\ket{nm}
\end{eqnarray}
Due to indistinguishability, we are able to suppress the electron coordinate indices in the operators $h_1$ and $h_2$ without ambiguity.

\section{Derivation of HF from the Variational Principle}

In this section we derive the Hartree-Fock equations, analogous to Eqs. 3 and 4, that are applicable to the Slater-determinant trial function. The HF equations will be a set of coupled, nonlinear Schr\"odinger equations for the each of the single-particle states. The arguments presented here originate from John Slater (he of the determinant!) who first performed the following analysis on the Hartree iteration.

We begin by reminding the reader of the \emph{variational principle.} For any choice of $\Psi$, the energy expectation $\bra{\Psi}H\ket{\Psi}$ represents an upper bound to the true ground state energy of $H$. Having constrained $\Psi$ to be an element of some set of functions, the best approximation to the ground state is obtained by minimization of the energy expectation over that set.

In the Hartree-Fock theory, the many-particle wavefunction $\Psi$ is constrained to remain a Slater determinant formed by mutually orthonormal single-particle states $\left\{\ket{m}\:|\:m = 1,2,\ldots,N\right\}$. However, as in the original Hartree procedure, the single particle states are not yet identified, and therein lie our variational degrees of freedom. More precisely, we view the energy expectation $\bra{\Psi}H\ket{\Psi}$ as a \emph{functional} on $\left\{\ket{m}\right\}$. We can then apply the standard techniques of the calculus of variations, seeking an optimal set of single-particle states that makes $\bra{\Psi}H\ket{\Psi}$ stationary under arbitrary infinitesimal changes, $\ket{m} \rightarrow \ket{m}+\ket{\delta m}$. The variational principle then shows that the resulting set produces the best single-determinant approximation to the ground state.

An useful analogy is available. In classical mechanics, variational minimization of the Lagrangian functional yields a set of differential equations of motion in the individual coordinates called the Euler-Lagrange equations. Here, we are similarly expecting variational minimization of $\bra{\Psi}H\ket{\Psi}$ to yield the ``equations of motion'' e.g. the HF equations in each of the ``coordinates,'' namely $\left\{\ket{m}\right\}$.

In the current problem, the variations in $\left\{\ket{m}\right\}$ are constrained by the orthonormality requirement, $\braket{m}{n}-\delta_{mn}=0$. The standard procedure in accomodating such constraints in an optimization problem is to introduce Lagrange multipliers $\epsilon_{mn}$. This is a technique in which one minimizes the Lagrange function $L'$
\begin{equation*}
	L'(\left\{\ket{m}\right\}, \epsilon_{mn}) = \bra{\Psi}H\ket{\Psi} - \sum_{m=1}^N\sum_{n=1}^N\epsilon_{mn}(\braket{m}{n}-\delta_{mn})
\end{equation*}
rather than the energy expectation $\bra{\Psi}H\ket{\Psi}$ directly. 

However, for the sake of arriving at the HF equations more quickly, I will only enforce the normalization constraint $\braket{m}{m} - 1 = 0$ in the Lagrange function. Through the resulting equations, we can check \emph{a posteriori} that the single-particle states are also orthogonal as required. (We don't have the space to actually perform the verification, I'm afraid.) The possibility of this particular approach was shown in the reference by Bethe and Jackiw. The relevant Lagrange function $L$ is then,
\begin{eqnarray*}
	L &=& \bra{\Psi}H\ket{\Psi} - \sum_{m=1}^N \epsilon_m(\braket{m}{m}-1)\\
	  &=& \sum_{m=1}^N \bra{m}h_1\ket{m} + \frac{1}{2} \sum_{m=1}^{N} \sum_{n=1}^N \left\{\bra{mn}h_2\ket{mn} - \bra{mn}h_2\ket{nm}\right\} - \sum_{m=1}^N \epsilon_m(\braket{m}{m}-1)
\end{eqnarray*}

Applying the arbitrary changes $\ket{m} \rightarrow \ket{m}+\ket{\delta m}$ in the single-particle states, we find the first variation of $L$ to be
\begin{eqnarray}
	\delta L &=& \sum_{m=1}^N \bra{\delta m}h_1\ket{m} + \bra{m}h_1\ket{\delta m}\nonumber\\
					 &+& \frac{1}{2} \sum_{m=1}^{N} \sum_{n=1}^N \bra{(\delta m)n}h_2\ket{mn} + \bra{m (\delta n)}h_2\ket{mn} + \bra{mn}h_2\ket{(\delta m)n} + \bra{mn}h_2\ket{m (\delta n)}\nonumber\\
					 &-& \frac{1}{2} \sum_{m=1}^{N} \sum_{n=1}^N \bra{(\delta m)n}h_2\ket{nm} + \bra{m(\delta n)}h_2\ket{nm} + \bra{mn}h_2\ket{(\delta n)m} + \bra{mn}h_2\ket{n(\delta m)}\nonumber\\
					 &-& \sum_{m=1}^N \epsilon_m(\braket{\delta m}{m}+\braket{m}{\delta m})
					 \label{eqn:first_variation1}
\end{eqnarray} 
The key to making sense of the above expression is to recognize that the two-electron operator is invariant to an exchange in the order of electrons: $h_2(i,j) = h_2(j,i)$. This of course follows from the fact that $h_2$ represents Coulombic interaction, which depends only on the relative distance of the two interacting particles. In particular, the first term in the second double sum (third line of Eq. \ref{eqn:first_variation1}) may be rewritten:
\begin{eqnarray*}
	\bra{(\delta m)n}h_2\ket{nm} &=& \int d\vec{x}_1d\vec{x}_2 \ \delta\chi_m^*(\vec{x}_1)\chi_n^*(\vec{x}_2)h_2\chi_n(\vec{x}_1)\chi_m(\vec{x}_2)\\
															 &=& \int d\vec{x}_2d\vec{x}_1 \ \delta\chi_m^*(\vec{x}_2)\chi_n^*(\vec{x}_1)h_2\chi_n(\vec{x}_2)\chi_m(\vec{x}_1) = \bra{n(\delta m)}h_2\ket{mn}
\end{eqnarray*}
where, in the second line, we have essentially swapped the names of the ``dummy'' integration variables. Similarly, the second term of the second double sum can be shown to be $\bra{m(\delta n)}h_2\ket{nm} = \bra{(\delta n)m}h_2\ket{mn}$.

Making these substitutions, it can be shown that every term in Eq. \ref{eqn:first_variation1} occurs in complex conjugate pairs. For notational simplicity, we will show only the terms involving variations that are conjugated (i.e. a $\delta$ in the bra) and suppress their complex conjugates as ``c.c.''. With this convention, $\delta L$ can be expressed as
\begin{eqnarray*}
	\delta L &=& \sum_{m=1}^N \bra{\delta m}h_1\ket{m}\nonumber\\
					 &+& \frac{1}{2} \sum_{m=1}^{N} \sum_{n=1}^N \bra{(\delta m)n}h_2\ket{mn} + \bra{(\delta n)m}h_2\ket{nm}\nonumber\\
					 &-& \frac{1}{2} \sum_{m=1}^{N} \sum_{n=1}^N \bra{(\delta m)n}h_2\ket{nm} + \bra{(\delta n)m}h_2\ket{mn}\nonumber\\
					 &-& \sum_{m=1}^N \epsilon_m\braket{\delta m}{m} + c.c.
\end{eqnarray*}

Now note that the two-electron integral $\bra{(\delta a)b}h_2\ket{ab}$ involving any two single particle states $\ket{a}$ and $\ket{b}$ will be attained twice in the first double summation, namely, when $(m=a,n=b)$, and also when $(m=b,n=a)$. We can say the same for $\bra{(\delta a)b}h_2\ket{ba}$ in the second double sum. Therefore, we finally formulate $\delta L$ in a form suitable for use:
\begin{equation*}
	\delta L = \sum_{m=1}^N \bra{\delta m}h_1\ket{m} + \sum_{m=1}^{N} \sum_{n=1}^N \left\{\bra{(\delta m)n}h_2\ket{mn}-\bra{(\delta m)n}h_2\ket{nm}\right\} - \sum_{m=1}^N \epsilon_m\braket{\delta m}{m} + c.c.
\end{equation*}

Expressing the inner products in coordinate-space, and factoring out $\delta\chi_m^*(\vec{x}_1)$, which is common to all terms, yields:
% This is a hack for getting the equation to fit on the page without breaking up the lines
\begin{eqnarray}
	\scriptstyle\delta L &=& \scriptstyle\sum_{m=1}^N \int d\vec{x}_1 \delta\chi_m^*(\vec{x}_1) \nonumber\\ 
					 				&\times& \scriptstyle \left[h_1\chi_m(\vec{x}_1) + \sum_{n=1}^N \int d\vec{x}_2\chi_n^*(\vec{x}_2)h_2\chi_m(\vec{x}_1)\chi_n(\vec{x}_2) - \sum_{n=1}^N \int d\vec{x}_2 \chi_n^*(\vec{x}_2)h_2\chi_n(\vec{x}_1)\chi_m(\vec{x}_2) - \epsilon_m\chi_m(\vec{x}_1)\right] + c.c.\nonumber\\
	\scriptstyle\delta L &=& \scriptstyle\sum_{m=1}^N \int d\vec{x}_1 \nonumber\\
					 						&\times& \scriptstyle\delta\chi_m^*(\vec{x}_1) \left[h_1 + \sum_{n=1}^N \int d\vec{x}_2\frac{1}{r_{12}}|\chi_n(\vec{x}_2)|^2 - \sum_{n=1}^N \int d\vec{x}_2 \chi_n^*(\vec{x}_2)\frac{1}{r_{12}}P_2\chi_n(\vec{x}_2) - \epsilon_m\right]\chi_m(\vec{x_1}) + c.c.
	\label{eqn:first_variation2}
\end{eqnarray}
In the last line, we have substituted in $h_2 = r_{12}^{-1}$, and again used the operator $P_2$ that performs transposition of electrons 1 and 2, i.e. $P_2\chi_n(\vec{x}_2)\chi_m(\vec{x}_1) = \chi_n(\vec{x}_1)\chi_m(\vec{x}_2)$. As is the usual in the calculus of variations, we then argue that since $\delta\chi_m^*$ is arbitrary, the stationary condition $\delta L = 0$ is obtained when each of the multiplicative factors in Eq. \ref{eqn:first_variation2} are zero. In other words, the minimization condition is equivalent to:
\begin{eqnarray}
	\label{eqn:hf_iter_eqn}
	f(\vec{x}_1) \chi_m(\vec{x_1}) &=& \epsilon_m \chi_m(\vec{x}_1)\\
	f(\vec{x}_1) &=& h_1 + \sum_{n=1}^N \int d\vec{x}_2\frac{1}{r_{12}}|\chi_n(\vec{x}_2)|^2 - \sum_{n=1}^N \int d\vec{x}_2 \chi_n^*(\vec{x}_2)\frac{1}{r_{12}}P_2\chi_n(\vec{x}_2)\nonumber
\end{eqnarray}
which holds for $m = 1, 2, \ldots, N$. These equations, having the form of a single-particle Schr\"odinger equation, are the \emph{Hartree-Fock equations} that characterize the optimal single-particle states to be used in the Slater determinant. Given the structure of Eq. \ref{eqn:hf_iter_eqn}, we can also conclude that the corresponding Lagrange multipliers have the important physical interpretation as the single-particle energies. The operator $f(\vec{x}_1)$ is called the \emph{Fock operator}, and the orthogonality of its eigenfunctions is proved in Ref 2. Unfortunately, the Fock operator couples the $N$ equations, and makes Eq. \ref{eqn:hf_iter_eqn} a nonlinear SE; hence the need for iterative methods. We now note that the conjugate terms we have suppressed in $\delta L$ do not give independent constraints. Instead, they merely produce conjugated forms of Eq. \ref{eqn:hf_iter_eqn}.

It is reassuring to find the electronic repulsion term $\sum_{n=1}^N \int d\vec{x}_2\frac{1}{r_{12}}|\chi_n(\vec{x}_2)|^2$ in the HF equations, which agrees with the intuition embodied in the original Hartree iteration. However, the additional \emph{exchange term} $\sum_{n=1}^N \int d\vec{x}_2 \chi_n^*(\vec{x}_2)\frac{1}{r_{12}}P_2\chi_n(\vec{x}_2)$ originates from antisymmetrization of the trial wavefunction, and has no direct classical interpretation. A discussion of the exchange force can be found in Griffiths Ch. 5, in the context of a non-interacting two-electron system.

Thus ends our derivation of the Hartree-Fock equations from the variational principle. We have reduced the $N$-electron Hamiltonian into $N$ coupled single-particle problems that are then typically solved by fixed point iteration, as shown in the introduction.

\section{Computer implementation of HF}

It is apparent that the Hartree-Fock equations are more complicated than their counterparts in the Hartree procedure. Therefore, this section is devoted to simplifying and converting Eq. \ref{eqn:hf_iter_eqn} into a form suitable for practical implementation. Our mathematical method is to introduce a set of \emph{basis functions} that span the space of physically relevant wavefunctions. It is an explicit, numerical embodiment of the type of linear algebra we have encountered so far in QM. 

\subsection{Integration over the spin coordinate}

The first concession we make in exchange for simplification is to specialize in systems for which the number of electrons $N$ is even.

Recall that to form the many-particle ground state, we seek the $N$ lowest-energy single-particle eigenfunctions of the Hartree-Fock equation (Eq. \ref{eqn:hf_iter_eqn}). When $N$ is even, the Fock operator does not depend on electron spin, as will be shown below. It then follows that we can focus on the $\frac{N}{2}$ lowest-energy spatial states $\left\{\psi_n\:|\:n=1,2,\ldots,N/2\right\}$, and then doubly occupy each with electrons of opposite spin. In other words, we let:
\begin{equation}
	\chi_m = \psi_{n(m)}\otimes\ket{w(m)}\ \ \ \ \ m = 1, 2, \ldots, N
	\label{eqn:state_assignment}
\end{equation}
where $n(m) = \left\{ \begin{array}{l l} m/2 & \mbox{if $m$ is even}\\ (m+1)/2 & \mbox{if $m$ is odd}\end{array}\right.$. The spin variable is $w(m)=\pm\frac{1}{2}$, also depending on whether $m$ is even or odd.

Applying the Fock-operator (Eq. \ref{eqn:hf_iter_eqn}) to the single-particle state of Eq. \ref{eqn:state_assignment} yields:
\begin{eqnarray*}
	 f(\vec{x}_1)\chi_m(\vec{x}_1) &=& f(\vec{x}_1) \left[\psi_{n(m)}(\vec{r}_1)\ket{w_1(m)}\right]\\
	 															 &=& (h_1\psi_{n(m)}(\vec{r}_1))\ket{w_1(m)}\\
	 															 &+& \left\{\sum_{l=1}^N \int d\vec{r}_2 dw_2 \frac{1}{r_{12}} \left| \psi_{n(l)}^*(\vec{r}_2)\ket{w_2(l)}\right|^2 \cdot \psi_{n(m)}(\vec{r}_1) \right\} \ket{w_1(m)}\\
	 															 &-& \sum_{l=1}^N \int d\vec{r}_2 dw_2 \frac{1}{r_{12}}\left\{\psi_{n(l)}^*(\vec{r}_2) \bra{w_2(l)}\right\} P_2 \left\{\psi_{n(l)}(\vec{r}_2) \ket{w_2(l)}\right\}\left\{\psi_{n(m)}(\vec{r}_1)\ket{w_1(m)}\right\}
\end{eqnarray*}
In the second term, the inner product over the spin variable $w_2$ normalizes to unity. We analyze the last term more carefully, where the transposition operator $P_2$ swaps electron indices 1 and 2 to yield:
\begin{equation*}
	P_2\left\{\psi_{n(l)}(\vec{r}_2) \ket{w_2(l)}\right\}\left\{\psi_{n(m)}(\vec{r}_1)\ket{w_1(m)}\right\} =
		 \left\{\psi_{n(l)}(\vec{r}_1) \ket{w_1(l)}\right\}\left\{\psi_{n(m)}(\vec{r}_2)\ket{w_2(m)}\right\}
\end{equation*}
Since this last result is combined with $\psi_{n(l)}^*(\vec{r}_2) \otimes \bra{w_2(l)}$, the terms in the last summation are nonzero only when the the spins $\ket{w_2(l)}$ and $\ket{w_1(m)}$ align. With $N$ even and occupation as in Eq. \ref{eqn:state_assignment}, there are $\frac{N}{2}$ terms that meet this constraint for either $w_1(m) = \pm\frac{1}{2}$. Evidently, the Fock operator $f(\vec{x}_1)$ does not affect nor depend on the spin of $\chi_m(\vec{x}_1)$, so that we can write:
\begin{eqnarray}
	f(\vec{x}_1) &=& f(\vec{r}_1) \otimes \boldsymbol 1\\
	f(\vec{r}_1) &=& h_1 + \sum_{n=1}^{N/2}\left\{ 2 \int d\vec{r}_2 \frac{1}{r_{12}} \left|\psi_n(\vec{r}_2)\right|^2 - \int d\vec{r}_2 \frac{1}{r_{12}} \psi_n^*(\vec{r}_2) P_2 \psi_n(\vec{r}_2) \right\}
	\label{eqn:fock_operator}
\end{eqnarray}
where $f(\vec{r}_1)$ is the spatial Fock operator, and $\boldsymbol 1$ is the identity operator in the spin space. The transposition operator $P_2$ is understood in this context to swap the spatial coordinates. As indicated earlier, we have now proven that the full Fock operator is independent of spin in the case when $N$ is even. Our task is then to obtain the $\frac{N}{2}$ lowest-energy single-particle eigenstates of the spatial Hartree-Fock equation:
\begin{equation}
	f(\vec{r}_1) \psi_n(\vec{r}_1) = \epsilon_n \psi_n(\vec{r}_1)
	\label{eqn:spatial_hf}
\end{equation}

\subsection{Introduction of a basis}

In the introduction we remarked on the difficulty of solving the HF equations in coordinate space. The major advancement came in 1951 when C.C.J. Roothaan demonstrated that, by introducing a set of known spatial \emph{basis functions}, the differential Hartree-Fock equations could be reformulated as an algebraic equation to be solved by standard matrix techniques.

Suppose that $\left\{\phi_\mu\right\}$ represents a set of basis functions for the space of square integrable functions. In practice, we must choose some $K$-element subset of this basis for a computer implementation. We can then approximate the $i$-th spatial wavefunction by a linear combination
\begin{equation*}
	\psi_i = \sum_{\mu=1}^K C_{\mu i}\phi_\mu\ \ \ \ \ i = 1,2,\ldots,(K\geq\frac{N}{2})
\end{equation*}
The above expression would be exact if the truncated basis set $\left\{\phi_\mu\:|\:\mu=1,2,\ldots,K\right\}$ were in fact complete.\footnote{In order to obtain square matrices, we will seek $K\geq N/2$ spatial orbitals. As long as we have at least $N/2$ states, we're fine. We're not required by law to actually use every solution that we find.} However, in practice, the basis functions typically have no claim on rigorous completeness. In fact, in the calculations on HeH$^{+}$, I use a set of just two functions! The justification for such an audacious move is that typical applications do not demand mathematical completeness. Rather, the more relevant requirement is that our wavefunctions be expressible in the chosen basis. Therefore, by choosing functions that are appropriate for the particular physics, one gets away with deficient basis sets. In the current problem, the physically motivated basis set involves the atomic wavefunctions centered at each of the nuclei. 

Finally, we also note that the choice of a particular basis set does not affect the general theory that follows. In fact, in most implementations, the choice of basis set is configurable at the beginning of each simulation. (Not in my application, however!)

\subsection{Roothaan Equation}

To obtain the HF equations in matrix form, consider again the spatial Hartree-Fock equation (Eq. \ref{eqn:spatial_hf}). Begin by expanding $\psi_m(\vec{r}_1)$ in the chosen basis,
\begin{equation}
	f(\vec{r}_1)\sum_{\nu}C_{\nu m}\phi_\nu(\vec{r}_1) = \epsilon_m \sum_{\nu}C_{\nu m}\phi_\nu(\vec{r}_1)
	\label{eqn:expand_in_basis}
\end{equation}
We then multiply by $\phi_\mu^*(\vec{r}_1)$ on the left and integrate, to obtain:
\begin{equation}
	\sum_{\nu}\left\{\int d\vec{r}_1 \phi_\mu^*(\vec{r}_1) f(\vec{r}_1) \phi_\nu(\vec{r}_1)\right\} C_{\nu m} = \epsilon_m \sum_{\nu} \left\{\int d\vec{r}_1 \phi_\mu^*(\vec{r}_1)\phi_\nu(\vec{r}_1)\right\} C_{\nu m}
	\label{eqn:mult_by_phi_conj}
\end{equation}

This motivates the definition of two matrices.  The first is the \emph{Fock matrix} $F_{\mu\nu} = \int d\vec{r}_1 \phi_\mu^*(\vec{r}_1)f(\vec{r}_1)\phi_\nu(\vec{r}_1)$. The second is the \emph{overlap matrix} $S_{\mu\nu} = \int d\vec{r}_1 \phi_\mu^*(\vec{r}_1)\phi_\nu(\vec{r}_1)$. With these definitions Eq. \ref{eqn:mult_by_phi_conj} becomes,
\begin{equation}
	\sum_{\nu}F_{\mu\nu}C_{\nu m} = \epsilon_m \sum_{\nu} S_{\mu\nu}C_{\nu m}
\end{equation}

This result may more succinctly written as a single matrix equation, known as the \emph{Roothaan equation}:
\begin{equation}
	\boldsymbol F \boldsymbol C = \boldsymbol S \boldsymbol C \boldsymbol \epsilon
	\label{eqn:roothaan_eqn}
\end{equation}
Here, the matrix $\boldsymbol \epsilon$ is diagonal and contains the single-particle energy $\epsilon_m$ as the $m$-th element. Furthermore, $\boldsymbol C$ is the $K \times K$ \emph{coefficient matrix} whose $n$-th column denotes the expansion coefficients of $\psi_n$ in the basis set $\left\{\phi_\mu\right\}$. Hence, solving for the optimal single-particle states in the Hartree-Fock approximation is equivalent solving for the coefficient matrix $\boldsymbol C$ that solves the Roothaan equation!

\subsubsection{Structure of the Fock matrix}

The Roothaan equation is an eigenvalue problem for the columns of $\boldsymbol C$ and their corresponding eigenvalues in $\boldsymbol \epsilon$. With the basis set chosen, $\boldsymbol S$ is determined (Eq. \ref{eqn:mult_by_phi_conj}), so that the only remaining component in Eq. \ref{eqn:roothaan_eqn} is the Fock matrix, which we now calculate in terms of the chosen basis. From the definition of the Fock matrix (Eq. \ref{eqn:mult_by_phi_conj}) and $f(\vec{r}_1)$ (Eq. \ref{eqn:fock_operator}), we have:
\begin{eqnarray*}
	F_{\mu\nu} &=& \int d\vec{r}_1 \phi_\mu^*(\vec{r}_1)h_1\phi_\nu(\vec{r}_1)\\
						 &+&\sum_{n=1}^{N/2}\int d\vec{r}_1 \phi_\mu^*(\vec{r}_1)\left[\int d\vec{r}_2\frac{1}{r_{12}}|\psi_n(\vec{r}_2)|^2 - \int d\vec{r}_2 \psi_n^*(\vec{r}_2)\frac{1}{r_{12}}P_2\psi_n(\vec{r}_2)\right]\phi_\nu(\vec{r}_1)
\end{eqnarray*}
Using the following expansions: $\psi_n(\vec{r}_2) = \sum_\lambda C_{\lambda n} \phi_\lambda(\vec{r}_2)$, and $\psi_n^*(\vec{r}_2) = \sum_\sigma C_{\sigma n}^* \phi_\sigma^*(\vec{r}_2)$, the last term may be written as (after also exchanging the order of sums):
\begin{equation}
	\sum_{\lambda\sigma}\sum_{n=1}^{N/2} C_{\lambda n} C_{\sigma n}^* \left\{ 2 \int d\vec{r}_1 d\vec{r}_2 \phi_\mu^*(\vec{r}_1) \phi_\sigma^*(\vec{r}_2) \frac{1}{r_{12}} \phi_\nu(\vec{r}_1) \phi_\lambda(\vec{r}_2) - \int d\vec{r}_1 d\vec{r}_2 \phi_\mu^*(\vec{r}_1) \phi_\sigma^*(\vec{r}_2) \frac{1}{r_{12}} \phi_\lambda(\vec{r}_1) \phi_\nu(\vec{r}_2) \right\}
\end{equation}
For sanity, we shall define $P_{\lambda\sigma} = 2 \sum_{n=1}^{N/2} C_{\lambda n}C_{\sigma n}^*$ (sometimes called the \emph{density matrix}) and adopt a new ``bracket-like'' notation for the basis function integrals:
\begin{equation}
	(\mu\sigma|r_{12}^{-1}|\nu\lambda) = \int d\vec{r}_1 d\vec{r}_2 \phi_\mu^*(\vec{r}_1) \phi_\sigma^*(\vec{r}_2) \frac{1}{r_{12}} \phi_\nu(\vec{r}_1) \phi_\lambda(\vec{r}_2)\\
\end{equation}
then $F_{\mu\nu}$ takes the tolerable form:
\begin{equation}
	F_{\mu\nu} = H_{\mu\nu}^{core} + \sum_{\lambda\sigma} P_{\lambda\sigma} \left\{(\mu\sigma|r_{12}^{-1}|\nu\lambda) - \frac{1}{2}(\mu\sigma|r_{12}^{-1}|\lambda\nu)\right\}
\end{equation}
where the sums on $\lambda$ and $\sigma$ are over all of the basis functions. In the above, we have also defined the core-Hamiltonian matrix $H_{\mu\nu}^{core}$ which has its own internal structure:
\begin{eqnarray}
	H_{\mu\nu}^{core} &=& \int d\vec{r}_1 \phi_\mu^*(\vec{r}_1)h_1\phi_\nu(\vec{r}_1) = \int d\vec{r}_1 \phi_\mu^*(\vec{r}_1) \left\{ -\frac{1}{2}\nabla_1^2-\sum_{A=1}^M \frac{Z_A}{r_{1A}} \right\} \phi_\nu(\vec{r}_1)\nonumber\\
										&=& \int d\vec{r}_1 \phi_\mu^*(\vec{r}_1) \left\{ -\frac{1}{2}\nabla_1^2\right\} \phi_\nu(\vec{r}_1) + \int d\vec{r}_1 \phi_\mu^*(\vec{r}_1) \left\{-\sum_{A=1}^M \frac{Z_A}{r_{1A}} \right\} \phi_\nu(\vec{r}_1)\nonumber\\
										&=& T_{\mu\nu} + V_{\mu\nu}^{nucl}
\end{eqnarray}
Finally, we have defined the \emph{kinetic energy} $\boldsymbol T$ and the \emph{nuclear potential} $\boldsymbol V^{nucl}$ matrices that comprise $\boldsymbol H^{core}$. Given the bewildering number of new quantities we have named in this section, we will revisit the procedure for constructing the Fock matrix in Section 4.4 with the help of a flowchart.

\subsubsection{Solving the Roothaan equation}
In exploring the structure of the Fock matrix, it was shown that $\boldsymbol F$ depends on the coefficient matrix (through $\boldsymbol P$). It then follows that the Roothaan equation is nonlinear, and cannot be directly solved by standard linear techniques. 

Instead, we use an iterative approach in which we first compute $\boldsymbol F^{(i-1)}$ based on the previous set of coefficients $\boldsymbol C^{(i-1)}$ (or by an initial guess). The Fock matrix thus generated is then considered to be fixed, which allows us to solve for the next set of coefficients $\boldsymbol C^{(i)}$ via the Roothaan equation, which may now be notated as:
\begin{equation}
	\boldsymbol F^{(i-1)} \boldsymbol C^{(i)} = \boldsymbol S \boldsymbol C^{(i)} \boldsymbol \epsilon
	\label{eqn:roothaan_indexed}
\end{equation}
As in the introduction, such iteration is tantamount to holding the wavefunctions of the other electrons ($j\neq i$) fixed as we generate the new wavefunction for the $i$-th electron. The limit of the sequence of matrices $\boldsymbol C^{(i)} \rightarrow \boldsymbol C$ is then taken to be the solution of the Roothaan equations. The columns of the coefficient matrix can then be used to express the single-particle wavefunctions (in the chosen basis) of the Slater-determinant, thus completing our implementation.

There are several matrix techniques for solving Eq. \ref{eqn:roothaan_indexed}, which differs from standard eigenvalue equations by the presence of the overlap matrix. In my implementation, I utilize one possibility called symmetric orthogonalization.

\subsection{Summary of the algorithm}

We summarize in a flowchart the steps involved in a Hartree-Fock program.

\begin{figure}[ht]
	\begin{center}
		\includegraphics[scale=0.45]{flowchart.png}
	\end{center}
	\caption{\label{fig:flowchart}Flowchart for the Hartree-Fock algorithm}
\end{figure}

\section{Calculations on HeH$^+$}

To illustrate the variety of physical information one may obtain from a HF solver, we now present few of the results from a calculation on helium hydride. In this section, we will keep the implementation details to a minimum, referring the interested reader to the appendix (i.e. to the program itself) and to Ref 1.

The Hartree-Fock algorithm produces, for any set of nuclear coordinates $\left\{\vec{R}_A\right\}$, the optimal single-determinant electronic configuration. From this we can calculate the corresponding expected energy $\left\langle H_{elec}(\vec{R}_A)\right\rangle$.\footnote{Although related, the overall energy $\left\langle H_{elec}(\vec{R}_A)\right\rangle$ is not simply the sum of the single-particle energies we have obtained through the Fock operator. See Ref 1: pg. 125, 176.} Since the time scale of electronic motion far exceeds that of nuclear motion, we argue (as did Born and Oppenheimer) that the electronic system is always optimized for any instantaneous configuration of the nuclei. In such a case, the effective potential for nuclear motion is the sum of nuclear-nuclear repulsion and the average electronic energy $\left\langle H_{elec}(\vec{R}_A)\right\rangle$.

For the HeH$^+$ ion, the effective nuclear potential can be parameterized by the interatomic distance $R$. The result is plotted below:
\begin{figure}[ht]
	\begin{center}
		\includegraphics[scale=0.45]{nuclear_well.png}
	\end{center}
	\caption{\label{fig:nucl_eff_V}Effective potential for nuclear motion: $V_{eff}(R) = \frac{2}{R} + \left\langle H_{elec}(R)\right\rangle$}
\end{figure}

The validity of this numerical potential can be assessed by examining the limiting behavior as $R \rightarrow \infty$. This extreme case represents a hydrogen atom and a helium ion in complete separation. The corresponding theoretical total energy is $E_{\infty}^{Theory} = -13.6 eV + 4 \times -13.6 eV = -68 eV$. On the other hand, recalling the scale factors from the introduction, the HF solution yields $E_{\infty}^{HF} = \epsilon_a \times -2.7090 = -73.7 eV$. This is not a poor result, given that our basis set consisted of only two functions! 

With this calibration, Figure \ref{fig:nucl_eff_V} shows that there exists a stable equilibrium bond length of $R_{eq} = a_0 \times 1.8 = 0.92$ angstroms. Furthermore, by computing the curvature of the well, we deduce the (angular) vibrational frequency to be $5.1 \times 10^{14}$ Hz, which puts us in the infrared region, appropriate for a vibrational mode. Lastly, because the HF solution contains full three-dimensional information for the many-electron system, there is an opportunity for some wonderful visualizations: 
\begin{figure}[ht]
	\begin{center}
		\includegraphics[scale=0.4]{psisq_visual.png}
	\end{center}
	\caption{\label{fig:psisq_visual}Two visualizations of the electron spatial density. Helium is located at the \hspace*{18.5 mm}origin, and hydrogen is at $\left[1.8, 0, 0\right]$}
\end{figure}

In Figure \ref{fig:psisq_visual} are two representations for the electron density. (More precisely, $|\psi|^2$ of the lowest-energy spatial state.) The isosurface plot (left) clearly indicates the formation of a \emph{chemical bond} between the two nuclei. The density plot (right) corroborates our intuition that the electron is more likely to be found near the helium nucleus, where the nuclear charge is greater. In summary, with just pen and paper (and silicon!), we have fully specified the electronic structure of helium hydride! 

\section{Conclusion}

In this paper, we have given a basic, but complete account of Hartree-Fock theory and implementation. From the variational principle, we derived the Hartree-Fock equations that identify the single-particle states comprising the optimal Slater-determinant wavefunction. Then, by introducing a set of basis functions, we converted the resulting differential equations into matrix form, which can be solved efficiently on a computer.

Finally, we briefly showcased some of the physical information one can derive using a HF solver. My hope is that an interest has been piqued (perhaps there is now some desire to build an HF program to perform calculations on one's favorite molecule?); and if so, that the discussion presented here was sufficient for actual implementation.

In closing, I would like to thank my peer reviewer \colorbox{black}{Connor McEntee} and my graduate tutor \colorbox{black}{David Guarrera} for their careful reading of this rather long paper. Even beyond their suggestions for improving this work, I enjoyed discussing physics with them. In addition, I would also like to thank Prof. \colorbox{black}{Mookie Baik} of Indiana University, who was reckless enough to expose the ideas of quantum chemistry to a high-school junior, who then wondered about them for the next four years!

\begin{thebibliography}{9}
			
				\bibitem{szabo}
				Szabo and Ostlund.
				\emph{Modern Quantum Chemistry.}
				(New York: McGraw-Hill, Inc, 1989)
				
				\bibitem{bethe}
				Bethe and Jackiw.
				\emph{Intermediate Quantum Mechanics.} 
				(California: Benjamin/Cummings Publishing Company, 1986)
				
				\bibitem{griffiths}
				Griffiths, David.
				\emph{Introduction to Quantum Mechanics.}
				(New York: Prentice Hall, 2005)
				
\end{thebibliography}

\newpage
\appendix
\section{How to access the paper's programs}

All of the numerical computations in this paper were conducted in Matlab, and all scripts can be found at:
\begin{quote}
	\begin{verbatim}
		LINK REMOVED
	\end{verbatim}
\end{quote}
There, one finds the following subdirectories:

\begin{enumerate}
	\item ``first/'': This section contains the scripts responsible for the results presented in Section 5. The two-element basis set used for the calculation is called ``minimal STO-3G'', where each basis function is a linear combination of three Gaussian functions. Several decades of work by quantum chemists and applied mathematicians have gone into developing sophisticated and efficient mathematical routines involving Gaussian functions. (In particular, for calculating Eq. 26).
	\item ``hartree\_iteration/'': These are the programs used for conducting the first two iterations of the Hartree method (Section 1.1). There is an app to compute Eq. 2, and also to produce Figure 2 of the paper.
	\item ``scrap/'': In the paper, I did not discuss the sophisticated routines involving Gaussian functions. Hence, I attempted to implement a simpler HF solver with straightforward ``brute force'' methods for computing the necessary matrices. To my surprise, I found that it took over three minutes to compute (to terrible accuracy) a single basis function integral (Eq. 26). Since we need to perform hundreds of such integrations for a single HF run, this implementation is totally impractical, and was eventually ``scrapped''.
	\item ``second/'': Over the course of this paper, it was realized that the helium hydride ion produces identical results for the Hartree-Fock method and the Hartree iteration. (This follows because the exchange term of HF is always zero for $N=2$.) Hence, I worked on a four-electron system: namely, two-interacting hydrogen molecules. However, I have not yet established the correctness of the numerical results, so they were never incorporated into the paper.
\end{enumerate}
Finally, to produce Figure \ref{fig:psisq_visual}, I utilized the impressive ``Volume Browser'' program written by Eike Rietsch, obtained from the MATLAB Central File Exchange:
\begin{verbatim}
	http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=13526
\end{verbatim}
\end{document}