Next Article in Journal
Departure Process of Actively Managed Queue with Dependent Job Sizes
Previous Article in Journal
Quantifying the Linguistic Complexity of Pan-Homophonic Events in Stock Market Volatility Dynamics
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Coarse-Grained Drift Fields and Attractor-Basin Entropy in Kaprekar’s Routine

by
Christoph D. Dahl
Graduate Institute of Mind, Brain and Consciousness, Taipei Medical University, New Taipei City 235, Taiwan
Entropy 2026, 28(1), 92; https://doi.org/10.3390/e28010092
Submission received: 24 November 2025 / Revised: 27 December 2025 / Accepted: 5 January 2026 / Published: 12 January 2026
(This article belongs to the Section Complexity)

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 { 3 , 4 , 5 , 6 } . For each D, all states are enumerated and the transition structure is computed numerically; 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, a first-order Markov approximation is empirically estimated by counting one-step transitions induced by the exhaustively enumerated deterministic map. From the resulting empirical transition matrix, drift fields and the stationary distribution are computed numerically. These quantities serve as descriptive summaries of the projected dynamics and are not derived in closed form.

1. Introduction

Iterated digit transforms provide simple yet surprisingly rich examples of finite dynamical systems. Among them, Kaprekar’s routine occupies a special place: starting from a D-digit integer with at least two distinct digits, its digits are sorted into descending and ascending order, interpreted as integers, and subtracted. Formally, for a D-digit state x with digits ( d 1 , , d D ) , define
desc ( x ) = integer   formed   by   sorting   the   digits   of   x   in   descending   order , asc ( x ) = integer   formed   by   sorting   the   digits   of   x   in   ascending   order .
The Kaprekar map is then given by
K D ( x ) = desc ( x ) asc ( x ) ,
iterated on the finite state space of D-digit integers (with leading zeros allowed). For D = 4 , this process famously converges to the attractor 6174 for almost all initial conditions, while 495 plays an analogous role for D = 3 [1,2,3]. These facts are well known in recreational mathematics, and classical work has established existence, uniqueness, and basic properties of Kaprekar attractors in various bases and digit lengths [4,5,6,7,8,9]. Beyond these combinatorial results, however, relatively little is known about the global organisation of Kaprekar dynamics, its information-theoretic signatures, or how these properties depend on the digit length D. Seen as a finite dynamical system, Kaprekar’s routine raises a few concrete questions: (1) How are basins of attraction distributed as D increases, and how dominant is the largest basin? (2) How quickly does uncertainty about the eventual attractor collapse under iteration, when starting from a uniform prior over states? (3) Are there simple low-dimensional features of the digits that control whether a state is “easy” or “hard” to reach? (4) Can the dynamics be captured, at least approximately, by a stochastic process on a coarse-grained state space? Recent mathematical work has addressed structural and asymptotic properties of Kaprekar-type maps in a variety of settings, including b-adic generalisations, bounds on Kaprekar constants, and detailed analyses of two- and three-digit routines [10,11,12,13]. These studies highlight the richness of the underlying number-theoretic structure, but they do not aim to characterise the induced dynamics in information-theoretic or probabilistic terms. The present analysis focuses on base-10 Kaprekar maps with digit lengths D { 3 , 4 , 5 , 6 } . This range is small enough that the full state spaces can be enumerated exactly and all attractors and basins can be characterised without approximation, while still exhibiting clear changes in dynamical structure with increasing D. No asymptotic analysis in the limit of large digit length is attempted. Instead, the small-D regime is treated as a fully tractable model system on which information-theoretic and coarse-graining tools can be tested. Supplementary robustness checks in Appendix A.2 repeat selected analyses in base 8 to assess which qualitative conclusions are stable across bases.
Here a different angle is taken; instead of trying to obtain closed-form expressions for constants or loops, the Kaprekar map is treated as a finite directed graph, and questions are posed about its global statistics and coarse-grained descriptions: how entropy contracts, how permutation symmetries can be exploited, and how far simple ‘gap’ features go in explaining the dynamics. Standard tools from information theory and Markov-chain analysis [14,15,16] are used. In the present work these questions are addressed for D { 3 , 4 , 5 , 6 } by combining exhaustive enumeration with information-theoretic and statistical tools. The map K in (2) is treated as a deterministic update on a finite directed graph, and its structure is analysed at three complementary levels. First, at the level of individual states and attractors, all D-digit states with at least two distinct digits are enumerated, their attractors and distances (numbers of iterations) to convergence are obtained, and basin sizes are quantified. This representation makes it possible to construct entropy funnels: starting from a uniform distribution over states, the evolving distribution over attractors among the trajectories that have already converged is followed across iterations and the corresponding Shannon entropy is measured, providing a quantitative notion of uncertainty reduction under the dynamics. Second, the permutation symmetry of digit strings is exploited by grouping states into equivalence classes with identical digit multisets. This reduction yields a more compact representation that still respects the combinatorial constraints of the map. Multiset-level statistics are used to characterise how class sizes are distributed, how far typical classes lie from their attractors, and how different attractors are assembled from contributions of many small versus a few large classes. Third, a low-dimensional description is introduced in terms of simple digit-gap features. From the exact deterministic dynamics, empirical one-step transition frequencies between gap states can be estimated, yielding a first-order Markov approximation on this coarse-grained space. On this gap space, transition probabilities, stationary distributions, flow fields, and drift statistics are computed, and the resulting structure is related back to the basins and distances in the original state space. In addition, a simple linear regression framework is used to probe how far gap-based and aggregate digit features can account for the distance to attractor, viewed here as a notion of “difficulty” of reaching an attractor. All transition and stationary quantities reported for the gap-space chain are computed numerically from exhaustive enumeration; no closed-form derivation is claimed.
These three levels of description (states, multisets, and gap space) give a multiscale view of Kaprekar’s routine: from individual trajectories and basins to symmetry-reduced classes and finally to a very low-dimensional Markov approximation. The same approach should extend to other digit-based transforms and, more generally, to deterministic maps where one cares about coarse-grained information flow.

2. Materials and Methods

2.1. State Space, Attractors, and Distances

Fix a digit length D 3 and work in base 10. Let 𝒮 D denote the set of D-digit states with at least two distinct digits, allowing leading zeros. Throughout, states are represented as length-D digit strings (in base 10) with leading zeros allowed. Equivalently, each integer is padded to D digits before applying the Kaprekar step (e.g., for D = 4 , 100 is treated as 0100). All digit sorting operations are performed on these D digits, including any zeros. This convention, commonly adopted in the Kaprekar literature, ensures that 𝒮 D is closed under the map K D . For each D considered, restricting the initial ensemble to states without leading zeros does not change the attractor cycles reached or the entry times τ ( x ) for those states; it only changes the induced basin weights under a uniform prior, because the prior mass over 𝒮 D is altered. Write x 𝒮 D as a D-tuple of digits ( d 1 , , d D ) . The descending and ascending orderings desc ( x ) and asc ( x ) are defined as in (1), and the Kaprekar map is given by (2). When restricted to digit length D it is written as K D : 𝒮 D 𝒮 D .
Because 𝒮 D is finite and K D is deterministic, every trajectory is eventually periodic: for each x 𝒮 D there exist integers μ 0 and l 1 such that K D t + l ( x ) = K D t ( x ) for all t μ . Accordingly, an attractor is defined as a periodic orbit (cycle) of K D ; fixed points are the special case l = 1 .
Lemma 1 (Eventual periodicity on a finite state space).
Let f : S S be a function on a finite set S. Then for any x S the sequence x , f ( x ) , f 2 ( x ) , is eventually periodic: there exist μ 0 and l 1 such that f t + l ( x ) = f t ( x ) for all t μ .
Proof. 
Since S is finite, the sequence must repeat a value: there exist 0 i < j with f i ( x ) = f j ( x ) . Let μ = i and l = j i . Determinism implies that f t + l ( x ) = f t ( x ) for all t μ .    □
A periodic orbit (cycle) C 𝒮 D is an attractor if it is a directed cycle of K D : there exist l 1 and distinct states a 0 , , a l 1 𝒮 D such that C = { a 0 , , a l 1 } and K D ( a i ) = a ( i + 1 )   mod   l for all i. Fixed points are the special case l = 1 (then C = { a } with K D ( a ) = a ).
Given an attractor cycle C, its (forward) basin is
B ( C ) : = { x 𝒮 D : K D t ( x ) C   for   some   t 0 } .
For x B ( C ) the distance to attractor (cycle entry time) is defined as
dist ( x ) : = min { t 0 : K D t ( x ) C } .
It is convenient to write α ( x ) for the attractor cycle reached from x and τ ( x ) : = dist ( x ) for the corresponding convergence time. The observed cycle structure for each D { 3 , 4 , 5 , 6 } (including whether l > 1 occurs) is reported in Section 2.2 and Appendix A.3. For each D { 3 , 4 , 5 , 6 } the set 𝒮 D is enumerated, all attractor cycles are identified, basin sizes | B ( C ) | are computed, and dist ( x ) is recorded for all states.

