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 second term $\hat{V}$ is the interaction term between two particles.
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 often needs to resort to approximations.
Such a task is often infeasible for large systems and one needs to resort to approximations.
## Mean-field approximation
## Mean-field Hamiltonian
In many interacting systems, there exist constant order parameters $\langle A \rangle$ that describe the phase of the system.
Here we define $\hat{A}$ as some operator and $\langle \rangle$ denotes the expectation value with respect to the ground state of the system.
Famous examples of such order parameter is the magnetization in a ferromagnet and the superconducting order parameter in a superconductor.
If we are interested in properties of the system close to the ground state, we can re-write the operator $\hat{A}$ around the order parameter:
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:
where operator $\delta \hat{A}$ describes the fluctuations around the order parameter.
Let us consider an additional operator $\hat{B}$ and say we are interested in the product of the two operators $\hat{A}\hat{B}$.
If we assume that the fluctuations $\delta$ are small, we can approximate the product of operators into a sum of single operators and the product of the expectation values:
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:
$$
\hat{A}\hat{B} \approx \langle A \rangle \hat{B} + \hat{A} \langle B \rangle - \langle A \rangle \langle B\rangle
\rho_{ij} \equiv \langle c_i^\dagger c_j\rangle,
$$
where we neglect $\delta^2$ terms.
This approximation is known as the mean-field approximation.
## Mean-field Hamiltonian
and therefore act as an effective field acting on the system.
We apply the mean-field approximation to the quartic interaction term in {eq}`hamiltonian`: