spectroxide: A code package for computing cosmic microwave background spectral distortions
Listen
Radio episode about this paper
Transcript
Introduction to the show: ident: Astrophysics Radio. Generated commentary on the latest astrophysics papers.
Vera: I'm Vera.
Jocelyn: And I'm Jocelyn, here with Subrahmanyan.
Vera: We're looking at the paper: "spectroxide: A code package for computing cosmic microwave background spectral distortions".
Paper summary: Vera: So we've seen how Spectroxide is this code package that handles cosmic microwave background spectral distortions using AI assistance to run huge physics problems on supercomputers.
Jocelyn: Yeah, and the authors are Baker, Liu, and Mishra-Sharma. They basically built a whole system—code in Rust and a Python interface—that lets you calculate how things get distorted as the universe evolves from very early times down to today.
Subrahmanyan: It’s about taking these complex equations describing how photons scatter and evolve over cosmic time, like Compton scattering and Bremsstrahlung, and making them runnable.
Vera: They're solving this by evolving the photon occupation number on a non-uniform frequency grid as the universe redshifts from five million years after the Big Bang down to zero.
Jocelyn: And they’re keeping energy conservation pretty tight, using two tricks—an implicit time stepping scheme and a specific subtraction method to handle those tricky double Compton
Conclusion: Vera: So to wrap up, this paper is about Spectroxide, which is basically a whole system of code they built to calculate how energy injections into the very early universe change the spectrum of the cosmic microwave background light we see today.
Jocelyn: And those are Baker, Liu, and Mishra-Sharma. They used AI assistance to create this package in Rust and a Python interface, letting people actually run these huge physics calculations without having to deal with all that low-level coding themselves.
Subrahmanyan: The main idea is taking the complex way photons scatter over cosmic time—like Compton scattering or Bremsstrahlung—and making it a runnable computer program that models everything from five million years after the Big Bang right up to now.
Vera: They manage this by evolving the photon occupation number on a non-uniform frequency grid, and they handle energy conservation with two different tricks, making sure the results are reliable even when dealing with those tricky coupling terms.
Jocelyn: The output gives them a mix of different distortion shapes—temperature shift, mu-type, and y-type—and they use this to extract the Bose-Einstein chemical potential, which is a key piece of information for understanding what happened in the very early universe.
Subrahmanyan: So what this means for us is that we can use this tool to test theories about dark matter or other exotic particles that might leave fingerprints on those spectral distortions we see in the CMB.
Vera: It’s a bridge, really, between the abstract math of particle physics and the actual observable light coming from space. It’s turning theoretical ideas into something concrete you can test with real telescope data.
Jocelyn: And they give us these tools, like visibility functions for different shapes and correction terms, so we can really probe different physical effects imprinted on that spectrum.
Subrahmanyan: It’s a practical way to use AI to manage the incredible complexity of coupled differential equations across timescales that are just too vast for traditional methods.
Vera: This package is a concrete way to explore how energy injection shapes the light we see today from those very first moments of cosmic history.
Jocelyn: And they’re setting up parallel processing so you can run many different historical scenarios at once using that run sweep tool, which opens up a whole new way to explore these possibilities.
Subrahmanyan: It gives us a robust framework for testing predictions about physics that happened way before we could ever directly observe it with other methods.
Vera: So this work is about taking the theoretical picture of cosmic evolution and turning it into a runnable calculation to see what kind of distortions we might expect from new physics.
Jocelyn: And the next step is taking these calculations and comparing them to actual observational data to see if they match what we measure out in the sky.
Boston University
astro-ph.CO, astro-ph.IM, cs.AI, hep-ph
Submitted: 2026-04-27
Updated: 2026-12-02
Comments: 35+21 pages, 12 figures, updated to match published version
Journal ref: SciPost Phys. Codebases 90 (2026)
DOI: 10.21468/SciPostPhysCodeb.90
Code: https://github.com/bakerem/spectroxide
License: http://creativecommons.org/licenses/by/4.0/
Importance score: 90/100
The gist: Spectroxide is a code package designed for computing cosmic microwave background (CMB) spectral distortions…
Key concepts
- Photon Occupation Number n(x)
- This represents the number of photons present at a specific frequency (x) in the cosmic microwave background. The solver tracks how this number changes over time and redshift as photons scatter, are created, or are injected into the system.
- Coupled Scattering Processes
- The evolution of n(x) is governed by three linked physical processes: Compton scattering, double Compton emission (DC), and Bremsstrahlung (BR). These interactions depend on the electron temperature ($T_e$), creating a complex feedback loop in how the photon spectrum evolves.
- Spectral Distortion Models
- The resulting distortion ($\Delta n$) is modeled as a combination of temperature-shift, $\mu$ (chemical potential), and $y$ (adiabatic) types. The package uses a specific formulation to fit these shapes, allowing extraction of the physical Bose-Einstein chemical potential ($\mu$) from observational data.
Terminology
Summary
Spectroxide is a code package designed for computing cosmic microwave background (CMB) spectral distortions, developed under human physicist supervision with AI assistance (Claude Code) to write approximately 14,500 lines of Rust code, a Python interface, and about 400 automated tests. p. 0 edu ¶ smishras@bu. edu
Abstract
We present spectroxide, a code package for computing cosmic microwave background spectral distortions in which all ∼14,500 lines of Rust code, Python
interface, and ∼400 automated tests were written by an AI assistant (Claude
Code) under human physicist supervision. edu
Abstract
We present spectroxide, a code package for computing cosmic microwave background spectral distortions in which all ∼14,500 lines of Rust code, Python
interface, and ∼400 automated tests were written by an AI assistant (Claude
Code) under human physicist supervision. The solver evolves the photon
Boltzmann equation under Compton scattering, double Compton emission,
and Bremsstrahlung from z ∼ 5 × 106
to the present, computing spectral distortions from arbitrary heat and photon injection within this redshift range.Where the paper says it
Where the paper says it
The physical problem is modeled by evolving the photon occupation number n(x) under three coupled scattering processes—Compton, DC, and BR—which are linked through the electron temperature T e. p. 4 The stiffness of these rates, combined
with the Compton near-cancellation, makes the system difficult to integrate (Appendix B). The three scattering processes are coupled through the electron temperature Te. spectroxide evolves ∆n(x, z) on a non-uniform frequency grid from an initial redshift zstart
(chosen to capture the full injection history) down to the present day. At each redshift
step, the solver: (i) updates the free electron fraction Xe(z) from a Peebles three-level
atom model [45, 46]; (ii) determines Te self-consistently from the current ∆n and heating
rate; and (iii) advances ∆n by one coupled Compton + DC/BR time step using the scheme
described in Appendix B. spectroxide evolves ∆n(x, z) on a non-uniform frequency grid from an initial redshift zstart
(chosen to capture the full injection history) down to the present day. At each redshift
step, the solver: (i) updates the free electron fraction Xe(z) from a Peebles three-level
atom model [45, 46]; (ii) determines Te self-consistently from the current ∆n and heating
rate; and (iii) advances ∆n by one coupled Compton + DC/BR time step using the scheme
described in Appendix B.Where the paper says it
Where the paper says it
Where the paper says it
Energy conservation is maintained to sub-percent accuracy through two mechanisms: (i) the implicit time-stepping conserves energy to high accuracy by construction, and (ii) a number-conserving temperature-shift subtraction removes the unobservable G bb component arising from DC/BR photon creation, preventing feedback into rho e and degrading energy balance. p. 1 4 Adaptive redshift stepping 44
B. 5 Energy conservation and temperature-shift subtraction 44
B. Because Compton scattering conserves photon
number but redistributes energy, the equilibrium temperature generally differs from Tγ,
absorbing part of the injected energy as an unobservable temperature shift. Expanding to
first order in ∆T /Tγ and µ gives
nBE − npl ≈
∆T
Tγ
−
µ
βµ
Gbb(x) + µ M(x), (5)
where the first term is a temperature shift (unobservable, as discussed above) and
M(x) =
x
βµ
− 1
e
x
(e
x − 1)2
(6)
is the observable µ-distortion spectral shape, with βµ = 3ζ(3)/ζ(2) ≈ 2. SciPost Physics Submission
injection after this epoch instead imprints slight deviations from the Planck spectrum. These spectral distortions encode the thermal history of the universe from z ∼ 2 × 106
to
the present, providing information complementary to CMB anisotropies and large-scale
structure [3, 4]. (15) but now includes the present-day
value (assuming that T ∝ (1 + z) at all times) of the velocity-dependent cross section. The flatter redshift scaling compared to s-wave shifts the energy injection toward higher
redshifts, producing a more µ-dominated spectrum.Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
The solver yields a numerical delta n(x) that is a mixture of temperature-shift, mu -, and y-type distortions, plus a residual component. p. 6 192 fixed by photon
number conservation (R
x
2M dx = 0). After stripping the unobservable temperature shift,
the residual distortion is ∆n ≈ µ M(x). There are no
restrictions on the functional form: the solver handles oscillatory profiles, sharp peaks,
broad power laws, and profiles with regions of net cooling, as demonstrated by the stress
tests in Sec. The returned result object contains the frequency grid x, the spectral
distortion ∆n(x), and the decomposed distortion parameters µ, y, and ∆T /T extracted
via the least-squares decomposition described in Appendix B. When Te > Tγ, electrons up-scatter photons, transferring
energy into the photon field. Because Compton scattering conserves photon number, it
can establish a Bose–Einstein distribution but cannot relax the chemical potential µ to
zero, which instead requires DC and BR. It is important to note that this picture applies to small distortions where ∆ρ/ρ ≪ 1; for
larger energy releases, nonlinear effects modify the thermalization process [12, 48], which
we do not model in this work. More generally, any spectral distortion ∆n(x) contains an unobservable temperatureshift component proportional to Gbb(x). There are no
restrictions on the functional form: the solver handles oscillatory profiles, sharp peaks,
broad power laws, and profiles with regions of net cooling, as demonstrated by the stress
tests in Sec. The returned result object contains the frequency grid x, the spectral
distortion ∆n(x), and the decomposed distortion parameters µ, y, and ∆T /T extracted
via the least-squares decomposition described in Appendix B. When Te > Tγ, electrons up-scatter photons, transferring
energy into the photon field. Because Compton scattering conserves photon number, it
can establish a Bose–Einstein distribution but cannot relax the chemical potential µ to
zero, which instead requires DC and BR.Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
Spectroxide is implemented in Rust with zero production dependencies and wrapped in a Python interface requiring no compilation. p. 3 SciPost Physics Submission
tortion solver, written in Rust with zero production dependencies. The code handles heat
and photon injection, and is validated against analytic limits, Green’s function approximations [24,28,38], and CosmoTherm public results where available across all thermalization
regimes (Sec. Sections 3 and 4 describe
the two injection mechanisms implemented in spectroxide—heat injection and photon
injection—including how each enters the PDE solver and the specific scenarios supported. Section 5 validates the code against analytic limits, spectral shapes, Green’s
function approximations, and tabulated Green’s functions provided by CosmoTherm. The omission is accurate for xinj ≫ 1
where npl is exponentially small; for xinj ≲ 1 the (1 + npl)
2
correction becomes significant
(npl ≈ 1/xinj, so the missing factor grows as 1/x2
inj) and should be included via the custom
photon source interface described below. More generally, electromagnetic cascades (pair
production, photon splitting), interactions with nuclei, and secondary photon production
are not modeled; these effects become important for high-energy injection (ω ≳ me) and
are left to future work. SciPost Physics Submission
tortion solver, written in Rust with zero production dependencies. The code handles heat
and photon injection, and is validated against analytic limits, Green’s function approximations [24,28,38], and CosmoTherm public results where available across all thermalization
regimes (Sec. 7 Convergence tests 46
B. 8 Performance 46
C Code architecture and usage 47
C.Where the paper says it
Where the paper says it
Where the paper says it
Where the paper says it
run sweep, which parallelizes across injection redshifts using all available cores. The C code architecture is modular, with dedicated modules for each physical process (e. p. 1Where the paper says it
kompaneets.rs, double compton.rs, bremsstrahlung.rs) and test-driven development covering over 400 automated tests, including PDE convergence checks.
Green — the paper says it, and the page is printed. Red — no passage carries it, so treat that sentence as unverified. The same check runs on your own text: check a summary against its source, $5.
Improvements for AI systems
-
Implement independent source validation in testing by requiring
Expected values must come from analytic limits, literature, or dimensional analysis
to prevent tests calibrated to code output from detecting systematic errors (Bug 1). -
Integrate mandatory dimensional checks before numerical output by instructing the system to verify that
the BR emission coefficient KBR must be dimensionless after Thomson time normalization,
catching errors like the spurious division by ne (Bug 1). -
Require a persistent memory file tracking
conventions, known bugs, and decisions made in previous sessions
to prevent drift across development sessions and ensure continuity for complex codes. -
Introduce specialized subagents for adversarial review, framing the task as finding flaws in code written by someone else to leverage sycophancy toward bug detection rather than away from it.
-
Enforce a strict testing philosophy where
every test target must be derived from an independent source (analytic limits, literature values, or dimensional analysis), never from the code's own output
to eliminate self-calibrated tests that pass due to internal consistency (Bug 1).
Abstract
We present spectroxide, a code package for computing cosmic microwave background spectral distortions in which all about 12, 000 lines of Rust code, Python interface, and over 950 automated tests were written by an AI assistant (Claude Code) under human physicist supervision. The solver evolves the photon Boltzmann equation under Compton scattering, double Compton emission, and Bremsstrahlung from z about 5 times 10 6 to the present, computing spectral distortions from arbitrary heat and photon injection within this redshift range. No fully open-source code of this kind is publicly available; we validate against analytic limits, published spectra, and publicly available precomputed Green's function tables. We document the development as a case study in AI-assisted scientific computing, highlighting how domain expertise caught physics bugs (incorrect dimensional prefactors, near-cancellation errors) that evaded the full automated test suite, and document the practices and validation methodology we found effective for human--AI collaborative development of scientific software. We make spectroxide publicly available on GitHub.
Sources
- Science with CMB spectral distortions
- New Horizons in Cosmology with Spectral Distortions of the Cosmic Microwave Background
- Taking the Universe's Temperature with Spectral Distortions of the Cosmic Microwave Background
- Rich structure of non-thermal relativistic CMB spectral distortions from high energy particle cascades at redshifts $z\lesssim 2\times 10^5$
- New CMB spectral distortion constraints on decaying dark matter with full evolution of electromagnetic cascades before recombination
- Exotic energy injection in the early universe II: CMB spectral distortions and constraints on light dark matter
- Dark Photon Oscillations in Our Inhomogeneous Universe
- Modeling Dark Photon Oscillations in Our Inhomogeneous Universe
- Revisiting Dark Photon Constraints from CMB Spectral Distortions
- Shaping Dark Photon Spectral Distortions
- Constraints on primordial magnetic fields from CMB distortions in the axiverse
- Polarized anisotropic spectral distortions of the CMB: Galactic and extragalactic constraints on photon-axion conversion
- Revisiting Constraints on Resonant Axion-Photon Conversions from CMB Spectral Distortions
- CMB spectral distortions constraints on primordial black holes, cosmic strings and long lived unstable particles revisited
- Constraints on the spectral signatures of superconducting cosmic strings
- A Limit on Primordial Small-Scale Magnetic Fields from CMB Distortions
- Probing early-universe phase transitions with CMB spectral distortions
- BISOU: a balloon project to measure the CMB spectral distortions
- SPECTER: An Instrument Concept for CMB Spectral Distortion Measurements with Enhanced Sensitivity
- Teasing bits of information out of the CMB energy spectrum
Related papers
- Dark Energy Survey Year 3 results: optimized w CDM simulation-based inference with weak lensing map-level hybrid statistics
- 21cmEMUv3: a hybrid diffusion-LSTM emulator of 21cmFAST summary observables
- Simulation-Based Priors and BAO Shifts from the Lyman- alpha Forest at the Field Level
- Improved constraints on axion inflation with the new code AxioGen: an efficient generator of curvature perturbations
- Connecting field-level and n-point function measurements of galaxy bias
- The Impact of Cosmic Variance and Satellites on JWST Clustering Measurements at Redshift around 6