Search NKS | Online
11 - 20 of 113 for Mod
![](/common/images/search/spacer.gif)
More colors [in additive cellular automata]
The pictures below show generalizations of rule 90 to k possible colors using the rule
CAStep[k_Integer, a_List] := Mod[RotateLeft[a] + RotateRight[a], k]
or equivalently Mod[ListCorrelate[{1, 0, 1}, a, 2], k] . … Mod[Binomial[t, n], k] is given for prime k by
With[{d = Ceiling[Log[k, Max[t, n] + 1]]}, Mod[Apply[Times, Apply[Binomial, Transpose[ {IntegerDigits[t, k, d] , IntegerDigits[n, k, d] }], {1}]], k]]
The patterns obtained for any k are nested.
In the algebraic representation discussed on page 869 , rule 22 is Mod[p + q + r + p q r, 2] , rule 126 is Mod[(p + q)(q + r) + (p + r), 2] , rule 150 is Mod[p + q + r, 2] and rule 182 is Mod[p r (1 + q) + (p + q + r), 2] .
Given three cells {a 1 , a 2 , a 3 } the rule specifies that the new value of the center cell will be Mod[a 1 + a 3 , 2] . But given {a 1 , 0, a 2 , 0, a 3 , 0} the value after one step is {Mod[a 1 + a 2 , 2], 0, Mod[a 2 + a 3 , 2], 0} and after two steps is again {Mod[a 1 + a 3 , 2], 0} .
[Repetition in] systems based on numbers
An iterated map of the kind discussed on page 150 with rule x Mod[a x, 1] (with rational a ) will yield repetitive behavior when its initial condition is a rational number. The same is true for higher-dimensional generalizations such as so-called Anosov maps {x, y} Mod[m . … The continued fraction map x Mod[1/x, 1] discussed on page 914 becomes repetitive whenever its initial condition is a solution to a quadratic equation.
Sierpiński pattern
Other ways to generate step n of the pattern shown here in various orientations include:
• Mod[Array[Binomial, {2, 2} n , 0], 2]
(see pages 611 and 870 )
• 1 - Sign[Array[BitAnd, {2, 2} n , 0]]
(see pages 608 and 871 )
• NestList[Mod[RotateLeft[#] + #, 2] &, PadLeft[{1}, 2 n ], 2 n - 1]
(see page 870 )
• NestList[Mod[ListConvolve[{1, 1}, #, -1], 2] &, PadLeft[{1}, 2 n ], 2 n - 1]
(see page 870 )
• IntegerDigits[NestList[BitXor[2#, #] &, 1, 2 n - 1], 2, 2 n ]
(see page 906 )
• NestList[Mod[Rest[FoldList[Plus, 0, #]], 2] &, Table[1, {2 n }], 2 n - 1]
(see page 1034 )
• Table[PadRight[ Mod[CoefficientList[(1 + x) t - 1 , x], 2], 2 n - 1], {t, 2 n }]
(see pages 870 and 951 )
• Reverse[Mod[CoefficientList[Series[1/(1 - (1 + x)y), {x, 0, 2 n - 1}, {y, 0, 2 n - 1}], {x, y}], 2]]
(see page 1091 )
• Nest[Apply[Join, MapThread[ Join, {{#, #}, {0 #, #}}, 2]] &, {{1}}, n]
(compare page 1073 )
The positions of black squares can be found from:
• Nest[Flatten[2# /.
But the presence of the Mod takes the points off this line whenever a n[i] ≥ m . … The reason for this is that
n[i + 2] Mod[65539 2 n[i], 2 31 ] Mod[6 n[i + 1] - 9 n[i], 2 31 ]
so that in computing n[i + 2] from n[i + 1] and n[i] only small coefficients are involved.
… The simplest example uses the rule
n Mod[n 2 , m]
It was shown that for m = p q with p and q prime the sequence Mod[n, 2] was in a sense as difficult to predict as the number m is to factor (see page 1090 ).
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]]
A simpler example is the rule
Mod[RotateLeft[list] + RotateRight[list], 1]
With a single nonzero initial cell with value 1/k the pattern produced is just Pascal's triangle modulo k . … If k is irrational then equidistribution of Mod[Binomial[t, x], k] implies that all possible values eventually appear; the corresponding patterns seem fairly irregular, as shown below.
Implementation of digit sequences
A whole number n can be converted to a sequence of digits in base k using IntegerDigits[n,k] or (see also page 1094 )
Reverse[Mod[NestWhileList[Floor[#/k] &, n, # ≥ k &], k]]
and from a sequence of digits using FromDigits[list,k] or
Fold[k #1 + #2 &, 0, list]
For a number x between 0 and 1, the first m digits in its digit sequence in base k are given by RealDigits[x, k, m] or
Floor[k NestList[Mod[k #, 1]&, x, m - 1]]
and from these digits one can reconstruct an approximation to the number using FromDigits[{list, 0}, k] or
Fold[#1/k + #2 &, 0, Reverse[list]]/k
Mod 3 [cellular automaton] rule
Code 420 is an example of an additive rule, and yields a pattern corresponding to Pascal's triangle modulo 3, as discussed on page 870 .
![](/common/images/search/spacer.gif)