2.2. Attractor Detection and Cycle Structure

For each digit length D, the map K D was iterated from every state x 𝒮 D until the trajectory first revisited a previously visited state. From this first repeat, the resulting periodic orbit (cycle) C ( x ) and its length l ( x ) = | C ( x ) | were extracted and recorded. For D = 3 and D = 4 , all attracting cycles had length one (fixed points). For D = 5 , all attractors were genuine cycles with l > 1 (one 2-cycle and two 4-cycles). For D = 6 , both fixed points ( l = 1 ) and a dominant 7-cycle ( l = 7 ) were observed. The full cycle lists, lengths, and basin weights are provided in Appendix A.3.

2.3. Entropy Funnels

To quantify information funnels an initial distribution that is uniform over all non-trivial states for a given D is considered. For each iteration t 0 define the subset of states that have already reached an attractor by time t,
A t : = { x 𝒮 D : τ ( x ) t } ,   N t : = | A t | .
Among these converged states, the empirical distribution over attractors at time t is
p t ( a ) = 1 N t { x A t : α ( x ) = a } ,
where the sum over a runs over all attractors for the given D. The Shannon entropy
H t = a p t ( a ) log 2 p t ( a )
is then computed as a function of iteration t. For small t the distribution p t is dominated by attractors that are reached quickly; as t increases and more trajectories converge, p t approaches the basin size distribution. Plotting H t yields a raw entropy funnel. To compare decay profiles across D, the normalised entropy is plotted,
H ˜ t = H t H H 0 H ,
where H denotes the basin size entropy, i.e., the entropy of the attractor distribution obtained once all states have converged ( t t max : = max x 𝒮 D τ ( x ) , so that A t = 𝒮 D and p t = p ), and in practice H is set to H T with T t max in the computations. Thus H ˜ 0 = 1 and H ˜ t 0 as t .

2.4. Multiset Representation

Because permuting the digits of x does not affect the outcome of a Kaprekar step, many states form equivalence classes with identical digit multisets. Formally, an equivalence relation is defined on 𝒮 D by x y if their digits coincide as multisets. The equivalence classes are in bijection with digit multisets and are referred to as multiset classes. Each class has a size (number of distinct permutations) and a well-defined mean distance to attractor obtained by averaging dist ( x ) over the states in the class. For each D all digit multisets, their class sizes, and their mean distances are enumerated. It is also recorded, for each attractor, how many states in its basin arise from each multiset class.

2.5. Gap Features and Markov Chain in Gap Space

To obtain a low-dimensional, permutation-invariant description of digit structure, two simple “gap” features are used (defined formally in Equation (9)). The first captures overall digit spread, while the second captures an internal separation that distinguishes configurations in which one or two extreme digits are separated from a more homogeneous bulk. In preliminary exploratory work, additional quantities such as further internal gaps, digit sum, and digit variance were inspected. Digit sum and digit variance are later included as predictors in the regression analysis, but ( g 1 , g 2 ) are adopted for the Markov-chain description because they already generate a compact and interpretable gap space. Appendix A.2 further compares induced occupancy and mean drift fields under alternative definitions of g 2 , quantifying agreement via cellwise correlations and the mean cosine similarity of drift vectors.
For each state x 𝒮 D simple digit features are computed. For notational convenience, let d ( 1 ) ( x ) d ( 2 ) ( x ) d ( D ) ( x ) denote the digits of x sorted in non-increasing order (including leading zeros). The gap features used for the gap-space projection are defined as
g 1 ( x ) = d ( 1 ) ( x ) d ( D ) ( x ) , g 2 ( x ) = d ( 2 ) ( x ) d ( 3 ) ( x ) .
Here d ( k ) ( x ) denotes the k-th largest digit of x. The choice g 2 = d ( 2 ) ( x ) d ( 3 ) ( x ) is intended to capture an internal break between the leading digits and the remaining digits. In particular, many digit configurations share the same overall spread g 1 but differ in whether there are two extreme digits separated from a more homogeneous bulk; this distinction is directly reflected in d ( 2 ) d ( 3 ) . By contrast, the alternative d ( 1 ) d ( 2 ) primarily detects a single extreme digit and is therefore often partly redundant with g 1 . To assess the robustness of the coarse-grained description, Appendix A.2 compares the induced flow fields obtained from several alternative definitions of g 2 and reports which qualitative conclusions are stable across choices.
These define a discrete set
G D : = ( g 1 ( x ) , g 2 ( x ) ) : x 𝒮 D
of possible gap pairs ( g 1 , g 2 ) .
Because the projection x g ( x ) = ( g 1 ( x ) , g 2 ( x ) ) is many-to-one, the induced dynamics on G D is generally non-deterministic: distinct digit strings sharing the same gap state g can transition to different successor gap states under the deterministic Kaprekar map K D . An empirical first-order Markov approximation on this discrete grid is therefore defined by counting one-step transitions across the exhaustively enumerated map.
For each gap state g = ( g 1 , g 2 ) G D , consider the collection of underlying states
𝒮 D ( g ) : = { x 𝒮 D : ( g 1 ( x ) , g 2 ( x ) ) = g } .
One Kaprekar step is applied to each x 𝒮 D ( g ) , the successor gap state g ( x ) : = ( g 1 ( K D ( x ) ) ,   g 2 ( K D ( x ) ) ) is recorded, and empirical transition frequencies
P D ( g h ) : = 1 | 𝒮 D ( g ) | { x 𝒮 D ( g ) : g ( x ) = h }
are estimated.
Equivalently, letting N D ( g , h ) = { x 𝒮 D : g ( x ) = g ,   g ( K D ( x ) ) = h } , one has P D ( g h ) = N D ( g , h ) / u G D N D ( g , u ) . The matrix P D is row-stochastic and summarises the average one-step behaviour of the full deterministic map after projection to the gap space.
A stationary distribution of the Markov approximation is any distribution π D on G D satisfying π D = π D P D . In practice, the stationary distribution reported is obtained numerically by iterating q t + 1 = q t P D until convergence from the initial gap distribution induced by the uniform prior on 𝒮 D ; when the chain is ergodic, this is equivalent to computing the normalised left eigenvector of P D associated with eigenvalue 1.
For visualisation of gap-space flow fields, a drift vector is associated with each occupied gap state g G D . Writing g ( x ) : = ( g 1 ( x ) , g 2 ( x ) ) and Δ g ( x ) : = g   K D ( x ) g ( x ) , the empirical mean one-step drift at g is
v D ( g ) : = 1 | 𝒮 D ( g ) | x 𝒮 D ( g ) Δ g ( x ) .
Because 𝒮 D is exhaustively enumerated for each D { 3 , 4 , 5 , 6 } , this average includes all states x consistent with the gap pair g. To quantify within-cell heterogeneity (i.e., how much Δ g ( x ) varies across different states x sharing the same gap pair g), the empirical covariance of increments is also computed,
Σ D ( g ) : = 1 | 𝒮 D ( g ) | 1 x 𝒮 D ( g ) Δ g ( x ) v D ( g ) Δ g ( x ) v D ( g ) .
Appendix A.1 reports representative examples and summary dispersion statistics, providing a direct visualisation of variability around the mean drift arrows.
These empirical probabilities define a first-order Markov chain on G D with transition matrix P D , which provides a coarse-grained approximation to the projected dynamics on the gap space (the true projected process need not be strictly Markov). It should be emphasised that P D is used here as a descriptive first-order approximation to the projected dynamics on the gap space. Quantifying the approximation error (e.g., by comparing against higher-order models) is an important direction but is beyond the scope of the present work. The chain is therefore treated primarily as a compact summary of average flow patterns rather than an exact probabilistic model of the projected dynamics. The following quantities are computed: (1) the stationary distribution π D satisfying π D P D = π D (computed numerically, e.g., as the normalised left eigenvector of P D or by power iteration); (2) the empirical distribution of gap states under the uniform prior on 𝒮 D ; and (3) average changes Δ g 1 and Δ g 2 per step for each gap state.

