Binary fraction 2026-10-25
A base-two positional fraction with a binary point separating nonnegative and negative powers of two. For example, . A finite expansion is a dyadic rational: with fractional places, its value is an integer divided by . Conversely, any nonnegative reduced fraction whose denominator is a power of two has a finite binary expansion. Leading integer zeroes and trailing fractional zeroes do not change its value.
Binary powering multiplication count Created 2026-10-14 Updated 2026-10-24
For the optimized left-to-right exponentiation by squaring algorithm, let be the length of the binary expansion of a positive integer , and let be its Hamming weight, the number of digits equal to one. There are exactly digits after the leading one, and exactly remaining ones. Therefore the count is
Here counts squarings and counts further multiplications by the base; every squaring counts as one multiplication in . Assignment, digit reading, and any inversion are outside this count. The formula includes , which requires zero multiplications; define separately.
For a fixed length , the bounds are . A power of two reaches the lower bound because its Hamming weight is one; reaches the upper bound because all digits are one. For , and , giving . Thus the arithmetic operation count is in Big O notation, but inputs of similar magnitude can have different counts.
Figure 1.
Exact multiplication counts for optimized exponentiation by squaring depend on binary length and Hamming weight
. For positive exponents through , dots show , including each squaring. The dashed curves bound all counts at each binary length. Successive multiplication needs operations. The second panel compares squarings and further multiplications for exponents . These are exact counts, not timing measurements. Details.
This is a count for the specified algorithm, not a claim that it always minimizes multiplications among all methods. For instance, at the count is six, but the powers with exponents can be built in five multiplications: square, multiply by , square, square, then multiply by the already stored . Saving operations this way uses a different schedule and stored intermediate powers.
Binomial coefficients with even interior terms Created 2026-10-05 Updated 2026-10-06
For a positive integer , all binomial coefficients with are even exactly when is a power of two. Write the binary expansion . In the polynomial ring , repeated squaring gives
If has one element, there are no interior terms. If it has more than one, the coefficient of is one and that exponent lies strictly between zero and . This characterization gives a useful parity obstruction directly from the binary expansion.
The binary powering multiplication count counts arithmetic operations. The time complexity measured in operations on individual bits also depends on operand lengths. Put , the binary length of the modulus, and let be the positive exponent's binary length. Stored residues use at most bits, and an unreduced product uses at most bits.
With ordinary long multiplication and division with remainder, one modular product costs operations on bits. Combining that cost with modular products gives
This bound includes reductions in the loop, and assumes the base has already been reduced and the exponent is available as a binary expansion. Reading the exponent takes additional work; initial reduction of a very long base depends on its input length, and an inverse for a negative exponent adds further work. More generally, if a modular product costs operations on bits, the powering loop costs . Faster multiplication and reduction methods can improve the quadratic bound.[ref]
For ordinary integer powers with , the output itself has binary digits. Even writing it takes work proportional to that length. Consequently multiplications does not imply operations on bits: the operands grow during ordinary exponentiation by squaring, whereas modular exponentiation keeps them bounded by the modulus. A squaring or multiplication by a small fixed base can also cost less than a general product, so equal counts need not mean equal running times.
Map each real into , choose its canonical binary expansion, and flatten the resulting countable array of bits using a bijection . Interpret these bits as ternary digits zero and one. At a first differing position, the leading difference exceeds the sum of all possible tail differences, so this is an injection from real sequences to a bounded real interval. The bijection lists successive finite diagonals.
Digit block frequency 2026-10-14
For a finite prefix of digits in positional notation, the digit block frequency of a length- word is its number of overlapping occurrences divided by , the number of available starting positions. All such digit block frequencies sum to one. The infinite limit used for a normal number can instead divide counts by : the factor tends to one for fixed .
For the six binary digits , the single-digit counts are three zeros and three ones. Its five adjacent pairs are , giving
This example explains both the overlapping convention and the end correction in a finite sample. The corresponding infinite binary expansion has pair frequencies , rather than the four values required of a normal number in base two.
Exponentiation by squaring Created 2026-10-03 Updated 2026-10-20
Exponentiation by squaring computes an integer power by reading the exponent's binary expansion. Appending a binary digit to a prefix of value replaces by , so the corresponding power changes by
Each new digit requires one squaring and, only for digit one, one further multiplication. The number of digits grows with the logarithm of the exponent, making this useful for modular exponentiation, primality testing, and powers of matrices using matrix multiplication.[ref]
For a concrete calculation, , so . The optimized left-to-right algorithm used here instead keeps one accumulated power: initialize from the leading digit one, then process only the remaining digits :
Thus , using three squarings and two further multiplications, instead of twelve successive multiplications starting at .
Figure 1.
Reading the same binary expansion computes and
. Each appended binary digit changes the prefix value by . The ordinary-power row grows to ; the modular exponentiation row stores only remainders . Both traces use three squarings and two further multiplications. Details.
For a general positive integer with leading digit , set and, for , first replace by , then multiply it by if . Return . This explicitly skips the leading digit's otherwise unnecessary operations on one. A Computational Introduction to Number Theory and Algebra by Victor Shoup (Section 3.4, pp. 65–66) presents the version initialized at one and processing every digit; the optimization here makes the counting convention unambiguous.
The loop invariant is , where is the value of the digits already read. Initially and . If the next digit is , then squaring and optionally multiplying give , exactly the next prefix. At termination . This proof uses associativity of multiplication; it works in any monoid, including matrices with the identity matrix as identity element, and needs no commutativity between different bases.
For , return the identity element without performing a multiplication. This is the empty-product convention ; if , the algorithm therefore returns one for by convention, rather than resolving its meaning in every mathematical setting. Negative integer exponents require an inverse element: compute , counting the inversion separately. Over the integers, such an inverse generally leaves the integers, and a zero base has no inverse.
Every finite coloring of an IP set has a color class that is an IP set. Here is a reduction to the ordinary Hindman theorem. Given in the original set, color an integer by the color of , where the support consists of positions of its nonzero digits in the binary expansion. The Hindman theorem produces with monochromatic . Replace the by consecutive, disjoint finite block sums with separated binary supports: after a block has been chosen, take above all previously used positions; two of partial sums of a fresh tail agree modulo , so their positive difference supplies the next block sum divisible by . Now binary addition of distinct has no carries. Therefore generates a monochromatic finite-sums set in the original IP set.
For the nontrivial case , every and
The probability ordering makes . At a dyadic number, choose the terminating binary expansion followed by zeros. Let be the first bits of , and let
be its binary cylinder interval.
Suppose and were a prefix of . Since , the numbers and would have the same first bits, so both would lie in . In particular . But
a contradiction. A later word cannot be a shorter prefix of an earlier word because the lengths are nondecreasing; equal-length coincidences were also excluded. Thus the cumulative Shannon code is a prefix code.
The ceiling inequalities give
Multiply by and sum to obtain
For a one-symbol deterministic source the displayed construction assigns the empty word and gives . This zero-bit convention is valid when the number of source emissions is supplied separately. It is not an unframed uniquely decodable code: concatenating different numbers of empty words gives the same bit string. If positive-length unframed words are required, the shortest deterministic code has length , so the strict upper bound requires the nontrivial-source assumption.
Let and let be the probability cell of symbol . Its midpoint is . Use the binary expansion terminating in zeros at a dyadic rational, so truncation to bits gives
The chosen codeword corresponds to the dyadic interval . It contains , and its width satisfies . Consequently
Thus . The probability cells are disjoint, so the code intervals are disjoint. If one binary codeword were a prefix of another, its dyadic interval would contain the other's interval, contradicting this disjointness. Hence the code is instantaneous.
Finally, . Multiplying by and summing yields
This is the Shannon-Fano-Elias code: the extra bit makes the dyadic interval narrow enough to remain inside the cell around its midpoint.
Figure 1. . An original example with probabilities two fifths, three tenths, one fifth, and one tenth. Each orange dyadic code interval contains its black midpoint and lies inside its blue probability cell, proving that the displayed codewords cannot be prefixes of one another. Details.
Outside the countable set of dyadic rational numbers, the binary expansion is unique. Multiplication by two modulo one deletes the first binary digit, so
Let . By part (b), the doubling map is a measure-preserving transformation and is ergodic for Lebesgue measure. Applying the Birkhoff ergodic theorem to this indicator function gives
for almost every . The dyadic rationals have Lebesgue measure zero, so the choice of their two possible binary expansions does not affect the conclusion. Thus the limiting frequency of the digit one is almost everywhere.
Call an IP set when it contains an infinite finite-sums set with all . We first need the relative consequence of the Hindman theorem: a finite union can be an IP set only if one of its constituents is an IP set. This does not follow by simply applying the theorem to a coloring of all integers, because its monochromatic finite-sums set might lie outside the given set.
Here is a reduction that proves the partition regularity of IP sets. Suppose and is finitely colored. Index the generators by . For , let be the set of positions of the nonzero digits in its binary expansion, and color by the color of . By the Hindman theorem, there are with monochromatic in this new finite coloring.
We can take disjoint, successively later finite blocks of the whose sums have separated binary expansion supports. Start with . Having chosen finitely many blocks, take larger than every binary position used in their sums. On a fresh tail of the , consider partial sums, including the zero partial sum. Two have the same residue class modulo , by the pigeonhole principle. Their positive difference is a consecutive block sum divisible by . Discard all indices up to that block's end and repeat. Thus every bit of is above every bit in the preceding block sums.
There are no carries in a sum of distinct , so
Also , since the underlying blocks are disjoint. Consequently
satisfies , with all these sums the same original color. This proves the relative assertion. In particular, if contains an infinite finite-sums set, color its points by the first constituent containing them and apply this argument; one is an IP set.
Let be the family of sets that are not IP sets. It is closed under subsets and, by the preceding argument, under finite unions. It contains every finite set, since positive successive partial sums of an infinite sequence are unbounded. It does not contain . Therefore
is a proper filter on a set: it contains , excludes the empty set, is upward closed, and is closed under finite intersections. Its members are exactly the IP-star sets, the sets meeting every IP set. Indeed, failure to meet an IP set is equivalent to having an IP complement. This identifies the sets that must belong to the required ultrafilter.
Apply the ultrafilter lemma to extend the IP-star filter to an ultrafilter . For completeness, Zorn lemma applies to its proper filter extensions ordered by inclusion, because the union of a chain is still a proper filter on a set. A maximal extension decides every set : if cannot be adjoined while keeping the filter proper, some filter member is disjoint from , forcing into the filter. This is the defining ultrafilter property.
If were not an IP set, then , contradicting properness. Hence every member of contains an infinite finite-sums set. Conversely, any ultrafilter with finite-sums members must contain every IP-star set, since it cannot contain such a set's non-IP complement. Thus this construction captures precisely the forced filter, without making an unnecessary claim about idempotence.
To prove nonuniqueness, put
For a nonempty finite set of exponents with largest exponent , the associated sum of distinct powers of four satisfies
Thus . Doubling the inequality gives
so . These alternating dyadic intervals contain disjoint IP sets.
Every member of meets and also , because it meets every IP set. A finite intersection of members of is again a member, so both and have the finite intersection property. Extend the proper filters they generate to ultrafilters and . Each extends , so the previous argument makes each an ultrafilter with finite-sums members. But and , so
Use binary expansions ending in zeros at dyadic rationals. The doubling map shifts the expansion left:
In ordinary coordinates it is on and on . The branches are continuous; the left limit at is while its value and right limit are . This is its only discontinuity in the half-open interval.
For every , the repeating binary block gives
Its least period is : a shorter repeating block would make more than one digit equal to one in a length- period. The orbit avoids the discontinuity, and its multiplier is , so these periodic orbits are repelling and unstable. The same multiplier argument applies to every periodic orbit, with the endpoint fixed point treated one-sidedly.
In the two-branch horseshoe formulation of Glendinning chaos, disjoint subintervals are each mapped onto the same interval by an iterate. Here , and already satisfy . Their inverse branches and realize every binary itinerary. This is a horseshoe for a piecewise continuous map; on the circle the endpoint jump disappears. The symbolic explanation also shows dense periodic points, by repeating any prescribed finite prefix, and topological transitivity, because an iterate maps any sufficiently small dyadic cylinder onto . Finally every neighborhood contains points sharing an arbitrarily long prefix but with different subsequent digits; an appropriate iterate separates their images by a fixed amount, for instance more than . This proves sensitive dependence on initial conditions as well. The binary shift has full two-symbol chaotic dynamics.
For any function , form the diagonal subset
If were surjective, some would satisfy . Then would hold exactly when , which is impossible. Thus no set surjects onto its power set, including the empty-set case. This is Cantor's theorem proved by the Cantor diagonal argument.
Use real-number pairing by separated digits for an explicit injection . First map a real number to by , and use its unique binary expansion that is not eventually all ones. If and , define
This places the two binary digit strings in alternating ternary positions. Such ternary strings, using only digits zero and one, are unique: at a first differing position , the difference exceeds the maximum tail . Thus the output recovers both digit strings and both inputs. The use of base three avoids any endpoint ambiguity caused by interleaving digits in base two.
For a fixed , the affine sections of a planar set are indexed by
There is an injection , for example by applying to each coordinate pair and then once more to those two results. Suppose every subset of were a section of . Define a function from to by assigning to the corresponding section, and assigning the empty set to every real outside . Injectivity of makes this definition unambiguous. It would be a surjection onto , contradicting the first argument. No planar set has every subset of the real line as a section. Allowing different parametrizations of the same line does not evade this obstruction.
For all countable sets, however, such a planar set does exist. To build one, first encode every real sequence by one real number. Let be the canonical binary digits of , and choose the explicit indexing
This is a bijection from positive integer pairs to positive integers. Define the coding of real sequences by ternary digits
The same first-differing-digit argument proves that is injective; all its values lie in . Now take
For every nonempty countable set , choose an enumeration of , repeating terms if is finite. On the vertical line with and , the section of is precisely : injective sequence coding means no other sequence can contribute extra values in this column. The empty set is the section on the line , since all code columns have first coordinate at most . This constructs the required universal planar set for countable real sections. No assertion about its other, nonvertical sections is needed.
First apply the Cantor theorem by diagonalization. If an injection existed, it would define a surjection by the unique inverse value on 's image, and by elsewhere. The set cannot equal for any , since would be equivalent to . This contradicts surjectivity. There is no injection from the power set of the real line into the real line.
For the opposite type of encoding, let , an injective map from to . Give its canonical binary expansion, choosing the terminating expansion with trailing zeros whenever two expansions exist. If the binary digits of are , define a real-number pairing by separated digits:
This uses ternary digits only , alternating the two input digit sequences. If two outputs first differ at ternary position , that difference has magnitude , while every later digit together contributes at most . Their outputs therefore differ. The digits recover both binary sequences, hence both inputs. Neither output endpoint nor occurs because the input numbers lie strictly between zero and one. Thus is an injection from into . The ternary construction avoids an unjustified decimal-interleaving argument at ambiguous expansions.
For a finite modification of the identity on the real line, let have size , and sort it uniquely as . Its finite record is . It determines completely, with the identity used outside the recorded points. Repeatedly applying the pairing gives an injection for every positive finite : take and . Encode by
Different lengths occupy disjoint intervals , and within a fixed length the record is recoverable. Hence
Indeed the cardinality is exactly that of : the functions that alter only , assigning it an arbitrary real value, give an injection in the other direction, and the Cantor-Schröder-Bernstein theorem applies.
Use uncountability by interleaving prescribed binary coordinates. For each arbitrary binary sequence , define another binary sequence by
There are infinitely many zero coordinates, namely , so . There are also infinitely many coordinates agreeing with the prescribed binary expansion, namely , so . The coordinates recover , making this map an injection of the uncountable set of all binary sequences into . If were a countable set, composing with an injection into would make all binary sequences countable, contrary to part (i). Therefore The construction works for every prescribed binary sequence ; no special distribution property of the digits of is needed.
The chosen non-eventually-one binary expansion fixes the ambiguity at dyadic rationals. Its th digit is
In particular
This is a finite union of Borel sets; the zero-digit preimage is its complement in . Since only takes the values zero and one, every Borel preimage is a union of these two sets. Thus it is Borel measurable. The half-open intervals implement the terminating-zero convention at dyadic endpoints.
The map swaps each adjacent pair of binary digits: . Canonical expansions with no eventual all-ones tail remain canonical under this swap, and .
Under Lebesgue measure, any specified values of distinct binary digits have probability . Indeed they describe a union of dyadic intervals at the largest of the specified positions, with that total length. The preimage of a cylinder prescribing its first output digits prescribes distinct input digits and therefore has the same measure. The half-open dyadic intervals, with the empty set, form a pi-system generating the Borel sigma-algebra. Apply the preceding uniqueness result to obtain
The choice of binary expansion matters at dyadic endpoints for the map's pointwise definition; the chosen convention removes that ambiguity and those endpoints are null in the measure calculation.
This is an infinite binary expansion with digits in . If the usual expansion of has infinitely many digits, list their positions as . If it terminates with a final term , replace that term by
this also covers every dyadic rational. For , use . Thus every has the required form.
The representation by an infinite strictly increasing sequence is unique. If two sequences first differ at exponent , one sum contains and the other does not. The latter's entire possible tail is at most , while the former has plus its own nonempty tail, so the sums cannot agree.
The relation makes a root of unity, so and normalization gives . Write the binary expansion . Then , and hence
up to the convention for ordering the binary digits. This explicit tensor product of one-qubit states proves that is a product state.