Collatz conjecture

The Collatz conjecture is a conjecture in mathematics that concerns sequences defined as follows: start with any positive integer . Then each term is obtained from the previous term as follows: if the previous term is even, the next term is one half of the previous term. If the previous term is odd, the next term is 3 times the previous term plus 1. The conjecture is that no matter what value of , the sequence will always reach 1.
The conjecture is named after Lothar Collatz, who introduced the idea in 1937, two years after receiving his doctorate. It is also known as the problem, the conjecture, the Ulam conjecture (after Stanisław Ulam), Kakutani's problem (after Shizuo Kakutani), the Thwaites conjecture (after Sir Bryan Thwaites), Hasse's algorithm (after Helmut Hasse), or the Syracuse problem. 
The sequence of numbers involved is sometimes referred to as the hailstone sequence or hailstone numbers (because the values are usually subject to multiple descents and ascents like hailstones in a cloud), or as wondrous numbers.
Paul Erdős said about the Collatz conjecture: "Mathematics may not be ready for such problems." He also offered US$500 for its solution. Jeffrey Lagarias stated in 2010 that the Collatz conjecture "is an extraordinarily difficult problem, completely out of reach of present day mathematics."
Statement of the problem.
Consider the following operation on an arbitrary positive integer:
In modular arithmetic notation, define the function as follows:
Now form a sequence by performing this operation repeatedly, beginning with any positive integer, and taking the result at each step as the input at the next.
In notation:
(that is: is the value of applied to recursively times; ).
The Collatz conjecture is: "This process will eventually reach the number 1, regardless of which positive integer is chosen initially."
If the conjecture is false, it can only be because there is some starting number which gives rise to a sequence that does not contain 1. Such a sequence would either enter a repeating cycle that excludes 1, or increase without bound. No such sequence has been found.
The smallest such that is called the stopping time of . Similarly, the smallest such that is called the total stopping time of . If one of the indexes or doesn't exist, we say that the stopping time or the total stopping time, respectively, is infinite.
The Collatz conjecture asserts that the total stopping time of every is finite. It is also equivalent to saying that every has a finite stopping time.
Since is even whenever is odd, one may instead use the "shortcut" form of the Collatz function
formula_3
This definition yields smaller values for the stopping time and total stopping time without changing the overall dynamics of the process.
Empirical data.
For instance, starting with , one gets the sequence 12, 6, 3, 10, 5, 16, 8, 4, 2, 1.
The number takes longer to reach 1: 19, 58, 29, 88, 44, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1.
The sequence for , listed and graphed below, takes 111 steps (41 steps through odd numbers, in bold), climbing as high as 9232 before descending to 1.
Numbers with a total stopping time longer than that of any smaller starting value form a sequence beginning with:
The starting values whose maximum trajectory point is greater than that of any smaller starting value are as follows:
Number of steps for to reach 1 are
The starting value having the largest total stopping time while being
These numbers are the lowest ones with the indicated step count, but not necessarily the only ones below the given limit. As an example, has 1132 steps, as does .
The starting values having the smallest total stopping time with respect to their number of digits (in base 2) are the powers of two since is halved times to reach 1, and is never increased.
Supporting arguments.
Although the conjecture has not been proven, most mathematicians who have looked into the problem think the conjecture is true because experimental evidence and heuristic arguments support it.
Experimental evidence.
, the conjecture has been checked by computer for all starting values up to 268 ≈ 2.95×1020. All initial values tested so far eventually end in the repeating cycle of period 3. 
This computer evidence is not sufficient to prove that the conjecture is true for all starting values. As in the case of some disproved conjectures, like the Pólya conjecture, counterexamples might be found when considering very large numbers.
However, such verifications may have other implications. For example, one can derive additional constraints on the period and structural form of a non-trivial cycle.
A probabilistic heuristic.
If one considers only the "odd" numbers in the sequence generated by the Collatz process, then each odd number is on average of the previous one. (More precisely, the geometric mean of the ratios of outcomes is .) This yields a heuristic argument that every Hailstone sequence should decrease in the long run, although this is not evidence against other cycles, only against divergence. The argument is not a proof because it assumes that Hailstone sequences are assembled from uncorrelated probabilistic events. (It does rigorously establish that the 2-adic extension of the Collatz process has two division steps for every multiplication step for almost all 2-adic starting values.)
Stopping times.
As proved by Terras, almost every positive integer has a finite stopping time. In other words, almost every Collatz sequence reaches a point that is strictly below its initial value. The proof is based on the distribution of parity vectors and uses the central limit theorem.
In 2019, Terence Tao considerably improved this result by showing, using logarithmic density, that almost all Collatz orbits are descending below any given function of the starting point, provided that this function diverges to infinity, no matter how slowly. Responding to this work, "Quanta Magazine" wrote that Tao "came away with one of the most significant results on the Collatz conjecture in decades."
Lower bounds.
In a computer-aided proof, Krasikov and Lagarias showed that the number of integers in the interval that eventually reach 1 is at least equal to for all sufficiently large .
Cycles.
In this part, consider the shortcut form of the Collatz function
A cycle is a sequence of distinct positive integers where , , ..., and .
The only known cycle is of period 2, called the trivial cycle.
Cycle length.
The length of a non-trivial cycle is known to be at least . In fact, Eliahou (1993) proved that the period of any non-trivial cycle is of the form 
where , and are non-negative integers, and . This result is based on the continued fraction expansion of .
A similar reasoning that accounts for the recent verification of the conjecture up to leads to the improved lower bound (or without the "shortcut"). This lower bound is consistent with the above result, since 
-cycles.
A -cycle is a cycle that can be partitioned into contiguous subsequences: increasing sequences of odd numbers alternating with decreasing sequences of even numbers. For instance, if the cycle consists of a single increasing sequence of odd numbers followed by a decreasing sequence of even numbers, it is called a "1-cycle".
Steiner (1977) proved that there is no 1-cycle other than the trivial . Simons (2004) used Steiner's method to prove that there is no 2-cycle. Simons & de Weger (2005) extended this proof up to 68-cycles: there is no -cycle up to . For each beyond 68, this method gives an upper bound for the smallest term of a -cycle: for example, if there is a 77-cycle, then at least one element of the cycle is less than . Along with the verification of the conjecture up to , this implies the nonexistence of a non-trivial -cycle up to . As exhaustive computer searches continue, larger values may be ruled out. To state the argument more intuitively: we need not look for cycles that have at most 77 circuits, where each circuit consists of consecutive ups followed by consecutive downs.
Other formulations of the conjecture.
In reverse.
There is another approach to prove the conjecture, which considers the bottom-up
method of growing the so-called "Collatz graph". The "Collatz graph" is a graph defined by the inverse relation
So, instead of proving that all positive integers eventually lead to 1, we can try to prove that 1 leads backwards to all positive integers. For any integer , if and only if . Equivalently, if and only if . Conjecturally, this inverse relation forms a tree except for the 1–2–4 loop (the inverse of the 4–2–1 loop of the unaltered function defined in the Statement of the problem section of this article).
When the relation of the function is replaced by the common substitute "shortcut" relation , the Collatz graph is defined by the inverse relation,
For any integer , if and only if . Equivalently, if and only if . Conjecturally, this inverse relation forms a tree except for a 1–2 loop (the inverse of the 1–2 loop of the function f(n) revised as indicated above).
Alternatively, replace the with where and is the highest power of 2 that divides (with no remainder). The resulting function maps from odd numbers to odd numbers. Now suppose that for some odd number , applying this operation times yields the number 1 (that is, ). Then in binary, the number can be written as the concatenation of strings where each is a finite and contiguous extract from the representation of . The representation of therefore holds the repetends of , where each repetend is optionally rotated and then replicated up to a finite number of bits. It is only in binary that this occurs. Conjecturally, every binary string that ends with a '1' can be reached by a representation of this form (where we may add or delete leading '0's to ).
As an abstract machine that computes in base two.
Repeated applications of the Collatz function can be represented as an abstract machine that handles strings of bits. The machine will perform the following three steps on any odd number until only one "1" remains:
Example.
The starting number 7 is written in base two as 111. The resulting Collatz sequence is:
 111
 1111
 10110
 10111
 100010
 100011
 110100
 11011
 101000
 1011
 10000
