Search NKS | Online
31 - 40 of 115 for IntegerDigits
But given t steps in this sequence as a list of 0's and 1's, the following function will reconstruct the rightmost t digits in the starting value of n :
IntegerDigits[First[Fold[{Mod[If[OddQ[#2], 2 First[#1] - 1, 2 First[#1] PowerMod[5, -1, Last[#1]]], Last[#1]], 2 Last[#1]} &, {0, 2}, Reverse[list]]], 2, Length[list]]
Thus for example if x is an integer with n digits then evaluating Sin[x] or FractionalPart[x c] requires respectively finding π or c to n -digit precision. … The best-known algorithms for evaluating Zeta[1/2 + x] (see page 918 ) to fixed precision take roughly √ x operations—or 2 n/2 operations if x is an n -digit integer. … Unlike for continuous mathematical functions, known algorithms for number theoretical functions such as FactorInteger[x] or MoebiusMu[x] typically seem to require a number of operations that grows faster with the number of digits n in x than any power of n (see page 1090 ).
Symmetric 5-neighbor [2D cellular automaton] rules
Among the 32 possible 5-cell neighborhoods shown for example on page 941 there are 12 classes related by symmetries, given by
s = {{1}, {2, 3, 9, 17}, {4, 10, 19, 25}, {5}, {6, 7, 13, 21}, {8, 14, 23, 29}, {11, 18}, {12, 20, 26, 27}, {15, 22}, {16, 24, 30, 31}, {28}, {32}}
Completely symmetric 5-neighbor rules can be numbered from 0 to 4095, with each digit specifying the new color of the cell for each of these symmetry classes of neighborhoods. Such rule numbers can be converted to general form using
FromDigits[Map[Last, Sort[Flatten[Map[Thread, Thread[{s, IntegerDigits[n, 2, 12]}]], 1]]], 2]
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.
Nested radicals
Given a list of integers acting like digits one can consider representing numbers in the form Fold[Sqrt[#1 + #2]&, 0, Reverse[list]] . … Repeats of a digit block b give numbers that solve Fold[(#1 2 - #2) &, x, b] x . … For any number x the first n digits are given by
Ceiling[NestList[(2 - Mod[-#, 1]) 2 &, x 2 , n - 1] - 2]
Even rational numbers such as 3/2 do not yield simple digit sequences.
whatever sequence of digits are left behind being taken to be the output of the computation.
… The number is given as a base 2 digit sequence; the Turing machine runs until its head hits the gray stripe on the right. … The result turns out to be given by 2 IntegerExponent[x + 1, 2] + 3 , which has a maximum of 2n+3 , where n is the length of the digit sequence of x , or Floor[Log[2, x]] .
Ultimately these examples can usually be traced to nesting in the pattern of digits of successive integers, but significant translation is often required.
What they do is to give a fixed number of digits as the result of every computation, whether or not all those digits are known to be correct. … But if the computer gives a fixed number of digits at each step, then additional digits must be filled in on the right. … (Starting with initial condition x the digit sequence at step n is essentially
IntegerDigits[Mod[2 n Floor[2 53 x], 2 53 ], 2, 53]
on the computer, and
Flatten[IntegerDigits[IntegerDigits[ Mod[2 n Floor[10 12 x], 10 12 ], 10, 12], 2, 4]]
on the calculator.
The maximum halting times for the first few sizes n are
{5, 159, 161, 1021, 5419, 315391, 1978213883, 1978213885, 3018415453261}
These occur for inputs {1, 2, 5, 10, 26, 34, 106, 213, 426} and correspond to outputs (each themselves maximal for given n )
2^{3, 23, 24, 63, 148, 1148, 91148, 91149, 3560523} - 1
Such maxima often seem to occur when the input x has the form (20 4 s - 2)/3 (and so has digits {1, 1, 0, 1, 0, … , 1, 0} ). … The corresponding halting time t[x] is Last[Nest[h, {8, 4s + 24 }, s]] - 1 with
h[{i_, j_}] := With[{e = IntegerExponent[3i + 4, 2]}, {13/6 + (i + 4/3)(5/2) e + 1 , ((154 + 75(i + 4/3)(5/2) e ) 2 - 16321 - 7860i - 900i 2 + 3360e)/3780 + j}]
For s > 3 it then turns out that f[x] is extremely close to 3560523 (5/2) r , and t[x] to 18865098979373 (5/2) 2r , for some integer r .
… But if IntegerDigits[x, 2] involves no consecutive 0's then for example f[x] can be obtained from
2^(b[Join[{1, 1}, #], Length[#]] &)[IntegerDigits[x, 2]] - 1
a[{l_, _}, r_] := ({l + (5r - 3#)/2, #} &)[Mod[r, 2]]
a[{l_, 0}, 0] := {l + 1, 0}
a[{l_, 1}, 0] := ({(13 + #(5/2)^IntegerExponent[#, 2])/6, 0} &[6l + 2]
b[list_, i_] := First[Fold[a, {Apply[Plus, Drop[list, -i]], 0}, Apply[Plus, Split[Take[list, -i], #1 #2 ≠ 0 &], 1]]]
(The corresponding expression for t[x] is more complicated.)
Second-order cellular automata
Second-order elementary rules can be implemented using
CA2EvolveList[rule_List, {a_List, b_List}, t_Integer] := Map[First, NestList[CA2Step[rule, #]&, {a, b}, t]]
CA2Step[rule_List, {a_, b_}] := {b, Mod[a + rule 〚 8 - (RotateLeft[b] + 2 (b + 2 RotateRight[b])) 〛 , 2]}
where rule is obtained from the rule number using IntegerDigits[n, 2, 8] .