Table of Contents
Fetching ...

Information funnels and multiscale gap-space dynamics in Kaprekar's routine

Christoph D. Dahl

TL;DR

On this gap space, Kaprekar's routine induces a first-order Markov approximation whose transition structure, stationary distribution and drift fields are characterised, showing that simple gap features strongly constrain the dynamics for D=3 but lose predictive power as D increases.

Abstract

Kaprekar's routine, i.e., sorting the digits of an integer in ascending and descending order and subtracting the two, defines a finite deterministic map on the state space of fixed-length digit strings. While its attractors (such as 495 for D = 3 and 6174 for D = 4) are classical, the global information-theoretic structure of the induced dynamics and its dependence on the digit length D have received little attention. Here an exhaustive analysis is carried out for D in {3,4,5,6}. For each D, all states are enumerated, their attractors and convergence distances are obtained, and the induced distribution over attractors across iterations is used to construct "entropy funnels". Despite the combinatorial growth of the state space, average distances remain small and entropy decays rapidly before entering a slow tail. Permutation symmetry is then exploited by grouping states into digit multisets and, in a further reduction, into low-dimensional digit-gap features. On this gap space, Kaprekar's routine induces a first-order Markov approximation whose transition structure, stationary distribution and drift fields are characterised, showing that simple gap features strongly constrain the dynamics for D=3 but lose predictive power as D increases.

Information funnels and multiscale gap-space dynamics in Kaprekar's routine

TL;DR

On this gap space, Kaprekar's routine induces a first-order Markov approximation whose transition structure, stationary distribution and drift fields are characterised, showing that simple gap features strongly constrain the dynamics for D=3 but lose predictive power as D increases.

Abstract

Kaprekar's routine, i.e., sorting the digits of an integer in ascending and descending order and subtracting the two, defines a finite deterministic map on the state space of fixed-length digit strings. While its attractors (such as 495 for D = 3 and 6174 for D = 4) are classical, the global information-theoretic structure of the induced dynamics and its dependence on the digit length D have received little attention. Here an exhaustive analysis is carried out for D in {3,4,5,6}. For each D, all states are enumerated, their attractors and convergence distances are obtained, and the induced distribution over attractors across iterations is used to construct "entropy funnels". Despite the combinatorial growth of the state space, average distances remain small and entropy decays rapidly before entering a slow tail. Permutation symmetry is then exploited by grouping states into digit multisets and, in a further reduction, into low-dimensional digit-gap features. On this gap space, Kaprekar's routine induces a first-order Markov approximation whose transition structure, stationary distribution and drift fields are characterised, showing that simple gap features strongly constrain the dynamics for D=3 but lose predictive power as D increases.

Paper Structure

This paper contains 10 sections, 13 equations, 7 figures.

Figures (7)

  • Figure 1: Flow fields in gap space for $D=3$--$6$. Panels (A)–(D) correspond to $D=3,4,5,6$, respectively. Each panel shows the occupancy of gap states $(g_1,g_2)$ under a uniform prior over $\mathcal{S}_D$ (colour scale) together with the corresponding average one-step drift induced by a single Kaprekar step. Arrows indicate the mean change in gap coordinates per iteration, with horizontal and vertical components corresponding to $\Delta g_2$ and $\Delta g_1$, respectively.
  • Figure 2: Global structure of Kaprekar dynamics as a function of digit length $D$. (A) Mean (solid) and median (dashed) number of iterations required to reach an attractor. (B) Maximal distance over all starting states. (C) Fraction of the state space contained in the largest basin of attraction. (D) Number of distinct attractors.
  • Figure 3: Entropy funnels across digit lengths. (A) Raw Shannon entropy of the induced distribution over attractors, conditional on trajectories that have converged by iteration $t$, for each $D$. (B) The same curves normalised by their final values $H_{t^\ast}$ (with $t^\ast$ chosen large enough that all states have converged), showing relative uncertainty about the final attractor. All digit lengths exhibit a rapid early collapse of uncertainty, followed by a slower tail governed by the distribution of basin sizes.
  • Figure 4: Multiset structure of Kaprekar dynamics across digit lengths. Panels (A), (C), (E), and (G) show the distributions of multiset sizes, i.e. the number of distinct permutations in each digit-multiset class, for $D = 3,4,5,6$, respectively. Panels (B), (D), (F), and (H) show the corresponding distributions of mean distance-to-attractor per multiset class (average number of Kaprekar iterations taken by all states sharing the same multiset of digits). Solid black lines show absolute counts (left $y$-axis); dashed red lines show the corresponding normalised probabilities (right $y$-axis). As $D$ increases, both the number and typical size of multiset classes grow sharply, and the distributions of multiset-averaged distances broaden and develop longer tails, indicating increasingly heterogeneous convergence behaviour. Note that most classes have small mean distance (fewer than three steps), with a long right tail for $D=5$ and $D=6$.
  • Figure 5: Digit features for easy and hard Kaprekar states. For each digit length $D$, states are split into the fastest and slowest deciles of distance-to-attractor. Panels (A)–(D) show, respectively, the mean digit spread $g_1 = \max(d) - \min(d)$, digit variance $\mathrm{Var}(d)$, digit sum, and the gap between the second and third largest digits $g_2$ for the two groups. Easy states consistently exhibit larger $g_1$ and, for some $D$, higher digit variance, whereas differences in digit sum are largely driven by the change in $D$.
  • ...and 2 more figures