where $c_i^\dagger$ and $c_i$ are creation and annihilation operators respectively for fermion in state $i$.
The first term $\hat{H}_0$ is the non-interacting Hamiltonian which by itself is straightforward to solve in a single-particle basis by direct diagonalizations made easy through packages such as `kwant`.
The first term $\hat{H^0}$ is the non-interacting Hamiltonian which by itself is straightforward to solve in a single-particle basis by direct diagonalizations made easy through packages such as `kwant`.
The second term $\hat{V}$ is density-density interaction term between two particles, for example Coulomb interaction.
In order to solve the interacting problem exactly, one needs to diagonalize the full Hamiltonian $\hat{H}$ in the many-particle basis which grows exponentially with the number of particles.
Such a task is often infeasible for large systems and one needs to resort to approximations.
## Mean-field Hamiltonian
### Mean-field approximaton
The first-order perturbative approximation to the interacting Hamiltonian is the Hartree-Fock approximation also known as the mean-field approximation.
The mean-field approximates the quartic term $\hat{V}$ in {eq}`hamiltonian` as a sum of bilinear terms weighted by the expectation values the remaining operators:
we neglect the superconducting pairing and constant offset terms.
The expectation value terms $\langle c_i^\dagger c_j \rangle$ are due to the ground-state density matrix:
$$
\rho_{ij} \equiv \langle c_i^\dagger c_j \rangle,
$$
and therefore act as an effective field acting on the system.
The expectation value terms $\langle c_i^\dagger c_j \rangle$ are due to the ground-state density matrix and therefore act as an effective field acting on the system.
where $\delta_{nm}$ is the Kronecker delta function.
### Infinite tight-binding grid
In the limit of a translationally invariant system, the index $n$ that labels the basis states partitions into two independent variables: the unit cell internal degrees of freedom (spin, orbital, sublattice, etc.) and the position of the unit cell $R_n$:
$$
V^\text{MF}_{nm} = \langle n | \hat{V}^{\text{MF}} | m \rangle = \sum_{i} \rho_{ii} v_{in} \delta_{nm} - \rho_{mn} v_{mn},
n \to n, R_n.
$$
where $\delta_{nm}$ is the Kronecker delta function.
Because of the translationaly invariance, the physical properties of the system are independent of the absolute unit cell position $R_n$ and rather depend on the relative position between the two unit cells $R_{nm} = R_n - R_m$:
$$
\rho_{mn} \to \rho_{mn}(R_{mn}).
$$
That allows us to re-write the mean-field interaction in {eq}`mf_finite` as:
where now indices $i, n, m$ label the internal degrees of freedom of the unit cell and $R$ is the relative position between the two unit cells in terms of the lattice vectors.
## Numerical solution of the mean-field Hamiltonian
In order to calculate the mean-field interaction in {eq}`mf_infinite`, we require the ground-state density matrix $\rho_{mn}(R)$.
However, the density matrix in {eq}`density` is a functional of the mean-field interaction $\hat{V}^{\text{MF}}$ itself.