🇩🇪 Deutsch
← Back to Hub

🔧 Algorithm Workflows

Step-by-step functionality of both approaches

⚡ T0 Period Finding - Workflow

Overview

The T0 algorithm performs period finding to determine factors of composite numbers. The implementation uses adaptive ξ-strategies for different number types and operates with rational arithmetic.

T0 Factorization Process
  • 1
    Input Validation and ξ-Strategy Selection
    The number is categorized (twin_prime, cousin_prime, etc.) and the corresponding ξ-strategy is selected.
    xi_strategy = self._select_optimized_xi_strategy(n) xi_value = self.xi_profiles[xi_strategy]
  • 2
    Trivial Factor Check
    Check for simple factors using small primes (2, 3, 5, 7) via GCD.
    for basis in [2, 3, 5, 7]: if math.gcd(basis, n) > 1: factor = math.gcd(basis, n) return [factor, n // factor]
  • 3
    Period Search with Resonance Evaluation
    For each base, periods are systematically searched and evaluated using the selected ξ-strategy.
    for r in range(2, max_periods): if pow(a, r, n) == 1: # Period found resonance = self._calculate_resonance(r, xi_value) if resonance > threshold: return self._extract_factors(a, r, n)
  • 4
    Factor Extraction
    When a suitable period is found, factors are extracted via x = a^(r/2) mod n.
    x = pow(a, period // 2, n) f1 = math.gcd(x - 1, n) f2 = math.gcd(x + 1, n) if 1 < f1 < n: return [f1, n // f1]

ξ-Strategy Selection Details

Decision Logic

IF |p - q| = 2
→ twin_prime_optimized (ξ = 1/50)
IF |p - q| ≤ 6
→ cousin_prime (ξ = 1/100)
IF n > 1000
→ medium_size (ξ = 1/1000)
ELSE
→ universal (ξ = 1/100)

🎼 Harmonic Factorization - Workflow

Overview

Harmonic factorization recognizes musical intervals in number ratios. It uses hierarchical 4-level search with logarithmic octave reduction and Euler's Gradus Suavitatis.

Harmonic Factorization Process
  • 1
    Find Factors
    Classical factor search using trial division up to √n.
    for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: return (i, n // i)
  • 2
    Calculate Ratio and Octave Reduction
    The ratio max(factors)/min(factors) is calculated and reduced to the base octave.
    ratio = max(factors) / min(factors) while ratio >= 2.0: ratio /= 2.0 octave_shift += 1
  • 3
    Level Prediction
    Based on maximum prime and ratio value, the optimal hierarchy level is predicted.
    if max_prime <= 7: level = 1 # BASIS elif max_prime <= 19: level = 2 # EXTENDED elif max_prime <= 31: level = 3 # COMPLEX else: level = 4 # ULTRA
  • 4
    Hierarchical Harmony Search
    The harmony levels are searched in optimal order, starting with the predicted level.
    for level_idx in search_order: for ratio, interval in level.intervals: cents_deviation = abs(1200 * log2(target_ratio / ratio)) if cents_deviation <= tolerance: return SUCCESS(interval, cents_deviation)
BASIS Level (95%)
Classical musical intervals: Unison (1:1), fifth (3:2), fourth (4:3), major third (5:4), etc. Handles the vast majority of cases.
EXTENDED Level (4%)
Jazz and modern harmonies: 11th harmonic (11:8), 13th harmonic (13:8), natural seventh (7:4). For more complex but recognizable ratios.
COMPLEX Level (0.9%)
Spectral music and microtonal: 29:16, 31:16, 25:16. Handles rare but mathematically interesting ratios.
ULTRA Level (0.1%)
Xenharmonic experiments: 37:32, 41:32, 61:32. For very large primes and experimental ratios.

🔄 Optimization Strategies for Both Approaches

Mathematical Bounds Filtering
Calculation of upper and lower bounds for valid ratios based on tolerance to reduce search time.
Cached Calculations
LRU cache for frequent octave reductions and logarithmic distance calculations using @lru_cache decorator.
Intelligent Search Order
Both approaches use prediction-based search optimization: T0 for ξ-strategies, Harmonic for level ordering.
Rational Arithmetic
Both use Fraction-based calculations to avoid rounding errors and guarantee deterministic results.

🎯 Differences Between Approaches

T0 Period Finding vs. Harmonic Ratio Search

T0 Period Finding: Searches for mathematical periods in modular arithmetic and evaluates them with ξ-parameters.

Harmonic Factorization: Directly analyzes the ratios between factors and maps them to musical intervals.

When to Use Which Approach?

For semiprimes with known properties:
→ T0 Period Finding (higher precision)
For unknown number ratios:
→ Harmonic Factorization (broader coverage)
For mathematical analysis:
→ Use both complementarily