Skip to content

Commit 6f9f77d

Browse files
committed
docs: split README into three languages with per-language TOC
1 parent 180d8ce commit 6f9f77d

3 files changed

Lines changed: 640 additions & 84 deletions

File tree

‎README.en.md‎

Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
**Contents:**
2+
3+
- [Chinese](README.md)
4+
- [English](README.en.md)
5+
- [Japanese](README.ja.md)
6+
7+
# Collatz Reverse Tree Interactive Visualizer
8+
9+
![Screenshot: the visualizer with a generated reverse Collatz tree](./docs/screenshot.png)
10+
11+
An interactive browser visualizer for the **cycle-pruned reverse Collatz tree** rooted at `1`. It supports adjustable depth, raw-number and `(m,k)` labels, forward-trajectory inspection, and PNG export of the fitted viewport.
12+
13+
> **Correctness note:** An earlier version of this README incorrectly claimed that the reverse subtrees rooted at `5` and `32` were isomorphic, described the recurrence below as having a 21-step cycle, and gave an incorrect `(m,k)` formula for an odd predecessor. Those claims are corrected here and covered by automated tests.
14+
15+
## Table of Contents
16+
17+
- [What the project does](#what-the-project-does)
18+
- [Features](#features)
19+
- [Mathematical facts used by the visualizer](#mathematical-facts-used-by-the-visualizer)
20+
- [Odd-predecessor and forking condition](#odd-predecessor-and-forking-condition)
21+
- [Multiples of 3](#multiples-of-3)
22+
- [Correct `(m,k)` reverse rules](#correct-mk-reverse-rules)
23+
- [Correction: the subtrees rooted at 5 and 32 are not isomorphic](#correction-the-subtrees-rooted-at-5-and-32-are-not-isomorphic)
24+
- [Correction: largest-prime-factor recurrence and the 233 cycle](#correction-largest-prime-factor-recurrence-and-the-233-cycle)
25+
- [Usage](#usage)
26+
- [Automated verification](#automated-verification)
27+
- [Repository structure](#repository-structure)
28+
- [Limitations](#limitations)
29+
- [References](#references)
30+
- [Research-integrity note](#research-integrity-note)
31+
- [Related reading](#related-reading)
32+
33+
## What the project does
34+
35+
`Collatz reverse tree.html` builds a breadth-first reverse tree from `1` using the ordinary, unaccelerated Collatz map
36+
37+
\[
38+
C(x)=
39+
\begin{cases}
40+
3x+1, & x\text{ odd},\\
41+
x/2, & x\text{ even}.
42+
\end{cases}
43+
\]
44+
45+
For a current value `n`, the possible reverse predecessors are:
46+
47+
1. `2n`, which is always valid;
48+
2. `(n-1)/3`, when it is a positive odd integer.
49+
50+
The visualizer deliberately omits the reverse edge from `4` to `1`. Without this exception, the reverse structure contains the familiar cycle `1 → 4 → 2 → 1` and is not a rooted tree. The page therefore displays a **cycle-pruned rooted tree**, not the complete reverse directed graph.
51+
52+
### Features
53+
54+
- Generate the cycle-pruned reverse tree to a selected depth.
55+
- Switch labels between `n` and `(m,k)`, where
56+
\[
57+
m=\lfloor n/6\rfloor,\qquad k=n\bmod 6.
58+
\]
59+
- Click a node to display its actual forward Collatz trajectory back to `1`.
60+
- Highlight the nodes and edges in that trajectory.
61+
- Export the graph after fitting it into the current canvas viewport.
62+
63+
## Mathematical facts used by the visualizer
64+
65+
### Odd-predecessor and forking condition
66+
67+
An odd reverse predecessor exists exactly when
68+
69+
\[
70+
\frac{n-1}{3}=2q+1
71+
\]
72+
73+
for some non-negative integer `q`. Rearranging gives
74+
75+
\[
76+
n=6q+4,
77+
\]
78+
79+
so, in the complete reverse graph,
80+
81+
\[
82+
n\text{ has an odd predecessor}\iff n\equiv4\pmod 6.
83+
\]
84+
85+
Every positive integer also has the even predecessor `2n`. Therefore a node has two reverse predecessors exactly when `n ≡ 4 (mod 6)`.
86+
87+
There is one display-specific exception: at `n=4`, the odd predecessor is `1`, and that edge is omitted to break the root cycle. Thus node `4` has only one displayed child in this cycle-pruned tree.
88+
89+
### Multiples of 3
90+
91+
If `n=3q`, then
92+
93+
\[
94+
\frac{n-1}{3}=q-\frac13
95+
\]
96+
97+
is not an integer. A multiple of `3` therefore has no odd reverse predecessor.
98+
99+
### Correct `(m,k)` reverse rules
100+
101+
Write
102+
103+
\[
104+
n=6m+k,\qquad 0\le k<6.
105+
\]
106+
107+
For the always-valid even predecessor,
108+
109+
\[
110+
2n=12m+2k,
111+
\]
112+
113+
so its coordinates are
114+
115+
\[
116+
\left(2m+\left\lfloor\frac{k}{3}\right\rfloor,\;2k\bmod6\right).
117+
\]
118+
119+
An odd predecessor exists only for `k=4`. In that case,
120+
121+
\[
122+
\frac{n-1}{3}=2m+1.
123+
\]
124+
125+
Its `(m,k)` coordinates must be computed from the resulting integer:
126+
127+
\[
128+
\left(
129+
\left\lfloor\frac{2m+1}{6}\right\rfloor,
130+
(2m+1)\bmod6
131+
\right).
132+
\]
133+
134+
Equivalently, if `m=3q+r` with `r∈{0,1,2}`, the odd predecessor has coordinates
135+
136+
\[
137+
(q,2r+1).
138+
\]
139+
140+
For example, `16=6·2+4` has odd predecessor `5`, whose coordinates are `(0,5)`.
141+
142+
## Correction: the subtrees rooted at 5 and 32 are not isomorphic
143+
144+
The earlier README inferred infinite structural isomorphism from a finite-depth visual similarity. That inference was false.
145+
146+
Apply the same reverse-branch word `EEEOEEOEO`, where `E(x)=2x` and `O(x)=(x-1)/3` when valid:
147+
148+
```text
149+
5 → 10 → 20 → 40 → 13 → 26 → 52 → 17 → 34 → 11
150+
32 → 64 → 128 → 256 → 85 → 170 → 340 → 113 → 226 → 75
151+
```
152+
153+
The corresponding values `11` and `75` are not congruent modulo `6`:
154+
155+
```text
156+
11 ≡ 5 (mod 6)
157+
75 ≡ 3 (mod 6)
158+
```
159+
160+
After one more even reverse step, they become `22` and `150`:
161+
162+
```text
163+
22 ≡ 4 (mod 6) → has an odd predecessor and forks
164+
150 ≡ 0 (mod 6) → has no odd predecessor
165+
```
166+
167+
Accordingly, the level counts of the two rooted reverse trees first differ at depth 11:
168+
169+
| Depth from subtree root | `T5` nodes | `T32` nodes |
170+
|---:|---:|---:|
171+
| 9 | 9 | 9 |
172+
| 10 | 12 | 12 |
173+
| 11 | 15 | 14 |
174+
| 12 | 19 | 17 |
175+
176+
This counterexample disproves the former isomorphism claim. It also illustrates why finite visual agreement and modulo-6 observations are insufficient to establish an infinite tree isomorphism.
177+
178+
## Correction: largest-prime-factor recurrence and the 233 cycle
179+
180+
The associated investigation considered the recurrence
181+
182+
\[
183+
F(n)=10\operatorname{LPF}(n)+(\operatorname{LPF}(n)\bmod10),
184+
\]
185+
186+
where `LPF(n)` is the largest prime factor of `n`.
187+
188+
Under this exact definition, the orbit starting at `233` is a **26-state cycle**, not a 21-step cycle:
189+
190+
```text
191+
233 → 2333 → 23333 → 233333 → 6611 → 6011 → 60111
192+
→ 66799 → 9977 → 9077 → 3133 → 2411 → 24111 → 477
193+
→ 533 → 411 → 1377 → 177 → 599 → 5999 → 8577 → 9533
194+
→ 95333 → 136199 → 194577 → 8211 → 233
195+
```
196+
197+
In particular, `9533` is prime, so
198+
199+
\[
200+
F(9533)=10·9533+3=95333,
201+
\]
202+
203+
not `233`.
204+
205+
This repository verifies the cycle above, but it **does not claim or prove that every starting integer enters this cycle**. Earlier unsupported statements about experiments up to `10^9` and pathway probabilities have been removed because the corresponding data and reproducible analysis were not present in the repository.
206+
207+
## Usage
208+
209+
1. Download or clone the repository.
210+
2. Open `Collatz reverse tree.html` in a modern browser with internet access. The page currently loads `vis-network` from a version-pinned CDN.
211+
3. Enter a depth and click **Generate / Refresh Tree**.
212+
4. Toggle `(m,k)` labels if desired.
213+
5. Click a node to inspect and highlight its forward trajectory to `1`.
214+
6. Click **Export PNG (Fitted View)** to save the graph as currently fitted into the canvas.
215+
216+
The depth input is limited to `30`. With the current cycle-pruned generator, depth `8` has `17` nodes, depth `12` has `47` nodes, and depth `27` has `1,748` nodes.
217+
218+
## Automated verification
219+
220+
The mathematical core is in `collatz-math.js`, which is shared by the browser page and the Node.js tests.
221+
222+
Run:
223+
224+
```bash
225+
node --test tests/collatz-math.test.js
226+
```
227+
228+
The tests check:
229+
230+
- every generated reverse edge maps back under the forward Collatz rule;
231+
- the special root-cycle pruning convention;
232+
- `(m,k)` round trips and the corrected odd-predecessor example;
233+
- known node counts at selected depths;
234+
- the explicit counterexample to `T5 ≅ T32`;
235+
- the complete 26-state cycle under the stated largest-prime-factor recurrence.
236+
237+
## Repository structure
238+
239+
```text
240+
├── Collatz reverse tree.html # Interactive visualizer
241+
├── collatz-math.js # Shared mathematical core
242+
├── tests/
243+
│ └── collatz-math.test.js # Automated mathematical checks
244+
└── README.md
245+
```
246+
247+
## Limitations
248+
249+
- The Collatz conjecture remains unproved; this visualizer is not a proof.
250+
- The visualizer shows a finite, cycle-pruned tree and cannot justify claims about infinite subtree equivalence from appearance alone.
251+
- JavaScript `Number` arithmetic is exact only for integers up to `2^53-1`; the UI depth cap keeps the current root-1 tree within that range, but any future extension should preserve explicit safe-integer checks.
252+
- PNG export captures the fitted canvas viewport; it is not an arbitrarily scalable full-graph renderer.
253+
- `vis-network` is loaded from the internet, so the page is not yet fully offline.
254+
255+
## References
256+
257+
- Lagarias, J. C. (1985). *The 3x + 1 problem and its generalizations*. American Mathematical Monthly, 92(1), 3–23.
258+
- Andrei, S., & Kudlek, M. *Some results on the Collatz problem*.
259+
260+
## Research-integrity note
261+
262+
The purpose of these corrections is to distinguish proven facts, computational observations, disproved conjectures, and open questions. Finding a counterexample to an earlier conjecture is part of the mathematical process and is more informative than retaining a claim contradicted by computation.
263+
264+
## Related reading
265+
266+
More projects, write-ups, and experiments live on my personal site: [keng0nion.github.io](https://keng0nion.github.io/).

0 commit comments

Comments
 (0)