Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

610986 views
1
2
2 Residue-Class-Wise Affine Mappings
3
4
This chapter contains the basic definitions, and it describes how to enter
5
residue-class-wise affine mappings and how to compute with them.
6
7
How to compute with residue-class-wise affine groups is described in detail
8
in the next chapter. The reader is encouraged to look there already after
9
having read the first few pages of this chapter, and to look up definitions
10
as he needs to.
11
12
13
2.1 Basic definitions
14
15
Residue-class-wise affine groups, or rcwa groups for short, are permutation
16
groups whose elements are bijective residue-class-wise affine mappings.
17
18
A mapping f: ℤ → ℤ is called residue-class-wise affine, or for short an rcwa
19
mapping, if there is a positive integer m such that the restrictions of f to
20
the residue classes r(m) ∈ ℤ/mℤ are all affine, i.e. given by
21
22
a_r(m) * n + b_r(m)
23
f|_r(m): r(m) -> Z, n |-> -------------------
24
c_r(m)
25
26
for certain coefficients a_r(m), b_r(m), c_r(m) ∈ ℤ depending on r(m). The
27
smallest possible m is called the modulus of f. It is understood that all
28
fractions are reduced, i.e. that gcd( a_r(m), b_r(m), c_r(m) ) = 1, and that
29
c_r(m) > 0. The lcm of the coefficients a_r(m) is called the multiplier
30
of f, and the lcm of the coefficients c_r(m) is called the divisor of f.
31
32
It is easy to see that the residue-class-wise affine mappings of ℤ form a
33
monoid under composition, and that the residue-class-wise affine
34
permutations of ℤ form a countable subgroup of Sym(ℤ). We denote the former
35
by Rcwa(ℤ), and the latter by RCWA(ℤ).
36
37
An rcwa mapping is called tame if the set of moduli of its powers is
38
bounded, or equivalently if it permutes a partition of ℤ into finitely many
39
residue classes on all of which it is affine. An rcwa group is called tame
40
if there is a common such partition for all of its elements, or equivalently
41
if the set of moduli of its elements is bounded. Rcwa mappings and -groups
42
which are not tame are called wild. Tame rcwa mappings and -groups are
43
something which one could call the trivial cases or basic building blocks,
44
while wild rcwa groups are the objects of primary interest.
45
46
The definitions of residue-class-wise affine mappings and -groups can be
47
generalized in the obvious way to suitable rings other than ℤ. In fact, this
48
package provides also some support for residue-class-wise affine groups over
49
ℤ^2, over semilocalizations of ℤ and over univariate polynomial rings over
50
finite fields. The ring ℤ^2 has been chosen as an example of a suitable ring
51
which is not a principal ideal domain, the semilocalizations of ℤ have been
52
chosen as examples of rings with only finitely many prime elements, and the
53
univariate polynomial rings over finite fields have been chosen as examples
54
of rings with nonzero characteristic.
55
56
57
2.2 Entering residue-class-wise affine mappings
58
59
Entering an rcwa mapping of ℤ requires giving the modulus m and the
60
coefficients a_r(m), b_r(m) and c_r(m) for r(m) running over the residue
61
classes (mod m).
62
63
This can be done easiest by RcwaMapping( coeffs ), where coeffs is a list of
64
m coefficient triples coeffs[r+1] = [a_r(m), b_r(m), c_r(m)], with r running
65
from 0 to m-1.
66
67
If some coefficient c_r(m) is zero or if images of some integers under the
68
mapping to be defined would not be integers, an error message is printed and
69
a break loop is entered. For example, the coefficient triple [1,4,3] is not
70
allowed at the first position. The reason for this is that not all integers
71
congruent to 1 ⋅ 0 + 4 = 4 mod m are divisible by 3.
72
73
For the general constructor for rcwa mappings, see RcwaMapping (2.2-5).
74
75
 Example 
76

77
gap> T := RcwaMapping([[1,0,2],[3,1,2]]); # The Collatz mapping.
78
<rcwa mapping of Z with modulus 2>
79
gap> [ IsSurjective(T), IsInjective(T) ];
80
[ true, false ]
81
gap> Display(T);
82

83
Surjective rcwa mapping of Z with modulus 2
84

85
 /
86
 | n/2 if n in 0(2)
87
 n |-> < (3n+1)/2 if n in 1(2)
88
 |
89
 \
90

91
gap> a := RcwaMapping([[2,0,3],[4,-1,3],[4,1,3]]);
92
<rcwa mapping of Z with modulus 3>
93
gap> IsBijective(a);
94
true
95
gap> Display(a); # This is Collatz' permutation:
96

97
Rcwa permutation of Z with modulus 3
98

99
 /
100
 | 2n/3 if n in 0(3)
101
 n |-> < (4n-1)/3 if n in 1(3)
102
 | (4n+1)/3 if n in 2(3)
103
 \
104

105
gap> Support(a);
106
Z \ [ -1, 0, 1 ]
107
gap> Cycle(a,44);
108
[ 44, 59, 79, 105, 70, 93, 62, 83, 111, 74, 99, 66 ]
109

110

111
112
There is computational evidence for the conjecture that any
113
residue-class-wise affine permutation of ℤ can be factored into members of
114
the following three series of permutations of particularly simple structure
115
(cf. FactorizationIntoCSCRCT (2.5-1)):
116
117
2.2-1 ClassShift
118
119
ClassShift( r, m )  function
120
ClassShift( cl )  function
121
Returns: the class shift ν_r(m).
122
123
The class shift ν_r(m) is the rcwa mapping of ℤ which maps n ∈ r(m) to n + m
124
and which fixes ℤ ∖ r(m) pointwise.
125
126
In the one-argument form, the argument cl stands for the residue class r(m).
127
Enclosing the argument list in list brackets is permitted.
128
129
 Example 
130

131
gap> Display(ClassShift(5,12));
132

133
Tame rcwa permutation of Z with modulus 12, of order infinity
134

135
 /
136
 | n+12 if n in 5(12)
137
 n |-> < n if n in Z \ 5(12)
138
 |
139
 \
140

141

142
143
2.2-2 ClassReflection
144
145
ClassReflection( r, m )  function
146
ClassReflection( cl )  function
147
Returns: the class reflection ς_r(m).
148
149
The class reflection ς_r(m) is the rcwa mapping of ℤ which maps n ∈ r(m) to
150
-n + 2r and which fixes ℤ ∖ r(m) pointwise, where it is understood that 0 ≤
151
r < m.
152
153
In the one-argument form, the argument cl stands for the residue class r(m).
154
Enclosing the argument list in list brackets is permitted.
155
156
 Example 
157

158
gap> Display(ClassReflection(5,9));
159

160
Rcwa permutation of Z with modulus 9, of order 2
161

162
 /
163
 | -n+10 if n in 5(9)
164
 n |-> < n if n in Z \ 5(9)
165
 |
166
 \
167

168

169
170
2.2-3 ClassTransposition
171
172
ClassTransposition( r1, m1, r2, m2 )  function
173
ClassTransposition( cl1, cl2 )  function
174
Returns: the class transposition τ_r_1(m_1),r_2(m_2).
175
176
Given two disjoint residue classes r_1(m_1) and r_2(m_2) of the integers,
177
the class transposition τ_r_1(m_1),r_2(m_2) ∈ RCWA(ℤ) is defined as the
178
involution which interchanges r_1+km_1 and r_2+km_2 for any integer k and
179
which fixes all other points. It is understood that m_1 and m_2 are
180
positive, that 0 ≤ r_1 < m_1 and that 0 ≤ r_2 < m_2. For a generalized class
181
transposition, the latter assumptions are not made.
182
183
The class transposition τ_r_1(m_1),r_2(m_2) interchanges the residue classes
184
r_1(m_1) and r_2(m_2) and fixes the complement of their union pointwise.
185
186
In the four-argument form, the arguments r1, m1, r2 and m2 stand for r_1,
187
m_1, r_2 and m_2, respectively. In the two-argument form, the arguments cl1
188
and cl2 stand for the residue classes r_1(m_1) and r_2(m_2), respectively.
189
Enclosing the argument list in list brackets is permitted. The residue
190
classes r_1(m_1) and r_2(m_2) are stored as an attribute TransposedClasses.
191
192
A list of all class transpositions interchanging residue classes with moduli
193
less than or equal to a given bound m can be obtained by
194
List(ClassPairs([P],m),ClassTransposition), where the function ClassPairs
195
returns a list of all 4-tuples (r_1,m_1,r_2,m_2) of integers corresponding
196
to the unordered pairs of disjoint residue classes r_1(m_1) and r_2(m_2)
197
with m_1 and m_2 less than or equal to the specified bound. If a list of
198
primes is given as optional argument P, then the returned list contains only
199
those 4-tuples where all prime factors of m_1 and m_2 lie in P. If the
200
option divisors is set, the returned list contains only the 4-tuples where
201
m_1 and m_2 divide m.
202
203
The function NrClassPairs(m) returns the length of the list ClassPairs(m),
204
where the result is computed much faster and without actually generating the
205
list of tuples. Given a class transposition ct, the corresponding 4-tuple
206
can be obtained by ExtRepOfObj(ct)
207
208
A class transposition can be written as a product of any given number k of
209
class transpositions. Such a decomposition can be obtained by
210
SplittedClassTransposition(ct,k).
211
212
 Example 
