# Integral evaluation#

## Integral transformation#

Most correlated wavefunction theories rely on the integrals in the molecular orbital basis. For some methods, like Møller-Plesset second order perturbation theory, this step is even the most time-consuming step of the calculation.

Conventionally, this is done by transforming the atomic orbital integrals (a four-dimensional tensor) to molecular basis. For example the $$\langle ij|ab \rangle$$ integrals can be obtained via

$\begin{eqnarray*} \langle \mu \nu|\lambda b \rangle &= \sum_{\sigma} C_{\sigma b} \langle \mu \nu | \lambda \sigma \rangle \\ \langle \mu \nu|a b \rangle &= \sum_{\lambda} C_{\lambda a} \langle \mu \nu | \lambda b \rangle \\ \langle \mu j|a b \rangle &= \sum_{\nu} C_{\nu j} \langle \mu \nu | a b \rangle \\ \langle i j|a b \rangle &= \sum_{\mu} C_{\mu i} \langle \mu j | a b \rangle \end{eqnarray*}$

where $$\mu$$, $$\nu$$, $$\lambda$$ and $$\sigma$$ denote the atomic orbitals. The computational cost of this procedure is $$O(N^5)$$, since each summation involves five indices. Note that the intermediate result of the transformation needs to be explicitly stored in memory. This can be demanding as the required memory increases as $$O(N^4)$$ where $$N$$ is the number of contracted basis functions.

An alternative way of getting the molecular orbital integrals is through the direct formation of many Fock matrices. Taking the $$\langle ij|ab \rangle$$ integrals as an example, we can in practice build $$N_{occ} \times N_{occ}$$ density matrices using the coefficients of the occupied orbitals, and form the corresponding Fock matrices that can then be transformed into molecular basis by the coefficients of the virtual orbitals.

$\begin{eqnarray*} D^{ij}_{\mu \nu} &= C_{\mu i} C_{\nu j} \\ K^{ij}_{\lambda \sigma} &= \sum_{\mu\nu} \langle \mu \nu| \lambda \sigma \rangle D^{ij}_{\mu\nu} \\ \langle ij|ab \rangle &= \sum_{\lambda \sigma} C_{\lambda a} K^{ij}_{\lambda \sigma} C_{\sigma b} \end{eqnarray*}$

The computational cost of this approach is formally $$O(N^6)$$; however, in practice the cost scales between $$O(N^4)$$ and $$O(N^5)$$ due to screening of integrals in the formation of Fock matrices. An advantage of this approach is that the Fock matrices can be computed and stored on individual compute nodes, making it suitable for large-scale parallelization on HPC systems.