2.6. Predicting Distance to Attractor from Digit Features

To link local digit structure to distance to attractor, a simple regression analysis is performed. For each D, up to N = 50,000 states (or all states when fewer are available) are drawn uniformly without replacement from 𝒮 D . For D = 6 this corresponds to a random sample of approximately 5 % of all admissible states, which keeps computation manageable while still covering a wide range of digit configurations. For each sampled state, g 1 and g 2 as defined above, the mean digit d ¯ ( x ) = D 1 i = 1 D d i ( x ) , and the variance of digits Var d ( x ) are computed. All reported goodness-of-fit metrics are computed on held-out test data: for each D, the sampled states were split into 80 % training and 20 % test sets, the model in (15) was fit on the training set, and R 2 and RMSE were evaluated on the test set. All features are standardised (zero mean and unit variance). The mean digit d ¯ ( x ) is used instead of the raw digit sum to remove trivial scaling with D. A linear model
τ ^ ( x ) = β 0 + β 1   g 1 ( x ) + β 2   g 2 ( x ) + β 3   d ¯ ( x ) + β 4   Var d ( x )
is then fit by least squares, and, for each D, the coefficient of determination R 2 , the root mean squared error (RMSE), and the learned weights  β are reported. For the comparisons between “easy” and “hard” states in Figure 1, states are ranked by τ ( x ) and the fastest and slowest deciles (smallest and largest 10 % of distances) are selected. Digit features are then averaged separately for these two groups. Throughout this subsection, linear regression is used deliberately as a simple and interpretable baseline. The model links distance to attractor to low-dimensional digit summaries in a way that allows direct inspection of feature weights and effect directions, at the cost of restricting attention to linear relationships. More flexible nonlinear models (e.g., decision trees or kernel-based methods) could in principle capture additional structure in the data but would make it harder to relate predictive performance back to specific digit features. For this reason, the present analysis treats the linear model as a reference point rather than an attempt to optimise predictive accuracy.

2.7. Numerical Setup

All computations were performed in MATLAB (R2024b, Mathworks®, Natick, MA, USA), using integer-valued operations for the Kaprekar map that are exactly represented in double-precision arithmetic for the ranges of D considered and double-precision arithmetic for derived quantities such as entropies. Enumeration of 𝒮 D and construction of the gap-space Markov chain are exact for each D { 3 , 4 , 5 , 6 } . Where sampling is used (in the regression analysis), the corresponding sample size is stated.

3. Results

3.1. Visualising Attractors and Basins

Before scalar summary statistics are introduced, the coarse-grained flow of Kaprekar dynamics in the gap space is visualised. Figure 2 shows, for each digit length D { 3 , 4 , 5 , 6 } , the occupancy of gap states ( g 1 , g 2 ) under a uniform prior over 𝒮 D together with the corresponding average one-step drift vectors.
Colours encode how many states realise a given gap pair, and arrows indicate the mean change ( Δ g 2 , Δ g 1 ) produced by a single Kaprekar step. For three digits, trajectories concentrate along a narrow band and converge towards a single high-occupancy region. For larger D the occupied region of the gap space broadens and the flow becomes more heterogeneous, with weaker and more dispersed drift, foreshadowing the more fragmented basin structure quantified below.
Because each gap cell g = ( g 1 , g 2 ) aggregates many distinct digit configurations, the arrows in Figure 2 represent conditional means of the increment Δ g ( x ) over all states consistent with that cell. Table 1 quantifies how much increment directions vary within a fixed gap cell across digit lengths, using the circular (angular) dispersion σ θ ( g ) . Directional variability is numerically negligible for D = 3 , 4 but becomes non-negligible for D 5 . A representative D = 6 example is visualised in Appendix A.1. This within-cell measure makes the qualitative notion of “more dispersed drift” in Figure 2 explicit.
Figure 3 summarises how the global structure of Kaprekar dynamics changes with the number of digits D. For each D the following summary quantities are reported: the number of distinct attractors, the fraction of states lying in the largest basin of attraction, the mean and median distance to attractor, and the maximal distance observed. Here the distance to attractor measures how many iterations of the Kaprekar map are needed before the trajectory enters its attractor cycle. Despite the combinatorial explosion of the state space as D increases, the average number of iterations needed to reach an attractor remains small for all values of D considered. By contrast, the maximal distance, the dominance of the largest basin, and the number of distinct attractors all vary systematically with D. For D = 3 and D = 4 , a single attractor dominates the dynamics, in the sense that most initial states eventually flow into one large basin. For D = 5 and D = 6 , the picture is more fragmented: the largest basin occupies a much smaller fraction of the state space and many additional, smaller attractors appear.
For D { 5 , 6 } the long-run attractor distribution under the uniform initial ensemble does not collapse to a single attractor: instead, multiple attractor cycles (including fixed points as the special case l = 1 ) carry non-zero basin weight. Consequently, the limiting attractor entropy H = H ( p ) is strictly positive, where p denotes the basin size distribution over attractor cycles (i.e., p ( C ) = | { x 𝒮 D : α ( x ) = C } | / | 𝒮 D | ). Table 2 summarises the number of distinct attractor cycles and the dominant basin weights for D = 5 , 6 , with full attractor lists (including cycle lengths) and basin sizes provided in Appendix A.3. Representative numerical examples of convergence to distinct attractor cycles are reported in Appendix A.3.

3.2. Entropy Funnels Across Digit Lengths

Information contraction under Kaprekar iteration can be summarised by entropy funnels, which track how uncertainty about the eventual attractor decreases over time. For each digit length D, Figure 4 shows the Shannon entropy of the induced distribution over attractors, among the trajectories that have converged by iteration t, as a function of iteration, together with a normalised version. High entropy corresponds to a situation in which many attractors are still plausible, whereas low entropy indicates that almost all initial states have effectively committed to a small subset of attractors. Raw entropy (in bits) decays rapidly in the first few iterations and then flattens as trajectories approach their attractors and the basin size distribution is revealed. This apparent “incomplete” decay is expected under the chosen conditioning: H t is computed on the subset of trajectories that have converged by iteration t, so the composition of the conditioned set changes with t as progressively slower trajectories enter it. Consequently, late-time changes in H t primarily reflect the basin weight distribution revealed by these late arrivals (a compositional effect), rather than continued uncertainty within trajectories already included in the conditioned set. The normalised curves show that, for all D, the bulk of uncertainty about the eventual attractor is resolved within roughly five iterations, but the final residual entropy depends strongly on the number and relative sizes of basins. For D = 3 and D = 4 , the normalised entropy drops close to zero, reflecting the near-complete dominance of a single attractor. For D = 5 and D = 6 , the decay is less complete, consistent with the proliferation of attractors and a more even distribution of basin sizes, so that some uncertainty about the final attractor remains even after many iterations.