213

214
gap> Display(ClassTransposition(1,2,8,10):CycleNotation:=false);
215

216
Rcwa permutation of Z with modulus 10, of order 2
217

218
 /
219
 | 5n+3 if n in 1(2)
220
 n |-> < (n-3)/5 if n in 8(10)
221
 | n if n in 0(2) \ 8(10)
222
 \
223

224
gap> List(ClassPairs(4),ClassTransposition);
225
[ ( 0(2), 1(2) ), ( 0(2), 1(4) ), ( 0(2), 3(4) ), ( 0(3), 1(3) ), 
226
 ( 0(3), 2(3) ), ( 0(4), 1(4) ), ( 0(4), 2(4) ), ( 0(4), 3(4) ), 
227
 ( 1(2), 0(4) ), ( 1(2), 2(4) ), ( 1(3), 2(3) ), ( 1(4), 2(4) ), 
228
 ( 1(4), 3(4) ), ( 2(4), 3(4) ) ]
229
gap> NrClassPairs(100);
230
3528138
231
gap> SplittedClassTransposition(ClassTransposition(0,2,1,4),3);
232
[ ( 0(6), 1(12) ), ( 2(6), 5(12) ), ( 4(6), 9(12) ) ]
233

234
235
The set of all class transpositions of the ring of integers generates the
236
simple group CT(ℤ) mentioned in Chapter 1. This group has a representation
237
as a GAP object -- see CT (3.1-9). The set of all generalized class
238
transpositions of ℤ generates a simple group as well, cf. [Koh10].
239
240
Class shifts, class reflections and class transpositions of rings R other
241
than ℤ are defined in an entirely analogous way -- all one needs to do is to
242
replace ℤ by R and to read < and ≤ in the sense of the ordering used by GAP.
243
They can also be entered basically as described above -- just prepend the
244
desired ring R to the argument list. Often also a sensible default ring (→
245
DefaultRing in the GAP Reference Manual) is chosen if that optional first
246
argument is omitted.
247
248
On rings which have more than two units, there is another basic series of
249
rcwa permutations which generalizes class reflections:
250
251
2.2-4 ClassRotation
252
253
ClassRotation( r, m, u )  function
254
ClassRotation( cl, u )  function
255
Returns: the class rotation ρ_r(m),u.
256
257
Given a residue class r(m) and a unit u of a suitable ring R, the class
258
rotation ρ_r(m),u is the rcwa mapping which maps n ∈ r(m) to un + (1-u)r and
259
which fixes R ∖ r(m) pointwise. Class rotations generalize class
260
reflections, as we have ρ_r(m),-1 = ς_r(m).
261
262
In the two-argument form, the argument cl stands for the residue class r(m).
263
Enclosing the argument list in list brackets is permitted. The argument u is
264
stored as an attribute RotationFactor.
265
266
 Example 
267

268
gap> Display(ClassRotation(ResidueClass(Z_pi(2),2,1),1/3));
269

270
Tame rcwa permutation of Z_( 2 ) with modulus 2, of order infinity
271

272
 /
273
 | 1/3 n + 2/3 if n in 1(2)
274
 n |-> < n if n in 0(2)
275
 |
276
 \
277

278
gap> x := Indeterminate(GF(8),1);; SetName(x,"x");
279
gap> R := PolynomialRing(GF(8),1);;
280
gap> cr := ClassRotation(1,x,Z(8)*One(R)); Support(cr);
281
ClassRotation( 1(x), Z(2^3) )
282
1(x) \ [ 1 ]
283
gap> Display(cr);
284

285
Rcwa permutation of GF(2^3)[x] with modulus x, of order 7
286

287
 /
288
 | Z(2^3)*P + Z(2^3)^3 if P in 1(x)
289
 P |-> < P otherwise
290
 |
291
 \
292

293

