Quarkonium-System

1. Numerics

Start at the bottom: functions with no physics in them, each with a test against an independent evaluation.

Special functions that do not cancel

The screened potential needs moments (Q_k=\int_0^\infty r^ke^{-ar^2-\mu r}dr). Integrating (\frac{d}{dr}\big[r^{k+1}e^{-ar^2-\mu r}\big]) from 0 to ∞ gives (2aQ_{k+2}+\mu Q_{k+1}=(k+1)Q_k), and (Q_0) is a scaled complementary error function. With (x=\mu/2\sqrt a) and (q_k=a^{(k+1)/2}Q_k):

[ q_{k+2}=\frac{k+1}2q_k-x\,q_{k+1}. ]

For small (x) this can be iterated upwards. For large (x) it subtracts nearly equal numbers and loses every digit. The cure is old (Miller’s algorithm in continued-fraction form): iterate the ratio (\rho_k=q_{k+1}/q_k=(k+1)/(2x+2\rho_{k+1})) downwards, where only positive numbers are added.

--8<-- "src/math/special.cpp:moments"

The same worry shapes erfcx (an asymptotic series for large arguments, where (e^{x^2}\mathrm{erfc}\,x) overflows times zero), the spherical Bessel functions (series below, recursion above) and the smeared potentials (Taylor series for small arguments).

Quadrature

Gauss–Legendre and generalized Gauss–Laguerre rules are computed by the Golub–Welsch method: the nodes are the eigenvalues of the symmetric tridiagonal matrix of the three-term recursion, the weights come from the first components of the eigenvectors. Rules are cached behind a mutex because fits run in threads.

Basis and matrix elements

A Basis is little more than the exponents (\nu_i) and (\ln N_i^2). Norms are kept as logarithms: (\Gamma(l+3/2)) and ((2\nu)^{l+3/2}) over- and underflow long before their ratio does.

The matrix elements are the boxed formulas written out. For the kinetic energy:

--8<-- "src/me/radial.cpp:p2"

The first branch handles complex-range functions: compute the bilinear form with complex exponents once, then assemble the cosine and sine combinations from real and imaginary parts. Every radial operator reuses that device.

Operators without a closed form fall back to composite Gauss–Legendre quadrature with panels crowded towards the origin, where the narrow Gaussians live. Derivatives of the smeared potentials (needed for spin terms) are obtained by carrying a truncated Taylor series through the formula instead of differentiating by hand.

The eigenproblem

Canonical orthogonalisation, complete:

--8<-- "src/linalg/gep.cpp:gep"

Symmetrising (H’) removes round-off asymmetry before the symmetric solver sees it.

How this layer is tested

tests/reference_quadrature.hpp integrates any operator between basis functions by brute force. Each analytic formula must agree with it for several (l), (l’) and widely different widths, which is where cancellations show. The solver is tested on the harmonic oscillator, hydrogen and the Airy levels of a linear potential.