nanoCMB: A minimal CMB power spectrum calculator in Python
Adam Moss
arXiv:2602.23466v1 Announce Type: new
Abstract: We present nanoCMB, a minimal but accurate calculator for the unlensed CMB temperature and polarisation angular power spectra ($C_ell^{TT}$, $C_ell^{EE}$, $C_ell^{TE}$) of flat $Lambda$CDM cosmologies. Written in $sim$1400 lines of readable Python, the code implements the full line-of-sight integration method: RECFAST recombination, coupled Einstein–Boltzmann perturbation equations in synchronous gauge with a tight-coupling approximation, precomputed spherical Bessel function tables, and optimally constructed non-uniform grids in wavenumber and conformal time. Despite its brevity, nanoCMB achieves sub-percent agreement with CAMB across the multipole range $2 le ell le 2500$, running in $sim$10 seconds on a modern laptop. The entire calculation lives in a single, easily modifiable Python script, designed as a pedagogical bridge between textbook treatments and research-level Boltzmann solvers, with every approximation and numerical choice made explicit. We describe the physics, equations, and computational methods in detail, with code snippets illustrating each stage of the calculation. The code is publicly available at https://github.com/adammoss/nanoCMB.arXiv:2602.23466v1 Announce Type: new
Abstract: We present nanoCMB, a minimal but accurate calculator for the unlensed CMB temperature and polarisation angular power spectra ($C_ell^{TT}$, $C_ell^{EE}$, $C_ell^{TE}$) of flat $Lambda$CDM cosmologies. Written in $sim$1400 lines of readable Python, the code implements the full line-of-sight integration method: RECFAST recombination, coupled Einstein–Boltzmann perturbation equations in synchronous gauge with a tight-coupling approximation, precomputed spherical Bessel function tables, and optimally constructed non-uniform grids in wavenumber and conformal time. Despite its brevity, nanoCMB achieves sub-percent agreement with CAMB across the multipole range $2 le ell le 2500$, running in $sim$10 seconds on a modern laptop. The entire calculation lives in a single, easily modifiable Python script, designed as a pedagogical bridge between textbook treatments and research-level Boltzmann solvers, with every approximation and numerical choice made explicit. We describe the physics, equations, and computational methods in detail, with code snippets illustrating each stage of the calculation. The code is publicly available at https://github.com/adammoss/nanoCMB.
2026-03-02