Post

T>T: FROST III, Certified Hartree–Fock for Diatomic Molecules

T>T: FROST III, Certified Hartree–Fock for Diatomic Molecules

TLDR: In this post learn how to take FROST from atoms to diatomic molecules and certify their Hartree–Fock energies as rigorous upper bounds: H₂ to 103 significant figures and HeH⁺ to 101, where the best previous values had 11 and 9, and LiH to 26, where it had 12. The trick is to make the problem ODEs again. In prolate spheroidal coordinates both nuclear cusps disappear, and expanding everything in Legendre polynomials of the angular coordinate gives equations that all have the same form, \((\xi^2-1)u''+2\xi u' = g\), which the Taylor shooting of the atoms integrates unchanged. The certificate needs logarithms this time (they turned up one paper late), and the reason LiH is so much more expensive per digit is the pair of complex singularities that I found in the helium orbital in the first FROST post.

This post is part of a series on Hartree-Fock theory:

The result (in hartrees)

Blue are the figures that were known before; red are new. All three are total energies, including the nuclear repulsion, at the internuclear distance \(R\) of the earlier benchmark studies.

H₂, R = 1.4 bohr: this work (2026), certified, 103 significant figures (previously 11, Jensen 1999)
−1.133629571468450847547407597905613260924610347375834524390831060315115611627072502294173788207552308777
HeH⁺, R = 1.455 bohr: this work (2026), certified, 101 significant figures (previously 9, Tasi & Császár 2007)
−2.9331032767890675221343136789246297987103950520371756817376634599511580174337268221458394176141473310
LiH, R = 3.015 bohr: this work (2026), certified, 26 significant figures (previously about 12, Beck et al. 2003 and x2dhf)
−7.9873522372333846259519458

Introduction, or how I was wrong again

FROST II ended with a list of what comes next, and one item was diatomic molecules. I wrote that the radial ODEs would become PDEs, that the method would need a two-dimensional analogue of the Taylor segments, and that I had no idea yet how to do that. It turns out that it does not need one as with the right coordinates and the right expansion the molecular HF equations become ODEs again, every one of them of the same form, and the machinery of the atoms carries over almost untouched. FROST II also opened with me being wrong about what came next, so this is becoming a tradition, and one I am quite happy to keep (and learned to live with it…) Why molecules? An atom is a very special problem: one nucleus, spherical symmetry, and equations in one variable. Chemistry happens between nuclei, and for molecules the Roothaan–Hall route of 1951, which expands the orbitals in a basis and solves a matrix eigenvalue problem, has been the standard ever since. Its accuracy is set by the basis, and even for H₂, the simplest molecule there is, the HF limit is known from basis-set extrapolations to only 11 significant figures (Jensen 1999).

Diatomic molecules are the exception, as two nuclei on an axis still leave a lot of symmetry. McCullough expanded the orbitals in partial waves in 1974, Laaksonen, Pyykkö and Sundholm introduced finite differences in two dimensions in 1983, which became the program x2dhf, and Lehtola combined finite elements with McCullough’s partial waves in HelFEM in 2019. In double precision these methods give total energies to 10–12 significant figures. That is the bar:

molecule\(R\) (bohr)previous bestfigures
H₂1.4−1.1336295715 (Jensen 1999)11
HeH⁺1.455−2.933103279(2) extrapolated, −2.933103266 variational (Tasi & Császár 2007)9
LiH3.015−7.987352237228 (Beck et al. 2003), −7.9873522372381 (x2dhf v3)≈12

As with helium in the first post, the digits buy something beyond themselves. Once the HF energy of H₂ is certified, its correlation energy, the part of the electron–electron interaction that a single determinant misses, is limited only by how well the exact energy is known, with nothing left to blame on the Hartree–Fock side (Part IV).

Try the code yourself

The code lives in the FROST repository, github.com/adambaskerville/frost, where release v3.0 is the code of this post. The molecule solver sits next to the atomic one and reuses its multiple shooting, Newton iteration, sparse LU and C kernel. The orbitals of every run in this post are archived on Zenodo, doi:10.5281/zenodo.23983909, so you can check any of the bounds below with certify_d.py without repeating the run, and the figure script is in FROST3Code/, next to this post.

filewhat it does
oracle_d.pythe solver for closed-shell diatomics with \(\sigma\) orbitals
certify_d.pythe exact certificate for its orbitals
h2plus.pyan independent reference for H₂⁺ to any number of digits
taylor.cthe C kernel, now with the channel integration and a double-precision LU
test_hf_taylor.pyend-to-end check (~30 s)
paper3/run_all.shevery run in this post

You need Python 3, gmpy2 and numpy, and for the C kernel MPFR and GMP, which a conda environment provides. Times are for the 12 cores of an Apple M4 Pro laptop.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
git clone https://github.com/adambaskerville/frost && cd frost
conda install -c conda-forge mpfr gmp   # for the C kernel
pip install -r requirements.txt

# H2 at R = 7/5 bohr to 40 digits with 16 channels (~10 s), then its certified bound (under a minute)
python oracle_d.py --R 7/5 --channels 16 --digits 40 --out h2.json
python certify_d.py h2.json

# HeH+ to 25 digits with 20 channels (~10 s)
python oracle_d.py --R 1.455 --ZA 2 --ZB 1 --channels 20 --digits 25 --out heh.json

# LiH, two sigma orbitals, to 16 digits with 24 channels (~2 min)
python oracle_d.py --R 3.015 --ZA 3 --ZB 1 --sigma 2 --channels 24 --digits 16 --out lih.json

# H2+ from its separated equations, to 100 digits (~5 s)
python h2plus.py --R 2 --digits 100

# every run in this post (a few hours)
paper3/run_all.sh runs && python paper3/make_paper3.py --extract runs

The 40-digit H₂ run is already correct to 43 figures, which is 32 more than were known before, in about a minute on a laptop.

Birds-eye view

The parts follow, more or less, the order in which things happened: an idea that made the problem one-dimensional again, a first version that worked but took over an hour, a series of fixes that brought it down to a minute, and a molecule that refused to converge as quickly as the others, which turned out to be the most interesting part.

  1. Part I is the formulation: prolate spheroidal coordinates, Legendre channels, and why every equation ends up with the same form
  2. Part II is the numerics: what carries over from the atoms, the new modes that the step control has to see, and how the run time of H₂ went from 73 minutes to 64 seconds
  3. Part III is the certificate, where logarithms finally appear
  4. Part IV is the results: H₂⁺ as a test, H₂ to 103 figures with its potential curve, HeH⁺ and LiH
  5. Part V is why LiH is so much harder than H₂, which the helium singularities of the first post predict with no adjustable parameter
  6. Part VI is the list of things that I broke along the way, and Part VII the lessons and what comes next

Part I: Making molecules ODEs again

1. Prolate spheroidal coordinates

Put nucleus \(A\), with charge \(Z_A\), and nucleus \(B\), with charge \(Z_B\), a distance \(R\) apart. An electron at distances \(r_A\) and \(r_B\) from them has the prolate spheroidal coordinates

\[\xi = \frac{r_A+r_B}{R}\in[1,\infty), \qquad \eta = \frac{r_A-r_B}{R}\in[-1,1],\]

together with the azimuth \(\phi\) around the axis. Surfaces of constant \(\xi\) are ellipsoids with the nuclei at their foci, surfaces of constant \(\eta\) are hyperboloids, and the two nuclei sit at the ends of the segment \(\xi = 1\).

Prolate spheroidal coordinates: ellipses of constant xi and hyperbolas of constant eta around two nuclei, the segment xi = 1 between them and the wall xi = xi_w. Prolate spheroidal coordinates in a plane through the axis. The segment \(\xi = 1\) between the nuclei plays the role that the nucleus played for the atoms, and the wall is the confocal spheroid \(\xi = \xi_w\).

These coordinates are old, as H₂⁺ has been solved in them since the 1920s, and they do two lovely things. The volume element is \((R/2)^3(\xi^2-\eta^2)\,d\xi\,d\eta\,d\phi\), and since \(r_A = R(\xi+\eta)/2\) and \(r_B = R(\xi-\eta)/2\), the metric factor cancels both Coulomb singularities at once:

\[(\xi^2-\eta^2)\Big(\frac{Z_A}{r_A}+\frac{Z_B}{r_B}\Big) = \frac2R\big[(Z_A+Z_B)\xi+(Z_B-Z_A)\eta\big].\]

The nuclear attraction becomes a linear function of the coordinates. Both cusps, the thing that makes Gaussian basis sets converge so slowly, are absorbed by the coordinates, just as dividing out \(r^{l+1}\) absorbed the single cusp of an atom.

2. The HF equations

I restrict this post to closed shells of \(n\) doubly occupied \(\sigma\) orbitals, which have no dependence on \(\phi\) and cover H₂, HeH⁺ and LiH. Write each orbital as \(\psi_a = (4/\pi R^3)^{1/2}\phi_a(\xi,\eta)\) and each pair potential as \(J_{ab} = \int\psi_a\psi_b/r_{12} = (4/R)\,w_{ab}\), and multiply the canonical HF equations by \(-(R^2/2)(\xi^2-\eta^2)\). With \(\mathcal L = \partial_\xi(\xi^2-1)\partial_\xi+\partial_\eta(1-\eta^2)\partial_\eta\), the Fock and Poisson equations become

\[\begin{aligned} \mathcal L\phi_a &= -R\big[(Z_A+Z_B)\xi+(Z_B-Z_A)\eta\big]\phi_a-(\xi^2-\eta^2)\Big[\tfrac{R^2\varepsilon_a}{2}\phi_a-2R\sum_bc_{ab}\phi_b\Big],\\ \mathcal Lw_{ab} &= -(\xi^2-\eta^2)\,\phi_a\phi_b, \end{aligned}\]

where \(c_{ab} = 2\delta_{ab}\sum_cw_{cc}-w_{ab}\) collects the Coulomb and exchange terms. Without the electron–electron terms the first equation is that of H₂⁺, which separates into one ODE in \(\xi\) and one in \(\eta\). The electron–electron terms couple the two coordinates, so HF does not separate, and this is why I thought last time that we would need a genuinely two-dimensional method.

3. Legendre channels

The way out is McCullough’s partial-wave idea from 1974, with a twist. Expand every orbital and every potential in orthonormal Legendre polynomials \(\hat P_l = (l+\tfrac12)^{1/2}P_l\) of \(\eta\),

\[\phi_a = \sum_{l\le l_{\max}}F_{al}(\xi)\,\hat P_l(\eta), \qquad w_{ab} = \sum_LW_{abL}(\xi)\,\hat P_L(\eta).\]

Since \(\partial_\eta(1-\eta^2)\partial_\eta\hat P_l = -l(l+1)\hat P_l\), projecting the two equations onto each \(\hat P_l\) gives, for every orbital channel and every potential channel,

\[\boxed{\;(\xi^2-1)u''+2\xi u' = g\;}\]

which is the molecular twin of the atoms’ \(ru''+2(L+1)u' = g\). Its point \(\xi = 1\) is a regular singular point with indices 0 and 0, where the regular solution is fixed by \(u(1)\) alone and the other one grows logarithmically. So every channel is integrated from the internuclear axis with one free value, exactly as every atomic orbital is integrated from the nucleus. In McCullough’s method the \(F_{al}\) are then discretised on a grid; in FROST they are fixed by ODEs and integrated by Taylor series to hundreds of digits.

The twist is in what gets truncated, and this is the part of the formulation I like best. Truncating the orbitals at \(l_{\max}\) restricts them to a subspace, so the energy is an upper bound that falls as \(l_{\max}\) grows. The potentials, however, are not truncated at all. For orbitals with \(l\le l_{\max}\), the source \((\xi^2-\eta^2)\phi_a\phi_b\) is a polynomial of degree \(2l_{\max}+2\) in \(\eta\), and because \(\mathcal L\) is diagonal in the Legendre index, the potential it generates has channels only up to \(L = 2l_{\max}+2\). Keep all of them, evaluate the projections on a Gauss–Legendre rule with \(2l_{\max}+3\) points, which is exact for every product that appears, and the channel equations are the exact Galerkin equations of the HF problem in the space of orbitals with \(l\le l_{\max}\). Besides the wall, the number of orbital channels is the only approximation, and it is variational.

4. One wall, again

As in FROST II, all orbitals share one wall, here the confocal spheroid \(\xi = \xi_w\), on which

\[F_{al}(\xi_w) = 0, \qquad W'_{abL}(\xi_w) = \frac{Q_L'(\xi_w)}{Q_L(\xi_w)}\,W_{abL}(\xi_w).\]

The second condition is exact, because outside the wall the potentials obey Laplace’s equation and decay, so every channel there is a multiple of the Legendre function of the second kind \(Q_L(\xi)\). Normalisation is once more a flux: the monopole channel of \(w_{aa}\) carries the charge of orbital \(a\) through the wall, and \((\xi_w^2-1)W'_{aa0}(\xi_w) = -1/\sqrt2\) makes it one electron’s worth, which is the molecular version of \(Ry^0_{aa}(R) = 1\). With one wall the canonical orbitals are eigenfunctions of one self-adjoint Fock operator, so they are orthogonal for free, as they were for the atoms. The wall error decays as \(e^{-2\kappa r_w}\), with \(\kappa = \sqrt{-2\varepsilon}\) of the highest occupied orbital and \(r_w\approx R\xi_w/2\), so for \(D\) digits we take \(\xi_w = (D+8)\ln10/(\kappa R)\), which for H₂ to 100 digits is \(\xi_w = 162.89\), about 114 bohr from the molecule.

Part II: The numerics

The solver is the one of FROST II applied to the channel system: Taylor series integrate all channels over segments, multiple shooting couples the segments, a chord Newton iteration solves the resulting equations, and a homotopy that switches on the electron–electron interaction supplies the starting point. Here is what is new.

5. The recurrence

Substituting \(u = \sum_ku_k(\xi-\xi_0)^k\) into \((\xi^2-1)u''+2\xi u' = g\) gives, on the axis \(\xi_0 = 1\),

\[u_{k+1} = \frac{g_k-k(k+1)u_k}{2(k+1)^2},\]

and about any \(\xi_0>1\)

\[u_{k+2} = \frac{g_k-2\xi_0(k+1)^2u_{k+1}-k(k+1)u_k}{(\xi_0^2-1)(k+1)(k+2)}.\]

The coefficients \(g_k\) contain products of channels, and a product of two Legendre series is not a Legendre series you can write down cheaply. So for each Taylor order the channel coefficients are transformed to the nodes of the \(\eta\) rule, the Cauchy products are formed there, and the result is projected back. That costs \(O(l_{\max}^2p)\) for the transforms and \(O(l_{\max}p^2)\) for the products per step of order \(p\), and the multiplications by \(\xi\) and \(\xi^2\) are just shifts of the series.

In code, for a molecule with one orbital such as H₂ or HeH⁺, a whole Taylor step looks like this. It is simplified from oracle_d.py, which also handles several orbitals, the exchange between them and the energy integrals, and I checked that this version gives the same coefficients:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def series(x0, F, W, eps, R, ZA, ZB, eta, wt, P, ls, Ls, p):
    """Order-p Taylor coefficients about x0 of the orbital channels F[i] (l = ls[i])
    and potential channels W[j] (L = Ls[j]) of a one-orbital molecule, H2 or HeH+.
    eta, wt: a Gauss-Legendre rule; P[q][l]: orthonormal Legendre polynomials at eta[q]."""
    xi = lambda s, k: x0 * s[k] + (s[k - 1] if k else 0)             # (xi s)_k
    xi2 = lambda s, k: x0 * xi(s, k) + (xi(s, k - 1) if k else 0)     # (xi^2 s)_k

    def nxt(u, g, k):           # (xi^2 - 1) u'' + 2 xi u' = g, solved for the next coefficient
        if x0 == 1:             # the axis: a regular singular point, one free value
            return (g - k * (k + 1) * u[k]) / (2 * (k + 1) ** 2)
        return (g - 2 * x0 * (k + 1) ** 2 * u[k + 1] - k * (k + 1) * u[k]) / ((x0 * x0 - 1) * (k + 1) * (k + 2))

    nodes = range(len(eta))
    phi, w, rho, wphi = ([[] for _ in nodes] for _ in range(4))
    for k in range(p):
        G, D = [], []
        for q in nodes:         # channels -> eta nodes, where products are just products
            phi[q].append(sum(P[q][l] * f[k] for l, f in zip(ls, F)))
            w[q].append(sum(P[q][L] * u[k] for L, u in zip(Ls, W)))
            rho[q].append(dot(phi[q], phi[q]))                          # (phi^2)_k
            wphi[q].append(dot(w[q], phi[q]))                           # (w phi)_k
            e2 = eta[q] ** 2
            G.append(-R * (ZA + ZB) * xi(phi[q], k) - R * (ZB - ZA) * eta[q] * phi[q][k]
                     - R * R * eps / 2 * (xi2(phi[q], k) - e2 * phi[q][k])
                     + 2 * R * (xi2(wphi[q], k) - e2 * wphi[q][k]))     # Fock right-hand side
            D.append(xi2(rho[q], k) - e2 * rho[q][k])                   # (xi^2 - eta^2) phi^2
        for l, f in zip(ls, F):  # eta nodes -> channels, then one step of the recurrence
            f.append(nxt(f, l * (l + 1) * f[k] + sum(wt[q] * P[q][l] * G[q] for q in nodes), k))
        for L, u in zip(Ls, W):
            u.append(nxt(u, L * (L + 1) * u[k] - sum(wt[q] * P[q][L] * D[q] for q in nodes), k))
    return F, W

Here dot is the one-line Cauchy product of the first post. Put it next to the helium series there and the family resemblance is obvious: the recurrence has changed and the products take a detour through the \(\eta\) nodes, but the start is still one value per channel on the axis, and every other coefficient is fixed by the equations.

6. Step control has to see what Newton sees (again)

The main lesson of FROST II was that the root test, which picks each Taylor step from the coefficients of the solution, does not see the modes that Newton’s corrections are made of. Molecules taught me the same lesson a second time, from a new direction. The potential channels have the homogeneous solutions \(P_L(\xi)\) and \(Q_L(\xi)\), and \(P_L\) grows like \(e^{L\,\mathrm{arccosh}\,\xi}\). With 32 orbital channels the potentials go up to \(L = 126\), and a mode that grows like \(P_{126}\) is wildly stiff near the axis, but the physical high-order potential channels are so small that the root test never notices them. The Jacobian columns of those channels were therefore badly truncated, and Newton’s method put corrections of order \(10^5\) into channels whose true values lie far below the target accuracy, then failed.

The fix is a cap on the step, as for the stiff orbitals of FROST II: a Taylor series of order \(p\) resolves \(P_L\) only if

\[h\le\frac{c_P\,p\,(\xi_0^2-1)^{1/2}}{e(L_{\max}+1)},\]

and on the axis, where \(P_L(1+x)\) behaves like \(I_0(L\sqrt{2x})\), only if \(h\le2c_Pp^2/[e^2(L_{\max}+1)^2]\). A second cap handles the \(Q_L\) modes, singular at \(\xi = 1\), in segments that start off the axis. These modes only need to be resolved well enough for the chord iteration to contract, because the physical high-order channels lie far below the target accuracy, so the caps use \(c_P = 1/2\) rather than the solution’s step fraction \(c = 0.15\). That made a 32-channel H₂ run 2.8 times faster, with the same energy to every digit.

7. Do the expensive part small

The first version that reached 100 digits for H₂ took 73 minutes. That is fine for one record, but not for a potential curve, or for HeH⁺, which needs more than twice as many channels, and almost all of the time went on things that did not need all 32 channels. The work of a stage grows as the cube of the number of channels: the Jacobian has \(m\propto l_{\max}\) columns per knot, each a sweep whose steps cost \(O(l_{\max}^2)\), and factorising it costs \(O(m^3)\) per segment. So the final design does everything that has to search on ten channels only, at ten digits:

  • The start. At \(t = 0\), with the electron–electron terms switched off, the orbitals are the lowest \(\sigma\) states of the one-electron problem, which, unlike the hydrogenic orbitals of an atom, are not known in closed form. A rough finite-volume solve on the first six channels finds them, and Newton’s method refines them
  • The homotopy. Exactly as in FROST II, the electron–electron coupling is multiplied by \(t\) and \(t\) goes from 0 to 1. Following the \(n\) lowest states selects the ground state, because within one symmetry the occupied orbitals are the lowest eigenfunctions of the Fock operator at every \(t\)
  • The wall. At \(t = 1\) the wall moves out to its final position in steps of up to a factor of four, where FROST II mostly used 1.2. Larger steps work because the guess beyond the old wall now continues each channel with its own logarithmic derivative from \(3/\kappa\) inside the old wall rather than \(1/\kappa\), where the old wall’s distortion has fallen to \(e^{-6}\)

Then the remaining channels join, with zero values, in a single stage on all channels that goes from ten digits to the full target on the final wall. That stage has its own problem. Near a heavy nucleus the channels fall slowly on the axis (for LiH by only a factor of about 0.4 per unit of \(l\), because the lithium cusp sits on the axis at \(\eta = -1\)), while \(P_l(\xi)\) grows rapidly away from it, so the zeros we started the new channels from grow into errors of order one across a segment, and Newton’s first correction lands far outside its linear range. The cure is short segments, over which no mode grows by more than \(10^4\). They cost the Jacobian little, since each column is still one sweep across its own segment, and they have a bonus: they make the Jacobian well conditioned enough to be factorised in double precision.

That is the change that took the run times from minutes to seconds. The Jacobian entries are forward differences carried to 48 digits, of which 24 are correct, rounded to double and factorised by a double-precision version of the sparse LU of FROST II, with rows and columns scaled by powers of two so that no entry leaves the range of a double. The residuals keep the full working precision, so the Jacobian only steers the chord iteration, and its precision sets the rate of convergence, not the accuracy. Because a residual costs about \(1/m\) of a Jacobian, the iteration now keeps its Jacobian until a correction fails to shrink at all, and contracts by three to five digits per iteration, from ten digits to 100, with a single Jacobian. Here is the run time of the 100-digit H₂ run as each piece went in:

versionH₂, 100 digitsLiH, 25 digits
first working version73 min—
step caps at \(c_P = 1/2\)33 min93 min
ten-channel homotopy, wall steps of 4×, better tails, parallel LU16 min19 min
one stage on all channels, Jacobian in double64 s4.9 min

Every version gave the same energy to all the digits it targeted. The parallel LU, by the way, eliminates the rows below each pivot in parallel threads but keeps the operations of the serial code in their serial order, so the factors are identical bit for bit to those of one thread, which keeps the runs reproducible.

Part III: The certificate, where the logarithms finally appear

In FROST II I owned up to being wrong about logarithms: I had predicted that the certificate for \(p\) and \(d\) shells would need logarithms, and Hartree’s variable made them vanish. For molecules they really do appear, one paper late.

The certificate is a separate program that reads the solver’s orbitals, which are piecewise polynomials in \(\xi\) for each Legendre channel, rounds their coefficients to dyadic rationals, imposes continuity and the wall exactly, and evaluates the closed-shell determinant energy

\[E = 2\sum_{ab}D_{ab}h_{ab}+\sum_{abcd}D_{ab}D_{cd}\big[2(ab\vert cd)-(ac\vert bd)\big], \qquad D = S^{-1},\]

which depends only on the space the orbitals span. By the variational principle, the result is an upper bound on the HF energy, whatever the quality of the orbitals.

The one-electron integrals are exact rationals (for rational \(R\), which is why H₂ is computed at \(R = 7/5\) exactly). The metric has cancelled from the kinetic energy and the singularities from the nuclear attraction, so every integrand is a polynomial in \(\eta\) times products of the channel polynomials in \(\xi\).

The two-electron integrals use Neumann’s expansion of \(1/r_{12}\), as Ruedenberg used it in 1951, in the form of the Green’s function of the Poisson equation above. Write the pair density as \(s_q = (\xi^2-\eta^2)\phi_a\phi_b = \sum_Ls_{qL}(\xi)P_L(\eta)\), which is a finite sum. Poisson’s equation is diagonal in \(L\) with the Green’s function \(P_L(\xi_<)Q_L(\xi_>)\), so

\[(q\vert p) = \frac4R\sum_L\frac{2}{2L+1}\big[C_L(q,p)+C_L(p,q)\big], \qquad C_L(q,p) = \int_1^{\xi_w}s_{qL}\,Q_L\int_1^\xi P_Ls_{pL}\,d\xi'\,d\xi,\]

with the inner integral carried across the pieces as an exact running antiderivative, just as in FROST II. And now the logarithm: \(Q_L = \tfrac12P_L\ln[(\xi+1)/(\xi-1)]-W_{L-1}\), with \(W_{L-1}\) a polynomial with rational coefficients. The polynomial part integrates exactly. For \(\int f\ln(\xi\pm1)\,d\xi\) over a piece, choose the antiderivative \(\tilde F\) of \(f\) that vanishes at \(\xi = \mp1\); integrating by parts then leaves \(\int\tilde F/(\xi\pm1)\,d\xi\), which is the integral of a polynomial. Every two-electron integral is therefore an exact rational plus rational multiples of \(\ln(\xi_k+1)\) and \(\ln(\xi_k-1)\) at the knots \(\xi_k\). On the axis the terms \((\xi-1)^j\ln(\xi-1)\) vanish, so the logarithm of zero never appears.

The energy is then an exact rational plus a rational combination of logarithms of dyadic rationals. MPFR rounds each logarithm correctly in a direction of our choosing, so the certificate rounds it up where its coefficient is positive and down where it is negative, at enough bits that the bound lies within \(10^{-D-10}\) of the true value, and sums everything exactly. The result is still a rigorous upper bound, and the only change from the atoms is that a handful of logarithms are rounded outwards instead of being absent. (The high-order \(Q_L\) cancel heavily between their logarithmic and polynomial parts, so the precision of the logarithms has to grow with \(L_{\max}\), which the program works out from the size of the coefficients.)

Part IV: Results

The test: H₂⁺

The one-electron ion tests the channel machinery against an exact answer. H₂⁺ separates, and Jaffé’s series in \(\xi\) and a Legendre series in \(\eta\) each reduce to a three-term recurrence whose minimal solution gives a continued-fraction condition. Solving the two conditions together gives, from a program completely independent of the solver,

\[E(\mathrm{H}_2^+, R = 2) = -1.1026342144949464615089689453183\ldots\ E_h\]

without the nuclear repulsion, which agrees with the literature. The channel solver does not use the separation, and it converges to this value as channels are added: with 4 even channels it lies \(3\times10^{-12}\) above, and with 8 channels \(9\times10^{-32}\) above. The exact \(\eta\) function is entire, so its Legendre coefficients fall faster than geometrically and the convergence accelerates. Remember that, because for H₂ it does not.

H₂ to 103 figures

For H₂ at \(R = 7/5\) bohr the energy converges geometrically, by 3.58 digits per even channel, so 100 digits need about 30 channels. Every molecule gets a certified run A and an independent run B, which targets 10 more digits with a larger wall, two more channels, a different step fraction (\(c = 0.25\) against 0.15) and fewer guard digits, and so a different mesh, order, knots and precision. Run B’s own errors are far smaller than run A’s, so the distance between run A’s certified bound and run B is the distance of the bound from the HF limit.

molecule\(R\)channels A/Bwall \(\xi_w\)segmentsrun Arun Bcertified s.f.previous
H₂7/532/34162.898064 s93 s10311
HeH⁺1.45576/7894.45848 min12 min1019
LiH3.01536/3832.45324.9 min5.2 min26≈12

Correct significant figures of the HF energies of H2, HeH+ and LiH, the previous best against FROST III. Correct significant figures of each certified bound (red) against the previous best (grey): Jensen’s basis-set extrapolation for H₂, Tasi and Császár’s distributed Gaussians for HeH⁺, and the finite-element and finite-difference values of Beck, Heinemann and Kolb and of x2dhf for LiH.

For H₂ the two runs agree to 103.2 significant figures, and the certified bound lies \(7.5\times10^{-104}\) hartree above run B, which is run A’s wall error. The first 11 figures agree with Jensen’s basis-set limit, as they should. Within each run the orbital energy agrees with \(h_{aa}+\sum_b(2J_{ab}-K_{ab})\), and the norm with 1, to \(2\times10^{-116}\).

A certified HF energy has a nice side effect. The exact nonrelativistic (Born–Oppenheimer) energy of H₂ at \(R = 1.4\) bohr is known to about 16 figures, \(-1.1744757142204434(5)\) hartree (Sims and Hagstrom 2006; Pachucki 2010), so the correlation energy of H₂,

\[E_{\rm corr} = -0.04084614275199255(5)\ E_h,\]

is now limited only by the exact energy, with no contribution from the HF side.

The same machinery gives the HF potential curve at little cost. Each point below comes from a certified run with 18 channels at 40 digits, which takes 10 to 12 seconds, and an independent run with 20 channels at 50 digits, and each is correct to at least 43 figures. The table shows the first 40:

\(R\) (bohr)\(E_{\rm HF}\le\) (hartree)
1.0−1.085138393602250443466018814173189038839…
1.2−1.125026248093143512480837460808247484492…
1.4−1.133629571468450847547407597905613260924…
1.6−1.126347983308178690514004813396272568487…
1.8−1.110958388387661880092186000238390749822…
2.0−1.091619846400596621822330342691009981779…
2.5−1.038800218592714891950121406285588786393…
3.0−0.9893593952219792463695264540728962593363…

HeH⁺ to 101 figures

HeH⁺ is the simplest heteronuclear molecule. Its orbital is drawn towards the helium nucleus, both parities of \(l\) occur, and the convergence is much slower, 1.48 digits per channel, so 100 digits need about 74 channels; Part VI explains why I ended up using 76. The two runs agree to 102.2 figures, and the bound lies \(1.7\times10^{-102}\) hartree above run B, again mostly run A’s wall error.

The fully numerical energy of Laaksonen, Pyykkö and Sundholm (1983), −2.93310325, is correct to eight figures. Tasi and Császár’s variational energy with 64 optimised Gaussians (2007), −2.933103266, lies \(1.1\times10^{-8}\) hartree above the limit, as an upper bound must, and their extrapolated limit, −2.933103279(2), lies \(2.2\times10^{-9}\) below it, just outside its stated uncertainty. The HF limit of HeH⁺ was known to about nine figures.

LiH to 26 figures

LiH, with the configuration \(1\sigma^22\sigma^2\), is the first molecule here with two orbitals, so with exchange between them and three pair potentials. The homotopy from the two lowest one-electron states lands on the ground state, the two canonical orbitals come out orthogonal to the working precision, and the certificate now uses \(D = S^{-1}\) and the exchange integrals. A 25-digit target needs 36 channels, which means 582 unknowns per knot, and the runs agree to 26.8 figures.

The best previous values are interesting. The extrapolated finite-element energy of Beck, Heinemann and Kolb, −7.987352237228, and the finite-difference energy of the current x2dhf, −7.9873522372381, lie on either side of ours, by about \(5\times10^{-12}\) hartree each, so both were correct to about 12 figures and between them they bracketed the answer.

So why only 26 figures for LiH, when H₂ and HeH⁺ went past 100? That is the most interesting part of the whole project.

Part V: Why LiH is hard, and what helium has to do with it

LiH converges at only 0.76 digits per channel, against 3.58 per even channel for H₂ and 1.48 per channel for HeH⁺. At that rate 100 digits would need about 130 channels and 25 digits already need 36. Where does the rate come from?

The Legendre series of a function on \([-1,1]\) converges geometrically if the function is analytic there, and its coefficients fall as \(\rho^{-l}\), where \(\rho>1\) labels the largest Bernstein ellipse (the ellipse with foci \(\pm1\)) inside which the function is analytic. If the nearest singularity sits at \(\eta_*\), the ellipse passes through it and \(\rho = \vert\eta_*+\sqrt{\eta_*^2-1}\vert\), taking the root that makes \(\rho>1\), so a singularity close to the interval means \(\rho\) close to 1 and slow convergence. The energy is quadratic in the orbital error, so it converges as \(\rho^{-2l}\). The question is therefore: where are the singularities of the HF orbitals, regarded as functions of \(\eta\)?

The first FROST post answered that question for helium. The hydrogen orbital \(e^{-Zr}\) is entire, with no singularities anywhere, but the HF equations are nonlinear, and the helium HF orbital has a complex-conjugate pair of singularities at

\[r_* = -1.099\pm0.577\,i\ \text{bohr},\]

which I found from the sign pattern of a 626th-order series at the nucleus and which explained both why Taylor steps work and why Laguerre basis sets converge slowly. A molecular orbital near a nucleus looks like an atomic orbital there, so its singularities near that nucleus should sit at a similar distance, which for a hydrogenic scaling to charge \(Z\) is \(r_*\approx(2/Z)(-1.099\pm0.577\,i)\). On the axis \(\xi = 1\), where the channels are largest, \(r_A = R(1+\eta)/2\), so the singularity maps to

\[\eta_* = -1+\frac{2r_*}{R},\]

just beyond the end of the interval. The closer \(\eta_*\) is to \(-1\), the thinner the Bernstein ellipse through it and the slower the convergence, and that depends only on \(r_*/R\), which is how big the atom’s singular region is compared with the bond. A heavier nucleus pulls its singularities closer to it, and a longer bond makes them look closer still on the scale of the molecule, so for LiH both work against us: for H₂, HeH⁺ and LiH, \(\eta_*\) is \(-4.14+1.65i\), \(-2.51+0.79i\) and \(-1.49+0.26i\).

The cleanest test is the size of the channels themselves, the largest value of each \(F_{al}(\xi)\) over \(\xi\), plotted against \(l\):

The largest value of each Legendre channel of the orbitals of H2, HeH+ and LiH against l, with the decay predicted from the helium singularity. Legendre channels of the orbitals of runs B. Dotted: the decay \(\rho^{-l}\) predicted from the image \(\eta_*\) of the helium singularity, scaled to the heavier nucleus; only the slopes are predicted, and the lines are offset for clarity. Both LiH orbitals fall at the rate set by the lithium core.

molecule\(\eta_*\)channel decay, predictedmeasuredenergy digits per channel, predictedmeasured
H₂\(-4.14+1.65i\)0.950.923.783.58
HeH⁺\(-2.51+0.79i\)0.710.711.421.48
LiH\(-1.49+0.26i\)0.430.41 / 0.400.850.76

The channel decays are in decades per unit of \(l\), and the energies in digits per channel; H₂ has only even channels, two units of \(l\) apart, so each of its channels gains twice as much, \(4\log_{10}\rho\) against \(2\log_{10}\rho\) for the others. The channel decays are predicted to within 6% with no adjustable parameter, from two complex numbers found in a different system. The energies follow at twice these rates, to within about 10%, with the scatter of measuring a difference of energies between runs. I find it remarkable that a singularity of the helium HF orbital, found by fitting the signs of Taylor coefficients, sets how many Legendre channels a lithium hydride calculation needs.

The detail I like most is that both LiH orbitals decay at the same rate, even though only the \(1\sigma\) looks like the lithium core and the bonding \(2\sigma\) lives mostly between the atoms. That is what the mechanism says should happen: the singularity belongs to the Fock operator, through the potentials of the core density, and every orbital inherits it. It is the same story as the induced tails of FROST II, where every orbital of an atom inherited the decay of the outermost one, with the roles of core and valence swapped.

This also says what molecules of heavier atoms will cost. For N₂ at its equilibrium distance the estimate gives about 1.4 digits per even channel, so 50 digits would need some 40 even channels, which is in line with the partial-wave counts that Lehtola needed for \(10^{-10}\). The limitation lies in the global Legendre basis in \(\eta\), not in the Taylor integration in \(\xi\). A basis refined towards \(\eta = \pm1\) would converge much faster, but the potentials would then be infinite Legendre series, and the certificate would need a different way to do the two-electron integrals.

Main lesson I learned. The analytic structure of a solution is not a curiosity. Two complex numbers from the first post explained why Taylor steps work for atoms, why Laguerre bases converge slowly, and now how many channels a molecule needs. If something converges slower than you expect, go and find the nearest singularity.

Part VI: Things that I broke along the way

  • The precision lesson, for the third time. The certificate computed \(\sqrt{l+\tfrac12}\) at the default 53 bits, because mpfr(x, bits)/2 rounds at the context’s precision, not at that of x. The bound sat \(2\times10^{-36}\) above the solver however many digits I asked for. Both earlier FROST posts had a version of this bug, and the fix is the same: check every operation outside the solver’s context
  • The step control that could not see the potentials. The first 32-channel H₂ homotopy failed close to \(t = 1\), with a singular Jacobian and then a non-finite residual. I replayed the failing stage, as FROST II taught me to, and found Newton’s method putting \(5\times10^5\) into the \(L = 126\) potential channel at the last knots. That led to the caps of §6
  • The wrong molecule, sort of. My first HeH⁺ runs used \(R = 1.4632\) bohr, the value in my copy of Szabo and Ostlund. The numerical and basis-set literature uses 1.455, so there was nothing to compare against. Everything was rerun at 1.455, and the old runs are kept as a reminder to check the benchmark geometry before running anything
  • A run that never ended. One LiH run sat for four hours without progress. A point near the wall was computed at the precision of the previous stage, and after a failed stage was retried at lower precision, the integration’s x0 += h stalled half an ulp below its endpoint, forever. Endpoints are now rounded to the working precision, and a test checks it
  • Jumping straight to the final wall. If larger wall steps are faster, why not jump from the homotopy’s wall to the final one in one go? For run A of H₂ it worked; for run B it failed after 26 minutes. Steps of at most four times, with a fall-back to 1.2, are robust
  • How far double precision goes. Factorising the Jacobian in double worked only after I found its limits by breaking it. Forward differences at 53 bits put corrections of \(10^{37}\) into potential derivatives near the wall; differences carried to 32 digits stalled near \(10^{-49}\); and segments over which modes grow by \(10^8\) made the first correction diverge. 48 digits and \(10^4\) work
  • A carry. The first 100-digit HeH⁺ runs, with 74 and 76 channels, agreed to 100.3 significant figures. But the bound ended in …73309 and run B in …73310, so the two shared only 99 leading digits, and I was about to print a 100th that was not confirmed. FROST now counts the figures as the smaller of the agreement and the digits actually shared, and HeH⁺ was rerun with two more channels. The same rule cost four atoms of FROST II one figure each (calcium, palladium, cadmium and xenon), and the paper and post have been corrected
  • Two tools that failed silently. zsh does not split $v into words in a for loop, so a batch of baseline runs ran with the wrong arguments. And after I deleted a conda environment to free disk space, the compiled C kernel still pointed at its libraries, failed to load, and the solver quietly fell back to pure Python, which works, just much more slowly. When a run is suddenly slow, check what was actually loaded

Lesson. Most of these were not bugs in the mathematics but in the plumbing: a precision that was not what I thought, a geometry that was not the one in the literature, a library that was not the one I compiled against. The A/B runs and the certificate caught every one that touched a digit, which is exactly why they exist.

Part VII: What might transfer to other fields

Lessons

  1. Look for the coordinates that turn your PDE into ODEs. The molecule is not separable, but in prolate spheroidal coordinates with a Legendre expansion every equation has one form and one free value at the axis, and all of the one-dimensional machinery carries over
  2. Expand in the basis that diagonalises the hard operator. Poisson’s equation is diagonal in the Legendre index, so the potentials are exact and the only truncation is in the orbitals, where it is variational
  3. Step control must see what Newton sees. It was true for stiff orbitals in FROST II and it is true for growing potential modes here
  4. Search on a small problem, finish on the big one. The homotopy and the wall continuation on ten channels, then one stage on all of them, took H₂ from 73 minutes to 64 seconds
  5. A Jacobian that only steers can be cheap. Short segments make it well conditioned, and then double precision is enough to steer a 100-digit iteration
  6. Agreement is not the same as shared digits. Two numbers can agree to 100.3 figures and share only 99; count what you print
  7. Know your analytic structure. A singularity of the helium orbital predicts the channel count of LiH

What next

  • \(\pi\) orbitals. N₂, CO and hydrogen fluoride need orbitals with \(m\ne0\). These carry the factor \((\xi^2-1)^{m/2}(1-\eta^2)^{m/2}\), and dividing it out, as Hartree’s \(r^{l+1}\) was divided out for the atoms, gives channel equations \((\xi^2-1)u''+2(m+1)\xi u' = g\) in Gegenbauer polynomials, with integer powers in every integrand of the certificate. Homonuclear molecules beyond H₂ also need odd channels for their ungerade orbitals. Both are straightforward
  • A better \(\eta\) basis. The harder limit is Part V: molecules with heavier atoms need many channels. A basis refined towards the nuclei would fix that, if the certificate can be made to work with it
  • Speed. Three posts of chasing digits raise the obvious question of what happens if you only want the 16 of a double. That is the next post, FROST BITE, which turns the atomic method into a millisecond code, with the certified limits of this series to check every last bit against. Diatomic molecules are the obvious next target for the same treatment
  • A lower bound. As before, the distance to the limit comes from an independent run and the exponential decay of the wall error, not from a theorem. A certified lower bound for a nonlinear eigenproblem at this precision is still open, so answers on a postcard, once again

References

  • G. Jaffé, Z. Phys. 87, 535 (1934).
  • K. Ruedenberg, “The evaluation of many-center two-electron integrals”, J. Chem. Phys. 19, 1459 (1951).
  • C. C. J. Roothaan, “New developments in molecular orbital theory”, Rev. Mod. Phys. 23, 69 (1951).
  • G. G. Hall, Proc. R. Soc. London, Ser. A 205, 541 (1951).
  • D. R. Bates, K. Ledsham and A. L. Stewart, Phil. Trans. R. Soc. London, Ser. A 246, 215 (1953).
  • E. A. McCullough, Jr., Chem. Phys. Lett. 24, 55 (1974); Comput. Phys. Rep. 4, 265 (1986).
  • A. D. Becke, J. Chem. Phys. 76, 6037 (1982).
  • L. Laaksonen, P. Pyykkö and D. Sundholm, Int. J. Quantum Chem. 23, 309 and 319 (1983); Chem. Phys. Lett. 96, 1 (1983); Comput. Phys. Rep. 4, 313 (1986).
  • J. Kobus, Chem. Phys. Lett. 202, 7 (1993).
  • J. Kobus, L. Laaksonen and D. Sundholm, Comput. Phys. Commun. 98, 346 (1996).
  • F. Jensen, “The basis set convergence of the Hartree–Fock energy for H₂”, J. Chem. Phys. 110, 6601 (1999).
  • O. Beck, D. Heinemann and D. Kolb, arXiv:physics/0307108 (2003).
  • J. S. Sims and S. A. Hagstrom, J. Chem. Phys. 124, 094101 (2006).
  • T. C. Scott, M. Aubert-Frécon and J. Grotendorst, Chem. Phys. 324, 323 (2006).
  • L. Fousse, G. Hanrot, V. Lefèvre, P. Pélissier and P. Zimmermann, “MPFR: A multiple-precision binary floating-point library with correct rounding”, ACM Trans. Math. Softw. 33, 13 (2007).
  • G. Tasi and A. G. Császár, Chem. Phys. Lett. 438, 139 (2007).
  • K. Pachucki, “Born-Oppenheimer potential for H₂”, Phys. Rev. A 82, 032509 (2010).
  • J. Kobus, Comput. Phys. Commun. 184, 799 (2013).
  • L. N. Trefethen, Approximation Theory and Approximation Practice (SIAM, 2013).
  • S. Lehtola, Int. J. Quantum Chem. 119, e25944 (2019).
  • J. Kobus and S. Lehtola, Comput. Phys. Commun. 311, 109576 (2025), and x2dhf.
  • The code: github.com/adambaskerville/frost, release v3.0; the orbitals: doi:10.5281/zenodo.23983909.
  • My earlier posts: “Hartree–Fock to 500 Significant Figures with FROST” and “FROST II, Certified Hartree–Fock from Neon to Xenon”.
This post is licensed under CC BY 4.0 by the author.