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
<!-- This is an automatically generated file. -->
4
<Chapter Label="Chapter_Examples">
5
<Heading>Examples</Heading>
6
7
<P/>
8
<Section Label="Chapter_Examples_Section_Generators">
9
<Heading>Generators</Heading>
10
11
<P/>
12
<Example><![CDATA[
13
gap> C := NmzCone(["integral_closure",[[2,1],[1,3]]]);
14
<a Normaliz cone>
15
gap> NmzHasConeProperty(C,"HilbertBasis");
16
false
17
gap> NmzHasConeProperty(C,"SupportHyperplanes");
18
false
19
gap> NmzConeProperty(C,"HilbertBasis");
20
[ [ 1, 1 ], [ 1, 2 ], [ 1, 3 ], [ 2, 1 ] ]
21
gap> NmzHasConeProperty(C,"SupportHyperplanes");
22
true
23
gap> NmzConeProperty(C,"SupportHyperplanes");
24
[ [ -1, 2 ], [ 3, -1 ] ]
25
]]></Example>
26
27
28
29
<P/>
30
</Section>
31
32
33
<Section Label="Chapter_Examples_Section_System_of_equations">
34
<Heading>System of equations</Heading>
35
36
<Example><![CDATA[
37
gap> D := NmzCone(["equations",[[1,2,-3]], "grading",[[0,-1,3]]]);
38
<a Normaliz cone>
39
gap> NmzCompute(D,["DualMode","HilbertSeries"]);
40
true
41
gap> NmzHilbertBasis(D);
42
[ [ 1, 1, 1 ], [ 0, 3, 2 ], [ 3, 0, 1 ] ]
43
gap> NmzHilbertSeries(D);
44
[ t^2-t+1, [ [ 1, 1 ], [ 3, 1 ] ] ]
45
gap> NmzHasConeProperty(D,"SupportHyperplanes");
46
true
47
gap> NmzSupportHyperplanes(D);
48
[ [ 1, 0, 0 ], [ 1, 3, -3 ] ]
49
gap> NmzEquations(D);
50
[ [ 1, 2, -3 ] ]
51
]]></Example>
52
53
54
55
<P/>
56
</Section>
57
58
59
<Section Label="Chapter_Examples_Section_System_of_inhomogeneous_equations">
60
<Heading>System of inhomogeneous equations</Heading>
61
62
<Example><![CDATA[
63
gap> P := NmzCone(["inhom_equations",[[1,2,-3,1]], "grading", [[1,1,1]]]);
64
<a Normaliz cone>
65
gap> NmzIsInhomogeneous(C);
66
false
67
gap> NmzIsInhomogeneous(P);
68
true
69
gap> NmzHilbertBasis(P);
70
[ [ 1, 1, 1, 0 ], [ 3, 0, 1, 0 ], [ 0, 3, 2, 0 ] ]
71
gap> NmzModuleGenerators(P);
72
[ [ 0, 1, 1, 1 ], [ 2, 0, 1, 1 ] ]
73
]]></Example>
74
75
76
77
<P/>
78
</Section>
79
80
81
<Section Label="Chapter_Examples_Section_Combined_input">
82
<Heading>Combined input</Heading>
83
84
Normaliz also allows the combination of different kinds of input, e.g.
85
multiple constraint types, or additional data like a grading.
86
<P/>
87
Suppose that you have a 3 by 3 <Q>square</Q> of nonnegative integers such that
88
the 3 numbers in all rows, all columns, and both diagonals sum to the same
89
constant <M>M</M>. Sometimes such squares are called magic and <M>M</M> is the
90
magic constant. This leads to a linear system of equations. The magic constant
91
is a natural choice for the grading. Additionally we force here the 4 corner
92
to have even value by adding congruences.
93
<P/>
94
<Example><![CDATA[
95
gap> Magic3x3even := NmzCone(["equations",
96
> [ [1, 1, 1, -1, -1, -1, 0, 0, 0],
97
> [1, 1, 1, 0, 0, 0, -1, -1, -1],
98
> [0, 1, 1, -1, 0, 0, -1, 0, 0],
99
> [1, 0, 1, 0, -1, 0, 0, -1, 0],
100
> [1, 1, 0, 0, 0, -1, 0, 0, -1],
101
> [0, 1, 1, 0, -1, 0, 0, 0, -1],
102
> [1, 1, 0, 0, -1, 0, -1, 0, 0] ],
103
> "congruences",
104
> [ [1, 0, 0, 0, 0, 0, 0, 0, 0, 2],
105
> [0, 0, 1, 0, 0, 0, 0, 0, 0, 2],
106
> [0, 0, 0, 0, 0, 0, 1, 0, 0, 2],
107
> [0, 0, 0, 0, 0, 0, 0, 0, 1, 2] ],
108
> "grading",
109
> [ [1, 1, 1, 0, 0, 0, 0, 0, 0] ] ] );
110
<a Normaliz cone>
111
gap> NmzHilbertBasis(Magic3x3even);
112
[ [ 0, 4, 2, 4, 2, 0, 2, 0, 4 ], [ 2, 0, 4, 4, 2, 0, 0, 4, 2 ],
113
[ 2, 2, 2, 2, 2, 2, 2, 2, 2 ], [ 2, 4, 0, 0, 2, 4, 4, 0, 2 ],
114
[ 4, 0, 2, 0, 2, 4, 2, 4, 0 ], [ 2, 3, 4, 5, 3, 1, 2, 3, 4 ],
115
[ 2, 5, 2, 3, 3, 3, 4, 1, 4 ], [ 4, 1, 4, 3, 3, 3, 2, 5, 2 ],
116
[ 4, 3, 2, 1, 3, 5, 4, 3, 2 ] ]
117
gap> NmzHilbertSeries(Magic3x3even);
118
[ t^3+3*t^2-t+1, [ [ 1, 1 ], [ 2, 2 ] ] ]
119
gap> NmzHilbertQuasiPolynomial(Magic3x3even);
120
[ 1/2*t^2+t+1, 1/2*t^2-1/2 ]
121
]]></Example>
122
123
124
125
<P/>
126
</Section>
127
128
129
<Section Label="Chapter_Examples_Section_Using_the_dual_mode">
130
<Heading>Using the dual mode</Heading>
131
132
For solving systems of equations and inequalities it is often faster to use
133
the dual Normaliz algorithm. We demonstrate how to use it with an
134
inhomogeneous system of equations and inequalities.
135
<P/>
136
The input consists of a system of 8 inhomogeneous equations in R^3. The first
137
row of the matrix M encodes the inequality <M>8x + 8y + 8z + 7 \geq 0</M>.
138
Additionally we say that <M>x, y, z</M> should be non-negative by giving the
139
sign vector and use the total degree.
140
<Example><![CDATA[
141
gap> M := [
142
> [ 8, 8, 8, 7 ],
143
> [ 0, 4, 0, 1 ],
144
> [ 0, 1, 0, 7 ],
145
> [ 0, -2, 0, 7 ],
146
> [ 0, -2, 0, 1 ],
147
> [ 8, 48, 8, 17 ],
148
> [ 1, 6, 1, 34 ],
149
> [ 2,-12, -2, 37 ],
150
> [ 4,-24, -4, 14 ]
151
> ];
152
[ [ 8, 8, 8, 7 ], [ 0, 4, 0, 1 ], [ 0, 1, 0, 7 ], [ 0, -2, 0, 7 ],
153
[ 0, -2, 0, 1 ], [ 8, 48, 8, 17 ], [ 1, 6, 1, 34 ],
154
[ 2, -12, -2, 37 ], [ 4, -24, -4, 14 ] ]
155
gap> D := NmzCone(["inhom_inequalities", M,
156
> "signs", [[1,1,1]],
157
> "grading", [[1,1,1]]]);
158
<a Normaliz cone>
159
gap> NmzCompute(D,["DualMode","HilbertBasis","ModuleGenerators"]);
160
true
161
gap> NmzHilbertBasis(D);
162
[ [ 1, 0, 0, 0 ], [ 1, 0, 1, 0 ] ]
163
gap> NmzModuleGenerators(D);
164
[ [ 0, 0, 0, 1 ], [ 0, 0, 1, 1 ], [ 0, 0, 2, 1 ], [ 0, 0, 3, 1 ] ]
165
]]></Example>
166
167
168
169
<P/>
170
As result we get the Hilbert basis of the cone of the solutions to the
171
homogeneous system and the module generators which are the base
172
solutions to the inhomogeneous system.
173
<P/>
174
</Section>
175
176
177
</Chapter>
178
179
180