3.3. Multiset Structure and Digit-Level Features

Factoring states into digit multisets provides a compact summary of the combinatorial structure of the map (Figure 5). A digit multiset records which digits appear and how often but ignores their order, so all permutations of the same digits belong to the same multiset class. This perspective separates purely combinatorial effects (how many permutations a given multiset admits) from dynamical effects (how quickly states built from that multiset converge). For each digit length D { 3 , 4 , 5 , 6 } , the left-hand panel shows the distribution of multiset sizes, i.e., the number of distinct permutations in each class, both as absolute counts (solid line, left axis) and as normalised probabilities (dashed line, right axis). As D increases, the number of multiset classes grows and the distributions shift towards larger sizes with heavier upper tails, indicating the appearance of rare digit patterns with many distinct permutations. The right-hand panels display the corresponding distributions of mean distance to attractor per multiset, obtained by averaging dist ( x ) over all states in a class. For all D, most multisets are associated with short mean distances, but the tails extend further for D = 5 and D = 6 , reflecting a growing minority of digit patterns that are systematically linked to longer transients. This multiset-level view shows that part of the complexity at higher digit lengths arises from an increasingly uneven allocation of basin structure across combinatorial classes.
For each digit length D, states are ranked by their distance to attractor and divided into two extreme groups: the fastest 10 % are referred to as “easy” states and the slowest 10 % as “hard” states. Comparing their digit features reveals systematic differences (Figure 1). Easy states tend to have a larger overall digit spread g 1 = max ( d ) min ( d ) , and for some D they also show higher digit variance, indicating that configurations whose digits are more widely dispersed are typically closer to an attractor in the dynamical sense. Differences in digit sum are much less informative: because the total sum of digits naturally increases with D, shifts in this feature are largely driven by digit length rather than by dynamical difficulty and should therefore be interpreted with caution.

3.4. Gap-Space Markov Structure and Drift

In the gap space, the projection onto ( g 1 , g 2 ) yields an empirical first-order Markov approximation (Section 2.5) whose flow fields are summarised in Figure 2. For D = 3 , the occupied region of the gap space forms a narrow wedge constrained by g 2 g 1 , with the highest occupancy at moderate g 1 and small-to-moderate g 2 . The corresponding drift vectors show a coherent flow towards larger g 1 and moderate g 2 , foreshadowing the basin structure quantified below. For larger D, the flow patterns become progressively more asymmetric, and the stationary distributions place most of their mass in regions with large g 1 and moderate g 2 , indicating a bias towards states with a wide overall digit spread but only a moderate gap between the second and third largest digits. Average drift vectors show a robust tendency to increase g 1 and decrease g 2 , with drift magnitudes decreasing as D grows. To summarise these trends across digit lengths, one-step changes Δ g 1 are regressed on g 2 and Δ g 2 on g 1 for each D, and mean changes per step are computed (Figure 6). The slopes of the linear relations Δ g 1 a D g 2 + b D and Δ g 2 c D g 1 + d D are negative for all D, but their magnitude decreases with D, indicating that the coupling between the two gap coordinates weakens in higher-digit systems. From a more intuitive perspective, the dynamics tend to push states towards regions of the gap space where one large overall digit range coexists with a more balanced configuration among the middle digits, but this directional bias becomes less pronounced as D grows.

3.5. Predictability of Distance from Digit Features

The regression analysis (Figure 7) quantifies how well this particular choice of simple digit features predicts distance to attractor. For D = 3 , the linear model explains approximately R 2 0.43 of the variance in distance, with a root mean squared error (RMSE) of about 1.08 steps over N = 998 states. For D = 4 , 5 , 6 , the R 2 values drop to roughly 0.02 0.03 with a markedly larger RMSE, indicating that, beyond three digits, only a very small fraction of the variability in distance to attractor can be accounted for by these four standardised features within a linear model. In other words, for D 4 , the link between this particular low-dimensional linear summary of local digit structure and global convergence time is weak. The learned regression weights highlight how the influence of individual features changes with D. For D = 3 , a large digit spread g 1 is strongly associated with faster convergence, and digit variance carries a clear positive weight, suggesting that states with more heterogeneous digits tend to approach their attractors quickly. For larger D, the weights shrink in magnitude and fluctuate in sign across features, consistent with a more entangled and higher-dimensional dependence of distance to attractor on the underlying digit configuration. Together, these results show that in the three-digit case simple low-dimensional linear descriptors based on ( g 1 , g 2 , digit   sum , digit   variance ) provide a substantially informative proxy for dynamical difficulty, whereas for D 4 these particular features, within a linear model, account for only a small fraction of the variability in distance to attractor. Richer feature sets or nonlinear models might recover additional structure but are beyond the scope of the present analysis.
Standard regression diagnostics were examined for all models. Residuals showed no systematic dependence on fitted values, and Q–Q plots indicated moderate deviations from normality, particularly for larger D, reflecting the discrete and bounded nature of the response variable. Given the large sample sizes, inference on regression coefficients is robust, and the conclusions rely on effect size ( R 2 and RMSE) rather than strict distributional assumptions.

4. Discussion

