A from-scratch, pure-Wolfram-Language implementation of persistent homology applied to the cosmic web — the network of galaxy clusters, filaments, sheets and voids that fills the large-scale Universe.
The post takes a 3D galaxy catalogue (a slice of the SDSS DR17 spectroscopic sample plus a log-normal Wolfram-native mock), builds an alpha complex from a Delaunay tetrahedrization, and reduces its boundary matrix to extract persistence pairs in degrees 0, 1 and 2. The resulting bars are the homological signature of the cosmic web:
| feature | persistent class | what it picks out |
|---|---|---|
| clusters | H₀ (long bar) | dense knots where galaxies merge into one component |
| filament loops | H₁ (long bar) | wedding-cake-shaped 1-D holes in the filament graph |
| voids | H₂ (long bar) | underdense regions enclosed by a sheet of galaxies |
- Pulls a real-data galaxy slice — SDSS DR17 spectroscopic galaxies from the SkyServer SQL service, in a thin redshift / sky window, converted to comoving Mpc/h via a flat-ΛCDM line-of-sight integral.
- Generates a Wolfram-native mock — a log-normal density field on a periodic 3D grid (Coles & Jones 1991), Poisson-sampled to give a noise-free "ground truth" cosmic web that the same pipeline can be tested against.
- Implements persistent homology from scratch in Wolfram Language:
- alpha complex via
DelaunayMesh+ per-simplex circumradius filtration (wolfram/alpha_complex.wl); - standard GF(2) column-reduction of the boundary matrix
(
wolfram/persistence.wl).
- alpha complex via
- Cross-checks the engine against
ResourceFunction["PersistentHomology"]and against analytic Betti numbers of reference shapes (circle, sphere, torus, Swiss cheese) intests/ph_sanity.wls. - Renders the publication figures — 3D galaxy scatter, persistence
diagrams, barcodes, Betti curves — and assembles a single
Wolfram Community notebook (
community/cosmic_ph.nb).
3D filament networks built from the alpha-complex 1-skeleton at the percentile cut where the graph first percolates — mock (left) and SDSS DR17 (right):
Anatomy of a persistence diagram (left) and side-by-side comparison with the literature filament-scale measurements (right):
Two complementary TDA summaries of the same point cloud — the
persistence diagram from the alpha complex (left) and the Mapper graph
from BuildMapper (right):
homologyoncosmicfilaments/
├── wolfram/ pure-WL pipeline
│ ├── alpha_complex.wl PH engine — filtration
│ ├── persistence.wl PH engine — reduction
│ ├── cosmology.wl flat-ΛCDM comoving distance
│ ├── load_data.wl CSV / JSON loaders
│ ├── fetcher_common.wl URLRead helpers
│ ├── fetch_sdss.wls SDSS DR17 SkyServer query
│ ├── mock_galaxies.wls log-normal Poisson mock
│ ├── reference_shapes.wls teaching figures (sphere / torus / cheese)
│ ├── filaments.wls PH on the galaxy catalogues
│ ├── fetch_all.wls one-shot data driver
│ └── run_all.wls one-shot figure driver
│
├── data/ tidy CSVs (committed)
│ ├── sdss_slice.csv
│ ├── mock_galaxies.csv
│ ├── persistence_sdss.csv
│ ├── persistence_mock.csv
│ └── raw/ bulk downloads (git-ignored)
│
├── community/ publication artefact
│ ├── build_notebook.wls assembles cosmic_ph.nb + .pdf
│ ├── cosmic_ph_helpers.wl cell + figure helpers
│ ├── images/ rasterized embedded figures
│ ├── cosmic_ph.nb the post
│ └── cosmic_ph.pdf rendered PDF
│
├── docs/
│ └── images/ figures referenced from README + notebook
│
└── tests/
└── ph_sanity.wls correctness checks
# 1. Fetch the SDSS slice and write the log-normal mock to data/
wolframscript -file wolfram/fetch_all.wls
# 2. Run the full figure pipeline: reference shapes, intuition figs,
# animation, walkthrough, and PH on both catalogues
wolframscript -file wolfram/run_all.wls
# 3. Sanity tests (circle / sphere / torus + RF cross-check)
wolframscript -file tests/ph_sanity.wls
# 4. Assemble the Wolfram Community notebook
wolframscript -file community/build_notebook.wlsTotal wall time on an M-series Mac: ~90 s for steps 1-3 plus ~10 s for the notebook build. The committed CSVs and PNGs make every step optional; the notebook builds even with no internet access.
The notebook embeds these PNG / GIF figures (under docs/images/):
| family | files | story |
|---|---|---|
| intuition | intuition_betti.png, intuition_rips_filmstrip.png |
gentle TDA intro for cosmologists |
intuition_alpha_filmstrip.png, intuition_persistence_anatomy.png |
alpha complex + annotated diagram | |
intuition_cosmic_web_legend.png |
cosmic-web slice with structures labelled | |
| animation | anim_alpha_growth.gif, anim_alpha_filmstrip.png |
live alpha filtration with \[Beta]\_1 counter |
| walkthrough | walk_alpha_snapshots.png, walk_matrix.png |
algorithm steps on a 10-point decagon |
| ref shapes | ref_circle.png, ref_sphere.png, ref_torus.png, ref_cheese.png |
analytic Betti-number cross-checks |
| mock | mock_density_slice.png, mock_scatter.png, mock_diagram.png |
log-normal cosmic-web mock |
mock_barcode.png, mock_betti.png, mock_hero.png |
||
| SDSS | sdss_scatter.png, sdss_diagram.png, sdss_barcode.png |
real galaxy slice from SDSS DR17 |
sdss_betti.png, sdss_hero.png |
- Wolfram Language 14.0+ (built and tested on 15.0).
- Internet access only for step 1 (SDSS SkyServer). The committed CSVs let everything else run offline.
Given
Active. Target publication: Wolfram Community before end of May 2026.
- ENSO-emergence — the notebook-build pipeline this repo's structure mirrors.
- BifurcationAutoWL —
WL idioms (
asRaster, cell helpers) reused here.