As a parity sequence.
For this section, consider the Collatz function in the slightly modified form
This can be done because when is odd, is always even.
If is the parity of a number, that is and , then we can define the Collatz parity sequence (or parity vector) for a number as , where , and .
Which operation is performed, or , depends on the parity. The parity sequence is the same as the sequence of operations.
Using this form for , it can be shown that the parity sequences for two numbers and will agree in the first terms if and only if and are equivalent modulo . This implies that every number is uniquely identified by its parity sequence, and moreover that if there are multiple Hailstone cycles, then their corresponding parity cycles must be different.
Applying the function times to the number will give the result , where is the result of applying the function times to , and is how many increases were encountered during that sequence (e.g. for there are 3 increases as 1 iterates to 2, 1, 2, 1, and finally to 2 so the result is ; for there is only 1 increase as 1 rises to 2 and falls to 1 so the result is ). When is then there will be rises and the result will be . The factor of 3 multiplying is independent of the value of ; it depends only on the behavior of . This allows one to predict that certain forms of numbers will always lead to a smaller number after a certain number of iterations, e.g. becomes after two applications of and becomes after 4 applications of . Whether those smaller numbers continue to 1, however, depends on the value of .
As a tag system.
For the Collatz function in the form
formula_9
Hailstone sequences can be computed by the extremely simple with production rules
In this system, the positive integer is represented by a string of copies of , and iteration of the tag operation halts on any word of length less than 2. (Adapted from De Mol.)
The Collatz conjecture equivalently states that this tag system, with an arbitrary finite string of as the initial word, eventually halts (see "" for a worked example).
Extensions to larger domains.
Iterating on all integers.
An extension to the Collatz conjecture is to include all integers, not just positive integers. Leaving aside the cycle 0 → 0 which cannot be entered from outside, there are a total of 4 known cycles, which all nonzero integers seem to eventually fall into under iteration of . These cycles are listed here, starting with the well-known cycle for positive :
Odd values are listed in large bold. Each cycle is listed with its member of least absolute value (which is always odd) first.
The generalized Collatz conjecture is the assertion that every integer, under iteration by , eventually falls into one of the four cycles above or the cycle 0 → 0. The 0 → 0 cycle is often regarded as "trivial" by the argument, as it is only included for the sake of completeness.
Iterating on rationals with odd denominators.
The Collatz map can be extended to (positive or negative) rational numbers which have odd denominators when written in lowest terms. 
The number is taken to be 'odd' or 'even' according to whether its numerator is odd or even. Then the formula for the map is exactly the same as when the domain is the integers: an 'even' such rational is divided by 2; an 'odd' such rational is multiplied by 3 and then 1 is added. A closely related fact is that the Collatz map extends to the ring of 2-adic integers, which contains the ring of rationals with odd denominators as a subring.
When using the "shortcut" definition of the Collatz map, it is known that any periodic parity sequence is generated by exactly one rational. Conversely, it is conjectured that every rational with an odd denominator has an eventually cyclic parity sequence (Periodicity Conjecture).
If a parity cycle has length and includes odd numbers exactly times at indices , then the unique rational which generates immediately and periodically this parity cycle is
For example, the parity cycle has length 7 and four odd terms at indices 0, 2, 3, and 6. It is repeatedly generated by the fraction
as the latter leads to the rational cycle 
Any cyclic permutation of is associated to one of the above fractions. For instance, the cycle is produced by the fraction
For a one-to-one correspondence, a parity cycle should be "irreducible", i.e., not partitionable into identical sub-cycles. As an illustration of this, the parity cycle and its sub-cycle are associated to the same fraction when reduced to lowest terms.
In this context, assuming the validity of the Collatz conjecture implies that and are the only parity cycles generated by positive whole numbers (1 and 2, respectively).
If the odd denominator of a rational is not a multiple of 3, then all the iterates have the same denominator and the sequence of numerators can be obtained by applying the "" generalization of the Collatz function
2-adic extension.
The function 
is well-defined on the ring of 2-adic integers, where it is continuous and measure-preserving with respect to the 2-adic measure. Moreover, its dynamics is known to be ergodic.
Define the "parity vector" function acting on as
The function is a 2-adic isometry. Consequently, every infinite parity sequence occurs for exactly one 2-adic integer, so that almost all trajectories are acyclic in formula_16.
An equivalent formulation of the Collatz conjecture is that
Iterating on real or complex numbers.
The Collatz map (with shortcut) can be viewed as the restriction to the integers of the smooth map
The iterations of this map on the real line lead to a dynamical system, further investigated by Chamberland.
He showed that the conjecture does not hold for positive real numbers since there are infinitely many fixed points, as well as orbits escaping monotonically to infinity. The function formula_19 has two attracting cycles of period 2, formula_20 and formula_21. Moreover, the set of unbounded orbits is conjectured to be of measure 0.
Letherman, Schleicher, and Wood extended the study to the complex plane, where most of the points have orbits that diverge to infinity (colored region on the illustration). The boundary between the colored region and the black components, namely the Julia set of formula_19, is a fractal pattern, sometimes called the "Collatz fractal".
Optimizations.
Time–space tradeoff.
The section "As a parity sequence" above gives a way to speed up simulation of the sequence. To jump ahead steps on each iteration (using the function from that section), break up the current number into two parts, (the least significant bits, interpreted as an integer), and (the rest of the bits as an integer). The result of jumping ahead steps can be found as:
The (or better ) and arrays are precalculated for all possible -bit numbers , where is the result of applying the function times to , and is the number of odd numbers encountered on the way. For example, if , one can jump ahead 5 steps on each iteration by separating out the 5 least significant bits of a number and using:
This requires precomputation and storage to speed up the resulting calculation by a factor of , a space–time tradeoff.
Modular restrictions.
For the special purpose of searching for a counterexample to the Collatz conjecture, this precomputation leads to an even more important acceleration, used by Tomás Oliveira e Silva in his computational confirmations of the Collatz conjecture up to large values of . If, for some given and , the inequality
holds for all , then the first counterexample, if it exists, cannot be modulo . For instance, the first counterexample must be odd because , smaller than ; and it must be 3 mod 4 because , smaller than . For each starting value which is not a counterexample to the Collatz conjecture, there is a for which such an inequality holds, so checking the Collatz conjecture for one starting value is as good as checking an entire congruence class. As increases, the search only needs to check those residues that are not eliminated by lower values of . Only an exponentially small fraction of the residues survive. For example, the only surviving residues mod 32 are 7, 15, 27, and 31.
Syracuse function.
If is an odd integer, then is even, so with odd and . The Syracuse function is the function from the set of odd integers into itself, for which .
Some properties of the Syracuse function are:
The Collatz conjecture is equivalent to the statement that, for all in , there exists an integer such that .
Undecidable generalizations.
In 1972, John Horton Conway proved that a natural generalization of the Collatz problem is algorithmically undecidable.
Specifically, he considered functions of the form
and are rational numbers which are so chosen that is always an integer.
The standard Collatz function is given by , , , , . Conway proved that the problem:
is undecidable, by representing the halting problem in this way.
Closer to the Collatz problem is the following "universally quantified" problem:
Modifying the condition in this way can make a problem either harder or easier to solve (intuitively, it is harder to justify a positive answer but might be easier to justify a negative one). Kurtz and Simon proved that the above problem is, in fact, undecidable and even higher in the arithmetical hierarchy, specifically -complete. This hardness result holds even if one restricts the class of functions by fixing the modulus to 6480.
In popular culture.
In the movie "Incendies", a graduate student in pure mathematics explains the Collatz conjecture to a group of undergraduates. She puts her studies on hold for a time to address some unresolved questions about her family's past. Late in the movie, the Collatz conjecture turns out to have foreshadowed a disturbing and difficult discovery that she makes about her family.