2pir

Farey

<!DOCTYPE html>

Nested Farey Channels & Fractional-Slice Coprimality - Wessen Getachew

Nested Farey Channels & Fractional-Slice Coprimality Heuristic

Wessen Getachew
October 2025
Explore more prime visualizations: GCD Patterns | Prime Spirals | Epsilon Pi Calculator
Abstract. We introduce the Nested Farey Channel Framework, a geometric representation of modular arithmetic on the unit circle, and develop two complementary heuristics for primality analysis. The Fractional-Slice Coprimality Heuristic provides rapid probabilistic prime detection by sampling coprime residues within restricted circular arcs, while the Chord Length Uniformity Heuristic offers an independent geometric signature based on inter-residue spacing. Each modulus m maps to m equidistant points at angles 2πr/m. Prime moduli exhibit maximal channel openness and uniform chord distributions, while composites show blocked Farey channels and irregular spacing. Extensive empirical validation across n ∈ [3, 10,000] reveals separation increasing from 32.7% to 92.3%, demonstrating robust scalability and asymptotic optimality. We prove formal bounds, derive decision thresholds, and provide interactive demonstrations with publication-quality visualizations featuring 10 coloring schemes and 4K export capabilities.
Part I: Nested Farey Channels Framework
Definition 1.1 (Channel Rings). For a modulus mN, define the ring Sm={e2πir/m:r=0,1,,m1}. Each element corresponds to a residue class r(modm) visualized on the unit circle.
Definition 1.2 (Open and Blocked Channels). A channel Cr,m is said to be: Cr,m={open,if gcd(r,m)=1,blocked,otherwise. The set of open channels has cardinality φ(m), Euler's totient function.
Proposition 1.3 (Prime Channel Completeness). For a prime modulus p, every residue r{1,2,,p1} satisfies gcd(r,p)=1. Thus Sp forms a maximally open ring with φ(p)=p1 open channels and a single blocked channel at r=0.
Modulus:13
Open Channels:12
Blocked Channels:0
Density δ(m):0.9231
Is Prime:Yes ✓
Figure 1: Channel ring visualization showing open (green) and blocked (red) channels
Part II: Fractional-Slice Coprimality Heuristic
2.1 Heuristic Definition

For any modulus m2, define the coprime density

δ(m)=φ(m)m,

the fraction of residues mod m that are coprime to m. For a prime p, this equals δ(p)=11p.

Definition 2.1 (Fractional Slice). Let S(m){1,2,,m1} denote a chosen sampling region, such as the half-circle Shalf(m)={1,,m/2} or a one-nth slice of residues distributed over 2π/n radians. The slice captures a geometric subset of the modular ring. Define δS(m)=|{rS(m):gcd(r,m)=1}||S(m)| as the local coprime density within that slice.
Sampling Rule. Sample k residues r1,,rk uniformly from S(m). If every sampled residue satisfies gcd(ri,m)=1, declare m a prime candidate under the fractional-slice test.
2.2 Probabilistic Bound

Assuming independent sampling, the probability of a composite m passing the test is approximately

Pr(passm)δS(m)k.

Proposition 2.2 (Fractional-Slice Coprimality Bound). Let m2 and let S{1,,m1} be a fixed sampling subset of size |S|. If a random residue rS is coprime to m with probability δS(m), then for k independent samples (with replacement), Pr(passm)=δS(m)k. If q is the smallest prime factor of m, then Pr(passm)(11q)k.

This yields the following key behavior:

  • For even composites (q=2): Pr(pass)(1/2)k
  • For q=3: Pr(pass)(2/3)k
  • For semiprimes with large factors (q1): the bound weakens, requiring larger k

Thus the heuristic strongly rejects composites with small factors, and becomes probabilistically weaker only for products of large primes.

2.3 Slice Dependence and Symmetry
Proposition 2.3 (Half-Circle Neutrality). For the half-circle slice, mirror symmetry ensures δhalf(m)=δ(m), since gcd(r,m)=gcd(mr,m). Hence the half-circle is a neutral choice that avoids residue bias.
3. Interactive Algorithm Demonstration
Test the Heuristic: Enter a modulus, choose sampling parameters, and watch the fractional-slice algorithm in action. The visualization shows which residues are tested and whether they pass the coprimality check.

Fractional-Slice Coprimality Test

Result: FAIL ✗ - 91 is composite (detected)
Modulus:91
Actual Status:Composite
Samples Tested:5
Passed Samples:4/5
Smallest Factor:7
Theoretical Pass Prob:0.4627

Test History

Single Test: m=91, k=5 11/8/2025, 5:32:14 AM
Result: PASS ✓ | Composite | Density: 0.7912
Details:
Samples: 5/5
Smallest Factor: 7
Theoretical Prob: 0.4627
Slice Type: half
4. Algorithmic Formulation
Algorithm 4.1 (Deterministic + Randomized Hybrid Filter).
function is_prime_candidate(m, k, slice="half", 
                           small_primes=[2,3,5,7,11,13]):
    // (1) Deterministic prefilter by small primes
    for q in small_primes:
        if m % q == 0 and m != q:
            return False
    
    // (2) Choose slice
    if slice == "half":
        S = {1, 2, ..., floor(m/2)}
    else if slice == "quarter":
        S = {1, 2, ..., floor(m/4)}
    else:
        S = {1, 2, ..., m-1}
    
    // (3) Random sampling
    for i in 1..k:
        r = random_choice(S)
        if gcd(r, m) != 1:
            return False
    
    return True  // passes fractional-slice test

The parameter k governs tradeoff between false-positive rate and computational cost. For a target false positive probability ε and smallest divisor threshold Q, choose

klogεlog(11/Q).

5. Experimental Evaluation

Large-Scale Empirical Testing

6. Geometric Interpretation and Concentric Rings

The fractional-slice heuristic can be visualized in two complementary ways: on the unit circle, and as a 2D plane of concentric rings.

6.1 Unit Circle Representation

Map each residue r{1,2,,m1} to the point

zr=e2πir/m.

Coprime residues lie on "open channels" that avoid blocked directions determined by the factors of m.

Angular Slices. Selecting a subset S(m) of size |S| corresponds to choosing an arc θ[2πr0m,2π(r0+|S|)m) on the unit circle.
  • Half-circle: |S|=m/2, spanning π radians.
  • One-nth slice: |S|=m/n, spanning 2π/n radians.

Blocked Farey channels appear as gaps along the arc where gcd(r,m)>1. Prime moduli maximize the fraction of occupied (coprime) points in every slice; composites produce visible voids aligned with their divisors.

Farey Sequence Connection: Positions of blocked residues correspond to fractions r/m reducible to lower terms, forming a subset of the Farey sequence Fm. Partial sampling of the circle thus samples a fractional Farey subsequence, producing a geometric signature for primality.
6.2 Concentric Ring Visualization

The unit circle can be extended to a 2D plane of concentric rings to capture the nested structure of residues for multiple moduli.

  • Let each ring correspond to a modulus m.
  • Place the points zr=e2πir/m on the ring of radius proportional to m.
  • Coprime residues are marked (filled dots), blocked residues are shown differently.

Concentric Rings: Nested Farey Structure

Resolution:
2px
0°
0°
0°
Hue=angle, Saturation=gcd, Brightness=slice
Visibility:
GCD=1 Labels:
24px
Figure 2: Concentric rings showing nested Farey channel structure across multiple moduli
Interpretation:
  • Each ring shows the local coprimality pattern for a single modulus.
  • Nested rings reveal how Farey channels propagate across successive moduli.
  • Angular gaps (blocked channels) align radially, illustrating the "nested" property: blocked residues of smaller divisors project outward to higher moduli.
Visualization Principle. By combining angular slices on the unit circle with concentric rings in 2D, we obtain a comprehensive geometric view: Prime moduli: full occupancy along slices and ringsComposite moduli: radial gaps aligned with factors. This representation underlies the fractional-slice heuristic and provides visual intuition for why primes maintain maximal channel openness, even when sampling only a fraction of the residues.
8. Chord Length Uniformity Analysis

Beyond fractional-slice sampling, we can analyze the geometric uniformity of coprime residues by measuring chord lengths between consecutive points on the unit circle. This provides an independent geometric signature for primality.

Chord Length. For consecutive coprime residues ri,ri+1Rn, the Euclidean chord length on the unit circle is: Li=2sin(πri+1rin) with wrap-around chord Lϕ(n)=2sin(πr1+nrϕ(n)n).
Proposition 8.1 (Chord Uniformity Heuristic). Prime moduli produce more uniform chord length distributions than composite moduli.

Quantification: Define the coefficient of variation CV(n)=σLμL where σL is the standard deviation and μL is the mean of all chord lengths.

Empirical Results: Extensive validation across multiple ranges:

Range Prime Avg CV Composite Avg CV Separation Significance
n ≤ 50 0.183 0.272 32.7% p < 0.001
n ≤ 100 0.155 0.297 47.6% p < 0.001
n ≤ 500 0.086 0.307 71.9% p < 0.0001
n ≤ 1,000 0.065 0.304 78.7% p < 0.0001
n ≤ 10,000 0.022 0.292 92.3% p < 0.0001

Key Findings:

  • Monotonic Increase: Separation grows from 32.7% to 92.3% as range increases
  • Asymptotic Behavior: Prime CV → 0 while composite CV remains ~0.3
  • Perfect Recall: 100% detection rate for primes (0 false negatives)
  • Scalability: Tested feasibly up to n=10,000; practical to n=100,000+
Geometric Interpretation: Primes distribute coprime residues nearly uniformly around the circle, producing consistent chord lengths. Composites create clustering (dense regions) and gaps (sparse regions), increasing chord length variance. The gap ratio max(Li)/min(Li) also distinguishes primes (avg 1.87) from composites (avg 2.02).

Extended Validation: Testing up to n=10,000 reveals that separation increases monotonically with range, suggesting asymptotic optimality: as n, CVprime0 while CVcomp remains bounded near 0.3, implying theoretical separation approaching 100%.

Chord Length Analysis

Figure 3: Chord length distribution reveals geometric uniformity — primes show lower variance
Algorithm 8.1 (Chord Uniformity Test).
1. Input: modulus n
2. Compute coprime residues R_n = {r : gcd(r,n)=1, 1≤r<n}
3. For each consecutive pair (r_i, r_{i+1}):
     L_i = 2·sin(π·(r_{i+1}-r_i)/n)
4. Compute statistics:
     μ_L = mean(L_i)
     σ_L = std_dev(L_i)
     CV = σ_L / μ_L
     gap_ratio = max(L_i) / min(L_i)
5. Decision thresholds (range-dependent):
     For n ≤ 100:    CV < 0.22 → likely prime
     For n ≤ 500:    CV < 0.15 → likely prime
     For n ≤ 1000:   CV < 0.12 → likely prime
     For n > 1000:   CV < 0.30/√(n/100) → likely prime
     Universal:      CV > 0.27 → likely composite
     Ambiguous zone: thresholds provide classification confidence
6. Return CV, gap_ratio, uniformity_score = 1/CV, verdict
            
9. Failure Modes and Limitations
  • Semiprime leakage: Composites with large prime factors can pass the test.
  • Carmichael-like pseudoprimes: These may evade simple gcd-based filtering.
  • Slice bias: Improper slice selection can undercount blocked channels.

The heuristic is therefore best used as a rapid prefilter prior to a deterministic or probabilistic primality test (e.g., Miller–Rabin).

10. Conclusion

Fractional-slice coprimality sampling provides a geometric and probabilistic bridge between Nested Farey Channel theory and practical number testing. It captures the essential property that prime moduli maintain maximal channel openness even when viewed through restricted arcs of the unit circle, while composites introduce blocked Farey channels visible through partial sampling.

This heuristic can serve both as:

  1. A fast preliminary screen for prime candidates within modular sieves.
  2. A geometric diagnostic tool for visualizing the distribution of coprime residues across modular arcs.

Further work includes: quantifying slice bias functions βS(m), linking partial-channel openness to residue equidistribution, and integrating this fractional sampling into the modular sieve hierarchy for scalable prime detection.

Interactive paper by Wessen Getachew, October 2025

Full framework implementation with live algorithm demonstrations