CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

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

Views: 418346
1
<?xml version="1.0" encoding="UTF-8"?>
2
3
<!--<Chapter Label="examples">
4
<Heading>
5
Examples of use of the <Package>IntPic</Package> package
6
</Heading>
7
<Index>
8
<Package>IntPic</Package> - Examples
9
</Index>-->
10
<Section>
11
<Heading>Other examples of use of the <Package>IntPic</Package> package</Heading>
12
13
<Subsection>
14
<Heading>Varia</Heading>
15
16
The following example shows how to produce <C>tikz</C> code for a picture containing the odd integers from <M>801</M> to <M>999</M>. Each line (except the highest) contains <M>15</M> cells.
17
<Example><![CDATA[
18
gap> rg := Filtered([801..889],u->(u mod 2)<>0);;
19
gap> flen := 15;;
20
gap> twins := Filtered(Primes, p -> p + 2 in Primes);;
21
gap> arr := [Primes,Union(twins,twins+2),Filtered(rg,u->(u mod 3)=0)];;
22
gap> tkz := IP_TikzArrayOfIntegers(rg,flen,rec(highlights:=arr));;
23
]]></Example>
24
The picture obtained highlights the primes, the twin primes and the multiples of <M>3</M>. As the twins are also primes, a gradient is used to highlight them. In this example the default list of colors is used.
25
<Alt Only="LaTeX">
26
\begin{center}
27
\includegraphics[width=0.95\textwidth]{../images/primesandtwinsamongodd}
28
\end{center}
29
</Alt>
30
<Alt Only="HTML">
31
&#60;br&#62;&#60;center&#62;&#60;img src=&#34;../images/primesandtwinsamongodd.jpg&#34;&#62;&#60;/center&#62;&#60;br&#62;
32
</Alt>
33
The same computations, but defining other color lists.
34
<Example><![CDATA[
35
gap> cls := IP_ColorsCompRedTones;;
36
gap> rg := Filtered([801..889],u->(u mod 2)<>0);;
37
gap> flen := 15;;
38
gap> twins := Filtered(Primes, p -> p + 2 in Primes);;
39
gap> arr := [Primes,Union(twins,twins+2),Filtered(rg,u->(u mod 3)=0)];;
40
gap> tkz := IP_TikzArrayOfIntegers(rg,flen,rec(colors := cls,highlights:=arr));;
41
]]></Example>
42
<Alt Only="LaTeX">
43
\begin{center}
44
\includegraphics[width=0.95\textwidth]{../images/primesandtwinsamongodd_comp_red}
45
\end{center}
46
</Alt>
47
<Alt Only="HTML">
48
&#60;br&#62;&#60;center&#62;&#60;img src=&#34;../images/primesandtwinsamongodd_comp_red.jpg&#34;&#62;&#60;/center&#62;&#60;br&#62;
49
</Alt>
50
<Example><![CDATA[
51
gap> cls := IP_ColorsDGrayTones;;
52
gap> rg := Filtered([801..889],u->(u mod 2)<>0);;
53
gap> flen := 15;;
54
gap> twins := Filtered(Primes, p -> p + 2 in Primes);;
55
gap> arr := [Primes,Union(twins,twins+2),Filtered(rg,u->(u mod 3)=0)];;
56
gap> tkz := IP_TikzArrayOfIntegers(rg,flen,rec(colors := cls,highlights:=arr));;
57
]]></Example>
58
<Alt Only="LaTeX">
59
\begin{center}
60
\includegraphics[width=0.95\textwidth]{../images/primesandtwinsamongodd_dark_gray}
61
\end{center}
62
</Alt>
63
<Alt Only="HTML">
64
&#60;br&#62;&#60;center&#62;&#60;img src=&#34;../images/primesandtwinsamongodd_dark_gray.jpg&#34;&#62;&#60;/center&#62;&#60;br&#62;
65
</Alt>
66
<Example><![CDATA[
67
gap> cls := ["blue","-blue","black"];;
68
gap> rg := Filtered([801..889],u->(u mod 2)<>0);;
69
gap> flen := 15;;
70
gap> twins := Filtered(Primes, p -> p + 2 in Primes);;
71
gap> arr := [Primes,Union(twins,twins+2),Filtered(rg,u->(u mod 3)=0)];;
72
gap> tkz := IP_TikzArrayOfIntegers(rg,flen,rec( colors := cls,highlights:=arr));;
73
]]></Example>
74
<Alt Only="LaTeX">
75
\begin{center}
76
\includegraphics[width=0.95\textwidth]{../images/primesandtwinsamongodd_other}
77
\end{center}
78
</Alt>
79
<Alt Only="HTML">
80
&#60;br&#62;&#60;center&#62;&#60;img src=&#34;../images/primesandtwinsamongodd_other.jpg&#34;&#62;&#60;/center&#62;&#60;br&#62;
81
</Alt>
82
The following example uses the
83
<Alt Not='Text'>
84
<URL
85
Text='NumericalSgps'>http://www.fc.up.pt/cmup/mdelgado/numericalsgps</URL>
86
</Alt>
87
<Alt Only='Text'>
88
<Package>NumericalSgps</Package>
89
</Alt>
90
package.
91
<Example><![CDATA[
92
93
gap> #LoadPackage("numericalsgps");
94
gap>
95
gap> ns := NumericalSemigroup(11,19,30,42,59);;
96
gap> cls := ShuffleIP_Colors([IP_ColorsGreenTones,IP_ColorsCompBlueTones]);;
97
gap> flen := 20;;
98
gap> #some notable elements
99
gap> arr := [SmallElementsOfNumericalSemigroup(ns),
100
> GapsOfNumericalSemigroup(ns),
101
> MinimalGeneratingSystemOfNumericalSemigroup(ns),
102
> FundamentalGapsOfNumericalSemigroup(ns),
103
> [ConductorOfNumericalSemigroup(ns)],
104
> PseudoFrobeniusOfNumericalSemigroup(ns)];;
105
gap>
106
gap> tkz := IP_TikzArrayOfIntegers(flen,rec(colors := cls,highlights:=arr));;
107
]]></Example>
108
<Alt Only="LaTeX">
109
\begin{center}
110
\includegraphics[width=0.95\textwidth]{../images/numericalsgp_notable}
111
\end{center}
112
</Alt>
113
<Alt Only="HTML">
114
&#60;br&#62;&#60;center&#62;&#60;img src=&#34;../images/numericalsgp_notable.jpg&#34;&#62;&#60;/center&#62;&#60;br&#62;
115
</Alt>
116
Using the default colors
117
<Alt Only="LaTeX">
118
\begin{center}
119
\includegraphics[width=0.95\textwidth]{../images/numericalsgp_notable_df_colors}
120
\end{center}
121
</Alt>
122
<Alt Only="HTML">
123
&#60;br&#62;&#60;center&#62;&#60;img src=&#34;../images/numericalsgp_notable_df_colors.jpg&#34;&#62;&#60;/center&#62;&#60;br&#62;
124
</Alt>
125
</Subsection>
126
<Subsection>
127
<Heading>The banner</Heading>
128
The code in the following example has been used to produce one possible banner for the homepage of the &IntPic; package. A nice picture to give an idea about the primes less than <M>10000</M>. Of course, other ranges could be chosen. I warn the user that pictures involving a large amount of data may face the problem of exceeding &TeX; capacity...
129
<Example><![CDATA[
130
gap> row_length := 200;; # the legth of each row
131
gap> columns := 50;; # the number of colums
132
gap> n := row_length*columns;
133
10000
134
gap>
135
gap> ##compute the primes less than n
136
gap> # Primes is a GAP variable representing the list of primes less than 1000
137
gap> mp := Maximum(Primes);
138
997
139
gap> newprimes := [];;
140
gap> while mp < n do
141
> mp := NextPrimeInt(mp);
142
> Add(newprimes, mp);
143
> od;
144
gap> small_primes := Union(Primes, newprimes);;
145
gap> ##compute the first element of each pair of twin primes less than n
146
gap> twins := Filtered(small_primes, p -> IsPrime(p+2));;
147
gap>
148
gap> rg := [1..n];;
149
gap>
150
gap> arr := [Intersection(small_primes,rg),[],[],
151
> Intersection(Union(twins,twins+2),rg),[],[],[],[],[],[],[],
152
> [],[],[],[],[],[],Difference(rg,small_primes)];;
153
gap>
154
gap> tkz:=IP_TikzArrayOfIntegers([1..n],row_length,rec(highlights:=arr,
155
> cell_width := "6",colsep:="0",rowsep:="0",inner_sep:="2",
156
> shape_only:=" ",line_width:="0",line_color:="black!20" ));;
157
]]></Example>
158
<Alt Only="LaTeX">
159
\begin{center}
160
\includegraphics[width=0.99\textwidth]{../images/intpic_banner.pdf}
161
\end{center}
162
</Alt>
163
<Alt Only="HTML">
164
&#60;br&#62;&#60;center&#62;&#60;img src=&#34;../images/intpic_banner.jpg&#34;&#62;&#60;/center&#62;&#60;br&#62;
165
</Alt>
166
167
</Subsection>
168
</Section>
169
<!--</Chapter>-->
170
171
172