The results above describe Kaprekar’s routine, for D = 3 –6, as a finite dynamical system seen through several information-theoretic lenses. A very simple digit transform already produces a surprisingly layered structure: shallow typical transients but long tails, a shift from one dominant basin to many smaller ones, and a useful, but ultimately limited, low-dimensional gap description. At the coarsest level, the global summaries in Figure 3 indicate that the Kaprekar dynamics remains shallow on average across all digit lengths considered: typical trajectories reach an attractor in only a few iterations, despite the combinatorial growth of the state space. This shallow behaviour coexists with marked changes in extremal and structural quantities. The maximal distance to attractor increases with D, the dominance of the largest basin decreases, and the number of distinct attractors rises. For three and four digits, the dynamics are effectively governed by a single large basin, whereas for five and six digits the state space splits into many smaller basins with more heterogeneous sizes. This transition from “one big funnel” to a more fragmented landscape is a first indication that, within the range D = 3 –6 examined here, the global organisation of the map shifts from dominance by a single large basin to a heterogeneous collection of smaller basins. The entropy funnels in Figure 4 provide a complementary information-theoretic view. Starting from a uniform prior over states, the induced distribution over attractors among the trajectories that have converged exhibits a rapid initial entropy drop, followed by a slower tail. In more concrete terms, most uncertainty about the eventual attractor is resolved within a handful of iterations, but a small residual uncertainty can persist for many steps, especially when many attractors of comparable basin size are present. For D = 3 and D = 4 , the normalised entropy curves fall close to zero, in line with the near-monopolisation of the state space by a single attractor. For D = 5 and D = 6 , the residual entropy remains appreciable, reflecting the proliferation of attractors and a more even spread of basin sizes. Thus, entropy funnels capture, in a single scalar time series, both the fast collapse of uncertainty and the dependence of long-term behaviour on basin geometry.
Factoring states into digit multisets yields a first level of symmetry reduction that separates combinatorial and dynamical effects (Figure 5). On the combinatorial side, both the number of multiset classes and their typical sizes grow quickly with D, and the size distributions develop heavier upper tails. This indicates the appearance of rare digit patterns that admit many distinct permutations. On the dynamical side, the distributions of mean distance to attractor per multiset remain concentrated on short distances but develop longer tails for D = 5 and D = 6 . A small subset of multisets is therefore systematically associated with longer transients. In other words, as D increases the basin structure is distributed more unevenly across multisets: a few digit patterns dominate large basins, while many others sit in small, long-tailed classes. The analysis of “easy” and “hard” states in Figure 1 moves one step closer to the digit level. By contrasting the fastest and slowest deciles of distance to attractor, simple patterns emerge: easy states tend to have a larger overall digit spread g 1 and, for some digit lengths, higher digit variance. Configurations whose digits are widely dispersed therefore tend, on average, to reach an attractor more quickly. In contrast, the total digit sum carries much less interpretable dynamical information once trivial scaling with D is taken into account. These observations suggest that certain aspects of “difficulty” are already visible in low-level digit statistics, even before more refined features are introduced.
Gap space provides a coarser, but highly structured, view of the dynamics. By tracking only the overall spread g 1 and the internal gap g 2 between the second and third largest digits, Kaprekar’s routine induces an empirical first-order Markov chain on a relatively small grid. The resulting flow fields and drift statistics reveal a consistent directional bias: on average, one Kaprekar step tends to increase g 1 and decrease g 2 , pushing states towards regions with a wide overall digit range but a more balanced configuration among the middle digits (Figure 6). For three digits, successor states concentrate near the diagonal g 1 g 2 , and the coupling between g 1 and g 2 is strong. As D increases, the stationary distributions shift and the linear relations between Δ g 1 and g 2 , and between Δ g 2 and g 1 , weaken in slope. This weakening suggests that, in higher-digit systems, the two gap coordinates no longer suffice to capture the dominant directions of flow and that additional degrees of freedom in the digit space become dynamically relevant. The gap-space Markov chain is therefore best viewed as a first-order coarse-grained description: it captures the main flow patterns in ( g 1 , g 2 ) but is not intended as an exact probabilistic model of the projected dynamics. The regression analysis in Figure 7 makes this limitation explicit. For D = 3 , a simple linear model based on ( g 1 , g 2 , digit   sum , digit   variance ) explains a substantial fraction of the variance in distance to attractor, with errors on the order of one step. In this regime, low-dimensional digit summaries provide a reasonably informative proxy for dynamical difficulty. For D = 4 , 5 , 6 , however, the coefficient of determination R 2 drops to a few percent and the learned feature weights shrink and fluctuate in sign. Beyond three digits, the relationship between local digit structure and global convergence time becomes increasingly high-dimensional and entangled, so that linear combinations of a small number of simple features capture only a small part of the behaviour. This breakdown of low-dimensional predictability within the present feature set is consistent with the more fragmented basin geometry and more heterogeneous multiset patterns observed at larger D.
Several limitations and extensions follow naturally from these findings. The present study is numerical and restricted to base 10 and digit lengths up to six. From a mathematical perspective, one natural direction is to seek analytic bounds on entropy decay, basin sizes, or gap-space drift as D grows, perhaps by exploiting known structural results on Kaprekar constants and loops in higher bases. Another direction is to refine the coarse-graining schemes: alternative feature sets, nonlinear mappings into the gap space, or higher-order Markov projections could be explored to recover part of the predictive power lost at larger D. The regression framework could also be extended beyond linear models, for example by investigating whether low-depth decision trees or other simple classifiers find more informative digit combinations without sacrificing interpretability.
More broadly, the picture that emerges is that of a finite information-processing system that rapidly funnels a large set of inputs into a much smaller set of outputs while retaining enough internal structure to defeat simple low-dimensional representations of the dynamics once the state space becomes sufficiently large. Kaprekar dynamics therefore offer a useful model system for studying information funnels and coarse-grained Markov structure in deterministic maps on finite spaces. Similar patterns occur in other settings: in statistical physics, many microscopic configurations are summarised by a few macroscopic variables, such as temperature or magnetisation [17,18]; in machine learning, deep networks and information bottleneck methods restrict information flow through low-dimensional latent or bottleneck layers, yielding compact internal codes that still support accurate predictions [19,20]; and in decision neuroscience, multiple streams of evidence are modelled as being accumulated into a single decision variable that governs choice [21,22,23]. Against this background, the Kaprekar map provides a fully tractable model system: the entire state space and all attractors are known explicitly, yet the induced information funnels and coarse-grained dynamics remain non-trivial. This makes the Kaprekar map a natural model system for testing methods that search for informative coarse-grainings or low-dimensional summaries and for exploring how such techniques might carry over to more biologically motivated dynamical models.

Funding

This research was funded by the National Science and Technology Council (NSTC), Taiwan, under grant numbers 112-2410-H-038-027-MY2 and 114-2410-H-038-045 and by the Higher Education Sprout Project by the Ministry of Education (MOE) in Taiwan.

Data Availability Statement

All data analysed in this study consist of deterministic outputs of the Kaprekar map in base 10 for digit lengths D = 3 –6. The MATLAB code used to enumerate the state spaces, compute all summary statistics, and generate the figures is openly available at https://github.com/ChristophDahl/kaprekar-routine-analysis (accessed on 22 November 2025) under the MIT licence. The repository includes a master script (run_kaprekar_all.m) that reproduces all analyses and figures reported in this manuscript.

Conflicts of Interest

The author declares no conflicts of interest. The funders had no role in the design of the study; in the collection, analysis, or interpretation of data; in the writing of the manuscript; or in the decision to publish the results.

Appendix A. Supplementary Analyses

Appendix A.1. Within-Cell Drift Variability

In the main text, arrows in Figure 2 depict the conditional mean gap increment v D ( g ) = E [ Δ g ( x ) g ( x ) = g ] , where Δ g ( x ) = g ( K D ( x ) ) g ( x ) and the average is taken over all underlying states x S D ( g ) = { x S D   :   g ( x ) = g } . Because many distinct digit configurations can map to the same gap cell g, it is useful to quantify how much the one-step increment Δ g ( x ) varies within a cell.
For each occupied gap state g, the empirical covariance of increments is computed as in Equation (14), and dispersion is summarised using (i) total increment variance tr ( Σ D ( g ) ) and (ii) an angular dispersion measure σ θ ( g ) computed from the directions of Δ g ( x ) . Figure A1 visualises these quantities and provides a representative example cell showing the distribution of increments around the mean drift arrow. In the Results, Table 1 summarises these within-cell dispersion statistics across digit lengths D { 3 , 4 , 5 , 6 } , showing that directional variability is negligible for D = 3 , 4 but becomes non-negligible for D 5 . A concrete visualisation is provided for the representative case D = 6 . In the right panel, marker area is proportional to log 10 ( count + 1 ) , where count is the number of underlying states x S D ( g * ) that realise a given discrete increment ( Δ g 2 , Δ g 1 ) .
Figure A1. Within-cell variability of the gap-space drift for D = 6 . (A) Angular dispersion σ θ ( g ) of increment directions Δ g ( x ) within each occupied gap cell g = ( g 1 , g 2 ) , with mean drift arrows (conditional means v D ( g ) ) overlaid; the marked cell indicates the example g * . (B) Discrete one-step increments ( Δ g 2 , Δ g 1 ) observed from the example cell g * , with the marker area proportional to log 10 ( count + 1 ) ; the arrow shows the mean increment for that cell.
Figure A1. Within-cell variability of the gap-space drift for D = 6 . (A) Angular dispersion σ θ ( g ) of increment directions Δ g ( x ) within each occupied gap cell g = ( g 1 , g 2 ) , with mean drift arrows (conditional means v D ( g ) ) overlaid; the marked cell indicates the example g * . (B) Discrete one-step increments ( Δ g 2 , Δ g 1 ) observed from the example cell g * , with the marker area proportional to log 10 ( count + 1 ) ; the arrow shows the mean increment for that cell.
Entropy 28 00092 g0a1

