GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
<!-- #################################################################### -->1<!-- ## ## -->2<!-- ## rcwamap.xml RCWA documentation Stefan Kohl ## -->3<!-- ## ## -->4<!-- #################################################################### -->56<Chapter Label="ch:RcwaMappings">7<Heading>Residue-Class-Wise Affine Mappings</Heading>89<Ignore Remark="settings for the example tester">10<Example>11<![CDATA[12gap> SizeScreen([75,24]);;13gap> SetAssertionLevel(0);14]]>15</Example>16</Ignore>1718This chapter contains the basic definitions, and it describes how to19enter residue-class-wise affine mappings and how to compute with them. <P/>2021How to compute with residue-class-wise affine groups is described in detail22in the next chapter. The reader is encouraged to look there already after23having read the first few pages of this chapter, and to look up definitions24as he needs to.2526<!-- #################################################################### -->2728<Section Label="sec:basicdefinitions">29<Heading>Basic definitions</Heading>3031<Index Key="rcwa mapping" Subkey="definition">rcwa mapping</Index>32<Index Key="rcwa group" Subkey="definition">rcwa group</Index>3334Residue-class-wise affine groups, or <E>rcwa</E> groups for short, are35permutation groups whose elements are bijective residue-class-wise affine36mappings. <P/>3738A mapping <M>f: &ZZ; \rightarrow &ZZ;</M> is called39<E>residue-class-wise affine</E>, or for short an <E>rcwa</E> mapping,40if there is a positive integer <M>m</M> such that the restrictions41of <M>f</M> to the residue classes42<M>r(m) \in &ZZ;/m&ZZ;</M> are all affine,43i.e. given by44<Alt Only="LaTeX">45<Display>46f|_{r(m)}: \ r(m) \rightarrow \mathbb{Z}, \ \ \47n \ \mapsto \ \frac{a_{r(m)} \cdot n + b_{r(m)}}{c_{r(m)}}48</Display>49</Alt>50<Alt Only="HTML"><![CDATA[<center>51<img src = "rcwamap.png" width = "366" height = "49"52alt = "f|_r(m): n |-> (a_r(m) * n + b_r(m)) / c_r(m)" />53</center>]]></Alt>54<Alt Only="Text"><Verb>55a_r(m) * n + b_r(m)56f|_r(m): r(m) -> Z, n |-> -------------------57c_r(m)58</Verb></Alt>59for certain coefficients <M>a_{r(m)}, b_{r(m)}, c_{r(m)} \in &ZZ;</M>60depending on <M>r(m)</M>.6162<Index Key="modulus" Subkey="definition">modulus</Index>63<Index Key="rcwa mapping" Subkey="modulus">rcwa mapping</Index>64<Index Key="multiplier" Subkey="definition">multiplier</Index>65<Index Key="rcwa mapping" Subkey="multiplier">rcwa mapping</Index>66<Index Key="divisor" Subkey="definition">divisor</Index>67<Index Key="rcwa mapping" Subkey="divisor">rcwa mapping</Index>6869The smallest possible <M>m</M> is called the <E>modulus</E>70of <M>f</M>. It is understood that all fractions are reduced,71i.e. that <M>\gcd( a_{r(m)}, b_{r(m)}, c_{r(m)} ) = 1</M>, and that72<M>c_{r(m)} > 0</M>. The lcm of the coefficients <M>a_{r(m)}</M>73is called the <E>multiplier</E> of <M>f</M>, and the lcm of the74coefficients <M>c_{r(m)}</M> is called the <E>divisor</E>75of <M>f</M>. <P/>7677It is easy to see that the residue-class-wise affine mappings of &ZZ;78form a monoid under composition, and that the residue-class-wise affine79permutations of &ZZ; form a countable subgroup of Sym(&ZZ;).80We denote the former by Rcwa(&ZZ;), and the latter by RCWA(&ZZ;). <P/>8182<Index Key="tame" Subkey="rcwa mapping">tame</Index>83<Index Key="tame" Subkey="rcwa group">tame</Index>84<Index Key="wild" Subkey="rcwa mapping">wild</Index>85<Index Key="wild" Subkey="rcwa group">wild</Index>86<Index Key="rcwa mapping" Subkey="tame">rcwa mapping</Index>87<Index Key="rcwa group" Subkey="tame">rcwa group</Index>88<Index Key="rcwa mapping" Subkey="wild">rcwa mapping</Index>89<Index Key="rcwa group" Subkey="wild">rcwa group</Index>9091An rcwa mapping is called <E>tame</E> if the set of moduli of its powers92is bounded, or equivalently if it permutes a partition93of &ZZ; into finitely many residue classes on all of which94it is affine. An rcwa group is called <E>tame</E> if there is a common such95partition for all of its elements, or equivalently if the set of moduli of96its elements is bounded. Rcwa mappings and -groups which are not tame97are called <E>wild</E>. Tame rcwa mappings and -groups are something which98one could call the <Q>trivial cases</Q> or <Q>basic building blocks</Q>,99while wild rcwa groups are the objects of primary interest. <P/>100101The definitions of residue-class-wise affine mappings and -groups102can be generalized in the obvious way to suitable rings other than &ZZ;.103In fact, this package provides also some support for residue-class-wise104affine groups over <M>&ZZ;^2</M>, over semilocalizations of &ZZ;105and over univariate polynomial rings over finite fields.106The ring <M>&ZZ;^2</M> has been chosen as an example of a suitable ring107which is not a principal ideal domain, the semilocalizations of &ZZ;108have been chosen as examples of rings with only finitely many prime elements,109and the univariate polynomial rings over finite fields have been chosen110as examples of rings with nonzero characteristic.111112</Section>113114<!-- #################################################################### -->115116<Section Label="sec:EnteringRcwaMappings">117<Heading>Entering residue-class-wise affine mappings</Heading>118119Entering an rcwa mapping of &ZZ; requires giving the120modulus <M>m</M> and the coefficients <M>a_{r(m)}</M>,121<M>b_{r(m)}</M> and <M>c_{r(m)}</M> for <M>r(m)</M> running over the122residue classes (mod <M>m</M>). <P/>123124This can be done easiest by <C>RcwaMapping( <A>coeffs</A> )</C>, where125<A>coeffs</A> is a list of <M>m</M> coefficient triples126<C>coeffs[</C><M>r+1</M><C>] = [</C><M>a_{r(m)}</M>, <M>b_{r(m)}</M>,127<M>c_{r(m)}</M><C>]</C>, with <M>r</M> running from 0 to <M>m-1</M>.128<P/>129130If some coefficient <M>c_{r(m)}</M> is zero or if images of some integers131under the mapping to be defined would not be integers, an error message is132printed and a break loop is entered. For example, the coefficient triple133<C>[1,4,3]</C> is not allowed at the first position.134The reason for this is that not all integers congruent to135<M>1 \cdot 0 + 4 = 4</M> mod <M>m</M>136are divisible by 3. <P/>137138For the general constructor for rcwa mappings, see139<Ref Meth="RcwaMapping" Label="by ring, modulus and list of coefficients"/>.140141<Example>142<![CDATA[143gap> T := RcwaMapping([[1,0,2],[3,1,2]]); # The Collatz mapping.144<rcwa mapping of Z with modulus 2>145gap> [ IsSurjective(T), IsInjective(T) ];146[ true, false ]147gap> Display(T);148149Surjective rcwa mapping of Z with modulus 2150151/152| n/2 if n in 0(2)153n |-> < (3n+1)/2 if n in 1(2)154|155\156157gap> a := RcwaMapping([[2,0,3],[4,-1,3],[4,1,3]]);158<rcwa mapping of Z with modulus 3>159gap> IsBijective(a);160true161gap> Display(a); # This is Collatz' permutation:162163Rcwa permutation of Z with modulus 3164165/166| 2n/3 if n in 0(3)167n |-> < (4n-1)/3 if n in 1(3)168| (4n+1)/3 if n in 2(3)169\170171gap> Support(a);172Z \ [ -1, 0, 1 ]173gap> Cycle(a,44);174[ 44, 59, 79, 105, 70, 93, 62, 83, 111, 74, 99, 66 ]175]]>176</Example>177178<Alt Only="LaTeX">\noindent</Alt>179There is computational evidence for the conjecture that any180residue-class-wise affine permutation of &ZZ; can be181factored into members of the following three series of permutations of182particularly simple structure183(cf. <Ref Attr="FactorizationIntoCSCRCT"184Label="for an rcwa permutation of Z"/>):185186<ManSection>187<Func Name="ClassShift" Arg="r, m" Label="r, m"/>188<Func Name="ClassShift" Arg="cl" Label="cl"/>189<Returns> the class shift <M>\nu_{r(m)}</M>. </Returns>190<Description>191The <E>class shift</E> <M>\nu_{r(m)}</M> is the rcwa mapping192of &ZZ; which maps <M>n \in r(m)</M> to <M>n + m</M>193and which fixes <M>&ZZ; \setminus r(m)</M> pointwise. <P/>194195In the one-argument form, the argument <A>cl</A> stands for the196residue class <M>r(m)</M>. Enclosing the argument list in list197brackets is permitted.198<Example>199<![CDATA[200gap> Display(ClassShift(5,12));201202Tame rcwa permutation of Z with modulus 12, of order infinity203204/205| n+12 if n in 5(12)206n |-> < n if n in Z \ 5(12)207|208\209]]>210</Example>211</Description>212</ManSection>213214<ManSection>215<Func Name="ClassReflection" Arg="r, m" Label="r, m"/>216<Func Name="ClassReflection" Arg="cl" Label="cl"/>217<Returns> the class reflection <M>\varsigma_{r(m)}</M>. </Returns>218<Description>219The <E>class reflection</E> <M>\varsigma_{r(m)}</M> is the rcwa mapping220of &ZZ; which maps <M>n \in r(m)</M> to <M>-n + 2r</M> and which221fixes <M>&ZZ; \setminus r(m)</M> pointwise, where it is understood that222<M>0 \leq r < m</M>. <P/>223224In the one-argument form, the argument <A>cl</A> stands for the225residue class <M>r(m)</M>. Enclosing the argument list in list226brackets is permitted.227<Example>228<![CDATA[229gap> Display(ClassReflection(5,9));230231Rcwa permutation of Z with modulus 9, of order 2232233/234| -n+10 if n in 5(9)235n |-> < n if n in Z \ 5(9)236|237\238]]>239</Example>240</Description>241</ManSection>242243<Alt Only="LaTeX">\pagebreak[4]</Alt>244245<ManSection>246<Func Name="ClassTransposition" Arg="r1, m1, r2, m2"247Label="r1, m1, r2, m2"/>248<Func Name="ClassTransposition" Arg="cl1, cl2"249Label="cl1, cl2"/>250<Returns>251the class transposition <M>\tau_{r_1(m_1),r_2(m_2)}</M>.252</Returns>253<Description>254Given two disjoint residue classes <M>r_1(m_1)</M> and <M>r_2(m_2)</M>255of the integers, the <E>class transposition</E>256<M>\tau_{r_1(m_1),r_2(m_2)}</M> <M>\in</M> RCWA(&ZZ;) is defined as the257involution which interchanges <M>r_1+km_1</M> and <M>r_2+km_2</M> for258any integer <M>k</M> and which fixes all other points.259It is understood that <M>m_1</M> and <M>m_2</M> are positive,260that <M>0 \leq r_1 < m_1</M> and that <M>0 \leq r_2 < m_2</M>.261For a <E>generalized class transposition</E>, the latter assumptions262are not made. <P/>263264The class transposition <M>\tau_{r_1(m_1),r_2(m_2)}</M> interchanges265the residue classes <M>r_1(m_1)</M> and <M>r_2(m_2)</M> and fixes the266complement of their union pointwise. <P/>267268<Index Key="TransposedClasses" Subkey="of a class transposition">269<C>TransposedClasses</C>270</Index>271272In the four-argument form, the arguments <A>r1</A>, <A>m1</A>, <A>r2</A>273and <A>m2</A> stand for <M>r_1</M>, <M>m_1</M>, <M>r_2</M>274and <M>m_2</M>, respectively.275In the two-argument form, the arguments <A>cl1</A> and <A>cl2</A>276stand for the residue classes <M>r_1(m_1)</M> and <M>r_2(m_2)</M>,277respectively. Enclosing the argument list in list brackets is permitted.278The residue classes <M>r_1(m_1)</M> and <M>r_2(m_2)</M> are stored279as an attribute <C>TransposedClasses</C>. <P/>280281<Index Key="ClassPairs" Subkey="m"><C>ClassPairs</C></Index>282283A list of all class transpositions interchanging residue classes with284moduli less than or equal to a given bound <A>m</A> can be obtained285by <C>List(ClassPairs([<A>P</A>],<A>m</A>),ClassTransposition)</C>,286where the function <C>ClassPairs</C> returns a list of all 4-tuples287<M>(r_1,m_1,r_2,m_2)</M> of integers corresponding to the unordered288pairs of disjoint residue classes <M>r_1(m_1)</M> and <M>r_2(m_2)</M>289with <M>m_1</M> and <M>m_2</M> less than or equal to the specified290bound. If a list of primes is given as optional argument <A>P</A>,291then the returned list contains only those 4-tuples where all prime292factors of <M>m_1</M> and <M>m_2</M> lie in <A>P</A>.293If the option <C>divisors</C> is set, the returned list contains294only the 4-tuples where <M>m_1</M> and <M>m_2</M> divide <A>m</A>. <P/>295296<Index Key="NrClassPairs" Subkey="m"><C>NrClassPairs</C></Index>297<Index Key="ExtRepOfObj" Subkey="for a class transposition">298<C>ExtRepOfObj</C>299</Index>300301The function <C>NrClassPairs(<A>m</A>)</C> returns the length of the302list <C>ClassPairs(<A>m</A>)</C>, where the result is computed much303faster and without actually generating the list of tuples.304Given a class transposition <A>ct</A>, the corresponding 4-tuple305can be obtained by <C>ExtRepOfObj(<A>ct</A>)</C> <P/>306307<Index Key="SplittedClassTransposition"308Subkey="for a class transposition and a number of factors">309<C>SplittedClassTransposition</C>310</Index>311312A class transposition can be written as a product of any given number313<M>k</M> of class transpositions. Such a decomposition can be obtained314by <C>SplittedClassTransposition(<A>ct</A>,<A>k</A>)</C>. <P/>315<Example>316<![CDATA[317gap> Display(ClassTransposition(1,2,8,10):CycleNotation:=false);318319Rcwa permutation of Z with modulus 10, of order 2320321/322| 5n+3 if n in 1(2)323n |-> < (n-3)/5 if n in 8(10)324| n if n in 0(2) \ 8(10)325\326327gap> List(ClassPairs(4),ClassTransposition);328[ ( 0(2), 1(2) ), ( 0(2), 1(4) ), ( 0(2), 3(4) ), ( 0(3), 1(3) ),329( 0(3), 2(3) ), ( 0(4), 1(4) ), ( 0(4), 2(4) ), ( 0(4), 3(4) ),330( 1(2), 0(4) ), ( 1(2), 2(4) ), ( 1(3), 2(3) ), ( 1(4), 2(4) ),331( 1(4), 3(4) ), ( 2(4), 3(4) ) ]332gap> NrClassPairs(100);3333528138334gap> SplittedClassTransposition(ClassTransposition(0,2,1,4),3);335[ ( 0(6), 1(12) ), ( 2(6), 5(12) ), ( 4(6), 9(12) ) ]]]>336</Example>337</Description>338</ManSection>339340<Alt Only="LaTeX">\noindent</Alt>341The set of all class transpositions of the ring of integers generates the342simple group CT(&ZZ;) mentioned in Chapter <Ref Label="ch:AboutRCWA"/>.343This group has a representation as a &GAP; object -- see <Ref Func="CT"344Label="the group generated by all class transpositions of a ring"/>.345The set of all generalized class transpositions of &ZZ;346generates a simple group as well, cf. <Cite Key="Kohl09"/>. <P/>347348Class shifts, class reflections and class transpositions of rings349<M>R</M> other than &ZZ; are defined in an entirely analogous350way -- all one needs to do is to replace &ZZ; by <M>R</M>351and to read <M><</M> and <M>\leq</M> in the sense of the ordering used352by &GAP;.353They can also be entered basically as described above -- just prepend354the desired ring <M>R</M> to the argument list. Often also a sensible355<Q>default ring</Q> (<M>\rightarrow</M> <C>DefaultRing</C> in the &GAP;356Reference Manual) is chosen if that optional first argument is omitted. <P/>357358On rings which have more than two units, there is another basic series359of rcwa permutations which generalizes class reflections:360361<ManSection>362<Func Name="ClassRotation" Arg="r, m, u" Label="r, m, u"/>363<Func Name="ClassRotation" Arg="cl, u" Label="cl, u"/>364<Returns> the class rotation <M>\rho_{r(m),u}</M>. </Returns>365<Description>366Given a residue class <M>r(m)</M> and a unit <M>u</M> of a suitable367ring <M>R</M>, the <E>class rotation</E> <M>\rho_{r(m),u}</M>368is the rcwa mapping which maps <M>n \in r(m)</M> to <M>un + (1-u)r</M>369and which fixes <M>R \setminus r(m)</M> pointwise.370Class rotations generalize class reflections, as we have371<M>\rho_{r(m),-1} = \varsigma_{r(m)}</M>. <P/>372373<Index Key="RotationFactor" Subkey="of a class rotation">374<C>RotationFactor</C>375</Index>376377In the two-argument form, the argument <A>cl</A> stands for the378residue class <M>r(m)</M>. Enclosing the argument list in list379brackets is permitted. The argument <A>u</A> is stored as an attribute380<C>RotationFactor</C>.381<Example>382<![CDATA[383gap> Display(ClassRotation(ResidueClass(Z_pi(2),2,1),1/3));384385Tame rcwa permutation of Z_( 2 ) with modulus 2, of order infinity386387/388| 1/3 n + 2/3 if n in 1(2)389n |-> < n if n in 0(2)390|391\392393gap> x := Indeterminate(GF(8),1);; SetName(x,"x");394gap> R := PolynomialRing(GF(8),1);;395gap> cr := ClassRotation(1,x,Z(8)*One(R)); Support(cr);396ClassRotation( 1(x), Z(2^3) )3971(x) \ [ 1 ]398gap> Display(cr);399400Rcwa permutation of GF(2^3)[x] with modulus x, of order 7401402/403| Z(2^3)*P + Z(2^3)^3 if P in 1(x)404P |-> < P otherwise405|406\407]]>408</Example>409</Description>410</ManSection>411412<Index Key="IsClassShift" Subkey="for an rcwa mapping">413<C>IsClassShift</C>414</Index>415<Index Key="IsClassReflection" Subkey="for an rcwa mapping">416<C>IsClassReflection</C>417</Index>418<Index Key="IsClassRotation" Subkey="for an rcwa mapping">419<C>IsClassRotation</C>420</Index>421<Index Key="IsClassTransposition" Subkey="for an rcwa mapping">422<C>IsClassTransposition</C>423</Index>424<Index Key="IsGeneralizedClassTransposition" Subkey="for an rcwa mapping">425<C>IsGeneralizedClassTransposition</C>426</Index>427428<C>IsClassShift</C>, <C>IsClassReflection</C>,429<C>IsClassRotation</C>, <C>IsClassTransposition</C> and430<C>IsGeneralizedClassTransposition</C> are properties which indicate431whether a given rcwa mapping belongs to the corresponding series. <P/>432433In the sequel we describe the general-purpose constructor for rcwa434mappings. The constructor may look a bit technical on a first glance,435but knowing all possible ways of entering an rcwa mapping is by no means436necessary for understanding this manual or for using this package.437438<ManSection>439<Heading> RcwaMapping (the general constructor) </Heading>440<Meth Name="RcwaMapping" Arg="R, m, coeffs"441Label="by ring, modulus and list of coefficients"/>442<Meth Name="RcwaMapping" Arg="R, coeffs"443Label="by ring and list of coefficients"/>444<Meth Name="RcwaMapping" Arg="coeffs"445Label="by list of coefficients"/>446<Meth Name="RcwaMapping" Arg="perm, range"447Label="by permutation and range"/>448<Meth Name="RcwaMapping" Arg="m, values"449Label="by modulus and list of values"/>450<Meth Name="RcwaMapping" Arg="pi, coeffs"451Label="by set of non-invertible primes and list of coefficients"/>452<Meth Name="RcwaMapping" Arg="q, m, coeffs"453Label="by finite field size, modulus and list of coefficients"/>454<Meth Name="RcwaMapping" Arg="P1, P2"455Label="by two partitions of a ring into residue classes"/>456<Meth Name="RcwaMapping" Arg="cycles"457Label="by residue class cycles"/>458<Meth Name="RcwaMapping" Arg="expression"459Label="by arithmetical expression"/>460<Returns> an rcwa mapping. </Returns>461<Description>462In all cases the argument <A>R</A> is the underlying ring,463<A>m</A> is the modulus and <A>coeffs</A> is the coefficient list.464A <E>coefficient list</E> for an rcwa mapping with modulus <M>m</M>465consists of <M>|R/mR|</M> coefficient triples466<C>[</C><M>a_{r(m)}</M>, <M>b_{r(m)}</M>, <M>c_{r(m)}</M><C>]</C>.467Their ordering is determined by the ordering of the representatives of468the residue classes (mod <M>m</M>) in the sorted list returned by469<C>AllResidues(<A>R</A>, <A>m</A>)</C>. In case <M>R = &ZZ;</M>470this means that the coefficient triple for the residue class <M>0(m)</M>471comes first and is followed by the one for <M>1(m)</M>, the one for472<M>2(m)</M> and so on. <P/>473474If one or several of the arguments <A>R</A>, <A>m</A> and475<A>coeffs</A> are omitted or replaced by other arguments, the former476are either derived from the latter or default values are chosen.477The meaning of the other arguments is defined in the detailed478description of the particular methods given in the sequel.479480The above methods return the rcwa mapping481<List>482<Mark>(a)</Mark>483<Item>484of <A>R</A> with modulus <A>m</A> and coefficients <A>coeffs</A>,485</Item>486<Mark>(b)</Mark>487<Item>488of <A>R</A> = &ZZ; or <A>R</A> = <M>&ZZ;_{(\pi)}</M> with modulus489<C>Length(<A>coeffs</A>)</C> and coefficients <A>coeffs</A>,490</Item>491<Mark>(c)</Mark>492<Item>493of <A>R</A> = &ZZ; with modulus <C>Length(<A>coeffs</A>)</C> and494coefficients <A>coeffs</A>,495</Item>496<Mark>(d)</Mark>497<Item>498of <A>R</A> = &ZZ;, permuting any set499<C><A>range</A>+k*Length(<A>range</A>)</C> like <A>perm</A>500permutes <A>range</A>,501</Item>502<Mark>(e)</Mark>503<Item>504of <A>R</A> = &ZZ; with modulus <A>m</A> and values given by a list505<A>val</A> of 2 pairs <C>[</C>preimage<C>, </C>image<C>]</C> per506residue class (mod <A>m</A>),507</Item>508<Mark>(f)</Mark>509<Item>510of <A>R</A> = <M>&ZZ;_{(\pi)}</M> with modulus511<C>Length(<A>coeffs</A>)</C> and coefficients <A>coeffs</A>512(the set of primes <M>\pi</M> which denotes the underlying ring513is passed as argument <A>pi</A>),514</Item>515<Mark>(g)</Mark>516<Item>517of <A>R</A> = GF(<A>q</A>)[<A>x</A>] with modulus <A>m</A> and518coefficients <A>coeffs</A>,519</Item>520<Mark>(h)</Mark>521<Item>522an rcwa permutation which induces a bijection between523the partitions <A>P1</A> and <A>P2</A> of <A>R</A> into residue524classes and which is affine on the elements of <A>P1</A>,525</Item>526<Mark>(i)</Mark>527<Item>528an rcwa permutation with <Q>residue class cycles</Q> given529by a list <A>cycles</A> of lists of pairwise disjoint residue classes,530each of which it permutes cyclically, or531</Item>532<Mark>(j)</Mark>533<Item>534the rcwa permutation of &ZZ; given by the535arithmetical expression <A>expression</A> -- a string consisting of536class transpositions (e.g. <C>"(0(2),1(4))"</C>) or cycles permuting537residue classes (e.g. <C>"(0(2),1(8),3(4),5(8))"</C>), class shifts538(e.g. <C>"cs(4(6))"</C>, class reflections (e.g. <C>"cr(3(4))"</C>),539arithmetical operators (<C>"*"</C>, <C>"/"</C> and <C>"&circum;"</C>)540and brackets (<C>"("</C>, <C>")"</C>),541</Item>542</List>543respectively.544The methods for the operation <C>RcwaMapping</C> perform a number of545argument checks, which can be skipped by using <C>RcwaMappingNC</C>546instead.547<Example>548<![CDATA[549gap> R := PolynomialRing(GF(2),1);; x := X(GF(2),1);; SetName(x,"x");550gap> RcwaMapping(R,x+1,[[1,0,x+One(R)],[x+One(R),0,1]]*One(R)); # (a)551<rcwa mapping of GF(2)[x] with modulus x+1>552gap> RcwaMapping(Z_pi(2),[[1/3,0,1]]); # (b)553Rcwa mapping of Z_( 2 ): n -> 1/3 n554gap> a := RcwaMapping([[2,0,3],[4,-1,3],[4,1,3]]); # (c)555<rcwa mapping of Z with modulus 3>556gap> RcwaMapping((1,2,3),[1..4]); # (d)557( 1(4), 2(4), 3(4) )558gap> T = RcwaMapping(2,[[1,2],[2,1],[3,5],[4,2]]); # (e)559true560gap> RcwaMapping([2],[[1/3,0,1]]); # (f)561Rcwa mapping of Z_( 2 ): n -> 1/3 n562gap> RcwaMapping(2,x+1,[[1,0,x+One(R)],[x+One(R),0,1]]*One(R)); # (g)563<rcwa mapping of GF(2)[x] with modulus x+1>564gap> a = RcwaMapping(List([[0,3],[1,3],[2,3]],ResidueClass),565> List([[0,2],[1,4],[3,4]],ResidueClass)); # (h)566true567gap> RcwaMapping([List([[0,2],[1,4],[3,8],[7,16]],ResidueClass)]); # (i)568( 0(2), 1(4), 3(8), 7(16) )569gap> Cycle(last,ResidueClass(0,2));570[ 0(2), 1(4), 3(8), 7(16) ]571gap> g := RcwaMapping("((0(4),1(6))*cr(0(6)))^2/cs(2(8))"); # (j)572<rcwa permutation of Z with modulus 72>573gap> g = (ClassTransposition(0,4,1,6) * ClassReflection(0,6))^2/574> ClassShift(2,8);575true576]]>577</Example>578</Description>579</ManSection>580581Rcwa mappings of &ZZ; can be <Q>translated</Q> to rcwa mappings582of some semilocalization <M>&ZZ;_{(\pi)}</M> of &ZZ;:583584<ManSection>585<Func Name="LocalizedRcwaMapping"586Arg="f, p" Label="for an rcwa mapping of Z and a prime"/>587<Func Name="SemilocalizedRcwaMapping"588Arg="f, pi" Label="for an rcwa mapping of Z and a set of primes"/>589<Returns>590the rcwa mapping of <M>&ZZ;_{(p)}</M> respectively591<M>&ZZ;_{(\pi)}</M> with the same coefficients as the rcwa mapping592<A>f</A> of &ZZ;.593</Returns>594<Description>595The argument <A>p</A> or <A>pi</A> must be a prime or a set of primes,596respectively. The argument <A>f</A> must be an rcwa mapping597of &ZZ; whose modulus is a power of <A>p</A>,598or whose modulus has only prime divisors which lie in <A>pi</A>,599respectively.600<Example>601<![CDATA[602gap> T := RcwaMapping([[1,0,2],[3,1,2]]);; # The Collatz mapping.603gap> Cycle(LocalizedRcwaMapping(T,2),131/13);604[ 131/13, 203/13, 311/13, 473/13, 716/13, 358/13, 179/13, 275/13,605419/13, 635/13, 959/13, 1445/13, 2174/13, 1087/13, 1637/13, 2462/13,6061231/13, 1853/13, 2786/13, 1393/13, 2096/13, 1048/13, 524/13, 262/13 ]607]]>608</Example>609</Description>610</ManSection>611612<Index Key="View" Subkey="for an rcwa mapping"><C>View</C></Index>613<Index Key="Display" Subkey="for an rcwa mapping"><C>Display</C></Index>614<Index Key="Print" Subkey="for an rcwa mapping"><C>Print</C></Index>615<Index Key="String" Subkey="for an rcwa mapping"><C>String</C></Index>616617<Alt Only="LaTeX">\noindent</Alt>618Rcwa mappings can be <C>View</C>ed, <C>Display</C>ed, <C>Print</C>ed and619written to a <C>String</C>. The output of the <C>View</C> method is kept620reasonably short. In most cases it does not describe an rcwa mapping621completely. In these cases the output is enclosed in brackets.622There are options <C>CycleNotation</C>, <C>AsClassMapping</C>,623<C>PrintNotation</C> and <C>AbridgedNotation</C> to take influence on624how certain rcwa mappings are shown. These options can either be not set,625set to <C>true</C> or set to <C>false</C>.626If the option <C>CycleNotation</C> is set, it is tried harder to write627down an rcwa permutation of &ZZ; of finite order as a product of disjoint628residue class cycles, if this is possible.629If the option <C>AsClassMapping</C> is set, <C>Display</C> shows630which residue classes are mapped to which by the affine partial mappings,631and marks any loops.632The option <C>PrintNotation</C> influences the output in favour of633&GAP; - readability, and the option <C>AbridgedNotation</C> can be used to634abridge longer names like <C>ClassShift</C>, <C>ClassReflection</C> etc..635By default, the output of the methods for <C>Display</C> and <C>Print</C>636describes an rcwa mapping in full. The <C>Print</C>ed representation of637an rcwa mapping is &GAP; - readable if and only if the <C>Print</C>ed638representation of the elements of the underlying ring is so. <P/>639640<Index Key="LaTeXStringRcwaMapping" Subkey="for an rcwa mapping">641<C>LaTeXStringRcwaMapping</C>642</Index>643644There is also an operation <C>LaTeXStringRcwaMapping</C>, which takes645as argument an rcwa mapping and returns a corresponding646&LaTeX; string. The output makes use of the &LaTeX; macro package647<Package>amsmath</Package>. If the option <A>Factorization</A> is set648and the argument is bijective, a factorization into class shifts,649class reflections, class transpositions and prime switches is printed650(cf. <Ref Attr="FactorizationIntoCSCRCT"651Label="for an rcwa permutation of Z"/>).652For rcwa mappings with modulus greater than 1, an indentation by653<A>Indentation</A> characters can be obtained by setting this option654value accordingly.655656<Example>657<![CDATA[658gap> Print(LaTeXStringRcwaMapping(T));659n \ \mapsto \660\begin{cases}661n/2 & \text{if} \ n \in 0(2), \\662(3n+1)/2 & \text{if} \ n \in 1(2).663\end{cases}664]]>665</Example>666667<Index Key="LaTeXAndXDVI" Subkey="for an rcwa mapping">668<C>LaTeXAndXDVI</C>669</Index>670671There is an operation <C>LaTeXAndXDVI</C> which displays an rcwa mapping672in an <Package>xdvi</Package> window.673This works as follows: The string returned by <C>LaTeXStringRcwaMapping</C>674is inserted into a &LaTeX; template file. This file is &LaTeX;'ed, and the675result is shown with <Package>xdvi</Package>.676Calling <C>Display</C> with option <A>xdvi</A> has the same effect.677The operation <C>LaTeXAndXDVI</C> is only available on UNIX systems,678and requires suitable installations of &LaTeX; and <Package>xdvi</Package>.679680</Section>681682<!-- #################################################################### -->683684<Section Label="sec:BasicArithmeticForRcwaMappings">685<Heading>Basic arithmetic for residue-class-wise affine mappings</Heading>686687<Index Key="rcwa mapping" Subkey="arithmetic operations">rcwa mapping</Index>688<Index Key="Order" Subkey="of an rcwa permutation"><C>Order</C></Index>689<Index Key="IsTame" Subkey="for an rcwa mapping"><C>IsTame</C></Index> <P/>690691Testing rcwa mappings for equality requires only comparing their692coefficient lists, hence is cheap.693Rcwa mappings can be multiplied, thus there is a method for <C>*</C>.694Rcwa permutations can also be inverted, thus there is a method for695<C>Inverse</C>. The latter method is usually accessed by raising a mapping696to a power with negative exponent. Multiplying, inverting and computing697powers of tame rcwa mappings is cheap. Computing powers of wild mappings698is usually expensive -- run time and memory requirements normally grow699approximately exponentially with the exponent. How expensive multiplying700a couple of wild mappings is, varies very much. In any case, the amount of701memory required for storing an rcwa mapping is proportional to its modulus.702Whether a given mapping is tame or wild can be determined by the operation703<C>IsTame</C>. There is a method for <C>Order</C>, which can not only704compute a finite order, but which can also detect infinite order.705706<Example>707<![CDATA[708gap> T := RcwaMapping([[1,0,2],[3,1,2]]);; # The Collatz mapping.709gap> a := RcwaMapping([[2,0,3],[4,-1,3],[4,1,3]]);; # Collatz' permutation.710gap> List([-4..4],k->Modulus(a^k));711[ 256, 64, 16, 4, 1, 3, 9, 27, 81 ]712gap> IsTame(T) or IsTame(a);713false714gap> IsTame(ClassShift(0,1)) and IsTame(ClassTransposition(0,2,1,2));715true716gap> T^2*a*T*a^-3;717<rcwa mapping of Z with modulus 768>718gap> (ClassShift(1,3)*ClassReflection(2,7))^1000000;719<rcwa permutation of Z with modulus 21>720]]>721</Example>722723<Index Key="IsInjective" Subkey="for an rcwa mapping">724<C>IsInjective</C>725</Index>726<Index Key="IsSurjective" Subkey="for an rcwa mapping">727<C>IsSurjective</C>728</Index>729<Index Key="IsBijective" Subkey="for an rcwa mapping">730<C>IsBijective</C>731</Index>732<Index Key="Image" Subkey="of an rcwa mapping">733<C>Image</C>734</Index>735736There are methods installed for <C>IsInjective</C>, <C>IsSurjective</C>,737<C>IsBijective</C> and <C>Image</C>.738739<Example>740<![CDATA[741gap> [ IsInjective(T), IsSurjective(T), IsBijective(a) ];742[ false, true, true ]743gap> Image(RcwaMapping([[2,0,1]]));7440(2)745]]>746</Example>747748<Index Key="rcwa mapping" Subkey="images under">rcwa mapping</Index>749750Images of elements, of finite sets of elements and of unions of finitely751many residue classes of the source of an rcwa mapping can be computed with752<C>&circum;</C>, the same symbol as used for exponentiation and conjugation.753The same works for partitions of the source into a finite number of754residue classes.755756<Example>757<![CDATA[758gap> 15^T;75923760gap> ResidueClass(1,2)^T;7612(3)762gap> List([[0,3],[1,3],[2,3]],ResidueClass)^a;763[ 0(2), 1(4), 3(4) ]764]]>765</Example>766767<Index Key="PreImageElm" Subkey="of a ring element under an rcwa mapping">768<C>PreImageElm</C>769</Index>770<Index Key="PreImagesElm" Subkey="of a ring element under an rcwa mapping">771<C>PreImagesElm</C>772</Index>773<Index Key="PreImage"774Subkey="of a set of ring elements under an rcwa mapping">775<C>PreImage</C>776</Index>777<Index Key="PreImage"778Subkey="of a residue class union under an rcwa mapping">779<C>PreImage</C>780</Index>781782For computing preimages of elements under rcwa mappings,783there are methods for <C>PreImageElm</C> and <C>PreImagesElm</C>.784The preimage of a finite set of ring elements or of a union of finitely785many residue classes under an rcwa mapping can be computed by786<C>PreImage</C>.787788<Example>789<![CDATA[790gap> PreImagesElm(T,8);791[ 5, 16 ]792gap> PreImage(T,ResidueClass(Integers,3,2));793Z \ 0(6) U 2(6)794gap> M := [1];; l := [1];;795gap> while Length(M) < 5000 do M := PreImage(T,M); Add(l,Length(M)); od; l;796[ 1, 1, 2, 2, 4, 5, 8, 10, 14, 18, 26, 36, 50, 67, 89, 117, 157, 208,797277, 367, 488, 649, 869, 1154, 1534, 2039, 2721, 3629, 4843, 6458 ]798]]>799</Example>800801<Index Key="Support" Subkey="of an rcwa mapping">802<C>Support</C>803</Index>804<Index Key="MovedPoints" Subkey="of an rcwa mapping">805<C>MovedPoints</C>806</Index>807<Index Key="RestrictedPerm"808Subkey="for an rcwa permutation and a residue class union">809<C>RestrictedPerm</C>810</Index>811<Index Key="DensityOfSupport"812Subkey="of an rcwa mapping">813<C>DensityOfSupport</C>814</Index>815<Index Key="DensityOfSetOfFixedPoints"816Subkey="of an rcwa mapping">817<C>DensityOfSetOfFixedPoints</C>818</Index>819820There is a method for the operation <C>Support</C> for computing the821support of an rcwa mapping. A synonym for <C>Support</C> is822<C>MovedPoints</C>. The natural density of the support of an rcwa mapping823of &ZZ; can be computed efficiently with the operation <C>DensityOfSupport</C>.824Likewise, the natural density of the set of fixed points of an rcwa mapping825of &ZZ; can be computed efficiently with the operation826<C>DensityOfSetOfFixedPoints</C>.827There is also a method for <C>RestrictedPerm</C>828for computing the restriction of an rcwa permutation to a union829of residue classes which it fixes setwise.830831<Example>832<![CDATA[833gap> List([a,a^2],Support);834[ Z \ [ -1, 0, 1 ], Z \ [ -3, -2, -1, 0, 1, 2, 3 ] ]835gap> RestrictedPerm(ClassShift(0,2)*ClassReflection(1,2),836> ResidueClass(0,2));837<rcwa mapping of Z with modulus 2>838gap> last = ClassShift(0,2);839true840]]>841</Example>842843Rcwa mappings can be added and subtracted pointwise. However, please note844that the set of rcwa mappings of a ring does not form a ring under845<C>+</C> and <C>*</C>. <P/>846847<Example>848<![CDATA[849gap> b := ClassShift(0,3) * a;;850gap> [ Image((a + b)), Image((a - b)) ];851[ 2(4), [ -2, 0 ] ]852]]>853</Example>854855<Index Key="Modulus" Subkey="of an rcwa mapping"><C>Modulus</C></Index>856<Index Key="Mod" Subkey="for an rcwa mapping"><C>Mod</C></Index>857<Index Key="Coefficients" Subkey="of an rcwa mapping">858<C>Coefficients</C>859</Index>860<Index Key="rcwa mapping" Subkey="coercion">rcwa mapping</Index>861<Index Key="rcwa group" Subkey="coercion">rcwa group</Index>862863There are operations <C>Modulus</C> (abbreviated <C>Mod</C>) and864<C>Coefficients</C> for retrieving the modulus and the coefficient list865of an rcwa mapping. The meaning of the return values is as described866in Section <Ref Label="sec:EnteringRcwaMappings"/>. <P/>867868General documentation for most operations mentioned in this section can869be found in the &GAP; reference manual. For rcwa mappings of rings other870than &ZZ;, not for all operations applicable methods are871available. <P/>872873As in general a subring relation <M>R_1<R_2</M> does <E>not</E> give874rise to a natural embedding of RCWA(<M>R_1</M>) into RCWA(<M>R_2</M>),875there is no coercion between rcwa mappings or rcwa groups over different876rings.877878</Section>879880<!-- #################################################################### -->881882<Section Label="sec:AttributesAndPropertiesOfRcwaMappings">883<Heading>884Attributes and properties of residue-class-wise affine mappings885</Heading>886887<Index Key="class-wise translating" Subkey="definition">888class-wise translating889</Index>890<Index Key="integral" Subkey="definition">integral</Index>891<Index Key="balanced" Subkey="definition">balanced</Index>892<Index Key="sign-preserving" Subkey="definition">sign-preserving</Index>893<Index Key="maximal shift" Subkey="definition">maximal shift</Index>894895<Index Key="rcwa mapping" Subkey="prime set">rcwa mapping</Index>896<Index Key="rcwa mapping" Subkey="maximal shift">rcwa mapping</Index>897<Index Key="rcwa mapping" Subkey="class-wise translating">898rcwa mapping899</Index>900<Index Key="rcwa mapping" Subkey="integral">rcwa mapping</Index>901<Index Key="rcwa mapping" Subkey="balanced">rcwa mapping</Index>902<Index Key="rcwa mapping"903Subkey="class-wise order-preserving">904rcwa mapping905</Index>906<Index Key="rcwa mapping" Subkey="sign-preserving">rcwa mapping</Index>907908<Index Key="Multiplier" Subkey="of an rcwa mapping"><C>Multiplier</C></Index>909<Index Key="Mult" Subkey="for an rcwa mapping"><C>Mult</C></Index>910<Index Key="Divisor" Subkey="of an rcwa mapping"><C>Divisor</C></Index>911<Index Key="Div" Subkey="for an rcwa mapping"><C>Div</C></Index>912<Index Key="PrimeSet" Subkey="of an rcwa mapping"><C>PrimeSet</C></Index>913<Index Key="MaximalShift" Subkey="of an rcwa mapping of Z">914<C>MaximalShift</C>915</Index>916917<Index Key="IsClassWiseTranslating" Subkey="for an rcwa mapping">918<C>IsClassWiseTranslating</C>919</Index>920<Index Key="IsIntegral" Subkey="for an rcwa mapping">921<C>IsIntegral</C>922</Index>923<Index Key="IsBalanced" Subkey="for an rcwa mapping">924<C>IsBalanced</C>925</Index>926<Index Key="IsClassWiseOrderPreserving" Subkey="for an rcwa mapping">927<C>IsClassWiseOrderPreserving</C>928</Index>929<Index Key="IsSignPreserving" Subkey="for an rcwa mapping">930<C>IsSignPreserving</C>931</Index>932933A number of basic attributes and properties of an rcwa mapping are derived934immediately from the coefficients of its affine partial mappings. This holds935for example for the multiplier and the divisor. These two values are stored936as attributes <C>Multiplier</C> and <C>Divisor</C>, or for short <C>Mult</C>937and <C>Div</C>. The <E>prime set</E> of an rcwa mapping is the set of938prime divisors of the product of its modulus and its multiplier.939It is stored as an attribute <C>PrimeSet</C>.940The <E>maximal shift</E> of an rcwa mapping of &ZZ; is the maximum of941the absolute values of its coefficients <M>b_{r(m)}</M> in the notation942introduced in Section <Ref Label="sec:basicdefinitions"/>.943It is stored as an attribute <C>MaximalShift</C>.944An rcwa mapping is called <E>class-wise translating</E> if all of its affine945partial mappings are translations, it is called <E>integral</E> if its946divisor equals 1, and it is called <E>balanced</E> if its multiplier947and its divisor have the same prime divisors. A class-wise translating948mapping has the property <C>IsClassWiseTranslating</C>, an integral mapping949has the property <C>IsIntegral</C> and a balanced mapping has the property950<C>IsBalanced</C>.951An rcwa mapping of the ring of integers or of one of its semilocalizations952is called <E>class-wise order-preserving</E> if and only if all coefficients953<M>a_{r(m)}</M> (cf. Section <Ref Label="sec:basicdefinitions"/>)954in the numerators of the affine partial mappings are positive.955The corresponding property is <C>IsClassWiseOrderPreserving</C>.956An rcwa mapping of &ZZ; is called <E>sign-preserving</E> if957it does not map nonnegative integers to negative integers or vice versa.958The corresponding property is <C>IsSignPreserving</C>. All elements of the959simple group CT(&ZZ;) generated by the set of all class transpositions are960sign-preserving.961962<Example>963<![CDATA[964gap> u := RcwaMapping([[3,0,5],[9,1,5],[3,-1,5],[9,-2,5],[9,4,5]]);;965gap> IsBijective(u);; Display(u);966967Rcwa permutation of Z with modulus 5968969/970| 3n/5 if n in 0(5)971| (9n+1)/5 if n in 1(5)972n |-> < (3n-1)/5 if n in 2(5)973| (9n-2)/5 if n in 3(5)974| (9n+4)/5 if n in 4(5)975\976977gap> Multiplier(u);9789979gap> Divisor(u);9805981gap> PrimeSet(u);982[ 3, 5 ]983gap> IsIntegral(u) or IsBalanced(u);984false985gap> IsClassWiseOrderPreserving(u) and IsSignPreserving(u);986true987]]>988</Example>989990There are a couple of further attributes and operations related to the991affine partial mappings of an rcwa mapping:992993<ManSection>994<Attr Name="LargestSourcesOfAffineMappings"995Arg="f" Label="for an rcwa mapping"/>996<Returns>997the coarsest partition of <C>Source(<A>f</A>)</C> on whose998elements the rcwa mapping <A>f</A> is affine.999</Returns>1000<Description>1001<Example>1002<![CDATA[1003gap> LargestSourcesOfAffineMappings(ClassShift(3,7));1004[ Z \ 3(7), 3(7) ]1005gap> LargestSourcesOfAffineMappings(ClassReflection(0,1));1006[ Integers ]1007gap> u := RcwaMapping([[3,0,5],[9,1,5],[3,-1,5],[9,-2,5],[9,4,5]]);;1008gap> List( [ u, u^-1 ], LargestSourcesOfAffineMappings );1009[ [ 0(5), 1(5), 2(5), 3(5), 4(5) ], [ 0(3), 1(3), 2(9), 5(9), 8(9) ] ]1010gap> kappa := ClassTransposition(2,4,3,4) * ClassTransposition(4,6,8,12)1011> * ClassTransposition(3,4,4,6);1012<rcwa permutation of Z with modulus 12>1013gap> LargestSourcesOfAffineMappings(kappa);1014[ 2(4), 1(4) U 0(12), 3(12) U 7(12), 4(12), 8(12), 11(12) ]1015]]>1016</Example>1017</Description>1018</ManSection>10191020<ManSection>1021<Attr Name="FixedPointsOfAffinePartialMappings"1022Arg="f" Label="for an rcwa mapping"/>1023<Returns>1024a list of the sets of fixed points of the affine partial mappings of1025the rcwa mapping <A>f</A> in the quotient field of its source.1026</Returns>1027<Description>1028The returned list contains entries for the restrictions1029of <A>f</A> to all residue classes modulo <C>Mod(<A>f</A>)</C>.1030A list entry can either be an empty set, the source of <A>f</A>1031or a set of cardinality 1. The ordering of the entries corresponds1032to the ordering of the residues in1033<C>AllResidues(Source(<A>f</A>),<A>m</A>)</C>.1034<Example>1035<![CDATA[1036gap> FixedPointsOfAffinePartialMappings(ClassShift(0,2));1037[ [ ], Rationals ]1038gap> List([1..3],k->FixedPointsOfAffinePartialMappings(T^k));1039[ [ [ 0 ], [ -1 ] ], [ [ 0 ], [ 1 ], [ 2 ], [ -1 ] ],1040[ [ 0 ], [ -7 ], [ 2/5 ], [ -5 ], [ 4/5 ], [ 1/5 ], [ -10 ], [ -1 ] ] ]1041]]>1042</Example>1043</Description>1044</ManSection>10451046<ManSection>1047<Oper Name="Multpk" Arg="f, p, k"1048Label="for an rcwa mapping, a prime and an exponent"/>1049<Returns>1050the union of the residue classes <M>r(m)</M> such that1051<M>p^k||a_{r(m)}</M> if <M>k \geq 0</M>, and the union of the residue1052classes <M>r(m)</M> such that <M>p^k||c_{r(m)}</M> if <M>k \leq 0</M>.1053In this context, <M>m</M> denotes the modulus of <A>f</A>, and1054<M>a_{r(m)}</M> and <M>c_{r(m)}</M> denote the coefficients1055of <A>f</A> as introduced in1056Section <Ref Label="sec:basicdefinitions"/>.1057</Returns>1058<Description>1059<Example>1060<![CDATA[1061gap> T := RcwaMapping([[1,0,2],[3,1,2]]);; # The Collatz mapping.1062gap> [ Multpk(T,2,-1), Multpk(T,3,1) ];1063[ Integers, 1(2) ]1064gap> u := RcwaMapping([[3,0,5],[9,1,5],[3,-1,5],[9,-2,5],[9,4,5]]);;1065gap> [ Multpk(u,3,0), Multpk(u,3,1), Multpk(u,3,2), Multpk(u,5,-1) ];1066[ [ ], 0(5) U 2(5), Z \ 0(5) U 2(5), Integers ]1067]]>1068</Example>1069</Description>1070</ManSection>10711072<Index Key="ClassWiseOrderPreservingOn">1073<C>ClassWiseOrderPreservingOn</C>1074</Index>1075<Index Key="ClassWiseConstantOn">1076<C>ClassWiseConstantOn</C>1077</Index>1078<Index Key="ClassWiseOrderReversingOn">1079<C>ClassWiseOrderReversingOn</C>1080</Index>10811082There are attributes <C>ClassWiseOrderPreservingOn</C>,1083<C>ClassWiseConstantOn</C> and <C>ClassWiseOrderReversingOn</C> which1084store the union of the residue classes (mod <C>Mod(<A>f</A>)</C>) on1085which an rcwa mapping <A>f</A> of &ZZ; or of a semilocalization1086thereof is class-wise order-preserving, class-wise constant or class-wise1087order-reversing, respectively.10881089<Example>1090<![CDATA[1091gap> List([ClassTransposition(1,2,0,4),ClassShift(2,3),1092> ClassReflection(2,5)],ClassWiseOrderPreservingOn);1093[ Integers, Integers, Z \ 2(5) ]1094]]>1095</Example>10961097<Index Key="ShiftsUpOn"><C>ShiftsUpOn</C></Index>1098<Index Key="ShiftsDownOn"><C>ShiftsDownOn</C></Index>10991100Also there are attributes <C>ShiftsUpOn</C> and <C>ShiftsDownOn</C>1101which store the union of the residue classes1102(mod <C>Mod(<A>f</A>)</C>) on which an rcwa mapping <A>f</A>1103of &ZZ; induces affine mappings <M>n \mapsto n + c</M> for1104<M>c > 0</M>, respectively, <M>c < 0</M>. <P/>11051106Finally, there are epimorphisms from the subgroup of RCWA(&ZZ;)1107formed by all class-wise order-preserving elements to (&ZZ;,+)1108and from RCWA(&ZZ;) itself to the cyclic group of order 2,1109respectively:11101111<ManSection>1112<Meth Name="Determinant" Arg="f" Label="of an rcwa mapping of Z"/>1113<Returns>1114the determinant of the rcwa mapping <A>f</A> of &ZZ;.1115</Returns>1116<Description>1117The <E>determinant</E> of an affine mapping <M>n \mapsto (an+b)/c</M>1118whose source is a residue class <M>r(m)</M> is defined by <M>b/|a|m</M>.1119This definition is extended additively to determinants of rcwa mappings.1120<P/>11211122Let <M>f</M> be an rcwa mapping of the integers, and let1123<M>m</M> denote its modulus. Using the notation1124<M>f|_{r(m)}: n \mapsto (a_{r(m)} \cdot n + b_{r(m)})/c_{r(m)}</M>1125for the affine partial mappings, the <E>determinant</E> det(<M>f</M>)1126of <M>f</M> is given by1127<Alt Only="LaTeX">1128<Display>1129\sum_{r(m) \in \mathbb{Z}/m\mathbb{Z}} b_{r(m)}/(|a_{r(m)}| \cdot m).1130</Display>1131</Alt>1132<Alt Only="HTML"><![CDATA[<center>1133<img src = "det.png" width = "177" height = "58"1134alt = "sum_{r(m) in Z/mZ}1135b_{r(m)}/(|a_{r(m)}| \cdot m)."/>1136</center>]]></Alt>1137<Alt Only="Text"><Verb>1138-----1139\ b_r(m)1140> --------------1141/ |a_{r(m)}| * m1142-----1143r(m) in Z/mZ .1144</Verb></Alt>1145The determinant mapping is an epimorphism from the group of all1146class-wise order-preserving rcwa permutations of &ZZ;1147to (&ZZ;,+), see <Cite Key="Kohl05"/>, Theorem 2.11.9.1148<Example>1149<![CDATA[1150gap> List([ClassTransposition(0,4,5,12),ClassShift(3,7)],Determinant);1151[ 0, 1 ]1152gap> Determinant(ClassTransposition(0,4,5,12)*ClassShift(3,7)^100);11531001154]]>1155</Example>1156</Description>1157</ManSection>11581159<ManSection>1160<Attr Name="Sign" Arg="g" Label="of an rcwa permutation of Z"/>1161<Returns>1162the sign of the rcwa permutation <A>g</A> of &ZZ;.1163</Returns>1164<Description>1165Let <M>\sigma</M> be an rcwa permutation of the integers, and let1166<M>m</M> denote its modulus. Using the notation1167<M>\sigma|_{r(m)}: n \mapsto (a_{r(m)} \cdot n + b_{r(m)})/c_{r(m)}</M>1168for the affine partial mappings, the <E>sign</E> of <M>\sigma</M>1169is defined by1170<Alt Only="LaTeX">1171<Display>1172(-1)^{\displaystyle{{\rm det}(\sigma)1173+ \sum_{r(m): \ a_{r(m)} < 0} \frac{m - 2r}{m}}}.1174</Display>1175</Alt>1176<Alt Only="HTML"><![CDATA[<center>1177<img src = "sgn.png" width = "284" height = "63"1178alt = "(-1)^(det(sigma)1179+ sum_{r(m): \ a_{r(m)} < 0} (m - 2r)/m)."/>1180</center>]]></Alt>1181<Alt Only="Text"><Verb>1182-----1183\ m - 2r1184det(sigma) + > -------1185/ m1186-----1187a_r(m) < 01188(-1) .1189</Verb></Alt>1190The sign mapping is an epimorphism from RCWA(&ZZ;) to the group1191<M>&ZZ;^\times</M> of units of &ZZ;, see <Cite Key="Kohl05"/>,1192Theorem 2.12.8. Therefore the kernel of the sign mapping is a normal1193subgroup of RCWA(&ZZ;) of index 2. The simple group CT(&ZZ;) is1194a subgroup of this kernel.1195<Example>1196<![CDATA[1197gap> List([ClassTransposition(3,4,2,6),1198> ClassShift(0,3),ClassReflection(2,5)],Sign);1199[ 1, -1, -1 ]1200]]>1201</Example>1202</Description>1203</ManSection>12041205</Section>12061207<!-- #################################################################### -->12081209<Section Label="sec:FactoringRcwaMappings">1210<Heading>Factoring residue-class-wise affine permutations</Heading>12111212Factoring group elements into the members of some <Q>nice</Q> set of1213generators is often helpful. In this section we describe an operation which1214attempts to solve this problem for the group RCWA(&ZZ;).1215Elements of finitely generated rcwa groups can be factored into generators1216<Q>as usual</Q>, see <Ref Meth="PreImagesRepresentative"1217Label="for an epi. from a free group to an rcwa group"/>.12181219<ManSection>1220<Attr Name="FactorizationIntoCSCRCT"1221Arg="g" Label="for an rcwa permutation of Z"/>1222<Meth Name="Factorization" Arg="g" Label="for an rcwa permutation of Z"/>1223<Returns>1224a factorization of the rcwa permutation <A>g</A> of &ZZ;1225into class shifts, class reflections and class transpositions, provided1226that such a factorization exists and the method finds it.1227</Returns>1228<Description>1229The method may return <C>fail</C>, stop with an error message or run1230into an infinite loop. If it returns a result, this result is always1231correct. <P/>12321233The problem of obtaining a factorization as described is algorithmically1234difficult, and this factorization routine is currently perhaps the most1235sophisticated part of the &RCWA; package. Information about the1236progress of the factorization process can be obtained by setting the1237info level of the Info class <Ref InfoClass="InfoRCWA"/> to 2. <P/>12381239By default, prime switches (<M>\rightarrow</M>1240<Ref Func="PrimeSwitch" Label="p"/>) are taken as one factor.1241If the option <A>ExpandPrimeSwitches</A> is set, they are each1242decomposed into the 6 class transpositions given in the definition. <P/>12431244By default, the factoring process begins with splitting off factors1245from the right. This can be changed by setting the option1246<A>Direction</A> to <C>"from the left"</C>. <P/>12471248By default, a reasonably coarse respected partition of the integral1249mapping occurring in the final stage of the algorithm is computed.1250This can be suppressed by setting the option <A>ShortenPartition</A>1251equal to <C>false</C>. <P/>12521253By default, at the end it is checked whether the product of the1254determined factors indeed equals <A>g</A>. This check can be1255suppressed by setting the option <A>NC</A>.1256<Example>1257<![CDATA[1258gap> Factorization(Comm(ClassShift(0,3)*ClassReflection(1,2),1259> ClassShift(0,2)));1260[ ClassReflection( 2(3) ), ClassShift( 2(6) )^-1, ( 0(6), 2(6) ),1261( 0(6), 5(6) ) ]1262]]>1263</Example>1264</Description>1265</ManSection>12661267For purposes of demonstrating the capabilities of the factorization routine,1268in Section <Ref Label="sec:FactoringTheCollatzPermutation"/>1269Collatz' permutation is factored. Lothar Collatz has investigated this1270permutation in 1932. Its cycle structure is unknown so far. <P/>12711272The permutations of the following kind play an important role in1273factoring rcwa permutations of &ZZ; into class shifts,1274class reflections and class transpositions:12751276<ManSection>1277<Meth Name="PrimeSwitch" Arg="p" Label="p"/>1278<Meth Name="PrimeSwitch" Arg="p, k" Label="p, k"/>1279<Meth Name="PrimeSwitch" Arg="p, r, m" Label="p, r, m"/>1280<Meth Name="PrimeSwitch" Arg="p, cl" Label="p, cl"/>1281<Returns>1282in the first form the <E>prime switch</E>1283<M>\sigma_p := \tau_{0(8),1(2p)} \cdot \tau_{4(8),-1(2p)} \cdot1284\tau_{0(4),1(2p)} \cdot \tau_{2(4),-1(2p)} \cdot \tau_{2(2p),1(4p)}1285\cdot \tau_{4(2p),2p+1(4p)}</M>, in the second form1286the restriction of <M>\sigma_p</M> by <M>n \mapsto kn</M>,1287and in the third and fourth form the <E>prime switch</E>1288<M>\sigma_{p,r(m)} := \tau_{r_1(m/2),r_2(m)} \cdot1289\tau_{r_2(m),r_1(pm/2)} \cdot \tau_{r(m/2),r_1(pm/2)}</M>.1290In the latter case, <A>cl</A> is the residue class1291<M>r(m)</M>, the residue <M>r_1</M> is <M>1-(r \mod 2)</M>, and1292<M>r_2</M> is defined by the equality <M>r(m) \cup r_2(m) = r(m/2)</M>.1293</Returns>1294<Description>1295For an odd prime <M>p</M>, the prime switch <M>\sigma_p</M> is1296an rcwa permutation of &ZZ; with modulus <M>4p</M>,1297multiplier <M>p</M> and divisor 2.1298The prime switch <M>\sigma_{p,r(m)}</M> has1299multiplier <M>p</M> and divisor 2, and the class where1300the multiplication by <M>p</M> occurs is just <M>r(m)</M>.1301The key mathematical property of a prime switch is that it is1302a product of class transpositions whose multiplier and divisor1303are coprime. <P/>13041305Prime switches can be distinguished from other1306rcwa mappings by their &GAP; property <C>IsPrimeSwitch</C>.1307<Index Key="IsPrimeSwitch" Subkey="for an rcwa mapping">1308<C>IsPrimeSwitch</C>1309</Index>1310<Example>1311<![CDATA[1312gap> Display(PrimeSwitch(3));13131314Wild rcwa permutation of Z with modulus 1213151316/1317| (3n+4)/2 if n in 2(4)1318| n-1 if n in 5(6) U 8(12)1319| n+1 if n in 1(6)1320n |-> < n/2 if n in 0(12)1321| n-3 if n in 4(12)1322| n if n in 3(6)1323|1324\13251326gap> Display(PrimeSwitch(3):AsClassMapping);13271328Wild rcwa permutation of Z with modulus 12132913300(12) -> 0(6) loop13311(6) -> 2(6)13322(4) -> 5(6)13333(6) -> 3(6) id13344(12) -> 1(12)13355(6) -> 4(6)13368(12) -> 7(12)13371338gap> Factorization(PrimeSwitch(3));1339[ ( 1(6), 0(8) ), ( 5(6), 4(8) ), ( 0(4), 1(6) ), ( 2(4), 5(6) ),1340( 2(6), 1(12) ), ( 4(6), 7(12) ) ]1341gap> Display(PrimeSwitch(5,3,4));13421343Wild rcwa permutation of Z with modulus 2013441345/1346| n+1 if n in 0(2)1347| 5n-5 if n in 3(4)1348n |-> < (n-1)/2 if n in 1(4) \ 1(20)1349| n-1 if n in 1(20)1350|1351\13521353gap> Multpk(PrimeSwitch(5,3,4),5,1);13543(4)1355gap> PrimeSwitch(5,3,4) = PrimeSwitch(5,ResidueClass(3,4));1356true1357gap> Factorization(PrimeSwitch(5,3,4));1358[ ( 0(2), 1(4) ), ( 1(4), 0(10) ), ( 1(2), 0(10) ) ]1359]]>1360</Example>1361</Description>1362</ManSection>13631364Obtaining a factorization of an rcwa permutation into class shifts,1365class reflections and class transpositions is particularly difficult if1366multiplier and divisor are coprime. A prototype of permutations which have1367this property has been introduced in a different context1368in <Cite Key="Keller99"/>:13691370<ManSection>1371<Func Name="mKnot" Arg="m" Label="for an odd integer"/>1372<Returns>1373the permutation <M>g_m</M> as defined in <Cite Key="Keller99"/>.1374</Returns>1375<Description>1376The argument <A>m</A> must be an odd integer greater than 1.1377<Example>1378<![CDATA[1379gap> Display(mKnot(5));13801381Wild rcwa permutation of Z with modulus 513821383/1384| 6n/5 if n in 0(5)1385| (4n+1)/5 if n in 1(5)1386n |-> < (6n-2)/5 if n in 2(5)1387| (4n+3)/5 if n in 3(5)1388| (6n-4)/5 if n in 4(5)1389\1390]]>1391</Example>1392</Description>1393</ManSection>13941395<Alt Only="LaTeX">\noindent</Alt>1396In his article, Timothy P. Keller shows that a permutation of this type1397cannot have infinitely many cycles of any given finite length.13981399</Section>14001401<!-- #################################################################### -->14021403<Section Label="sec:ExtractingRoots">1404<Heading>1405Extracting roots of residue-class-wise affine mappings1406</Heading>14071408<ManSection>1409<Meth Name="Root"1410Arg="f, k" Label="k-th root of an rcwa mapping"/>1411<Returns>1412an rcwa mapping <C>g</C> such that <C>g&circum;<A>k</A>=<A>f</A></C>,1413provided that such a mapping exists and that there is a method available1414which can determine it.1415</Returns>1416<Description>1417Currently, extracting roots is implemented for rcwa permutations1418of finite order.1419<Example>1420<![CDATA[1421gap> Root(ClassTransposition(0,2,1,2),100);1422( 0(8), 2(8), 4(8), 6(8), 1(8), 3(8), 5(8), 7(8) )1423gap> Display(last:CycleNotation:=false);14241425Tame rcwa permutation of Z with modulus 814261427/1428| n+2 if n in Z \ 6(8) U 7(8)1429n |-> < n-5 if n in 6(8)1430| n-7 if n in 7(8)1431\14321433gap> last^100 = ClassTransposition(0,2,1,2);1434true1435]]>1436</Example>1437</Description>1438</ManSection>14391440</Section>14411442<!-- #################################################################### -->14431444<Section Label="sec:NonBijectiveMappings">1445<Heading>1446Special functions for non-bijective mappings1447</Heading>14481449<ManSection>1450<Attr Name="RightInverse" Arg="f" Label="of an injective rcwa mapping"/>1451<Returns>1452a right inverse of the injective rcwa mapping <A>f</A>,1453i.e. a mapping <M>g</M> such that <A>f</A><M>g</M> = 1.1454</Returns>1455<Description>1456<Example>1457<![CDATA[1458gap> twice := 2*IdentityRcwaMappingOfZ;1459Rcwa mapping of Z: n -> 2n1460gap> twice * RightInverse(twice);1461IdentityMapping( Integers )1462]]>1463</Example>1464</Description>1465</ManSection>14661467<ManSection>1468<Oper Name="CommonRightInverse" Arg="l, r"1469Label="of two injective rcwa mappings"/>1470<Returns>1471a mapping <M>d</M> such that <A>l</A><M>d</M> = <A>r</A><M>d</M> = 1.1472</Returns>1473<Description>1474The mappings <A>l</A> and <A>r</A> must be injective, and their images1475must form a partition of their source.1476<Example>1477<![CDATA[1478gap> twice := 2*IdentityRcwaMappingOfZ; twiceplus1 := twice+1;1479Rcwa mapping of Z: n -> 2n1480Rcwa mapping of Z: n -> 2n + 11481gap> Display(CommonRightInverse(twice,twiceplus1));14821483Rcwa mapping of Z with modulus 214841485/1486| n/2 if n in 0(2)1487n |-> < (n-1)/2 if n in 1(2)1488|1489\1490]]>1491</Example>1492</Description>1493</ManSection>14941495<ManSection>1496<Attr Name="ImageDensity" Arg="f" Label="of an rcwa mapping"/>1497<Returns>1498the <E>image density</E> of the rcwa mapping <A>f</A>.1499</Returns>1500<Description>1501In the notation introduced in the definition of an rcwa mapping,1502the <E>image density</E> of an rcwa mapping <M>f</M> is defined by1503<Alt Not="LaTeX">1/m</Alt><Alt Only="LaTeX"><M>\frac{1}{m}</M></Alt>1504<M>\sum_{r(m) \in R/mR} |R/c_{r(m)}R|/|R/a_{r(m)}R|</M>.1505The image density of an injective rcwa mapping is <M>\leq 1</M>, and1506the image density of a surjective rcwa mapping is <M>\geq 1</M>1507(this can be seen easily). Thus in particular the image density of1508a bijective rcwa mapping is 1.1509<Example>1510<![CDATA[1511gap> T := RcwaMapping([[1,0,2],[3,1,2]]);; # The Collatz mapping.1512gap> List( [ T, ClassShift(0,1), RcwaMapping([[2,0,1]]) ], ImageDensity );1513[ 4/3, 1, 1/2 ]1514]]>1515</Example>1516</Description>1517</ManSection>15181519<Index Key="InjectiveAsMappingFrom" Subkey="for an rcwa mapping">1520<C>InjectiveAsMappingFrom</C>1521</Index>15221523Given an rcwa mapping <C>f</C>, the function <C>InjectiveAsMappingFrom</C>1524returns a set <C>S</C> such that the restriction of <C>f</C> to <C>S</C>1525is injective, and such that the image of <C>S</C> under <C>f</C> is the1526entire image of <C>f</C>.15271528<Example>1529<![CDATA[1530gap> InjectiveAsMappingFrom(T);15310(2)1532]]>1533</Example>15341535</Section>15361537<!-- #################################################################### -->15381539<Section Label="sec:Trajectories">1540<Heading>1541On trajectories and cycles of residue-class-wise affine mappings1542</Heading>15431544&RCWA; provides various methods to compute trajectories of rcwa mappings:15451546<ManSection>1547<Heading> Trajectory (methods for rcwa mappings) </Heading>1548<Meth Name="Trajectory" Arg="f, n, length"1549Label="for rcwa mapping, starting point, length"/>1550<Meth Name="Trajectory" Arg="f, n, length, m"1551Label="for rcwa mapping, starting point, length, modulus"/>1552<Meth Name="Trajectory" Arg="f, n, terminal"1553Label="for rcwa mapping, starting point, set of end points"/>1554<Meth Name="Trajectory" Arg="f, n, terminal, m"1555Label="for rcwa mapping, starting point, set of end points, modulus"/>1556<Returns>1557the first <A>length</A> iterates in the trajectory of the1558rcwa mapping <A>f</A> starting at <A>n</A>, respectively the1559initial part of the trajectory of the rcwa mapping <A>f</A>1560starting at <A>n</A> which ends at the first occurrence of an1561iterate in the set <A>terminal</A>. If the argument <A>m</A> is given,1562the iterates are reduced (mod <A>m</A>).1563</Returns>1564<Description>1565To save memory when computing long trajectories containing huge1566iterates, the reduction (mod <A>m</A>) is done each time before1567storing an iterate.1568In place of the ring element <A>n</A>, the methods also accept1569a finite set of ring elements or a union of residue classes.1570<Example>1571<![CDATA[1572gap> T := RcwaMapping([[1,0,2],[3,1,2]]);; # The Collatz mapping.1573gap> Trajectory(T,27,15); Trajectory(T,27,20,5);1574[ 27, 41, 62, 31, 47, 71, 107, 161, 242, 121, 182, 91, 137, 206, 103 ]1575[ 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 0, 3, 0, 0, 3 ]1576gap> Trajectory(T,15,[1]); Trajectory(T,15,[1],2);1577[ 15, 23, 35, 53, 80, 40, 20, 10, 5, 8, 4, 2, 1 ]1578[ 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1 ]1579gap> Trajectory(T,ResidueClass(Integers,3,0),Integers);1580[ 0(3), 0(3) U 5(9), 0(3) U 5(9) U 7(9) U 8(27),1581<union of 20 residue classes (mod 27) (6 classes)>,1582<union of 73 residue classes (mod 81)>, Z \ 10(81) U 37(81), Integers ]1583]]>1584</Example>1585</Description>1586</ManSection>15871588<ManSection>1589<Heading>1590Trajectory (methods for rcwa mappings -- <Q>accumulated coefficients</Q>)1591</Heading>1592<Meth Name="Trajectory" Arg="f, n, length, whichcoeffs"1593Label="for rcwa mapping, starting point, length, coeff.-spec."/>1594<Meth Name="Trajectory" Arg="f, n, terminal, whichcoeffs"1595Label="for rcwa mapping, starting point, set of end points, coeff.-spec."/>1596<Returns>1597either the list <C>c</C> of triples of coprime coefficients such that1598for any <C>k</C> it holds that1599<C><A>n</A>&circum;(<A>f</A>&circum;(k-1)) =1600(c[k][1]*<A>n</A> + c[k][2])/c[k][3]</C> or the last entry of that list,1601depending on whether <A>whichcoeffs</A> is <C>"AllCoeffs"</C> or1602<C>"LastCoeffs"</C>.1603</Returns>1604<Description>1605The meanings of the arguments <A>length</A> and <A>terminal</A> are1606the same as in the methods for the operation <C>Trajectory</C>1607described above. In general, computing only the last coefficient triple1608(<A>whichcoeffs</A> = <C>"LastCoeffs"</C>) needs considerably less1609memory than computing the entire list.1610<Example>1611<![CDATA[1612gap> Trajectory(T,27,[1],"LastCoeffs");1613[ 36472996377170786403, 195820718533800070543, 1180591620717411303424 ]1614gap> (last[1]*27+last[2])/last[3];161511616]]>1617</Example>1618</Description>1619</ManSection>16201621When dealing with problems like the <M>3n+1</M>-Conjecture or when1622determining the degree of transitivity of the natural action of an rcwa group1623on its underlying ring, an important task is to determine the residue classes1624whose elements get larger or smaller when applying a given rcwa mapping:16251626<ManSection>1627<Heading> IncreasingOn & DecreasingOn (for an rcwa mapping) </Heading>1628<Attr Name="IncreasingOn" Arg="f" Label="for an rcwa mapping"/>1629<Attr Name="DecreasingOn" Arg="f" Label="for an rcwa mapping"/>1630<Returns>1631the union of all residue classes <M>r(m)</M> such that1632<M>|R/a_{r(m)}R| > |R/c_{r(m)}R|</M> or1633<M>|R/a_{r(m)}R| < |R/c_{r(m)}R|</M>, respectively, where <M>R</M>1634denotes the source, <M>m</M> denotes the modulus and <M>a_{r(m)}</M>,1635<M>b_{r(m)}</M> and <M>c_{r(m)}</M> denote the coefficients1636of <A>f</A> as introduced in1637Section <Ref Label="sec:basicdefinitions"/>.1638</Returns>1639<Description>1640If the argument is an rcwa mapping of &ZZ; in sparse representation,1641an option <C>classes</C> is interpreted; if set, the step of forming1642the union of the residue classes in question is omitted, and the1643list of residue classes is returned instead of their union.1644This may save time and memory if the modulus is large.1645<Example>1646<![CDATA[1647gap> List([1..3],k->IncreasingOn(T^k));1648[ 1(2), 3(4), 3(4) U 1(8) U 6(8) ]1649gap> List([1..3],k->DecreasingOn(T^k));1650[ 0(2), Z \ 3(4), 0(4) U 2(8) U 5(8) ]1651gap> a := RcwaMapping([[2,0,3],[4,-1,3],[4,1,3]]);; # Collatz' permutation1652gap> List([-2..2],k->IncreasingOn(a^k));1653[ Z \ 1(8) U 7(8), 0(2), [ ], Z \ 0(3), 1(9) U 4(9) U 5(9) U 8(9) ]1654]]>1655</Example>1656</Description>1657</ManSection>16581659We assign certain directed graphs to rcwa mappings, which encode the order1660in which trajectories may traverse the residue classes modulo some modulus:16611662<ManSection>1663<Oper Name="TransitionGraph"1664Arg="f, m" Label="for an rcwa mapping and a modulus"/>1665<Returns>1666the transition graph of the rcwa mapping <A>f</A>1667for modulus <A>m</A>.1668</Returns>1669<Description>1670<Index Key="rcwa mapping" Subkey="transition graph">rcwa mapping</Index>1671<Alt Only="LaTeX">\noindent</Alt>1672The <E>transition graph</E> <M>\Gamma_{f,m}</M> of <M>f</M> for1673modulus <M>m</M> is defined as follows:1674<Enum>1675<Item>1676The vertices are the residue classes (mod <M>m</M>).1677</Item>1678<Item>1679There is an edge from <M>r_1(m)</M> to <M>r_2(m)</M> if and only if1680there is some <M>n \in r_1(m)</M> such that1681<M>n^f \in r_2(m)</M>.1682</Item>1683</Enum>1684The assignment of the residue classes (mod <M>m</M>) to the1685vertices of the graph corresponds to the ordering of the residues in1686<C>AllResidues(Source(<A>f</A>),<A>m</A>)</C>.1687The result is returned in the format used by the package1688<Package>GRAPE</Package> <Cite Key="GRAPE"/>.1689</Description>1690</ManSection>16911692There are a couple of operations and attributes which are based1693on these graphs:16941695<ManSection>1696<Oper Name="OrbitsModulo"1697Arg="f, m" Label="for an rcwa mapping and a modulus"/>1698<Returns>1699the partition of <C>AllResidues(Source(<A>f</A>),<A>m</A>)</C>1700corresponding to the weakly connected components of the transition1701graph of the rcwa mapping <A>f</A> for modulus <A>m</A>.1702</Returns>1703<Description>1704<Example>1705<![CDATA[1706gap> OrbitsModulo(ClassTransposition(0,2,1,4),8);1707[ [ 0, 1, 4 ], [ 2, 5, 6 ], [ 3 ], [ 7 ] ]1708]]>1709</Example>1710</Description>1711</ManSection>17121713<ManSection>1714<Oper Name ="FactorizationOnConnectedComponents"1715Arg = "f, m" Label="for an rcwa mapping and a modulus"/>1716<Returns>1717the set of restrictions of the rcwa mapping <A>f</A> to the1718weakly connected components of its transition graph <M>\Gamma_{f,m}</M>.1719</Returns>1720<Description>1721The product of the returned mappings is <A>f</A>.1722They have pairwise disjoint supports, hence any two of them commute.1723<Example>1724<![CDATA[1725gap> sigma := ClassTransposition(1,4,2,4) * ClassTransposition(1,4,3,4)1726> * ClassTransposition(3,9,6,18) * ClassTransposition(1,6,3,9);;1727gap> List(FactorizationOnConnectedComponents(sigma,36),Support);1728[ 33(36) U 34(36) U 35(36), 9(36) U 10(36) U 11(36),1729<union of 23 residue classes (mod 36)> \ [ -6, 3 ] ]1730]]>1731</Example>1732</Description>1733</ManSection>17341735<ManSection>1736<Oper Name="TransitionMatrix"1737Arg="f, m" Label="for an rcwa mapping and a modulus"/>1738<Returns>1739the transition matrix of the rcwa mapping <A>f</A> for1740modulus <A>m</A>.1741</Returns>1742<Description>1743Let <M>M</M> be this matrix. Then for any two residue classes <M>r_1(m),1744r_2(m) \in R/mR</M>, the entry <M>M_{r_1(m),r_2(m)}</M> is defined by1745<Alt Only="LaTeX">1746<Display>1747<![CDATA[M_{r_1(m),r_2(m)} \ := \1748\displaystyle{\frac{|R/mR|}{|R/\hat{m}R|}} \cdot1749\left|\left\{r(\hat{m}) \in R/\hat{m}R | \ r \in r_1(m)1750\wedge r^f \in r_2(m)\right\}\right|,]]>1751</Display>1752</Alt>1753<Alt Only="HTML"><![CDATA[<center>1754<img src = "transmat.png" width = "599" height = "47"1755alt = "(see the PDF version of the manual),"/>1756</center>]]></Alt>1757<Alt Only="Text">1758(see the PDF- or HTML version of the manual),1759</Alt>1760where <M>\hat{m}</M> is the product of <A>m</A> and the square of the1761modulus of <A>f</A>.1762The assignment of the residue classes (mod <A>m</A>) to the rows and1763columns of the matrix corresponds to the ordering of the residues in1764<C>AllResidues(Source(<A>f</A>),<A>m</A>)</C>. <P/>17651766The transition matrix is a weighted adjacency matrix of the corresponding1767transition graph <C>TransitionGraph(<A>f</A>,<A>m</A>)</C>.1768The sums of the rows of a transition matrix are always equal to 1.1769<Example>1770<![CDATA[1771gap> T := RcwaMapping([[1,0,2],[3,1,2]]);; # The Collatz mapping.1772gap> Display(TransitionMatrix(T^3,3));1773[ [ 1/8, 1/4, 5/8 ],1774[ 0, 1/4, 3/4 ],1775[ 0, 3/8, 5/8 ] ]1776]]>1777</Example>1778</Description>1779</ManSection>17801781<ManSection>1782<Heading> Sources & Sinks (of an rcwa mapping) </Heading>1783<Attr Name="Sources" Arg="f" Label="of an rcwa mapping"/>1784<Attr Name="Sinks" Arg="f" Label="of an rcwa mapping"/>1785<Returns>1786a list of unions of residue classes modulo the modulus <M>m</M>1787of the rcwa mapping <A>f</A>, as described below.1788</Returns>1789<Description>1790The returned list contains an entry for any strongly1791connected component of the transition graph of <A>f</A> for1792modulus <C>Mod(<A>f</A>)</C> which has only outgoing edges1793(<Q>source</Q>) or which has only ingoing edges (<Q>sink</Q>),1794respectively. The list entry corresponding to such a component1795is the union of the vertices belonging to it.1796<Example>1797<![CDATA[1798gap> g := ClassTransposition(0,2,1,2)*ClassTransposition(0,2,1,4);;1799gap> Sources(g); Sinks(g);1800[ 0(4) ]1801[ 1(4) ]1802]]>1803</Example>1804</Description>1805</ManSection>18061807<ManSection>1808<Attr Name="Loops" Arg="f" Label="of an rcwa mapping"/>1809<Returns>1810if <A>f</A> is bijective, the list of non-isolated vertices of the1811transition graph of <A>f</A> for modulus <C>Mod(<A>f</A>)</C>1812which carry a loop. In general, the list of vertices of that transition1813graph which carry a loop, but which <A>f</A> does not fix setwise.1814</Returns>1815<Description>1816The returned list may also include supersets of the named1817residue classes instead if <A>f</A> is affine even on these.1818<Example>1819<![CDATA[1820gap> Loops(ClassTransposition(0,2,1,2)*ClassTransposition(0,2,1,4));1821[ 0(4), 1(4) ]1822]]>1823</Example>1824</Description>1825</ManSection>18261827There is a nice invariant of trajectories of the Collatz mapping:18281829<ManSection>1830<Func Name="GluckTaylorInvariant" Arg="a" Label="of a trajectory"/>1831<Returns>1832the invariant defined in <Cite Key="GluckTaylor02"/>. This is1833<M>(\sum_{i=1}^l a_i \cdot a_{i \mod l + 1})/(\sum_{i=1}^l a_i^2)</M>,1834where <M>l</M> denotes the length of <A>a</A>.1835</Returns>1836<Description>1837The argument <A>a</A> must be a list of integers.1838In <Cite Key="GluckTaylor02"/> it is shown that if <A>a</A>1839is a trajectory of the `original' Collatz mapping <M>n</M>1840<M>\mapsto</M> (<M>n/2</M> if <M>n</M> even, <M>3n+1</M> if1841<M>n</M> odd) starting at an odd integer <M>\geq 3</M> and ending1842at 1, then the invariant lies in the interval <M>]9/13,5/7[</M>.1843<Example>1844<![CDATA[1845gap> C := RcwaMapping([[1,0,2],[3,1,1]]);;1846gap> List([3,5..49],n->Float(GluckTaylorInvariant(Trajectory(C,n,[1]))));1847[ 0.701053, 0.696721, 0.708528, 0.707684, 0.706635, 0.695636, 0.711769,18480.699714, 0.707409, 0.693833, 0.710432, 0.706294, 0.714242, 0.699935,18490.714242, 0.705383, 0.706591, 0.698198, 0.712222, 0.714242, 0.709048,18500.69612, 0.714241, 0.701076 ]1851]]>1852</Example>1853</Description>1854</ManSection>18551856Quite often one can make certain <Q>educated guesses</Q> on the overall1857behaviour of the trajectories of a given rcwa mapping. For example it is1858reasonably straightforward to make the conjecture that all trajectories of1859the Collatz mapping eventually enter the finite set <M>\{-136, -91, -82, -68,1860-61, -55, -41, -37, -34, -25, -17, -10, -7, -5, -1, 0, 1, 2 \}</M>, or that1861<Q>on average</Q> the next number in a trajectory of the Collatz mapping is1862smaller than the preceding one by a factor of <M>\sqrt{3}/2</M>. However it1863is clear that such guesses can be wrong, and that they therefore cannot be1864used to prove anything. Nevertheless they can sometimes be useful:18651866<ManSection>1867<Oper Name="LikelyContractionCentre"1868Arg="f, maxn, bound" Label="of an rcwa mapping"/>1869<Returns> a list of ring elements (see below). </Returns>1870<Description>1871This operation tries to compute the <E>contraction centre</E> of the1872rcwa mapping <A>f</A>. Assuming its existence this is the unique finite1873subset <M>S_0</M> of the source of <A>f</A> on which <A>f</A>1874induces a permutation and which intersects non-trivially with any1875trajectory of <A>f</A>. The mapping <A>f</A> is assumed1876to be <E>contracting</E>, i.e. to have such a contraction centre.1877As in general contraction centres are likely not computable, the methods1878for this operation are probabilistic and may return wrong results.1879The argument <A>maxn</A> is a bound on the starting1880value and <A>bound</A> is a bound on the elements of the trajectories1881to be searched.1882If the limit <A>bound</A> is exceeded, an Info message on Info1883level 3 of <C>InfoRCWA</C> is given.1884<Example>1885<![CDATA[1886gap> T := RcwaMapping([[1,0,2],[3,1,2]]);; # The Collatz mapping.1887gap> S0 := LikelyContractionCentre(T,100,1000);1888#I Warning: `LikelyContractionCentre' is highly probabilistic.1889The returned result can only be regarded as a rough guess.1890See ?LikelyContractionCentre for more information.1891[ -136, -91, -82, -68, -61, -55, -41, -37, -34, -25, -17, -10, -7, -5,1892-1, 0, 1, 2 ]1893]]>1894</Example>1895</Description>1896</ManSection>18971898<ManSection>1899<Oper Name="GuessedDivergence" Arg="f" Label="of an rcwa mapping"/>1900<Returns>1901a floating point value which is intended to be a rough guess on how fast1902the trajectories of the rcwa mapping <A>f</A> diverge (return value1903greater than 1) or converge (return value smaller than 1).1904</Returns>1905<Description>1906Nothing particular is guaranteed.1907<Example>1908<![CDATA[1909gap> GuessedDivergence(T);1910#I Warning: GuessedDivergence: no particular return value is guaranteed.19110.8660251912]]>1913</Example>1914</Description>1915</ManSection>19161917</Section>19181919<!-- #################################################################### -->19201921<Section Label="sec:SparseRepresentationOfRcwaMappings">1922<Heading>1923Saving memory -- the sparse representation of rcwa mappings1924</Heading>19251926<Index Key="rcwa mapping" Subkey="sparse representation">1927rcwa mapping1928</Index>1929<Index Key="RcwaMapping"1930Subkey="by list of coefficients, sparse representation">1931<C>RcwaMapping</C>1932</Index>19331934It is quite common that an rcwa mapping with large modulus1935has only few distinct affine partial mappings. In this case the1936<Q>standard</Q> representation which stores a coefficient triple for each1937residue class modulo the modulus is unsuitable. For this reason there is1938a second representation of rcwa mappings, the <Q>sparse</Q> representation.1939Depending on the rcwa mappings involved, using this representation may1940speed up computations and reduce memory requirements by orders of1941magnitude. For rcwa mappings with almost as many distinct affine partial1942mappings as there are residue classes modulo the modulus, using sparse1943representation makes computations slower and more memory-consuming.1944Presently, the sparse representation is only available for rcwa mappings1945of &ZZ;. <P/>19461947The sparse representation of an rcwa mapping consists of the modulus and1948a list of 5-tuples <M>(r,m,a_{r(m)},b_{r(m)},c_{r(m)})</M> of integers.1949Any such 5-tuple specifies the coefficients of the restriction1950<M>n \mapsto (a_{r(m)} \cdot n + b_{r(m)})/c_{r(m)}</M> of the mapping1951to a residue class <M>r(m)</M>. The <M>r(m)</M> are chosen to form the1952coarsest possible partition of &ZZ; into residue classes such that the1953restriction of the mapping to any of them is affine. Also the list of1954coefficient tuples is sorted, all <M>c_{r(m)}</M> are positive and1955<M>\gcd(c_{r(m)},\gcd(a_{r(m)},b_{r(m)})) = 1</M>. This way the coefficient1956list of an rcwa mapping of &ZZ; is unique. <P/>19571958Changing the representation of rcwa mappings does not change their1959behaviour with respect to <Q><C>=</C></Q> and <Q><C><</C></Q>1960The product of two rcwa mappings in sparse representation is in sparse1961representation again, just like the product of two rcwa mappings in1962standard representation is in standard representation. Also, inverses1963are in the same representation. The product of two rcwa mappings in1964different representation may be in any of the representations of the1965factors.19661967<ManSection>1968<Oper Name="SparseRepresentation" Arg="f" Label="of an rcwa mapping"/>1969<Oper Name="SparseRep" Arg="f" Label="of an rcwa mapping"/>1970<Oper Name="StandardRepresentation" Arg="f" Label="of an rcwa mapping"/>1971<Oper Name="StandardRep" Arg="f" Label="of an rcwa mapping"/>1972<Returns>1973the rcwa mapping <A>f</A> in sparse, respectively, standard1974representation.1975</Returns>1976<Description>1977Appropriate attribute values and properties are copied over1978to the rcwa mapping in the <Q>new</Q> representation.1979<Example>1980<![CDATA[1981gap> a := ClassTransposition(1,2,4,6);1982( 1(2), 4(6) )1983gap> b := ClassTransposition(1,3,2,6);1984( 1(3), 2(6) )1985gap> c := ClassTransposition(2,3,4,6);1986( 2(3), 4(6) )1987gap> g := (b*a*c)^2*a;1988<rcwa permutation of Z with modulus 288>1989gap> h := SparseRep(g);1990<rcwa permutation of Z with modulus 288 and 21 affine parts>1991gap> g = h;1992true1993gap> Coefficients(h);1994[ [ 0, 6, 1, 0, 1 ], [ 1, 3, 16, -1, 3 ], [ 2, 96, 9, 14, 16 ],1995[ 3, 24, 9, 5, 4 ], [ 5, 24, 3, 1, 4 ], [ 8, 36, 2, -7, 9 ],1996[ 9, 48, 27, 29, 8 ], [ 11, 24, 9, 5, 4 ], [ 14, 48, 27, 38, 8 ],1997[ 15, 24, 27, 19, 4 ], [ 17, 48, 9, 7, 8 ], [ 20, 72, 3, 4, 4 ],1998[ 21, 24, 1, -3, 6 ], [ 23, 24, 27, 19, 4 ], [ 26, 48, 3, 2, 8 ],1999[ 32, 36, 4, -11, 9 ], [ 33, 48, 9, 7, 8 ], [ 38, 48, 9, 10, 8 ],2000[ 41, 48, 27, 29, 8 ], [ 50, 96, 27, 58, 16 ], [ 56, 72, 1, 0, 4 ] ]2001gap> h^2;2002<rcwa permutation of Z with modulus 13824 and 71 affine parts>2003gap> h^3;2004<rcwa permutation of Z with modulus 663552 and 201 affine parts>2005]]>2006</Example>2007Memory consumption may differ a lot between sparse- and standard2008representation:2009<Log>2010gap> MemoryUsage(h^3); # on a 64-bit machine2011182542012gap> MemoryUsage(StandardRep(h^3)); # on a 64-bit machine2013424678942014</Log>2015</Description>2016</ManSection>20172018</Section>20192020<!-- #################################################################### -->20212022<Section Label="sec:CategoriesOfRcwaMappings">2023<Heading>The categories and families of rcwa mappings</Heading>20242025<ManSection>2026<Filt Name="IsRcwaMapping" Arg="f"/>2027<Filt Name="IsRcwaMappingOfZ" Arg="f"/>2028<Filt Name="IsRcwaMappingOfZ_pi" Arg="f"/>2029<Filt Name="IsRcwaMappingOfGFqx" Arg="f"/>2030<Returns>2031<C>true</C> if <A>f</A> is an rcwa mapping,2032an rcwa mapping of the ring of integers,2033an rcwa mapping of a semilocalization of the ring of integers or2034an rcwa mapping of a polynomial ring in one variable over a finite field,2035respectively, and <C>false</C> otherwise.2036</Returns>2037<Description>2038Often the same methods can be used for rcwa mappings of the ring of2039integers and of its semilocalizations. For this reason there is2040a category <C>IsRcwaMappingOfZOrZ&uscore;pi</C> which is the union of2041<C>IsRcwaMappingOfZ</C> and <C>IsRcwaMappingOfZ&uscore;pi</C>.2042<Index Key="IsRcwaMappingOfZOrZ_pi">2043<C>IsRcwaMappingOfZOrZ&uscore;pi</C>2044</Index>2045The internal representation of rcwa mappings is called2046<C>IsRcwaMappingStandardRep</C>.2047<Index Key="IsRcwaMappingStandardRep">2048<C>IsRcwaMappingStandardRep</C>2049</Index>2050There are methods available for <C>ExtRepOfObj</C> and2051<C>ObjByExtRep</C>.2052<Index Key="ExtRepOfObj"><C>ExtRepOfObj</C></Index>2053<Index Key="ObjByExtRep"><C>ObjByExtRep</C></Index>2054</Description>2055</ManSection>20562057<ManSection>2058<Func Name="RcwaMappingsFamily" Arg="R" Label="of a ring"/>2059<Returns>2060the family of rcwa mappings of the ring <A>R</A>.2061</Returns>2062</ManSection>20632064</Section>20652066<!-- #################################################################### -->20672068</Chapter>20692070<!-- #################################################################### -->207120722073