294
295
IsClassShift, IsClassReflection, IsClassRotation, IsClassTransposition and
296
IsGeneralizedClassTransposition are properties which indicate whether a
297
given rcwa mapping belongs to the corresponding series.
298
299
In the sequel we describe the general-purpose constructor for rcwa mappings.
300
The constructor may look a bit technical on a first glance, but knowing all
301
possible ways of entering an rcwa mapping is by no means necessary for
302
understanding this manual or for using this package.
303
304
305
2.2-5 RcwaMapping (the general constructor)
306
307
RcwaMapping( R, m, coeffs )  method
308
RcwaMapping( R, coeffs )  method
309
RcwaMapping( coeffs )  method
310
RcwaMapping( perm, range )  method
311
RcwaMapping( m, values )  method
312
RcwaMapping( pi, coeffs )  method
313
RcwaMapping( q, m, coeffs )  method
314
RcwaMapping( P1, P2 )  method
315
RcwaMapping( cycles )  method
316
RcwaMapping( expression )  method
317
Returns: an rcwa mapping.
318
319
In all cases the argument R is the underlying ring, m is the modulus and
320
coeffs is the coefficient list. A coefficient list for an rcwa mapping with
321
modulus m consists of |R/mR| coefficient triples [a_r(m), b_r(m), c_r(m)].
322
Their ordering is determined by the ordering of the representatives of the
323
residue classes (mod m) in the sorted list returned by AllResidues(R, m). In
324
case R = ℤ this means that the coefficient triple for the residue class 0(m)
325
comes first and is followed by the one for 1(m), the one for 2(m) and so on.
326
327
If one or several of the arguments R, m and coeffs are omitted or replaced
328
by other arguments, the former are either derived from the latter or default
329
values are chosen. The meaning of the other arguments is defined in the
330
detailed description of the particular methods given in the sequel. The
331
above methods return the rcwa mapping
332
333
(a)
334
of R with modulus m and coefficients coeffs,
335
336
(b)
337
of R = ℤ or R = ℤ_(π) with modulus Length(coeffs) and coefficients
338
coeffs,
339
340
(c)
341
of R = ℤ with modulus Length(coeffs) and coefficients coeffs,
342
343
(d)
344
of R = ℤ, permuting any set range+k*Length(range) like perm permutes
345
range,
346
347
(e)
348
of R = ℤ with modulus m and values given by a list val of 2 pairs
349
[preimage, image] per residue class (mod m),
350
351
(f)
352
of R = ℤ_(π) with modulus Length(coeffs) and coefficients coeffs (the
353
set of primes π which denotes the underlying ring is passed as
354
argument pi),
355
356
(g)
357
of R = GF(q)[x] with modulus m and coefficients coeffs,
358
359
(h)
360
an rcwa permutation which induces a bijection between the partitions
361
P1 and P2 of R into residue classes and which is affine on the
362
elements of P1,
363
364
(i)
365
an rcwa permutation with residue class cycles given by a list cycles
366
of lists of pairwise disjoint residue classes, each of which it
367
permutes cyclically, or
368
369
(j)
370
the rcwa permutation of ℤ given by the arithmetical expression
371
expression -- a string consisting of class transpositions (e.g.
372
"(0(2),1(4))") or cycles permuting residue classes (e.g.
373
"(0(2),1(8),3(4),5(8))"), class shifts (e.g. "cs(4(6))", class
374
reflections (e.g. "cr(3(4))"), arithmetical operators ("*", "/" and
375
"^") and brackets ("(", ")"),
376
377
respectively. The methods for the operation RcwaMapping perform a number of
378
argument checks, which can be skipped by using RcwaMappingNC instead.
379
380
 Example 
381

382
gap> R := PolynomialRing(GF(2),1);; x := X(GF(2),1);; SetName(x,"x");
383
gap> RcwaMapping(R,x+1,[[1,0,x+One(R)],[x+One(R),0,1]]*One(R)); # (a)
384
<rcwa mapping of GF(2)[x] with modulus x+1>
385
gap> RcwaMapping(Z_pi(2),[[1/3,0,1]]); # (b)
386
Rcwa mapping of Z_( 2 ): n -> 1/3 n
387
gap> a := RcwaMapping([[2,0,3],[4,-1,3],[4,1,3]]); # (c)
388
<rcwa mapping of Z with modulus 3>
389
gap> RcwaMapping((1,2,3),[1..4]); # (d)
390
( 1(4), 2(4), 3(4) )
391
gap> T = RcwaMapping(2,[[1,2],[2,1],[3,5],[4,2]]); # (e)
392
true
393
gap> RcwaMapping([2],[[1/3,0,1]]); # (f)
394
Rcwa mapping of Z_( 2 ): n -> 1/3 n
395
gap> RcwaMapping(2,x+1,[[1,0,x+One(R)],[x+One(R),0,1]]*One(R)); # (g)
396
<rcwa mapping of GF(2)[x] with modulus x+1>
397
gap> a = RcwaMapping(List([[0,3],[1,3],[2,3]],ResidueClass),
398
>  List([[0,2],[1,4],[3,4]],ResidueClass)); # (h)
399
true
400
gap> RcwaMapping([List([[0,2],[1,4],[3,8],[7,16]],ResidueClass)]); # (i)
401
( 0(2), 1(4), 3(8), 7(16) )
402
gap> Cycle(last,ResidueClass(0,2));
403
[ 0(2), 1(4), 3(8), 7(16) ]
404
gap> g := RcwaMapping("((0(4),1(6))*cr(0(6)))^2/cs(2(8))"); # (j)
405
<rcwa permutation of Z with modulus 72>
406
gap> g = (ClassTransposition(0,4,1,6) * ClassReflection(0,6))^2/
407
>  ClassShift(2,8);
408
true
409

410

411
412
Rcwa mappings of ℤ can be translated to rcwa mappings of some
413
semilocalization ℤ_(π) of ℤ:
414
415
2.2-6 LocalizedRcwaMapping
416
417
LocalizedRcwaMapping( f, p )  function
418
SemilocalizedRcwaMapping( f, pi )  function
419
Returns: the rcwa mapping of ℤ_(p) respectively ℤ_(π) with the same
420
coefficients as the rcwa mapping f of ℤ.
421
422
The argument p or pi must be a prime or a set of primes, respectively. The
423
argument f must be an rcwa mapping of ℤ whose modulus is a power of p, or
424
whose modulus has only prime divisors which lie in pi, respectively.
425
426
 Example 
427

428
gap> T := RcwaMapping([[1,0,2],[3,1,2]]);; # The Collatz mapping.
429
gap> Cycle(LocalizedRcwaMapping(T,2),131/13);
430
[ 131/13, 203/13, 311/13, 473/13, 716/13, 358/13, 179/13, 275/13, 
431
 419/13, 635/13, 959/13, 1445/13, 2174/13, 1087/13, 1637/13, 2462/13, 
432
 1231/13, 1853/13, 2786/13, 1393/13, 2096/13, 1048/13, 524/13, 262/13 ]
433

434

435
436
Rcwa mappings can be Viewed, Displayed, Printed and written to a String. The
437
output of the View method is kept reasonably short. In most cases it does
438
not describe an rcwa mapping completely. In these cases the output is
439
enclosed in brackets. There are options CycleNotation, AsClassMapping,
440
PrintNotation and AbridgedNotation to take influence on how certain rcwa
441
mappings are shown. These options can either be not set, set to true or set
442
to false. If the option CycleNotation is set, it is tried harder to write
443
down an rcwa permutation of ℤ of finite order as a product of disjoint
444
residue class cycles, if this is possible. If the option AsClassMapping is
445
set, Display shows which residue classes are mapped to which by the affine
446
partial mappings, and marks any loops. The option PrintNotation influences
447
the output in favour of GAP - readability, and the option AbridgedNotation
448
can be used to abridge longer names like ClassShift, ClassReflection etc..
449
By default, the output of the methods for Display and Print describes an
450
rcwa mapping in full. The Printed representation of an rcwa mapping is GAP -
451
readable if and only if the Printed representation of the elements of the
452
underlying ring is so.
453
454
There is also an operation LaTeXStringRcwaMapping, which takes as argument
455
an rcwa mapping and returns a corresponding LaTeX string. The output makes
456
use of the LaTeX macro package amsmath. If the option Factorization is set
457
and the argument is bijective, a factorization into class shifts, class
458
reflections, class transpositions and prime switches is printed (cf.
459
FactorizationIntoCSCRCT (2.5-1)). For rcwa mappings with modulus greater
460
than 1, an indentation by Indentation characters can be obtained by setting
461
this option value accordingly.
462
463
 Example 
464

465
gap> Print(LaTeXStringRcwaMapping(T));
466
n \ \mapsto \
467
\begin{cases}
468
 n/2 & \text{if} \ n \in 0(2), \\
469
 (3n+1)/2 & \text{if} \ n \in 1(2).
470
\end{cases}
471

472

473
474
There is an operation LaTeXAndXDVI which displays an rcwa mapping in an xdvi
475
window. This works as follows: The string returned by LaTeXStringRcwaMapping
476
is inserted into a LaTeX template file. This file is LaTeX'ed, and the
477
result is shown with xdvi. Calling Display with option xdvi has the same
478
effect. The operation LaTeXAndXDVI is only available on UNIX systems, and
479
requires suitable installations of LaTeX and xdvi.
480
481
482
2.3 Basic arithmetic for residue-class-wise affine mappings
483
484
Testing rcwa mappings for equality requires only comparing their coefficient
485
lists, hence is cheap. Rcwa mappings can be multiplied, thus there is a
486
method for *. Rcwa permutations can also be inverted, thus there is a method
487
for Inverse. The latter method is usually accessed by raising a mapping to a
488
power with negative exponent. Multiplying, inverting and computing powers of
489
tame rcwa mappings is cheap. Computing powers of wild mappings is usually
490
expensive -- run time and memory requirements normally grow approximately
491
exponentially with the exponent. How expensive multiplying a couple of wild
492
mappings is, varies very much. In any case, the amount of memory required
493
for storing an rcwa mapping is proportional to its modulus. Whether a given
494
mapping is tame or wild can be determined by the operation IsTame. There is
495
a method for Order, which can not only compute a finite order, but which can
496
also detect infinite order.
497
498
 Example 
499

500
gap> T := RcwaMapping([[1,0,2],[3,1,2]]);; # The Collatz mapping.
501
gap> a := RcwaMapping([[2,0,3],[4,-1,3],[4,1,3]]);; # Collatz' permutation.
502
gap> List([-4..4],k->Modulus(a^k));
503
[ 256, 64, 16, 4, 1, 3, 9, 27, 81 ]
504
gap> IsTame(T) or IsTame(a);
505
false
506
gap> IsTame(ClassShift(0,1)) and IsTame(ClassTransposition(0,2,1,2));
507
true
508
gap> T^2*a*T*a^-3;
509
<rcwa mapping of Z with modulus 768>
510
gap> (ClassShift(1,3)*ClassReflection(2,7))^1000000;
511
<rcwa permutation of Z with modulus 21>
512

513

514
515
There are methods installed for IsInjective, IsSurjective, IsBijective and
516
Image.
517
518
 Example 
519

520
gap> [ IsInjective(T), IsSurjective(T), IsBijective(a) ];
521
[ false, true, true ]
522
gap> Image(RcwaMapping([[2,0,1]]));
523
0(2)
524

525

526
527
Images of elements, of finite sets of elements and of unions of finitely
528
many residue classes of the source of an rcwa mapping can be computed with
529
^, the same symbol as used for exponentiation and conjugation. The same
530
works for partitions of the source into a finite number of residue classes.
531
532
 Example 
533

534
gap> 15^T;
535
23
536
gap> ResidueClass(1,2)^T;
537
2(3)
538
gap> List([[0,3],[1,3],[2,3]],ResidueClass)^a;
539
[ 0(2), 1(4), 3(4) ]
540

541

542
543
For computing preimages of elements under rcwa mappings, there are methods
544
for PreImageElm and PreImagesElm. The preimage of a finite set of ring
545
elements or of a union of finitely many residue classes under an rcwa
546
mapping can be computed by PreImage.
547
548
 Example 
549

550
gap> PreImagesElm(T,8);
551
[ 5, 16 ]
552
gap> PreImage(T,ResidueClass(Integers,3,2));
553
Z \ 0(6) U 2(6)
554
gap> M := [1];; l := [1];;
555
gap> while Length(M) < 5000 do M := PreImage(T,M); Add(l,Length(M)); od; l;
556
[ 1, 1, 2, 2, 4, 5, 8, 10, 14, 18, 26, 36, 50, 67, 89, 117, 157, 208, 
557
 277, 367, 488, 649, 869, 1154, 1534, 2039, 2721, 3629, 4843, 6458 ]
558

559

560
561
There is a method for the operation Support for computing the support of an
562
rcwa mapping. A synonym for Support is MovedPoints. The natural density of
563
the support of an rcwa mapping of ℤ can be computed efficiently with the
564
operation DensityOfSupport. Likewise, the natural density of the set of
565
fixed points of an rcwa mapping of ℤ can be computed efficiently with the
566
operation DensityOfSetOfFixedPoints. There is also a method for
567
RestrictedPerm for computing the restriction of an rcwa permutation to a
568
union of residue classes which it fixes setwise.
569
570
 Example 
571

572
gap> List([a,a^2],Support);
573
[ Z \ [ -1, 0, 1 ], Z \ [ -3, -2, -1, 0, 1, 2, 3 ] ]
574
gap> RestrictedPerm(ClassShift(0,2)*ClassReflection(1,2),
575
>  ResidueClass(0,2));
576
<rcwa mapping of Z with modulus 2>
577
gap> last = ClassShift(0,2);
578
true
579

580

581
582
Rcwa mappings can be added and subtracted pointwise. However, please note
583
that the set of rcwa mappings of a ring does not form a ring under + and *.
584
585
 Example 
586

587
gap> b := ClassShift(0,3) * a;;
588
gap> [ Image((a + b)), Image((a - b)) ];
589
[ 2(4), [ -2, 0 ] ]
590

591

592
593
There are operations Modulus (abbreviated Mod) and Coefficients for
594
retrieving the modulus and the coefficient list of an rcwa mapping. The
595
meaning of the return values is as described in Section 2.2.
596
597
General documentation for most operations mentioned in this section can be
598
found in the GAP reference manual. For rcwa mappings of rings other than ℤ,
599
not for all operations applicable methods are available.
600
601
As in general a subring relation R_1<R_2 does not give rise to a natural
602
embedding of RCWA(R_1) into RCWA(R_2), there is no coercion between rcwa
603
mappings or rcwa groups over different rings.
604
605
606
2.4 Attributes and properties of residue-class-wise affine mappings
607
608
A number of basic attributes and properties of an rcwa mapping are derived
609
immediately from the coefficients of its affine partial mappings. This holds
610
for example for the multiplier and the divisor. These two values are stored
611
as attributes Multiplier and Divisor, or for short Mult and Div. The prime
612
set of an rcwa mapping is the set of prime divisors of the product of its
613
modulus and its multiplier. It is stored as an attribute PrimeSet. The
614
maximal shift of an rcwa mapping of ℤ is the maximum of the absolute values
615
of its coefficients b_r(m) in the notation introduced in Section 2.1. It is
616
stored as an attribute MaximalShift. An rcwa mapping is called class-wise
617
translating if all of its affine partial mappings are translations, it is
618
called integral if its divisor equals 1, and it is called balanced if its
619
multiplier and its divisor have the same prime divisors. A class-wise
620
translating mapping has the property IsClassWiseTranslating, an integral
621
mapping has the property IsIntegral and a balanced mapping has the property
622
IsBalanced. An rcwa mapping of the ring of integers or of one of its
623
semilocalizations is called class-wise order-preserving if and only if all
624
coefficients a_r(m) (cf. Section 2.1) in the numerators of the affine
625
partial mappings are positive. The corresponding property is
626
IsClassWiseOrderPreserving. An rcwa mapping of ℤ is called sign-preserving
627
if it does not map nonnegative integers to negative integers or vice versa.
628
The corresponding property is IsSignPreserving. All elements of the simple
629
group CT(ℤ) generated by the set of all class transpositions are
630
sign-preserving.
631
632
 Example 
633

634
gap> u := RcwaMapping([[3,0,5],[9,1,5],[3,-1,5],[9,-2,5],[9,4,5]]);;
635
gap> IsBijective(u);; Display(u);
636

637
Rcwa permutation of Z with modulus 5
638

639
 /
640
 | 3n/5 if n in 0(5)
641
 | (9n+1)/5 if n in 1(5)
642
 n |-> < (3n-1)/5 if n in 2(5)
643
 | (9n-2)/5 if n in 3(5)
644
 | (9n+4)/5 if n in 4(5)
645
 \
646

647
gap> Multiplier(u);
648
9
649
gap> Divisor(u);
650
5
651
gap> PrimeSet(u);
652
[ 3, 5 ]
653
gap> IsIntegral(u) or IsBalanced(u);
654
false
655
gap> IsClassWiseOrderPreserving(u) and IsSignPreserving(u);
656
true
657

658

659
660
There are a couple of further attributes and operations related to the
661
affine partial mappings of an rcwa mapping:
662
663
2.4-1 LargestSourcesOfAffineMappings
664
665
LargestSourcesOfAffineMappings( f )  attribute
666
Returns: the coarsest partition of Source(f) on whose elements the rcwa
667
mapping f is affine.
668
669
 Example 
670

671
gap> LargestSourcesOfAffineMappings(ClassShift(3,7));
672
[ Z \ 3(7), 3(7) ]
673
gap> LargestSourcesOfAffineMappings(ClassReflection(0,1));
674
[ Integers ]
675
gap> u := RcwaMapping([[3,0,5],[9,1,5],[3,-1,5],[9,-2,5],[9,4,5]]);;
676
gap> List( [ u, u^-1 ], LargestSourcesOfAffineMappings );
677
[ [ 0(5), 1(5), 2(5), 3(5), 4(5) ], [ 0(3), 1(3), 2(9), 5(9), 8(9) ] ]
678
gap> kappa := ClassTransposition(2,4,3,4) * ClassTransposition(4,6,8,12)
679
>  * ClassTransposition(3,4,4,6);
680
<rcwa permutation of Z with modulus 12>
681
gap> LargestSourcesOfAffineMappings(kappa);
682
[ 2(4), 1(4) U 0(12), 3(12) U 7(12), 4(12), 8(12), 11(12) ]
683

684

685
686
2.4-2 FixedPointsOfAffinePartialMappings
687
688
FixedPointsOfAffinePartialMappings( f )  attribute
689
Returns: a list of the sets of fixed points of the affine partial mappings
690
of the rcwa mapping f in the quotient field of its source.
691
692
The returned list contains entries for the restrictions of f to all residue
693
classes modulo Mod(f). A list entry can either be an empty set, the source
694
of f or a set of cardinality 1. The ordering of the entries corresponds to
695
the ordering of the residues in AllResidues(Source(f),m).
696
697
 Example 
698

699
gap> FixedPointsOfAffinePartialMappings(ClassShift(0,2));
700
[ [ ], Rationals ]
701
gap> List([1..3],k->FixedPointsOfAffinePartialMappings(T^k));
702
[ [ [ 0 ], [ -1 ] ], [ [ 0 ], [ 1 ], [ 2 ], [ -1 ] ], 
703
 [ [ 0 ], [ -7 ], [ 2/5 ], [ -5 ], [ 4/5 ], [ 1/5 ], [ -10 ], [ -1 ] ] ]
704

705

706
707
2.4-3 Multpk
708
709
Multpk( f, p, k )  operation
710
Returns: the union of the residue classes r(m) such that p^k||a_r(m) if k ≥
711
0, and the union of the residue classes r(m) such that p^k||c_r(m)
712
if k ≤ 0. In this context, m denotes the modulus of f, and a_r(m)
713
and c_r(m) denote the coefficients of f as introduced in
714
Section 2.1.
715
716
 Example 
717

718
gap> T := RcwaMapping([[1,0,2],[3,1,2]]);; # The Collatz mapping.
719
gap> [ Multpk(T,2,-1), Multpk(T,3,1) ];
720
[ Integers, 1(2) ]
721
gap> u := RcwaMapping([[3,0,5],[9,1,5],[3,-1,5],[9,-2,5],[9,4,5]]);;
722
gap> [ Multpk(u,3,0), Multpk(u,3,1), Multpk(u,3,2), Multpk(u,5,-1) ];
723
[ [ ], 0(5) U 2(5), Z \ 0(5) U 2(5), Integers ]
724

725

726
727
There are attributes ClassWiseOrderPreservingOn, ClassWiseConstantOn and
728
ClassWiseOrderReversingOn which store the union of the residue classes
729
(mod Mod(f)) on which an rcwa mapping f of ℤ or of a semilocalization
730
thereof is class-wise order-preserving, class-wise constant or class-wise
731
order-reversing, respectively.
732
733
 Example 
734

735
gap> List([ClassTransposition(1,2,0,4),ClassShift(2,3),
736
>  ClassReflection(2,5)],ClassWiseOrderPreservingOn);
737
[ Integers, Integers, Z \ 2(5) ]
738

739

740
741
Also there are attributes ShiftsUpOn and ShiftsDownOn which store the union
742
of the residue classes (mod Mod(f)) on which an rcwa mapping f of ℤ induces
743
affine mappings n ↦ n + c for c > 0, respectively, c < 0.
744
745
Finally, there are epimorphisms from the subgroup of RCWA(ℤ) formed by all
746
class-wise order-preserving elements to (ℤ,+) and from RCWA(ℤ) itself to the
747
cyclic group of order 2, respectively:
748
749
2.4-4 Determinant
750
751
Determinant( f )  method
752
Returns: the determinant of the rcwa mapping f of ℤ.
753
754
The determinant of an affine mapping n ↦ (an+b)/c whose source is a residue
755
class r(m) is defined by b/|a|m. This definition is extended additively to
756
determinants of rcwa mappings.
757
758
Let f be an rcwa mapping of the integers, and let m denote its modulus.
759
Using the notation f|_r(m): n ↦ (a_r(m) ⋅ n + b_r(m))/c_r(m) for the affine
760
partial mappings, the determinant det(f) of f is given by
761
762
-----
763
\ b_r(m)
764
> --------------
765
/ |a_{r(m)}| * m
766
-----
767
r(m) in Z/mZ .
768
769
770
The determinant mapping is an epimorphism from the group of all class-wise
771
order-preserving rcwa permutations of ℤ to (ℤ,+), see [Koh05],
772
Theorem 2.11.9.
773
774
 Example 
775

776
gap> List([ClassTransposition(0,4,5,12),ClassShift(3,7)],Determinant);
777
[ 0, 1 ]
778
gap> Determinant(ClassTransposition(0,4,5,12)*ClassShift(3,7)^100); 
779
100
780

781

782
783
2.4-5 Sign
784
785
Sign( g )  attribute
786
Returns: the sign of the rcwa permutation g of ℤ.
787
788
Let σ be an rcwa permutation of the integers, and let m denote its modulus.
789
Using the notation σ|_r(m): n ↦ (a_r(m) ⋅ n + b_r(m))/c_r(m) for the affine
790
partial mappings, the sign of σ is defined by
791
792
-----
793
\ m - 2r
794
det(sigma) + > -------
795
/ m
796
-----
797
a_r(m) < 0
798
(-1) .
799
800
801
The sign mapping is an epimorphism from RCWA(ℤ) to the group ℤ^× of units
802
of ℤ, see [Koh05], Theorem 2.12.8. Therefore the kernel of the sign mapping
803
is a normal subgroup of RCWA(ℤ) of index 2. The simple group CT(ℤ) is a
804
subgroup of this kernel.
805
806
 Example 
807

808
gap> List([ClassTransposition(3,4,2,6),
809
>  ClassShift(0,3),ClassReflection(2,5)],Sign);
810
[ 1, -1, -1 ]
811

812

813
814
815
2.5 Factoring residue-class-wise affine permutations
816
817
Factoring group elements into the members of some nice set of generators is
818
often helpful. In this section we describe an operation which attempts to
819
solve this problem for the group RCWA(ℤ). Elements of finitely generated
820
rcwa groups can be factored into generators as usual,
821
see PreImagesRepresentative (3.2-3).
822
823
2.5-1 FactorizationIntoCSCRCT
824
825
FactorizationIntoCSCRCT( g )  attribute
826
Factorization( g )  method
827
Returns: a factorization of the rcwa permutation g of ℤ into class shifts,
828
class reflections and class transpositions, provided that such a
829
factorization exists and the method finds it.
830
831
The method may return fail, stop with an error message or run into an
832
infinite loop. If it returns a result, this result is always correct.
833
834
The problem of obtaining a factorization as described is algorithmically
835
difficult, and this factorization routine is currently perhaps the most
836
sophisticated part of the RCWA package. Information about the progress of
837
the factorization process can be obtained by setting the info level of the
838
Info class InfoRCWA (9.5-1) to 2.
839
840
By default, prime switches (→ PrimeSwitch (2.5-2)) are taken as one factor.
841
If the option ExpandPrimeSwitches is set, they are each decomposed into the
842
6 class transpositions given in the definition.
843
844
By default, the factoring process begins with splitting off factors from the
845
right. This can be changed by setting the option Direction to "from the
846
left".
847
848
By default, a reasonably coarse respected partition of the integral mapping
849
occurring in the final stage of the algorithm is computed. This can be
850
suppressed by setting the option ShortenPartition equal to false.
851
852
By default, at the end it is checked whether the product of the determined
853
factors indeed equals g. This check can be suppressed by setting the option
854
NC.
855
856
 Example 
857

858
gap> Factorization(Comm(ClassShift(0,3)*ClassReflection(1,2),
859
>  ClassShift(0,2)));
860
[ ClassReflection( 2(3) ), ClassShift( 2(6) )^-1, ( 0(6), 2(6) ), 
861
 ( 0(6), 5(6) ) ]
862

863

864
865
For purposes of demonstrating the capabilities of the factorization routine,
866
in Section 7.2 Collatz' permutation is factored. Lothar Collatz has
867
investigated this permutation in 1932. Its cycle structure is unknown so
868
far.
869
870
The permutations of the following kind play an important role in factoring
871
rcwa permutations of ℤ into class shifts, class reflections and class
872
transpositions:
873
874
2.5-2 PrimeSwitch
875
876
PrimeSwitch( p )  method
877
PrimeSwitch( p, k )  method
878
PrimeSwitch( p, r, m )  method
879
PrimeSwitch( p, cl )  method
880
Returns: in the first form the prime switch σ_p := τ_0(8),1(2p) ⋅
881
τ_4(8),-1(2p) ⋅ τ_0(4),1(2p) ⋅ τ_2(4),-1(2p) ⋅ τ_2(2p),1(4p) ⋅
882
τ_4(2p),2p+1(4p), in the second form the restriction of σ_p by n ↦
883
kn, and in the third and fourth form the prime switch σ_p,r(m) :=
884
τ_r_1(m/2),r_2(m) ⋅ τ_r_2(m),r_1(pm/2) ⋅ τ_r(m/2),r_1(pm/2). In
885
the latter case, cl is the residue class r(m), the residue r_1 is
886
1-(r mod 2), and r_2 is defined by the equality r(m) ∪ r_2(m) =
887
r(m/2).
888
889
For an odd prime p, the prime switch σ_p is an rcwa permutation of ℤ with
890
modulus 4p, multiplier p and divisor 2. The prime switch σ_p,r(m) has
891
multiplier p and divisor 2, and the class where the multiplication by p
892
occurs is just r(m). The key mathematical property of a prime switch is that
893
it is a product of class transpositions whose multiplier and divisor are
894
coprime.
895
896
Prime switches can be distinguished from other rcwa mappings by their GAP
897
property IsPrimeSwitch.
898
899
 Example 
900

901
gap> Display(PrimeSwitch(3));
902

903
Wild rcwa permutation of Z with modulus 12
904

905
 /
906
 | (3n+4)/2 if n in 2(4)
907
 | n-1 if n in 5(6) U 8(12)
908
 | n+1 if n in 1(6)
909
 n |-> < n/2 if n in 0(12)
910
 | n-3 if n in 4(12)
911
 | n if n in 3(6)
912
 |
913
 \
914

915
gap> Display(PrimeSwitch(3):AsClassMapping);
916

917
Wild rcwa permutation of Z with modulus 12
918

919
 0(12) -> 0(6) loop
920
 1(6) -> 2(6)
921
 2(4) -> 5(6)
922
 3(6) -> 3(6) id
923
 4(12) -> 1(12)
924
 5(6) -> 4(6)
925
 8(12) -> 7(12)
926

927
gap> Factorization(PrimeSwitch(3));
928
[ ( 1(6), 0(8) ), ( 5(6), 4(8) ), ( 0(4), 1(6) ), ( 2(4), 5(6) ), 
929
 ( 2(6), 1(12) ), ( 4(6), 7(12) ) ]
930
gap> Display(PrimeSwitch(5,3,4));
931

932
Wild rcwa permutation of Z with modulus 20
933

934
 /
935
 | n+1 if n in 0(2)
936
 | 5n-5 if n in 3(4)
937
 n |-> < (n-1)/2 if n in 1(4) \ 1(20)
938
 | n-1 if n in 1(20)
939
 |
940
 \
941

942
gap> Multpk(PrimeSwitch(5,3,4),5,1);
943
3(4)
944
gap> PrimeSwitch(5,3,4) = PrimeSwitch(5,ResidueClass(3,4));
945
true
946
gap> Factorization(PrimeSwitch(5,3,4));
947
[ ( 0(2), 1(4) ), ( 1(4), 0(10) ), ( 1(2), 0(10) ) ]
948

949

950
951
Obtaining a factorization of an rcwa permutation into class shifts, class
952
reflections and class transpositions is particularly difficult if multiplier
953
and divisor are coprime. A prototype of permutations which have this
954
property has been introduced in a different context in [Kel99]:
955
956
2.5-3 mKnot
957
958
mKnot( m )  function
959
Returns: the permutation g_m as defined in [Kel99].
960
961
The argument m must be an odd integer greater than 1.
962
963
 Example 
964

965
gap> Display(mKnot(5));
966

967
Wild rcwa permutation of Z with modulus 5
968

969
 /
970
 | 6n/5 if n in 0(5)
971
 | (4n+1)/5 if n in 1(5)
972
 n |-> < (6n-2)/5 if n in 2(5)
973
 | (4n+3)/5 if n in 3(5)
974
 | (6n-4)/5 if n in 4(5)
975
 \
976

977

978
979
In his article, Timothy P. Keller shows that a permutation of this type
980
cannot have infinitely many cycles of any given finite length.
981
982
983
2.6 Extracting roots of residue-class-wise affine mappings
984
985
2.6-1 Root
986
987
Root( f, k )  method
988
Returns: an rcwa mapping g such that g^k=f, provided that such a mapping
989
exists and that there is a method available which can determine
990
it.
991
992
Currently, extracting roots is implemented for rcwa permutations of finite
993
order.
994
995
 Example 
996

997
gap> Root(ClassTransposition(0,2,1,2),100);
998
( 0(8), 2(8), 4(8), 6(8), 1(8), 3(8), 5(8), 7(8) )
999
gap> Display(last:CycleNotation:=false);
1000

1001
Tame rcwa permutation of Z with modulus 8
1002

1003
 /
1004
 | n+2 if n in Z \ 6(8) U 7(8)
1005
 n |-> < n-5 if n in 6(8)
1006
 | n-7 if n in 7(8)
1007
 \
1008

1009
gap> last^100 = ClassTransposition(0,2,1,2);
1010
true
1011

1012

1013
1014
1015
2.7 Special functions for non-bijective mappings
1016
1017
2.7-1 RightInverse
1018
1019
RightInverse( f )  attribute
1020
Returns: a right inverse of the injective rcwa mapping f, i.e. a mapping g
1021
such that fg = 1.
1022
1023
 Example 
1024

1025
gap> twice := 2*IdentityRcwaMappingOfZ;
1026
Rcwa mapping of Z: n -> 2n
1027
gap> twice * RightInverse(twice);
1028
IdentityMapping( Integers )
1029

1030

1031
1032
2.7-2 CommonRightInverse
1033
1034
CommonRightInverse( l, r )  operation
1035
Returns: a mapping d such that ld = rd = 1.
1036
1037
The mappings l and r must be injective, and their images must form a
1038
partition of their source.
1039
1040
 Example 
1041

1042
gap> twice := 2*IdentityRcwaMappingOfZ; twiceplus1 := twice+1;
1043
Rcwa mapping of Z: n -> 2n
1044
Rcwa mapping of Z: n -> 2n + 1
1045
gap> Display(CommonRightInverse(twice,twiceplus1));
1046

1047
Rcwa mapping of Z with modulus 2
1048

1049
 /
1050
 | n/2 if n in 0(2)
1051
 n |-> < (n-1)/2 if n in 1(2)
1052
 |
1053
 \
1054

1055

1056
1057
2.7-3 ImageDensity
1058
1059
ImageDensity( f )  attribute
1060
Returns: the image density of the rcwa mapping f.
1061
1062
In the notation introduced in the definition of an rcwa mapping, the image
1063
density of an rcwa mapping f is defined by 1/m ∑_r(m) ∈ R/mR
1064
|R/c_r(m)R|/|R/a_r(m)R|. The image density of an injective rcwa mapping is ≤
1065
1, and the image density of a surjective rcwa mapping is ≥ 1 (this can be
1066
seen easily). Thus in particular the image density of a bijective rcwa
1067
mapping is 1.
1068
1069
 Example 
1070

1071
gap> T := RcwaMapping([[1,0,2],[3,1,2]]);; # The Collatz mapping.
1072
gap> List( [ T, ClassShift(0,1), RcwaMapping([[2,0,1]]) ], ImageDensity );
1073
[ 4/3, 1, 1/2 ]
1074

1075

1076
1077
Given an rcwa mapping f, the function InjectiveAsMappingFrom returns a set S
1078
such that the restriction of f to S is injective, and such that the image of
1079
S under f is the entire image of f.
1080
1081
 Example 
1082

1083
gap> InjectiveAsMappingFrom(T);
1084
0(2)
1085

1086

1087
1088
1089
2.8 On trajectories and cycles of residue-class-wise affine mappings
1090
1091
RCWA provides various methods to compute trajectories of rcwa mappings:
1092
1093
1094
2.8-1 Trajectory (methods for rcwa mappings)
1095
1096
Trajectory( f, n, length )  method
1097
Trajectory( f, n, length, m )  method
1098
Trajectory( f, n, terminal )  method
1099
Trajectory( f, n, terminal, m )  method
1100
Returns: the first length iterates in the trajectory of the rcwa mapping f
1101
starting at n, respectively the initial part of the trajectory of
1102
the rcwa mapping f starting at n which ends at the first
1103
occurrence of an iterate in the set terminal. If the argument m is
1104
given, the iterates are reduced (mod m).
1105
1106
To save memory when computing long trajectories containing huge iterates,
1107
the reduction (mod m) is done each time before storing an iterate. In place
1108
of the ring element n, the methods also accept a finite set of ring elements
1109
or a union of residue classes.
1110
1111
 Example 
1112

1113
gap> T := RcwaMapping([[1,0,2],[3,1,2]]);; # The Collatz mapping.
1114
gap> Trajectory(T,27,15); Trajectory(T,27,20,5);
1115
[ 27, 41, 62, 31, 47, 71, 107, 161, 242, 121, 182, 91, 137, 206, 103 ]
1116
[ 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 0, 3, 0, 0, 3 ]
1117
gap> Trajectory(T,15,[1]); Trajectory(T,15,[1],2);
1118
[ 15, 23, 35, 53, 80, 40, 20, 10, 5, 8, 4, 2, 1 ]
1119
[ 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1 ]
1120
gap> Trajectory(T,ResidueClass(Integers,3,0),Integers);
1121
[ 0(3), 0(3) U 5(9), 0(3) U 5(9) U 7(9) U 8(27), 
1122
 <union of 20 residue classes (mod 27) (6 classes)>, 
1123
 <union of 73 residue classes (mod 81)>, Z \ 10(81) U 37(81), Integers ]
1124

1125

1126
1127
1128
2.8-2 Trajectory (methods for rcwa mappings -- accumulated coefficients)
1129
1130
Trajectory( f, n, length, whichcoeffs )  method
1131
Trajectory( f, n, terminal, whichcoeffs )  method
1132
Returns: either the list c of triples of coprime coefficients such that for
1133
any k it holds that n^(f^(k-1)) = (c[k][1]*n + c[k][2])/c[k][3] or
1134
the last entry of that list, depending on whether whichcoeffs is
1135
"AllCoeffs" or "LastCoeffs".
1136
1137
The meanings of the arguments length and terminal are the same as in the
1138
methods for the operation Trajectory described above. In general, computing
1139
only the last coefficient triple (whichcoeffs = "LastCoeffs") needs
1140
considerably less memory than computing the entire list.
1141
1142
 Example 
1143

1144
gap> Trajectory(T,27,[1],"LastCoeffs");
1145
[ 36472996377170786403, 195820718533800070543, 1180591620717411303424 ]
1146
gap> (last[1]*27+last[2])/last[3];
1147
1
1148

1149

1150
1151
When dealing with problems like the 3n+1-Conjecture or when determining the
1152
degree of transitivity of the natural action of an rcwa group on its
1153
underlying ring, an important task is to determine the residue classes whose
1154
elements get larger or smaller when applying a given rcwa mapping:
1155
1156
1157
2.8-3 IncreasingOn & DecreasingOn (for an rcwa mapping)
1158
1159
IncreasingOn( f )  attribute
1160
DecreasingOn( f )  attribute
1161
Returns: the union of all residue classes r(m) such that |R/a_r(m)R| >
1162
|R/c_r(m)R| or |R/a_r(m)R| < |R/c_r(m)R|, respectively, where R
1163
denotes the source, m denotes the modulus and a_r(m), b_r(m) and
1164
c_r(m) denote the coefficients of f as introduced in Section 2.1.
1165
1166
If the argument is an rcwa mapping of ℤ in sparse representation, an option
1167
classes is interpreted; if set, the step of forming the union of the residue
1168
classes in question is omitted, and the list of residue classes is returned
1169
instead of their union. This may save time and memory if the modulus is
1170
large.
1171
1172
 Example 
1173

1174
gap> List([1..3],k->IncreasingOn(T^k));
1175
[ 1(2), 3(4), 3(4) U 1(8) U 6(8) ]
1176
gap> List([1..3],k->DecreasingOn(T^k));
1177
[ 0(2), Z \ 3(4), 0(4) U 2(8) U 5(8) ]
1178
gap> a := RcwaMapping([[2,0,3],[4,-1,3],[4,1,3]]);; # Collatz' permutation
1179
gap> List([-2..2],k->IncreasingOn(a^k));
1180
[ Z \ 1(8) U 7(8), 0(2), [ ], Z \ 0(3), 1(9) U 4(9) U 5(9) U 8(9) ]
1181

1182

1183
1184
We assign certain directed graphs to rcwa mappings, which encode the order
1185
in which trajectories may traverse the residue classes modulo some modulus:
1186
1187
2.8-4 TransitionGraph
1188
1189
TransitionGraph( f, m )  operation
1190
Returns: the transition graph of the rcwa mapping f for modulus m.
1191
1192
The transition graph Γ_f,m of f for modulus m is defined as follows:
1193
1194
1 The vertices are the residue classes (mod m).
1195
1196
2 There is an edge from r_1(m) to r_2(m) if and only if there is some n
1197
∈ r_1(m) such that n^f ∈ r_2(m).
1198
1199
The assignment of the residue classes (mod m) to the vertices of the graph
1200
corresponds to the ordering of the residues in AllResidues(Source(f),m). The
1201
result is returned in the format used by the package GRAPE [Soi16].
1202
1203
There are a couple of operations and attributes which are based on these
1204
graphs:
1205
1206
2.8-5 OrbitsModulo
1207
1208
OrbitsModulo( f, m )  operation
1209
Returns: the partition of AllResidues(Source(f),m) corresponding to the
1210
weakly connected components of the transition graph of the rcwa
1211
mapping f for modulus m.
1212
1213
 Example 
1214

1215
gap> OrbitsModulo(ClassTransposition(0,2,1,4),8);
1216
[ [ 0, 1, 4 ], [ 2, 5, 6 ], [ 3 ], [ 7 ] ]
1217

1218

1219
1220
2.8-6 FactorizationOnConnectedComponents
1221
1222
FactorizationOnConnectedComponents( f, m )  operation
1223
Returns: the set of restrictions of the rcwa mapping f to the weakly
1224
connected components of its transition graph Γ_f,m.
1225
1226
The product of the returned mappings is f. They have pairwise disjoint
1227
supports, hence any two of them commute.
1228
1229
 Example 
1230

1231
gap> sigma := ClassTransposition(1,4,2,4) * ClassTransposition(1,4,3,4)
1232
>  * ClassTransposition(3,9,6,18) * ClassTransposition(1,6,3,9);;
1233
gap> List(FactorizationOnConnectedComponents(sigma,36),Support);
1234
[ 33(36) U 34(36) U 35(36), 9(36) U 10(36) U 11(36), 
1235
 <union of 23 residue classes (mod 36)> \ [ -6, 3 ] ]
1236

1237

1238
1239
2.8-7 TransitionMatrix
1240
1241
TransitionMatrix( f, m )  operation
1242
Returns: the transition matrix of the rcwa mapping f for modulus m.
1243
1244
Let M be this matrix. Then for any two residue classes r_1(m), r_2(m) ∈
1245
R/mR, the entry M_r_1(m),r_2(m) is defined by
1246
1247
(see the PDF- or HTML version of the manual), where hatm is the product of m
1248
and the square of the modulus of f. The assignment of the residue classes
1249
(mod m) to the rows and columns of the matrix corresponds to the ordering of
1250
the residues in AllResidues(Source(f),m).
1251
1252
The transition matrix is a weighted adjacency matrix of the corresponding
1253
transition graph TransitionGraph(f,m). The sums of the rows of a transition
1254
matrix are always equal to 1.
1255
1256
 Example 
1257

1258
gap> T := RcwaMapping([[1,0,2],[3,1,2]]);; # The Collatz mapping.
1259
gap> Display(TransitionMatrix(T^3,3));
1260
[ [ 1/8, 1/4, 5/8 ],
1261
 [ 0, 1/4, 3/4 ],
1262
 [ 0, 3/8, 5/8 ] ]
1263

1264

1265
1266
1267
2.8-8 Sources & Sinks (of an rcwa mapping)
1268
1269
Sources( f )  attribute
1270
Sinks( f )  attribute
1271
Returns: a list of unions of residue classes modulo the modulus m of the
1272
rcwa mapping f, as described below.
1273
1274
The returned list contains an entry for any strongly connected component of
1275
the transition graph of f for modulus Mod(f) which has only outgoing edges
1276
(source) or which has only ingoing edges (sink), respectively. The list
1277
entry corresponding to such a component is the union of the vertices
1278
belonging to it.
1279
1280
 Example 
1281

1282
gap> g := ClassTransposition(0,2,1,2)*ClassTransposition(0,2,1,4);;
1283
gap> Sources(g); Sinks(g);
1284
[ 0(4) ]
1285
[ 1(4) ]
1286

1287

1288
1289
2.8-9 Loops
1290
1291
Loops( f )  attribute
1292
Returns: if f is bijective, the list of non-isolated vertices of the
1293
transition graph of f for modulus Mod(f) which carry a loop. In
1294
general, the list of vertices of that transition graph which carry
1295
a loop, but which f does not fix setwise.
1296
1297
The returned list may also include supersets of the named residue classes
1298
instead if f is affine even on these.
1299
1300
 Example 
1301

1302
gap> Loops(ClassTransposition(0,2,1,2)*ClassTransposition(0,2,1,4));
1303
[ 0(4), 1(4) ]
1304

1305

1306
1307
There is a nice invariant of trajectories of the Collatz mapping:
1308
1309
2.8-10 GluckTaylorInvariant
1310
1311
GluckTaylorInvariant( a )  function
1312
Returns: the invariant defined in [GT02]. This is (∑_i=1^l a_i ⋅ a_i mod l
1313
+ 1)/(∑_i=1^l a_i^2), where l denotes the length of a.
1314
1315
The argument a must be a list of integers. In [GT02] it is shown that if a
1316
is a trajectory of the `original' Collatz mapping n ↦ (n/2 if n even, 3n+1
1317
if n odd) starting at an odd integer ≥ 3 and ending at 1, then the invariant
1318
lies in the interval ]9/13,5/7[.
1319
1320
 Example 
1321

1322
gap> C := RcwaMapping([[1,0,2],[3,1,1]]);;
1323
gap> List([3,5..49],n->Float(GluckTaylorInvariant(Trajectory(C,n,[1]))));
1324
[ 0.701053, 0.696721, 0.708528, 0.707684, 0.706635, 0.695636, 0.711769,
1325
 0.699714, 0.707409, 0.693833, 0.710432, 0.706294, 0.714242, 0.699935,
1326
 0.714242, 0.705383, 0.706591, 0.698198, 0.712222, 0.714242, 0.709048,
1327
 0.69612, 0.714241, 0.701076 ]
1328

1329

1330
1331
Quite often one can make certain educated guesses on the overall behaviour
1332
of the trajectories of a given rcwa mapping. For example it is reasonably
1333
straightforward to make the conjecture that all trajectories of the Collatz
1334
mapping eventually enter the finite set {-136, -91, -82, -68, -61, -55, -41,
1335
-37, -34, -25, -17, -10, -7, -5, -1, 0, 1, 2 }, or that on average the next
1336
number in a trajectory of the Collatz mapping is smaller than the preceding
1337
one by a factor of sqrt3/2. However it is clear that such guesses can be
1338
wrong, and that they therefore cannot be used to prove anything.
1339
Nevertheless they can sometimes be useful:
1340
1341
2.8-11 LikelyContractionCentre
1342
1343
LikelyContractionCentre( f, maxn, bound )  operation
1344
Returns: a list of ring elements (see below).
1345
1346
This operation tries to compute the contraction centre of the rcwa mapping
1347
f. Assuming its existence this is the unique finite subset S_0 of the source
1348
of f on which f induces a permutation and which intersects non-trivially
1349
with any trajectory of f. The mapping f is assumed to be contracting, i.e.
1350
to have such a contraction centre. As in general contraction centres are
1351
likely not computable, the methods for this operation are probabilistic and
1352
may return wrong results. The argument maxn is a bound on the starting value
1353
and bound is a bound on the elements of the trajectories to be searched. If
1354
the limit bound is exceeded, an Info message on Info level 3 of InfoRCWA is
1355
given.
1356
1357
 Example 
1358

1359
gap> T := RcwaMapping([[1,0,2],[3,1,2]]);; # The Collatz mapping.
1360
gap> S0 := LikelyContractionCentre(T,100,1000);
1361
#I Warning: `LikelyContractionCentre' is highly probabilistic.
1362
The returned result can only be regarded as a rough guess.
1363
See ?LikelyContractionCentre for more information.
1364
[ -136, -91, -82, -68, -61, -55, -41, -37, -34, -25, -17, -10, -7, -5, 
1365
 -1, 0, 1, 2 ]
1366

1367

1368
1369
2.8-12 GuessedDivergence
1370
1371
GuessedDivergence( f )  operation
1372
Returns: a floating point value which is intended to be a rough guess on
1373
how fast the trajectories of the rcwa mapping f diverge (return
1374
value greater than 1) or converge (return value smaller than 1).
1375
1376
Nothing particular is guaranteed.
1377
1378
 Example 
1379

1380
gap> GuessedDivergence(T);
1381
#I Warning: GuessedDivergence: no particular return value is guaranteed.
1382
0.866025
1383

1384

1385
1386
1387
2.9 Saving memory -- the sparse representation of rcwa mappings
1388
1389
It is quite common that an rcwa mapping with large modulus has only few
1390
distinct affine partial mappings. In this case the standard representation
1391
which stores a coefficient triple for each residue class modulo the modulus
1392
is unsuitable. For this reason there is a second representation of rcwa
1393
mappings, the sparse representation. Depending on the rcwa mappings
1394
involved, using this representation may speed up computations and reduce
1395
memory requirements by orders of magnitude. For rcwa mappings with almost as
1396
many distinct affine partial mappings as there are residue classes modulo
1397
the modulus, using sparse representation makes computations slower and more
1398
memory-consuming. Presently, the sparse representation is only available for
1399
rcwa mappings of ℤ.
1400
1401
The sparse representation of an rcwa mapping consists of the modulus and a
1402
list of 5-tuples (r,m,a_r(m),b_r(m),c_r(m)) of integers. Any such 5-tuple
1403
specifies the coefficients of the restriction n ↦ (a_r(m) ⋅ n +
1404
b_r(m))/c_r(m) of the mapping to a residue class r(m). The r(m) are chosen
1405
to form the coarsest possible partition of ℤ into residue classes such that
1406
the restriction of the mapping to any of them is affine. Also the list of
1407
coefficient tuples is sorted, all c_r(m) are positive and
1408
gcd(c_r(m),gcd(a_r(m),b_r(m))) = 1. This way the coefficient list of an rcwa
1409
mapping of ℤ is unique.
1410
1411
Changing the representation of rcwa mappings does not change their behaviour
1412
with respect to = and < The product of two rcwa mappings in sparse
1413
representation is in sparse representation again, just like the product of
1414
two rcwa mappings in standard representation is in standard representation.
1415
Also, inverses are in the same representation. The product of two rcwa
1416
mappings in different representation may be in any of the representations of
1417
the factors.
1418
1419
2.9-1 SparseRepresentation
1420
1421
SparseRepresentation( f )  operation
1422
SparseRep( f )  operation
1423
StandardRepresentation( f )  operation
1424
StandardRep( f )  operation
1425
Returns: the rcwa mapping f in sparse, respectively, standard
1426
representation.
1427
1428
Appropriate attribute values and properties are copied over to the rcwa
1429
mapping in the new representation.
1430
1431
 Example 
1432

1433
gap> a := ClassTransposition(1,2,4,6);
1434
( 1(2), 4(6) )
1435
gap> b := ClassTransposition(1,3,2,6);
1436
( 1(3), 2(6) )
1437
gap> c := ClassTransposition(2,3,4,6);
1438
( 2(3), 4(6) )
1439
gap> g := (b*a*c)^2*a;
1440
<rcwa permutation of Z with modulus 288>
1441
gap> h := SparseRep(g);
1442
<rcwa permutation of Z with modulus 288 and 21 affine parts>
1443
gap> g = h;
1444
true
1445
gap> Coefficients(h);
1446
[ [ 0, 6, 1, 0, 1 ], [ 1, 3, 16, -1, 3 ], [ 2, 96, 9, 14, 16 ], 
1447
 [ 3, 24, 9, 5, 4 ], [ 5, 24, 3, 1, 4 ], [ 8, 36, 2, -7, 9 ], 
1448
 [ 9, 48, 27, 29, 8 ], [ 11, 24, 9, 5, 4 ], [ 14, 48, 27, 38, 8 ], 
1449
 [ 15, 24, 27, 19, 4 ], [ 17, 48, 9, 7, 8 ], [ 20, 72, 3, 4, 4 ], 
1450
 [ 21, 24, 1, -3, 6 ], [ 23, 24, 27, 19, 4 ], [ 26, 48, 3, 2, 8 ], 
1451
 [ 32, 36, 4, -11, 9 ], [ 33, 48, 9, 7, 8 ], [ 38, 48, 9, 10, 8 ], 
1452
 [ 41, 48, 27, 29, 8 ], [ 50, 96, 27, 58, 16 ], [ 56, 72, 1, 0, 4 ] ]
1453
gap> h^2;
1454
<rcwa permutation of Z with modulus 13824 and 71 affine parts>
1455
gap> h^3;
1456
<rcwa permutation of Z with modulus 663552 and 201 affine parts>
1457

1458

1459
1460
Memory consumption may differ a lot between sparse- and standard
1461
representation:
1462
1463
 Example 
1464
gap> MemoryUsage(h^3); # on a 64-bit machine
1465
18254
1466
gap> MemoryUsage(StandardRep(h^3)); # on a 64-bit machine
1467
42467894
1468

1469
1470
1471
2.10 The categories and families of rcwa mappings
1472
1473
2.10-1 IsRcwaMapping
1474
1475
IsRcwaMapping( f )  filter
1476
IsRcwaMappingOfZ( f )  filter
1477
IsRcwaMappingOfZ_pi( f )  filter
1478
IsRcwaMappingOfGFqx( f )  filter
1479
Returns: true if f is an rcwa mapping, an rcwa mapping of the ring of
1480
integers, an rcwa mapping of a semilocalization of the ring of
1481
integers or an rcwa mapping of a polynomial ring in one variable
1482
over a finite field, respectively, and false otherwise.
1483
1484
Often the same methods can be used for rcwa mappings of the ring of integers
1485
and of its semilocalizations. For this reason there is a category
1486
IsRcwaMappingOfZOrZ_pi which is the union of IsRcwaMappingOfZ and
1487
IsRcwaMappingOfZ_pi. The internal representation of rcwa mappings is called
1488
IsRcwaMappingStandardRep. There are methods available for ExtRepOfObj and
1489
ObjByExtRep.
1490
1491
2.10-2 RcwaMappingsFamily
1492
1493
RcwaMappingsFamily( R )  function
1494
Returns: the family of rcwa mappings of the ring R.
1495
1496
1497