Appendix A.2. Robustness to Alternative Gap-Pair Definitions

To assess whether the qualitative gap-space flow patterns depend strongly on the specific choice of the internal gap g 2 , occupancy and mean drift fields were recomputed under two alternatives to the main-text definition g 2 = d ( 2 ) d ( 3 ) : g 2 ( top ) = d ( 1 ) d ( 2 ) and (for D 4 ) g 2 ( inner ) = d ( 3 ) d ( 4 ) . For each definition, drift fields were constructed by averaging ( Δ g 2 , Δ g 1 ) over all states consistent with a given gap cell, analogously to Equation (13). Figure A2Figure A5 show gap-space flows for base 8 and D { 3 , 4 , 5 , 6 } under the main-text (mid) definition and two alternatives (top and inner). Figure A3 shows entropy funnels for base 8 computed under the same mid definition. Table A1 reports summary similarity statistics (occupancy correlation and drift vector cosine similarity) relative to the main-text mid definition.
Table A1. Similarity of occupancy and mean drift fields for alternative g 2 definitions, relative to the main-text definition g 2 = d ( 2 ) d ( 3 ) (mid). Occupancy similarity is measured as the Pearson correlation of gap-state occupancies across occupied cells; drift similarity is measured as the mean cosine similarity between drift vectors over cells occupied under both definitions.
Table A1. Similarity of occupancy and mean drift fields for alternative g 2 definitions, relative to the main-text definition g 2 = d ( 2 ) d ( 3 ) (mid). Occupancy similarity is measured as the Pearson correlation of gap-state occupancies across occupied cells; drift similarity is measured as the mean cosine similarity between drift vectors over cells occupied under both definitions.
Dcorr(N) (Top)corr(N) (Inner) cos (Top) cos (Inner)
31.0000.595
40.9980.612
50.9870.9720.6410.618
60.9810.9630.6580.631
Figure A2. Flow fields in the gap space for base 8 and D = 3 –6 using the main-text definition g 2 = d ( 2 ) d ( 3 ) (mid). Panels (AD) 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 𝒮 D (colour scale), where # denotes the number (count) of underlying base-8 digit states in each gap cell. Arrows indicate the average one-step drift induced by a single Kaprekar step; horizontal and vertical components correspond to Δ g 2 and Δ g 1 , respectively.
Figure A2. Flow fields in the gap space for base 8 and D = 3 –6 using the main-text definition g 2 = d ( 2 ) d ( 3 ) (mid). Panels (AD) 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 𝒮 D (colour scale), where # denotes the number (count) of underlying base-8 digit states in each gap cell. Arrows indicate the average one-step drift induced by a single Kaprekar step; horizontal and vertical components correspond to Δ g 2 and Δ g 1 , respectively.
Entropy 28 00092 g0a2
Figure A3. Entropy funnels in base 8 (mid definition). (A) Raw Shannon entropy of the induced distribution over attractors, conditional on trajectories that have converged by iteration t, for each D (base 8; D { 3 , 4 , 5 , 6 } ). (B) The same curves normalised as H ˜ t = ( H t H ) / ( H 0 H ) , with H set to the terminal value H T at the final plotted iteration T (chosen such that T t max for each D). Analog of Figure 4 computed for base 8 using the same entropy-funnel procedure as in the main text, under the mid definition g 2 = d ( 2 ) d ( 3 ) .
Figure A3. Entropy funnels in base 8 (mid definition). (A) Raw Shannon entropy of the induced distribution over attractors, conditional on trajectories that have converged by iteration t, for each D (base 8; D { 3 , 4 , 5 , 6 } ). (B) The same curves normalised as H ˜ t = ( H t H ) / ( H 0 H ) , with H set to the terminal value H T at the final plotted iteration T (chosen such that T t max for each D). Analog of Figure 4 computed for base 8 using the same entropy-funnel procedure as in the main text, under the mid definition g 2 = d ( 2 ) d ( 3 ) .
Entropy 28 00092 g0a3
Figure A4. Flow fields in the gap space for base 8 and D = 3 –6 using the top definition g 2 ( top ) = d ( 1 ) d ( 2 ) . Panels (AD) 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 𝒮 D (colour scale), where # denotes the number (count) of underlying base-8 digit states in each gap cell. Arrows indicate the average one-step drift induced by a single Kaprekar step; horizontal and vertical components correspond to Δ g 2 and Δ g 1 , respectively. Same plotting conventions as Figure A2.
Figure A4. Flow fields in the gap space for base 8 and D = 3 –6 using the top definition g 2 ( top ) = d ( 1 ) d ( 2 ) . Panels (AD) 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 𝒮 D (colour scale), where # denotes the number (count) of underlying base-8 digit states in each gap cell. Arrows indicate the average one-step drift induced by a single Kaprekar step; horizontal and vertical components correspond to Δ g 2 and Δ g 1 , respectively. Same plotting conventions as Figure A2.
Entropy 28 00092 g0a4
Figure A5. (A) Flow fields in the gap space for base 8 using the inner definition g 2 ( inner ) = d ( 3 ) d ( 4 ) , which is defined only for D 4 (hence no panel for D = 3 ). Panels (BD) correspond to D = 4 , 5 , 6 , respectively. Each panel shows the occupancy of gap states ( g 1 , g 2 ) under a uniform prior over 𝒮 D (colour scale), where # denotes the number (count) of underlying base-8 digit states in each gap cell. Arrows indicate the average one-step drift induced by a single Kaprekar step; horizontal and vertical components correspond to Δ g 2 and Δ g 1 , respectively. Same plotting conventions as Figure A2.
Figure A5. (A) Flow fields in the gap space for base 8 using the inner definition g 2 ( inner ) = d ( 3 ) d ( 4 ) , which is defined only for D 4 (hence no panel for D = 3 ). Panels (BD) correspond to D = 4 , 5 , 6 , respectively. Each panel shows the occupancy of gap states ( g 1 , g 2 ) under a uniform prior over 𝒮 D (colour scale), where # denotes the number (count) of underlying base-8 digit states in each gap cell. Arrows indicate the average one-step drift induced by a single Kaprekar step; horizontal and vertical components correspond to Δ g 2 and Δ g 1 , respectively. Same plotting conventions as Figure A2.
Entropy 28 00092 g0a5
Qualitatively, the geometry of the gap-space flow is preserved across these alternative g 2 definitions. Table A1 summarises occupancy and drift field similarity relative to the main-text mid definition.

Appendix A.3. Attractors and Basin Sizes

For completeness, Appendix A.3 reports the attractor cycles for D = 5 and D = 6 together with their basin sizes under the Kaprekar map. For an attractor cycle C, the basin size is | B ( C ) | = | { x 𝒮 D : α ( x ) = C } | , and the corresponding basin weight under the uniform initial ensemble on 𝒮 D is p ( C ) = | B ( C ) | / | 𝒮 D | . Cycle length is l = | C | , with fixed points corresponding to the special case l = 1 .
As an illustration (for D = 6 ), the initial state x = 873 , 210 maps to 860 , 832 in one step (cycle entry at t = 1 ), while x = 990 , 010 maps to ⋯ and first enters the same attractor at t = 8 . After entry, the trajectory follows the 7-cycle 860 , 832 862 , 632 642 , 654 420 , 876 851 , 742 750 , 843 840 , 852 860 , 832 . All observed attractors for D { 5 , 6 } are periodic orbits of the deterministic map K D (fixed points are the special case l = 1 ). No non-periodic attractors occur on a finite state space.
Table A2. Attractor cycles for D = 5 (base 10) and their basin sizes.
Table A2. Attractor cycles for D = 5 (base 10) and their basin sizes.
Cycle (Canonical)Basin SizeBasin Weight p
53,955 → 59,994231900.0319031903
61,974 → 82,962 → 75,933 → 63,954448,4800.4848484848
62,964 → 71,973 → 83,952 → 74,943448,3200.4832483248
Table A3. Attractor cycles for D = 6 (base 10) and their basin sizes.
Table A3. Attractor cycles for D = 6 (base 10) and their basin sizes.
Cycle (Canonical)Basin SizeBasin Weight p
420,876 → 851,742 → 750,843 → 840,852 → 860,832 → 862,632 → 642,6547935,5200.9355293553
631,764162,5200.0625206252
549,945119500.0019500195

