# Phylogenetic quartet (Jukes–Cantor) — exact Bayesian evidence (closed form in Q)

## The result

For the four-taxon Jukes–Cantor quartet under the exponential branch-length prior
(alpha = 1), the Bayesian evidence is an **exact rational number**:
Z(T; u, alpha) ∈ Q for all pattern counts u ∈ Z^15_{>=0} and alpha ∈ Q_{>0},
with denominator dividing 256^N · prod_e prod_{j=0}^{N} (j + alpha).

For the 20-site reference dataset u = {xxxx:10, xxyy:4, xyxy:2, xyyx:2, xxxy:1, xyzw:1}
on topology 12|34:

```
Z(12|34) =                8390002712695928886592363104613077773344802548241
           ---------------------------------------------------------------------------------------
           975764089122942807922559239182988593336005689311686648380848617182632879055070822400000
```

log Z(12|34) = -87.64924334921352951083970264655772400877 (40 d)

On the alternative topologies (13|24 and 14|23 are exactly equal by data symmetry):

```
Z(13|24) = Z(14|23) =      173020355441610359468376381550770727738294306819
           --------------------------------------------------------------------------------------
           487882044561471403961279619591494296668002844655843324190424308591316439527535411200000
```

log Z(13|24) = -90.83748304235128116508526548224139936558 (40 d)

**First exact phylogenetic Bayes factor:**
log[ Z(12|34) / Z(13|24) ] = 3.18823969313775165...

Verification: the exact-rational route (multi-prime CRT reconstruction) agrees with an
independent Gauss–Legendre 5-fold quadrature evaluation to **61.92 digits** on 12|34,
and to >= 58 digits on each alternative topology.

## The general evaluator

The general Z(T; u, alpha) is closed in the sense that an integer-coefficient
**contiguity recurrence of order 24, coefficient degree 19** (the GKZ/IBP shift in a
pattern count) transports 24 exact rational seeds to any alignment length in
O(24 N) rational operations. The 3-taxon order-(7,4) transport was verified to
78.46 / 79.19 digits at held-out alignment lengths n = 50 / 70; at n = 100 the direct
quadrature oracle collapses to 2.7 digits on the ~10^-66-peaked integrand while the
recurrence stays exact. Caveat: the order-24 recurrence is 27-row-overdetermined; it
was confirmed at a second independent prime (p = 2147483587, same order and degree
(r, d) = (24, 19)).

## Model extensions (all verified, 3-taxon probes)

- **GTR (general time-reversible):** Z ∈ Q(rates, pi, lambda) for every reversible
  model + Exp prior, via the tensor-resolvent identity. Verified at a generic rate
  point to 119.2 digits (225.4 digits at a second working precision). Example exact
  value (generic-rates probe with irreducible cubic eigenvalue field):
  Z = 8833624002186494814731721421681090361511812719223852032978968219985144988147
      / 15016215216752631591636391946435589967475001266061685104424343565151015593750000000.
- **Gamma(k) branch prior:** Z / Gamma(k)^{|E|} algebraic for rational k;
  k = 1/2 probe closed in pi^{3/2} Q(sqrt2, sqrt3, sqrt5), verified to 51.4 digits.
- **+Gamma rate heterogeneity (k = 1), single site, 3-taxon:**
  Z = (10 - 6 G)/64 with G = e·E_1(1) the Euler–Gompertz constant; verified to
  120.9 digits against an independent quadrature oracle that never used E_1. This is
  the first rung where Z leaves Q — into the exponential periods (Kummer
  U(1,1,lambda), irregular rank 1 at infinity), not the Fuchsian period ladder.

## Reproducing the numbers

The companion script `phylo-evaluate.py` (same download directory) recomputes all
three reference points at runtime from the kinematic inputs (pattern counts, prior
shape, topology), using only mpmath and the standard library: the exact rationals
Z(12|34), Z(13|24), Z(14|23) by Felsenstein pruning + exact expansion + exact edge
integration (and from them the Bayes factor), the GTR probe by the exact
tensor-resolvent solve, and the +Gamma point from G = e·E_1(1); each is gated live
against an independent oracle (5-fold Gauss–Legendre quadrature, spectral
eigendecomposition, E_1-free quadrature) with the agreement digits recomputed. The full pipeline — the exact-rational CRT evaluator,
the 15 multilinear pattern polynomials, the contiguity-recurrence machinery, and the
Landau-variety analysis — is described in the accompanying note linked from the
blog page.
