# Kohn-Sham method
Now we introduce the Kohn-Sham method.
Instead of directly doing calculation under the assumption that all particle are *independent*, Kohn-Sham method first adopts the assumption to calculate the energy, then adds an additional term for energy, called exchange-correlation functional $E_{\text{xc}}$, trying to remedy the error due to the assumption. Therefore, the exchange-correlation functional express all that is missing when we consider the particles are independent.
Kohn-Sham method belongs to one of the method in density functional theory.
The idea of the density functional theory, abbreviated in DFT, is to replace the minimization problem in the previous section, defined in terms of the unknown wavefunction $\psi$, with a minimization problem in terms of the unknown density $n$.
The minimization problem in the Kohn-Sham method, if we fully expand the Hamiltonian, is defined as
$$
\begin{align}
&\min_{\psi_i} \frac{1}{2}\sum_{i=1}^{N} \int \left | \nabla \psi_i \right |^2+ \int n V_{\text{ext}} + \frac12 \int \int \frac{n(x)n(y)}{|x - y|} + E_{\text{xc}}(n)\\
&s.t. \langle \psi_i | \psi_j \rangle = \delta_{ij}\\
\end{align}
$$
Here, the density $n$ is calculated from the wavefunction as follows:
$$n(\boldsymbol{r}) = \sum_{i=1}^{N} \big\vert{\psi_i(\boldsymbol{r} )}\big\vert^2,$$
in which $N$ is the total number of electrons.
Theorectically, the $E_{\text{xc}}$ term should make the Kohn-Sham method be an exact method. However, no one knows the analytical form of it. Along the years, many efforts have been proposed to approximate this term either by theorectically deduction or by fitting experimental data. This yields a large family of exchange-correlation functionals. These functionals are implemented in a library [libxc](https://gitlab.com/libxc/libxc/) for downstream calculation.
For the research of DFT in the context of deep learning, we also provide a library [jax-xc](https://github.com/sail-sg/jax_xc) to translate the C code of libxc into Jax code in python to enable end-to-end-differentiability, high-order derivative, and further boost the performance on various types of device (CPUs, GPUs, TPUs) thanks to the powerful features of Jax such as just-in-time compilation.
You may notice that, not all terms are solely determined by the density $n$: the kinetics part still consists of $\nabla \psi_i$. Therefore, computing from $\psi_i$ is still essential. Expressing the kinetics part using the density $n$ is still an open question.