Search NKS | Online
41 - 50 of 165 for FromDigits
![](/common/images/search/spacer.gif)
Runs of digits [in numbers]
One can consider any base 2 digit sequence as consisting of successive runs of 0's and 1's, constructed from the list of run lengths by
Fold[Join[#1, Table[1 - Last[#1], {#2}]] &, {0}, list]
This representation is related to so-called surreal numbers (though with the first few digits different). The number with run lengths corresponding to successive integers (so that the n th digit is Mod[Floor[1/2 + Sqrt[2n]], 2] ) turns out to be (1 - 2 1/4 EllipticTheta[2, 0, 1/2] + EllipticTheta[3, 0, 1/2])/2 , and appears at least not to be algebraic.
The number of black cells on row t is given by 2^DigitCount[t, 2, 1] , where DigitCount[t, 2, 1] is plotted on page 902 . The positions of the black cells are given by (and this establishes the connection with the picture on page 117 )
Fold[Flatten[{#1 - #2, #1 + #2}] &, {0}, 2^DigitPositions[t]]
DigitPositions[n_] := Flatten[Position[Reverse[IntegerDigits[n, 2]], 1]] - 1
The actual pattern generated by rule 90 corresponds to the coefficients in PolynomialMod[Expand[(1/x + x) t ], 2] (see page 1091 ); the color of a particular cell is thus given by Mod[Binomial[t, (n + t)/2], 2] /; EvenQ[n + t] .
… In this pattern, the color of a particular cell can be obtained directly from the digit sequences for t and n by 1 - Sign[BitAnd[-t, n]] or (see page 583 )
With[{d = Ceiling[Log[2, Max[t, n] + 1]]}, If[FreeQ[ IntegerDigits[t, 2, d] - IntegerDigits[n, 2, d], -1], 1, 0]]
The base 2 digit sequences obtained with this map starting from x = 1/8 are shown below for various values of a . … But at least for small a , progressively more digits on the left show purely repetitive behavior. … The detailed behavior is different for every value of a , but whenever the repetition period is 2 j , it turns out that with any initial condition the leftmost digit always eventually follows a sequence that consists of repetitions of step j in the evolution of the substitution system {1 {1, 0}, 0 {1, 1}} starting either from {0} or {1} .
Properties of [recursive] sequences
Sequence (d) is given by
f[n_] := (n + g[IntegerDigits[n, 2]])/2
g[{1 ..}] = 1; g[{1, 0 ..}] = 0
g[{1, s__}] := 1 + g[IntegerDigits[FromDigits[{s}, 2] + 1, 2]]
The list of elements in the sequence up to value m is given by
Flatten[Table[Table[n, {IntegerExponent[n, 2] + 1}], {n, m}]]
The differences between the first 2 (2 k -1) of these elements is
Nest[Replace[#, {x___} {x, 1, x, 0}]&, {}, k]
The largest n for which f[n] m is given by 2m + 1 - DigitCount[m, 2, 1] or IntegerExponent[(2m)!… The form of sequence (c) is similar to that obtained from concatenation numbers on page 913 . … The distinct nodes reached starting from f[12] for sequence (f) are then for example {{12}, {3, 7}, {1, 2, 4}, {1, 2}, {1}} .
With offset list os and k colors the possible neighborhood configurations are
Reverse[Table[IntegerDigits[i - 1, k, Length[os]], {i, k^Length[os]}]]
(These are shown on page 53 for elementary rules and page 941 for 5-neighbor rules.) If a cellular automaton rule takes the new color of a cell with neighborhood configuration IntegerDigits[i, k, Length[os]] to be u 〚 i + 1 〛 , then one can define its rule number to be FromDigits[Reverse[u], k] . A single step in evolution of a general cellular automaton with state a and rule number num is then given by
Map[IntegerDigits[num, k, k^Length[os]] 〚 -1 - # 〛 &, Apply[Plus, MapIndexed[k^(Length[os] - First[#2]) RotateLeft[a, #1] &, os]], {-1}]
or equivalently by
Map[IntegerDigits[num, k, k^Length[os]] 〚 -# - 1 〛 &, ListCorrelate[Fold[ReplacePart[k #1, 1, #2 + r + 1] &, Array[0 &, Table[2r + 1, {d}]], os], a, r + 1], {d}]
History of digit sequences
On an abacus or similar device numbers are in effect represented by digit sequences. … An exception was the Babylonian base 60 system (from which hours:minutes:seconds notation derives). … The study of fractals and nesting, the appearance of many algorithms involving digit sequences and the routine use of long numbers in Mathematica have however gradually made digit sequences be seen as more central to mathematics.
[No text on this page]
The behavior of the code 20 cellular automaton from the top of the facing page for all initial conditions with black cells in a region of size less than nine. … Each initial condition is assigned a number whose base 2 digit sequence gives the configuration of black and white cells in that initial condition.
IntegerDigits[n, 2] . … Flatten[IntegerDigits[ Append[2 - With[{w = Floor[Log[3, 2n]]}, IntegerDigits[n - (3 w + 1 - 1)/2, 3, w]], 3], 2, 2]]
(e) Fibonacci encoding. … Apply[Take, RealDigits[(N[#, N[Log[10, #] + 3]] &)[ n √ 5 /GoldenRatio 2 + 1/2], GoldenRatio]]
The representations of all the first Fibonacci[n] - 1 numbers can be obtained from (the version in the main text has Rest[RotateLeft[Join[#, {0, 1}]]] & applied)
Apply[Join, Map[Last, NestList[{# 〚 2 〛 ], Join[Map[Join[{1, 0}, Rest[#]] & , # 〚 2 〛 ], Map[Join[{1, 0}, #] &, # 〚 1 〛 ]]} &, {{}, {{1}}}, n-3]]]
Chaos Theory and Randomness from Initial Conditions…The basic idea is to represent the position of each point at each step as a number, say x , which runs from 0 to 1. … What differs between the two cases is the detailed digit sequences of the positions of the points: in the first case these digit sequences are quite random, while in the second case they have a simple repetitive form.
Computing n th digits directly
Most methods for computing mathematical constants progressively generate each additional digit. … As an example, the n th digit of Log[2] in base 2 is formally given by Round[FractionalPart[2 n Sum[2 -k /k, {k, ∞ }]]] . … The same basic approach as for Log[2] can be used to obtain base 16 digits in π from the following formula for π :
Sum[16 -k (4/(8k + 1) - 2/(8k + 4) - 1/(8k + 5)-1/(8k + 6)), {k, 0, ∞ }]
A similar approach can also be used for many other constants that can be viewed as related to values of PolyLog .
![](/common/images/search/spacer.gif)