Appendix A.4. Linear Regression Details and Diagnostics

Table A4. Multiple linear regression predicting steps to attractor from z-scored digit features. Coefficients are reported with standard errors (SEs), 95% confidence intervals (CIs), and two-sided p-values. Fit statistics (N, R 2 , adj. R 2 , and RMSE) are reported per D.
Table A4. Multiple linear regression predicting steps to attractor from z-scored digit features. Coefficients are reported with standard errors (SEs), 95% confidence intervals (CIs), and two-sided p-values. Fit statistics (N, R 2 , adj. R 2 , and RMSE) are reported per D.
DPredictorEstimateSECIlowCIhighp
D = 3 : N = 998 , R 2 = 0.431 , adj. R 2 = 0.429 , RMSE = 1.077
3Intercept3.22440.03423.15743.29150
3 g 1 −3.31130.1239−3.5545−3.06816.03 × 10−119
3 g 2 0.00420.0439−0.08200.09040.924
3sum( d i )−0.01490.0362−0.08590.05610.680
3Var(d)3.07430.12132.83633.31231.04 × 10−109
D = 4 : N = 9998 , R 2 = 0.017 , adj. R 2 = 0.017 , RMSE = 1.763
4Intercept4.66550.01764.63104.70010
4 g 1 0.31820.05910.20240.43407.31 × 10−8
4 g 2 −0.11440.0250−0.1635−0.06544.94 × 10−6
4sum( d i )−0.00110.0176−0.03570.03350.950
4Var(d)−0.38320.0663−0.5132−0.25327.70 × 10−9
D = 5 : N = 50 , 000 , R 2 = 0.029 , adj. R 2 = 0.029 , RMSE = 1.438
5Intercept2.64610.00642.63352.65870
5 g 1 −0.45620.0160−0.4875−0.42498.10 × 10−178
5 g 2 −0.21630.0077−0.2313−0.20139.49 × 10−174
5sum( d i )−0.02420.0065−0.0369−0.01142.03 × 10−4
5Var(d)0.40520.01720.37150.43881.11 × 10−122
D = 6 : N = 50 , 000 , R 2 = 0.010 , adj. R 2 = 0.010 , RMSE = 3.105
6Intercept5.23450.01395.20735.26180
6 g 1 −0.56020.0287−0.6166−0.50392.85 × 10−84
6 g 2 0.07700.01520.04730.10673.83e × 10−7
6sum( d i )0.01280.0142−0.01500.04070.367
6Var(d)0.34500.02960.28690.40312.67 × 10−31

References

  1. Kaprekar, D.R. Another solitaire game. Scr. Math. 1949, 15, 244–245. [Google Scholar]
  2. Kaprekar, D.R. An interesting property of the number 6174. Scr. Math. 1955, 21, 304. [Google Scholar]
  3. Nishiyama, Y. Mysterious Number 6174. Plus Mag. March 2006. Available online: https://plus.maths.org/issue38/features/nishiyama/2pdf/index.html/op.pdf (accessed on 30 October 2025).
  4. Trigg, C.W. Kaprekar’s Routine with Two-digit integers. Fibonacci Q. 1971, 9, 189–194. [Google Scholar] [CrossRef]
  5. Trigg, C.W. Kaprekar’s routine with five-digit integers. Math. Mag. 1972, 45, 121–129. [Google Scholar] [CrossRef]
  6. Eldridge, K.E.; Sagong, S. The determination of Kaprekar convergence and loop convergence of all three-digit numbers. Am. Math. Mon. 1988, 95, 105–112. [Google Scholar] [CrossRef]
  7. Prichett, G.; Ludington, A.; Lapenta, J. The determination of all decadic Kaprekar constants. Fibonacci Q. 1981, 19, 45–52. [Google Scholar] [CrossRef]
  8. Walden, B.L. Searching for Kaprekar’s constants: Algorithms and results. Int. J. Math. Math. Sci. 2005, 2005, 2999–3004. [Google Scholar] [CrossRef]
  9. Dolan, S. A classification of Kaprekar constant. Math. Gaz. 2011, 95, 437–443. [Google Scholar] [CrossRef]
  10. Yamagami, A. On 2-adic Kaprekar constants and 2-digit Kaprekar distances. J. Number Theory 2018, 185, 257–280. [Google Scholar] [CrossRef]
  11. Wang, Z.; Lu, W. On 2-digit and 3-digit Kaprekar’s Routine. arXiv 2021, arXiv:2101.09708. [Google Scholar]
  12. Nuez, F. Symmetries in Generalized Kaprekar’s Routine. Symmetry 2022, 14, 37. [Google Scholar] [CrossRef]
  13. Devlin, P.; Zeng, T. Maximum distances in the four-digit Kaprekar process. arXiv 2020, arXiv:2010.11756. [Google Scholar] [CrossRef]
  14. Shannon, C.E. A mathematical theory of communication. Bell Syst. Tech. J. 1948, 27, 379–423. [Google Scholar] [CrossRef]
  15. Cover, T.M. Elements of Information Theory; John Wiley & Sons: Hoboken, NJ, USA, 1999. [Google Scholar]
  16. Norris, J.R. Markov Chains; Cambridge University Press: Cambridge, UK, 1998. [Google Scholar]
  17. Huang, K. Statistical Mechanics; John Wiley & Sons: Hoboken, NJ, USA, 2008. [Google Scholar]
  18. Pathria, R.K.; Beale, P.D. The Theory of Simple Gases. In Statistical Mechanics, 3rd ed.; Academic Press: Boston, MA, USA, 2011; pp. 141–178. [Google Scholar]
  19. Barber, D. Bayesian Reasoning and Machine Learning; Cambridge University Press: Cambridge, UK, 2012. [Google Scholar]
  20. Tishby, N.; Zaslavsky, N. Deep learning and the information bottleneck principle. In Proceedings of the 2015 IEEE Information Theory Workshop (ITW), Jeju Island, Republic of Korea, 11–15 October 2015; IEEE: New York, NY, USA, 2015; pp. 1–5. [Google Scholar]
  21. Ratcliff, R.; McKoon, G. The diffusion decision model: Theory and data for two-choice decision tasks. Neural Comput. 2008, 20, 873–922. [Google Scholar] [CrossRef] [PubMed]
  22. Shadlen, M.N.; Newsome, W.T. Neural basis of a perceptual decision in the parietal cortex (area LIP) of the rhesus monkey. J. Neurophysiol. 2001, 86, 1916–1936. [Google Scholar] [CrossRef] [PubMed]
  23. Gold, J.I.; Shadlen, M.N. The neural basis of decision making. Annu. Rev. Neurosci. 2007, 30, 535–574. [Google Scholar] [CrossRef] [PubMed]
