# PySCF: 2-index and 3-index matrix

The 4-index 2-electron integral can be obtained for the He atom with the following code:

import numpy as np
from pyscf import gto, scf, ao2mo

mol = gto.Mole()
mol.atom = """
He    0.    0.    0.
"""
mol.basis = "cc-pvdz"
mol.build()

# Run Hartree-Fock.
mf = scf.RHF(mol)
mf.kernel()

# Find electron-repulsion integrals (eri).
eri = ao2mo.kernel(mol, mf.mo_coeff)
eri = np.asarray(ao2mo.restore(1, eri, mol.nao))


I am interested in obtaining the 2-index (A) and 3-index (CIAB) matrices, which can be used to form the 4-index 2-electron (eri) integral. I have looked at the list of possible means by which this is accomplished in PySCF code; however, I am unsure of the correct answer.

• +1. "I have looked at the list of possible means by which this is accomplished in PySCF code" -- What are the possible means? – Nike Dattani Oct 2 '20 at 18:04

## 1 Answer

In the density fitting / resolution-of-the-identity (RI) formalism, a two-electron integral $$(ij|kl)$$ in the atomic-orbital basis is approximated as $$(ij|kl) \approx \sum_{PQ} (ij|P) (P|Q)^{-1} (Q|kl)$$ where $$P$$ and $$Q$$ are auxiliary functions, and $$(P|Q)^{-1}$$ is the inverse Coulomb overlap matrix.

The RI expression can be written in a form that resembles the Cholesky expression $$(ij|kl) = \sum_P L_{ij}^P L_{kl}^P$$ by introducing the "B matrix" $$B_{ij}^Q = \sum_P (ij|P) (P|Q)^{-1/2}$$. With the B-matrix, you get the integral as $$(ij|kl) \approx \sum_Q B_{ij}^Q B_{kl}^Q$$. Using this form is convenient since you can use the same implementations for both Cholesky and RI.

The density fitting code in PySCF is documentated: https://sunqm.github.io/pyscf/df.html

The pyscf.df.incore.cholesky_eri function returns 2D array of (naux,nao*(nao+1)/2) in C-contiguous. This is the $$B$$ matrix.