mfsig.com
density-fittingresolution-of-identityauxiliary-basis5 min read

Density fitting in DFT, speed without changing the chemistry

Density fitting replaces four-centre repulsion integrals with three-centre ones via an auxiliary basis. It cuts cost sharply with a small, controlled error.

Updated November 28, 2026

Density fitting is a numerical technique that makes the electron-repulsion part of a DFT calculation much cheaper without changing the physics being described. It expands products of orbitals in an auxiliary basis, so that the four-centre integrals that dominate the cost are replaced by three-centre ones. The approximation introduces a small, systematic error that is far below the basis-set error, provided the auxiliary basis is matched to the orbital basis. For a σ-profile the effect is negligible against the bin width, which is why a production recipe can use it and still be called the same chemistry.

Where the cost of a DFT calculation comes from

Every self-consistent field iteration needs the Coulomb matrix J, which describes the classical repulsion between electrons, and, for a hybrid functional, the exchange matrix K. Both are built from electron-repulsion integrals over four basis functions at a time. With N basis functions there are of the order of N to the fourth such integrals. For paracetamol in def2-SVP, with 199 functions, that is over a billion before symmetry is used.

The integrals themselves are not the only problem. Storing them is often impossible, so they are recomputed every iteration. Contracting them with the density to form J and K is the step that dominates the wall time of a conventional hybrid DFT run.

What the auxiliary basis does

The product of two orbital basis functions is itself a function of space, roughly centred between the two atoms. Density fitting approximates every such product as a linear combination of functions from a second, auxiliary basis. The auxiliary set is also atom-centred and contains higher angular momenta than the orbital set, because products of two p functions contain d character.

Once the products are expanded, a four-centre integral becomes a sum over auxiliary functions of three-centre integrals multiplied by the inverse of a two-centre metric. The number of three-centre integrals scales as N squared times the size of the auxiliary basis, and the auxiliary basis is only a few times larger than N. The formal scaling drops by a power, and the constant in front drops as well.

For J alone the fit is forgiving. A J-fit auxiliary basis is modest and the error in the Coulomb energy is small. For K the situation is harder, because exchange couples pairs of orbitals rather than the total density. JK-fit auxiliary sets, developed by Weigend for exactly this purpose, are larger and are matched to a specific orbital basis. def2-svp-jkfit is the set matched to def2-SVP. Using an unmatched auxiliary set is a common mistake that produces larger and less systematic errors.

How big the error is, and why it does not matter here

The density-fitting error in the total energy is small and, more importantly, systematic. It depends on the elements present and on the auxiliary set, not much on the molecular environment. In a comparison between two molecules, or between two conformers of one molecule, most of it cancels.

For a σ-profile the relevant quantity is the electrostatic potential at the cavity surface, which comes from the converged density. Density fitting perturbs the density through its effect on the Fock matrix, and that perturbation is of the same order as the energy error. In practice the screening charges computed with and without fitting differ by far less than the width of a histogram bin. The guide on how σ-profiles are binned shows what a typical bin width is.

What does matter is consistency. A pipeline that fits in some runs and not in others, or that changes the auxiliary basis between runs, introduces an offset that nobody expects. That is why the auxiliary basis belongs in the recipe. MFsig pins def2-svp-jkfit alongside def2-SVP, for both J and K, and the full method block is on the recipes page and inside every .mfsig file.

Density fitting and the GPU

Density fitting is also what makes hybrid DFT practical on graphics processors. Three-centre integrals and the matrix contractions that follow map well onto hardware designed for dense linear algebra. The open-source gpu4pyscf project, which extends PySCF, is built around density-fitted J and K for exactly this reason. The guide on GPU-accelerated DFT for σ-profiles explains what changes when a calculation moves to a GPU and what does not.

Turning it on in PySCF

In PySCF the change from conventional integrals to density fitting is one method call, and the auxiliary basis can be named explicitly.

from pyscf import gto, dft

mol = gto.M(atom="N 0 0 0\nH 0 0 1.01\nH 0.95 0 -0.34\nH -0.48 0.83 -0.34",
            basis="def2-svp")

mf_exact = dft.RKS(mol, xc="wb97m-v").run()
mf_df = dft.RKS(mol, xc="wb97m-v").density_fit(auxbasis="def2-svp-jkfit").run()

print("difference in Eh:", mf_df.e_tot - mf_exact.e_tot)

The difference printed for ammonia is a small number that stays almost the same if the geometry is bent slightly, which is the signature of a systematic error. Run the same comparison for a molecule twice as large and the difference grows roughly in proportion to the number of atoms, not faster.

What density fitting is not

Density fitting is not a change of functional, basis set or solvation model. It does not alter the exchange-correlation energy, which is integrated on a separate numerical grid. It does not change the dielectric model or the cavity. It is an integral approximation, in the same category as the numerical integration grid for the functional, and it belongs in the recipe for the same reason. Two runs that differ only in whether they fit will agree to many decimal places in σ. Two runs that differ in the cavity radii will not. The guide on cavity radii, Bondi, Klamt and the scaling factor shows how much larger that effect is.

Key points

  • Density fitting expands orbital products in an auxiliary basis, turning four-centre integrals into cheaper three-centre ones.
  • The error is small and systematic, far below the basis-set error, when the auxiliary basis matches the orbital basis.
  • Fitting exchange needs a JK-fit auxiliary set. def2-svp-jkfit is the one matched to def2-SVP.
  • For a σ-profile the effect is well below the bin width, but the auxiliary basis must still be pinned in the recipe.
  • Density fitting is what makes hybrid DFT practical on GPUs.

Questions people ask

What is density fitting in quantum chemistry?
Density fitting, also called the resolution of the identity, expands products of two orbitals in an auxiliary basis of atom-centred functions. The four-centre electron-repulsion integrals become sums of three-centre and two-centre integrals, which are far cheaper to compute and store. The approximation is controlled by the quality of the auxiliary basis.
Does density fitting change the result of a DFT calculation?
Slightly and systematically. The fitted Coulomb and exchange energies differ from the exact ones by an amount much smaller than the basis-set error, and the difference is nearly constant for a given element and auxiliary basis. For a σ-profile the effect is well below the bin width when a matched auxiliary basis is used.
What is a JK-fit auxiliary basis?
An auxiliary basis designed to fit both the Coulomb (J) and the exact-exchange (K) matrices. Fitting exchange is harder than fitting Coulomb, so JK-fit sets are larger than J-only sets. def2-svp-jkfit is the auxiliary set matched to the def2-SVP orbital basis for hybrid functionals.

Further reading

In practice: The production recipe on mfsig.com (ωB97M-V, def2-SVP, C-PCM at ε = 80, modified Bondi radii scaled by 1.2) is published in full on the recipes page, so each choice discussed here can be checked against what actually runs.

Generate a σ-profile from your SMILES

Free converter for a profile you already have, a reference-grade DFT run with its provenance record when it has to be defensible.