Figure 1. 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 (AD) show, respectively, the mean digit spread g 1 (difference between the largest and smallest digit; Equation (9)), digit variance Var ( d ) , the mean digit d ¯ = 1 D i = 1 D d i (i.e., digit sum normalised by D; in (C), the Easy and Hard curves overlap), 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.
Figure 1. 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 (AD) show, respectively, the mean digit spread g 1 (difference between the largest and smallest digit; Equation (9)), digit variance Var ( d ) , the mean digit d ¯ = 1 D i = 1 D d i (i.e., digit sum normalised by D; in (C), the Easy and Hard curves overlap), 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.
Entropy 28 00092 g001
Figure 2. Flow fields in the gap space for D = 3 –6. Panels (AD) 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 𝒮 D (colour scale) where # denotes the number (count) of underlying digit states in S D that fall into each gap cell. Arrows indicate the 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 Δ g 2 and Δ g 1 , respectively. For each occupied gap state g, the arrow is the empirical mean drift v D ( g ) averaged over all underlying states x 𝒮 D ( g ) (Equation (13)). Within-cell variability around the mean drift is quantified by the increment covariance Σ D ( g ) (Equation (14)) and summarised in Appendix A.1.
Figure 2. Flow fields in the gap space for D = 3 –6. Panels (AD) 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 𝒮 D (colour scale) where # denotes the number (count) of underlying digit states in S D that fall into each gap cell. Arrows indicate the 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 Δ g 2 and Δ g 1 , respectively. For each occupied gap state g, the arrow is the empirical mean drift v D ( g ) averaged over all underlying states x 𝒮 D ( g ) (Equation (13)). Within-cell variability around the mean drift is quantified by the increment covariance Σ D ( g ) (Equation (14)) and summarised in Appendix A.1.
Entropy 28 00092 g002
Figure 3. 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. 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.
Entropy 28 00092 g003
Figure 4. 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 as H ˜ t = ( H t H ) / ( H 0 H ) , with H set to the terminal value H T at the final plotted iteration T (chosen such that T t max for each D). All digit lengths exhibit a rapid early collapse of uncertainty, followed by a slower tail governed by the distribution of basin sizes.
Figure 4. 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 as H ˜ t = ( H t H ) / ( H 0 H ) , with H set to the terminal value H T at the final plotted iteration T (chosen such that T t max for each D). All digit lengths exhibit a rapid early collapse of uncertainty, followed by a slower tail governed by the distribution of basin sizes.
Entropy 28 00092 g004
Figure 5. Multiset structure of Kaprekar dynamics across digit lengths. Panels (A,C,E,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,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 a small mean distance (fewer than three steps), with a long right tail for D = 5 and D = 6 .
Figure 5. Multiset structure of Kaprekar dynamics across digit lengths. Panels (A,C,E,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,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 a small mean distance (fewer than three steps), with a long right tail for D = 5 and D = 6 .
Entropy 28 00092 g005
Figure 6. Cross-digit summary of average gap drift. Panels (A,B) show the slopes of the linear relations Δ g 1 a D g 2 + b D and Δ g 2 c D g 1 + d D , respectively, as a function of D, obtained by ordinary least-squares fits across all occupied gap states. The negative slopes indicate a robust coupling between the two gap coordinates that weakens with increasing D. Panels (C,D) show the average drifts Δ g 1 and Δ g 2 per step, revealing a systematic tendency to increase g 1 and decrease g 2 that becomes smaller in magnitude for higher D.
Figure 6. Cross-digit summary of average gap drift. Panels (A,B) show the slopes of the linear relations Δ g 1 a D g 2 + b D and Δ g 2 c D g 1 + d D , respectively, as a function of D, obtained by ordinary least-squares fits across all occupied gap states. The negative slopes indicate a robust coupling between the two gap coordinates that weakens with increasing D. Panels (C,D) show the average drifts Δ g 1 and Δ g 2 per step, revealing a systematic tendency to increase g 1 and decrease g 2 that becomes smaller in magnitude for higher D.
Entropy 28 00092 g006
Figure 7. Predicting distance to attractor from simple digit features. Panel (A) shows the coefficient of determination R 2 for linear regression models predicting the number of Kaprekar steps from standardised features ( g 1 , g 2 , digit   sum , digit   variance ) as a function of digit length D. Predictive power is substantial for D = 3 but drops sharply for D 4 in this simple linear model. Panel (B) shows the learned regression weights for each feature across D, indicating that a large digit spread g 1 is strongly associated with faster convergence only for three digits, while for larger D the relationship between these local features and global distance to attractor becomes weak within this linear framework.
Figure 7. Predicting distance to attractor from simple digit features. Panel (A) shows the coefficient of determination R 2 for linear regression models predicting the number of Kaprekar steps from standardised features ( g 1 , g 2 , digit   sum , digit   variance ) as a function of digit length D. Predictive power is substantial for D = 3 but drops sharply for D 4 in this simple linear model. Panel (B) shows the learned regression weights for each feature across D, indicating that a large digit spread g 1 is strongly associated with faster convergence only for three digits, while for larger D the relationship between these local features and global distance to attractor becomes weak within this linear framework.
Entropy 28 00092 g007
Table 1. Within-cell directional variability of the gap-space increment Δ g across digit lengths D. For each occupied gap cell g = ( g 1 , g 2 ) , the circular dispersion σ θ ( g ) is computed from increment directions Δ g ( x ) over all states x mapping to that cell. Reported are the median and 90th percentile of σ θ ( g ) over occupied cells, the fraction of cells with σ θ ( g ) > 1 rad, and the number of occupied cells. # cells denotes the number of occupied gap cells (i.e., those with non-empty S D ( g ) ); for D { 3 , 4 , 5 , 6 } this count is 54.
Table 1. Within-cell directional variability of the gap-space increment Δ g across digit lengths D. For each occupied gap cell g = ( g 1 , g 2 ) , the circular dispersion σ θ ( g ) is computed from increment directions Δ g ( x ) over all states x mapping to that cell. Reported are the median and 90th percentile of σ θ ( g ) over occupied cells, the fraction of cells with σ θ ( g ) > 1 rad, and the number of occupied cells. # cells denotes the number of occupied gap cells (i.e., those with non-empty S D ( g ) ); for D { 3 , 4 , 5 , 6 } this count is 54.
DMedian σ θ p 90 ( σ θ ) Pr [ σ θ > 1 ] # Cells
30 1.55 × 10 8 054
40 5.03 × 10 8 054
5 0.173 0.903 0.0741 54
6 0.284 1.180 0.185 54
Table 2. Summary of attractor cycles for D = 5 , 6 and their basin weight distribution under the uniform initial ensemble on 𝒮 D . K D denotes the number of distinct attractor cycles; w i are the largest basin weights in descending order; and H is the corresponding basin size entropy in bits.
Table 2. Summary of attractor cycles for D = 5 , 6 and their basin weight distribution under the uniform initial ensemble on 𝒮 D . K D denotes the number of distinct attractor cycles; w i are the largest basin weights in descending order; and H is the corresponding basin size entropy in bits.
D K D w 1 w 2 w 3 H
530.4848480.4832480.0319031.171943
630.9355290.0625210.0019500.357554
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Dahl, C.D. Coarse-Grained Drift Fields and Attractor-Basin Entropy in Kaprekar’s Routine. Entropy 2026, 28, 92. https://doi.org/10.3390/e28010092

AMA Style

Dahl CD. Coarse-Grained Drift Fields and Attractor-Basin Entropy in Kaprekar’s Routine. Entropy. 2026; 28(1):92. https://doi.org/10.3390/e28010092

Chicago/Turabian Style

Dahl, Christoph D. 2026. "Coarse-Grained Drift Fields and Attractor-Basin Entropy in Kaprekar’s Routine" Entropy 28, no. 1: 92. https://doi.org/10.3390/e28010092

APA Style

Dahl, C. D. (2026). Coarse-Grained Drift Fields and Attractor-Basin Entropy in Kaprekar’s Routine. Entropy, 28(1), 92. https://doi.org/10.3390/e28010092

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop