This page describes a general algorithm that extracts continued-fraction convergents of an irrational parameter by observing return events in a dynamical system. Rather than computing the function value ( log, roots, or sin) and/or explicitly expanding its continued fraction, the method tracks a normalized orbit and an integer cocycle, detecting convergents via gap-structure collapse as described by the Three Gap Theorem. The approach applies uniformly to different functions, revealing a shared group-theoretic structure underlying these computations.
The idea is using the "gap restructuring" itself as a computational driver (specifically for transcendental functions) The algorithm consecutively jumps to the next convergent by only looking at the current gap state.
if the function has a diophantine target such that its "near-equality" condition can be linearized into a rotation on a torus, (or a group manifold). you dont need a different algorithm but knowing on which circle the points are rotating on.
a single dynamical template for different coordinate systems, implicitly, lattice / torus dynamics.
for example in logarithms, the return is multiplicative: \(a^q \times b^{-p} \approx 1\). (a rotation on the group (R _>0 ,×). taking the log linearizes it q log(a)- p log(b) \approx 0.)
in roots, the return is polynomial p^n -q^n a \approx 0, the rotation is in the space of n-th powers. p,q is the lattice point that sits closes to the curve y=x^n a (shifting from an exponential map to a power map, but keeping the same "return event" logic.)
since the the stepping of the algorithm only cares bout the tgt ordering of the points on a 1-manifold. and, if the target can be reduced to a mapping x↦x+α(mod 1), the geometry of the gaps must simplify when you hit a convergent. this topological event is the convergence
the algorithm is not necesarilly efficient as it is, but the optimizations actually make the logic more clear:
track only the active gaps rather than a full history( O(N) space to O(1) )!, so it only cares about the current state and the boundary conditions.
avoiding the BigInt explosion: by working with the reduced value (the "leftovers" in the group action) rather than ie a raw power 2^1000000 , it essentially perfors modular exponentiation in the continuous domain, tracking the phase of the rotation separate from the number of laps. (the order of the points dosnt change)
-Python implementation for the logarithm case, simple version dosnt handle arguments in the 0–1 range, provides the list of consecutive convergents found, excluding the first one if integer.
(Dual cyclic structure at convergents)
Let \(\alpha \in \mathbb{R}\setminus \mathbb{Q}\) with continued fraction convergent \(p/q\). Consider the rotation sequence \(r_x = \{x\alpha\}\in [0,1),\quad x=1,\dots,q\),
and let \(\sigma\) be the permutation that sorts \(r_x\) in increasing order: \(r_{\sigma(1)} < r_{\sigma(2)} < \cdots < r_{\sigma(q)}\).
Then:
(Index cycle) \(\sigma\) is an arithmetic progression modulo \(q\): \(\sigma(k) \equiv k\cdot p^{-1} \pmod q\),
where \(p^{-1}\) is the multiplicative inverse of \(p\) modulo \(q\).
(Overflow cycle / floor terms) Writing \(x\alpha = y_x + r_x\) with \(y_x=\lfloor x\alpha\rfloor\), the sequence \(y_{\sigma(k)}\) (as \(k=1,\dots,q\)) takes exactly two adjacent values that differ by 1 and forms \(q\) samples from a cycle in \(\mathbb{Z}/p\mathbb{Z}\) whose step is \(q^{-1}\pmod p\).
(Gap control) The consecutive differences \(r_{\sigma(k+1)}-r_{\sigma(k)}\) take two values (the “short” and “long” gaps) determined by \(p/q\); this is the Three Gap Theorem specialized at a convergent, where only two gaps appear across the first \(q\) points.
Proof sketch
Because \(p/q\) is a convergent, \(\|q\alpha-p\|\) is minimal in its range. The return map of the rotation by \(\alpha\) to the set of \(q\) points partitions the circle into two gap lengths. (TGT gives gap sizes.)
The order of the points is governed by the congruence \(x\alpha \approx x\frac{p}{q}\) modulo \(1\), so sorting by \(x\alpha\) matches sorting by \(xp/q\) modulo \(1\). The residues \(xp \bmod q\) run through \(\mathbb{Z}/q\mathbb{Z}\) in steps of \(p\), hence the sorting permutation is
\(\sigma(k)\equiv k\cdot p^{-1}\ (\bmod q)\). (This gives gap order.)
The floor/overflow terms satisfy \(y_{\sigma(k+1)}-y_{\sigma(k)} \in \{\lfloor p/q\rfloor, \lceil p/q\rceil\}\),
and, tracked modulo \(p\), they advance by \(q^{-1}\) because
\(q\alpha\approx p\) forces \(p\) steps in \(\alpha\)-space to coincide with \(q\) wraps. This yields the dual \(\mathbb{Z}/p\mathbb{Z}\) cycle.
(Logarithmic case via an isomorphism)
Let \(a,b>1\) and set \(\beta=\log_b{a}\). Define the multiplicative sequence \(R_x \;=\; a^x\, b^{-y_x} \in [1,b),\qquad y_x=\big\lfloor x\beta\big\rfloor\).
Then \(R_x = b^{\{x\beta\}}\). Hence ordering the \(R_x\) is the same as ordering \(\{x\beta\}\), and all claims of the Theorem transfer with \(\alpha=\beta\):
Sorting indices are \(\sigma(k)\equiv k\cdot p^{-1}\ (\bmod q)\) for any convergent \(p/q\) of \(\beta\).
The overflow exponents \(y_{\sigma(k)}\) form \(q\) samples from a \(\mathbb{Z}/p\mathbb{Z}\) cycle with step \(q^{-1}\ (\bmod p)\).
The MLA(mesopotamian logarithm algorithm) is just rotation on the circle in log-coordinates, so its consecutive outputs are convergents whenever you use windows aligned with denominators \(q\).
----
The version for computing roots then just swaps the rotation template, the "shadow" equation.
Instead of \(a^q \approx b^p\) as in logs; for \(p/q \approx a^{1/n}\) the orbit and cocycle become \( p^n \approx q^n a\)
----
for trig functions theres no mapping needed, (its the reason of why the other ones work at all), working directly with points on the unit interval as the angle, then you extract the quadrant and thats it, the specific function sin, cos, is recovered
----draft
Irrational: \(\alpha = \log_b(a)\)
Convergent: \(p/q \approx \log_b(a) \Rightarrow q \times log_b(a) \approx p \Rightarrow a^q \approx b^p\)
Sequence: \(r_x = a^x \times b^{y_x}\) reduced to \([1, b)\). This is like looking at \(a^x\) "modulo \(b\)" multiplicatively. \(y_x\) tracks the 'overflow' exponent of \(b\). (This highlights the absence of a standard shorthand notation for multiplicative modulus; see link)
Sorted Sequence: Sorting \(r_x\) for \(x=1\ldots q\) gives indices \(x_k\).
Structure: \(x_k\) forms \(\mathbb{Z}/q\mathbb{Z}\) (gen \(p^{-1} \mod q\)), \(y_{x_k}\) forms \(q\) terms of \(\mathbb{Z}/p\mathbb{Z}\) (gen \(q^{-1} \mod p\)).
Trigonometric Case (Angle)
Irrational: We need an irrational quantity related to the angle. Let's use \(\alpha = \theta / (2\pi)\). (assuming \(\theta\) is not a rational multiple of \(2\pi\)).
Convergent: \(p/q \approx \theta / (2\pi) \Rightarrow q \times \theta / (2\pi) \approx p \Rightarrow q\theta ≈ 2\pi p\). This means \(q\) rotations by \(\theta\) is close to \(p\) full \(2\pi\) rotations.
Sequence: What's the equivalent of \(a^x \mod 1:b\)? The natural analogue for angles is \(x\theta \mod 2\pi\). Let \(r_x = (x\theta) \pmod{2\pi}\). This sequence lives in \([0, 2\pi)\).
What is \(y_x\) ? It's the number of full rotations removed: \(xθ = y_x \times 2\pi + r_x\). So, \(y_x = \lfloor x\theta / (2\pi)\rfloor\).
Sorted Sequence: Sort \(r_x\) for \(x=1\ldots q\) to get indices \(x_k\).
Structure: \(x_k\) forms \(\mathbb{Z}/q\mathbb{Z}\) (gen \(p^{-1} \mod q\)), \(y_{x_k}\) forms \(q\) terms of \(\mathbb{Z}/p\mathbb{Z}\) (gen \(q^{-1} \mod p\)).
This directly mimics the log case by replacing the multiplicative group \((\mathbb{R}^+, \cdot)\) modulo \(b\) with the additive group \(\mathbb{R} \mod 2\pi\) (the circle group \(S^1\)). The relationship \(q\theta \approx 2\pi p\) is the direct analogue of \(a^q \approx b^p\). The Three Gap Theorem describes the structure of the sorted \(r_x\) values (the points \(x\theta \mod 2\pi\) on the circle), and their ordering is intimately linked to the continued fraction convergents \(p/q\). The generators likely arise from the relationship \(q(p'/q') - p(q'/q') = \pm \)1 between consecutive convergents.
(Need to test which inverse/element works. The structure \(p_{n-1} q_n - p_n q_{n-1} = (-1)^n\) from continued fractions is key here, likely determining the specific generators.)
No comments:
Post a Comment