# z5cube — shared Z5^3 (125-site) character / circulant / E47 tools

Shared by Nick's agents (HEPData cert, CERN Spectral, Spectral Fabric). numpy only.
Use: `import sys; sys.path.insert(0, "path/to/z5cube"); import z5cube as z`
Tests: `python3 tests/test_z5cube.py` (all PASS 2026-11-28).
Tip: set `OMP_NUM_THREADS=1` — on this box multithreaded BLAS makes the 125x125 ops ~100x slower.

## Conventions
* **Sites**: `itertools.product(range(5), repeat=3)`, flat index `i = 25*x1 + 5*x2 + x3` (= C-order reshape to (5,5,5)).
* **Characters**: `chi_k(x) = 125^(-1/2) exp(2πi k·x/5)`, k in the same lexicographic order. Coefficients
  `c_k = <chi_k, f>` = `np.fft.fftn(f.reshape(5,5,5), norm="ortho")` (unitary, Parseval).
* **Circulant**: `A[x,y] = a(x−y mod 5)`; eigenvalue on chi_k is `λ_k = Σ_d a(d) e^{−2πi k·d/5}` = `np.fft.fftn(a)`.
* **FCC Laplacian**: 12 neighbours ±{e1,e2,e3,e1−e2,e1−e3,e2−e3}; gap γ = (15−3√5)/2 ≈ 4.145898 (multiplicity 8).
* **Internal carrier** V2⊗V2⊗V2 ≅ C^125, same index, site digit x_i ↔ m_i = 2 − x_i (commutant.py convention).
  CERN Spectral's z5lattice uses m = x − 2; the reflection commutes with C so **P47 is identical** (max diff 1.7e-15).
* **E47** = ker K, K = (C−6I)(C−30I), C total Casimir ⇒ E47 = E(J=2) ⊕ E(J=5), dim 25+22 = 47.
  P47 is **not** translation-invariant (not a set of characters).
* **constant ⊗ E47**: on ℓ²(Z5^3) ⊗ (V2)^⊗3 = C^125 ⊗ C^125 (space first, internal second; array `F[x, a]`),
  `ker D = <u0> ⊗ E47`, `D = L_FCC ⊗ I + I ⊗ K²`, `P0 = |u0><u0| ⊗ P47`, u0 = 1/√125.
* Constants: `GAP_K2 = 11664`, `LAMBDA_MAX_K2 = 186624`, `RHO_STAR = 15/17`, `GAP_FCC = GAP_D = (15−3√5)/2`.
* Sources: E47-Kartekeya@e9be2dee `website/interfaces/fcc-e47-spatial-lift/index.html` L24–29;
  auth-kernel `e47-spectral-kernel/README.md` L9–17; E47-Kartekeya `website/citizens/citizens.json` L141 (machine_validated: false).

## API
| module | function | what |
|---|---|---|
| characters | `sites()`, `site_index(x)` | (125,3) site array; flat index |
| | `character_table()` | 125×125 unitary X[k,x] |
| | `to_characters(f)`, `from_characters(c)` | unitary FFT and inverse |
| circulant | `circulant_matrix(a)`, `symbol(a)`, `apply_circulant(a,f)` | build / diagonalize / apply any Z5^3-invariant operator from its kernel |
| | `fcc_kernel()`, `fcc_laplacian()`, `fcc_spectrum_exact()` | FCC Laplacian and exact (p+q√5)/2 spectrum |
| | `is_translation_invariant(M)` | diagonal-in-characters test |
| projectors | `casimir()`, `selector_K()`, `E47_basis()`, `P47()`, `P_const()` | internal operators |
| | `project_const_E47(F)`, `residual_const_E47(F)` | P0 F and ‖F−P0F‖/‖F‖ for F (125,125) |
| | `residual_internal(f)` | ‖(I−P47)f‖/‖f‖ for a single 125-vector |
| | `apply_D(F)`, `rayleigh_D(F)` | D action (FFT-fast), Rayleigh quotient |
| | `heat_residual_curve(F, ts)` | ‖e^{−tD}F − P0F‖ (exact spectral formula) |


---
**Hubs:** [Public App Index](https://gem-sunny-beacon-mountain.grok.me/) · [Instruments](https://nicholaskouns-create.github.io/instruments/) · [E47 Identity](https://nicholaskouns-create.github.io/e47-identity/) · [E47-Kartekeya](https://github.com/nicholaskouns-create/E47-Kartekeya)
