---
title: "Turning a molecule into a small matrix problem"
description: "Fix the nuclei, choose STO-3G functions and identify the overlap, one-electron and repulsion integrals that define the calculation."
canonical_url: "https://sandboxphysics.com/stories/molecular-electronic/basis-and-integrals/"
language: "en"
page_type: "story"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/stories/molecular-electronic/basis-and-integrals/"
last_modified: "2026-10-28"
---

[Molecular electrons and the breaking of a bond](https://sandboxphysics.com/stories/molecular-electronic/)

L1 · Chapter 2

# Turning a molecule into a small matrix problem

Sandbox Physics · 2026-10-28

A basis makes an electronic calculation manageable by limiting the shapes the orbitals can take. The integrals record how those shapes overlap, move and interact; they define the model before any method solves it.

## Before you begin

The previous chapter on orbitals and normalization. A matrix is a table of numbers that maps one set of coefficients to another; an eigenvector keeps its direction under that mapping.

[Review the preceding chapter](https://sandboxphysics.com/stories/molecular-electronic/variational-orbitals/)

- Separate fixed-nucleus electronic energy from nuclear repulsion.
- Explain why STO-3G gives two spatial functions for this molecule.
- Use overlap when normalizing orbitals and counting electrons.

## Freeze the nuclei before solving for electrons

Put the two hydrogen nuclei on the horizontal axis at $(-R/2,0,0)$ and $(R/2,0,0)$. The positive separation $R$ is in bohr. The Born–Oppenheimer approximation treats this nuclear geometry as fixed while the electronic state is solved. Repeating the calculation at many separations produces an electronic potential energy curve for nuclear motion.

The electronic Hamiltonian contains kinetic energy, attraction to both nuclei and repulsion between the two electrons. Nuclear repulsion is a separate constant at each geometry. It must be added to every electronic method before comparing total curves or differentiating them.

$$
\hat H_{\mathrm e}=\sum_{i=1}^{2}\left(-\frac12\nabla_i^2-\frac1{r_{iA}}-\frac1{r_{iB}}\right)+\frac1{r_{12}}
$$

All terms use atomic units. The Laplacian in the kinetic term adds second spatial derivatives, which measure curvature of the wavefunction. The nuclei have charge one.

$$
E_{\mathrm{tot}}(R)=E_{\mathrm e}(R)+\frac1R
$$

The fixed nuclei repel. Removing this term changes both the energy curve and its slope.

Reading: A. E. DePrince III · Psi4 manual

## Three Gaussians make one atomic basis function

The hydrogen STO-3G basis represents each atomic function by a fixed sum of three Gaussian primitives. Their exponents and contraction coefficients are part of the basis definition. They are not extra orbital coefficients for the SCF calculation to optimize.

There is one contracted spatial function on each hydrogen, so the molecule has two spatial basis functions. An orbital is a linear combination $\phi_p=\sum_{\mu=1}^{2}C_{\mu p}\chi_\mu$. Electron spin is an intrinsic angular momentum; along a chosen axis we use two spin labels. Each spatial orbital has two corresponding spin functions. Thus there are four spin orbitals, and placing two electrons in them gives $\binom42=6$ determinants, antisymmetric occupation states whose sign reverses when two electron coordinates are exchanged. Selecting a spin sector keeps states with specified spin properties.

Adding a larger basis changes the available spatial shapes. Mixing more determinants at a fixed basis changes how the electrons share those shapes. These are different improvements, and their errors should be inspected separately.

$$
\chi_A(\mathbf r)=\sum_{k=1}^{3}d_kN_k\exp[-\alpha_k|\mathbf r-\mathbf R_A|^2]
$$

The primitive normalization factors, exponents and contraction coefficients are fixed. Each hydrogen supplies one independent contracted function, made from three fixed primitives.

Reading: Basis Set Exchange · Psi4 manual

## The same integrals feed every electronic method

An overlap matrix $S$ records nonorthogonality. A one-electron matrix $h$ records kinetic energy and nuclear attraction. Four-index integrals record Coulomb repulsion between pairs of basis-function products. Here the indices label atomic functions, and the vertical bar separates the two electron coordinates.

Once these arrays and the nuclear repulsion are fixed, RHF, UHF and FCI solve different trial-state problems for the same Hamiltonian. Their energy differences can then be attributed to the method. Independently changing an integral or shifting one curve would destroy that comparison.

$$
S_{\mu\nu}=\int\chi_\mu(\mathbf r)\chi_\nu(\mathbf r)\,d^3r,\qquad h_{\mu\nu}=\langle\chi_\mu|\hat h|\chi_\nu\rangle
$$

The overlap is dimensionless; one-electron integrals have energy units.

$$
(\mu\nu|\lambda\sigma)=\iint\frac{\chi_\mu(\mathbf r_1)\chi_\nu(\mathbf r_1)\chi_\lambda(\mathbf r_2)\chi_\sigma(\mathbf r_2)}{|\mathbf r_1-\mathbf r_2|}\,d^3r_1\,d^3r_2
$$

This is the chemists’ ordering of real electron-repulsion integrals used throughout the course.

Reading: A. E. DePrince III

## Count electrons with the overlap included

For real orbitals, let $P_{\mu\nu}=\sum_p n_pC_{\mu p}C_{\nu p}$, where $n_p$ is the spatial-orbital occupation. Expanding the density in atomic functions and integrating gives $N=\operatorname{Tr}(PS)$. The trace adds the diagonal entries of the matrix product. It is not generally the trace of the density matrix alone.

As a worked check, take one doubly occupied symmetric orbital with atomic overlap $S_{AB}=0.2$. Its coefficients are both $1/\sqrt{2.4}$, so every density-matrix entry is $2/2.4=5/6$. The diagonal contributions sum to $5/3$, and the two overlap contributions add $1/3$. The electron count is two.

This numerical diagnostic tests a physical normalization in addition to checking iterative convergence. A density picture should be derived from this same matrix and these same basis functions.

$$
\rho(\mathbf r)=\sum_{\mu\nu}P_{\mu\nu}\chi_\mu(\mathbf r)\chi_\nu(\mathbf r),\qquad N=\int\rho\,d^3r=\operatorname{Tr}(PS)
$$

The total spatial density integrates to the number of electrons. Spin-resolved matrices can be summed to obtain the same total.

Reading: A. E. DePrince III

## Try the prediction

### [Relate a matrix to the molecular density](https://sandboxphysics.com/labs/h2-self-consistent-field/)

1. Choose a separation and compare the displayed density matrix with the shared cloud.
2. Check the electron count, then increase the separation. The diagonal entries may change without changing the total electron count.
3. Explain why a three-dimensional cloud and a two-by-two matrix can describe the same limited spatial model.

## Exercises and explanations

1. For a hypothetical calculation at $R=2$ bohr, the electronic energy is $-1.8$ hartree. What total energy should be plotted?

   Read the explanation

   Add the nuclear repulsion $1/R=0.5$ hartree to obtain $-1.3$ hartree. These deliberately hypothetical values illustrate how the electronic and nuclear terms are added.

2. Does a six-determinant FCI result remove the STO-3G basis error?

   Read the explanation

   It includes all two-electron configurations in four spin orbitals. The spatial functions remain the two prescribed contractions. A larger spatial basis adds freedom that no mixing of these six determinants can supply.

3. Why can $\operatorname{Tr}P$ change when the electron count stays two?

   Read the explanation

   The atomic functions overlap. The physical count is $\operatorname{Tr}(PS)$, and both the density matrix and overlap matrix can depend on separation. Only in an orthonormal representation does the count reduce to the trace of the density matrix.

[Previous: Choosing an orbital for one hydrogen electron](https://sandboxphysics.com/stories/molecular-electronic/variational-orbitals/) [Next: Making the density and its field agree](https://sandboxphysics.com/stories/molecular-electronic/self-consistent-field/)

## Sources and calculation scope

1. [A. E. DePrince III, The Hartree–Fock Self-Consistent Field Procedure](https://www.chem.fsu.edu/~deprince/tutorials/jupyter_notebooks/hartree_fock/hartree_fock.html)

   Author tutorial: electronic Hamiltonian, variational principle, density matrices, SCF, basis convergence and spin-symmetry breaking. The browser calculation specializes these equations to two hydrogen STO-3G functions.

2. [Psi4 manual, HF: Hartree–Fock Theory](https://psicode.org/psi4manual/master/scf.html)

   Theory and numerical methods sections: restricted and unrestricted references, generalized eigenproblem, total energy and convergence. The reproducible reference manifest records the installed version and settings.

3. [Psi4 manual, CI: Configuration Interaction](https://psicode.org/psi4manual/master/detci.html)

   CI expansion and full configuration interaction within a chosen orbital space. Here FCI is exact only for the stated finite-basis Hamiltonian.

4. [Basis Set Exchange, STO-3G basis data](https://www.basissetexchange.org/)

   Hydrogen STO-3G contraction: one contracted s function per atom, made from three Gaussian primitives. Basis coefficients and normalization are fixed in the calculation manifest.
