← Back to Application
Collatz mod P - Help
This application visualizes Collatz-like processes modulo P as interactive graphs. It explores generalized sequences where odd numbers follow the rule Nx + M instead of the standard 3x + 1.
Mathematical Background
The Collatz conjecture involves iterating the function:
- If x is even: x → x/2
- If x is odd: x → 3x + 1
This application generalizes this to Nx + M for odd numbers and visualizes the resulting directed graph modulo P.
The graph represents the dynamics of this generalized Collatz function on residue classes modulo P. Each node represents a residue class [i] = {i + kP | k ∈ ℤ}, and edges represent the function transitions between these classes.
Parameters
- Modulo (P): The modular arithmetic base. All calculations are done modulo P.
- N: Multiplier for odd numbers (must be odd to ensure the function is well-defined)
- M: Additive constant for odd numbers (must be odd to ensure odd numbers map to even numbers)
- Shortcut: When enabled, applies (Nx + M)/2 instead of Nx + M for odd numbers. This simulates the "shortcut" optimization used in Collatz analysis, where since Nx + M is always even (when x is odd and N,M are odd), we can immediately divide by 2. This effectively combines two iteration steps into one.
Cycles
- Search: Find cycles in the current Collatz process
- Click cycle: Highlight the cycle path on the graph
Graph Interpretation
- Nodes: Represent residue classes modulo P, labeled 0 to P-1. Each node [i] represents all integers congruent to i modulo P.
- Edges: Represent function transitions between residue classes according to the generalized Collatz rules.
- Solid edges: Transitions from odd residue classes via Nx + M (or (Nx + M)/2 if shortcut is enabled)
- Dashed edges: Transitions from even residue classes via x/2
- Node colors indicate parity:
- When P is odd: All nodes are grey (parity is not well-defined since both even and odd numbers can belong to the same residue class)
- When P is even:
- White nodes: Even residue classes (contain only even numbers)
- Black nodes: Odd residue classes (contain only odd numbers)
Special Cases
When P is a power of 2, the graph becomes a De Bruijn graph, and the symmetrize function applies a special transformation based on binary representations.
Toys
- P→2P: Double the modulo while preserving layout
- 2P→P: Halve the modulo (P must be even)
- Symmetrize: Apply central symmetry (requires P to be a power of 2)
- Show Cycle: Manually input and highlight a specific cycle
← Return to Application