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
2
3 Examples
3
4
5
3.1 Generators
6
7
 Example 
8
gap> C := NmzCone(["integral_closure",[[2,1],[1,3]]]);
9
<a Normaliz cone>
10
gap> NmzHasConeProperty(C,"HilbertBasis");
11
false
12
gap> NmzHasConeProperty(C,"SupportHyperplanes");
13
false
14
gap> NmzConeProperty(C,"HilbertBasis");
15
[ [ 1, 1 ], [ 1, 2 ], [ 1, 3 ], [ 2, 1 ] ]
16
gap> NmzHasConeProperty(C,"SupportHyperplanes");
17
true
18
gap> NmzConeProperty(C,"SupportHyperplanes");
19
[ [ -1, 2 ], [ 3, -1 ] ]
20

21
22
23
3.2 System of equations
24
25
 Example 
26
gap> D := NmzCone(["equations",[[1,2,-3]], "grading",[[0,-1,3]]]);
27
<a Normaliz cone>
28
gap> NmzCompute(D,["DualMode","HilbertSeries"]);
29
true
30
gap> NmzHilbertBasis(D);
31
[ [ 1, 1, 1 ], [ 0, 3, 2 ], [ 3, 0, 1 ] ]
32
gap> NmzHilbertSeries(D);
33
[ t^2-t+1, [ [ 1, 1 ], [ 3, 1 ] ] ]
34
gap> NmzHasConeProperty(D,"SupportHyperplanes");
35
true
36
gap> NmzSupportHyperplanes(D);
37
[ [ 1, 0, 0 ], [ 1, 3, -3 ] ]
38
gap> NmzEquations(D);
39
[ [ 1, 2, -3 ] ]
40

41
42
43
3.3 System of inhomogeneous equations
44
45
 Example 
46
gap> P := NmzCone(["inhom_equations",[[1,2,-3,1]], "grading", [[1,1,1]]]);
47
<a Normaliz cone>
48
gap> NmzIsInhomogeneous(C);
49
false
50
gap> NmzIsInhomogeneous(P);
51
true
52
gap> NmzHilbertBasis(P);
53
[ [ 1, 1, 1, 0 ], [ 3, 0, 1, 0 ], [ 0, 3, 2, 0 ] ]
54
gap> NmzModuleGenerators(P);
55
[ [ 0, 1, 1, 1 ], [ 2, 0, 1, 1 ] ]
56

57
58
59
3.4 Combined input
60
61
Normaliz also allows the combination of different kinds of input, e.g.
62
multiple constraint types, or additional data like a grading.
63
64
Suppose that you have a 3 by 3 square of nonnegative integers such that the
65
3 numbers in all rows, all columns, and both diagonals sum to the same
66
constant M. Sometimes such squares are called magic and M is the magic
67
constant. This leads to a linear system of equations. The magic constant is
68
a natural choice for the grading. Additionally we force here the 4 corner to
69
have even value by adding congruences.
70
71
 Example 
72
gap> Magic3x3even := NmzCone(["equations",
73
> [ [1, 1, 1, -1, -1, -1, 0, 0, 0],
74
>  [1, 1, 1, 0, 0, 0, -1, -1, -1],
75
>  [0, 1, 1, -1, 0, 0, -1, 0, 0],
76
>  [1, 0, 1, 0, -1, 0, 0, -1, 0],
77
>  [1, 1, 0, 0, 0, -1, 0, 0, -1],
78
>  [0, 1, 1, 0, -1, 0, 0, 0, -1],
79
>  [1, 1, 0, 0, -1, 0, -1, 0, 0] ],
80
> "congruences",
81
> [ [1, 0, 0, 0, 0, 0, 0, 0, 0, 2],
82
>  [0, 0, 1, 0, 0, 0, 0, 0, 0, 2],
83
>  [0, 0, 0, 0, 0, 0, 1, 0, 0, 2],
84
>  [0, 0, 0, 0, 0, 0, 0, 0, 1, 2] ],
85
> "grading",
86
> [ [1, 1, 1, 0, 0, 0, 0, 0, 0] ] ] );
87
<a Normaliz cone>
88
gap> NmzHilbertBasis(Magic3x3even);
89
[ [ 0, 4, 2, 4, 2, 0, 2, 0, 4 ], [ 2, 0, 4, 4, 2, 0, 0, 4, 2 ],
90
 [ 2, 2, 2, 2, 2, 2, 2, 2, 2 ], [ 2, 4, 0, 0, 2, 4, 4, 0, 2 ],
91
 [ 4, 0, 2, 0, 2, 4, 2, 4, 0 ], [ 2, 3, 4, 5, 3, 1, 2, 3, 4 ],
92
 [ 2, 5, 2, 3, 3, 3, 4, 1, 4 ], [ 4, 1, 4, 3, 3, 3, 2, 5, 2 ],
93
 [ 4, 3, 2, 1, 3, 5, 4, 3, 2 ] ]
94
gap> NmzHilbertSeries(Magic3x3even);
95
[ t^3+3*t^2-t+1, [ [ 1, 1 ], [ 2, 2 ] ] ]
96
gap> NmzHilbertQuasiPolynomial(Magic3x3even);
97
[ 1/2*t^2+t+1, 1/2*t^2-1/2 ]
98

99
100
101
3.5 Using the dual mode
102
103
For solving systems of equations and inequalities it is often faster to use
104
the dual Normaliz algorithm. We demonstrate how to use it with an
105
inhomogeneous system of equations and inequalities.
106
107
The input consists of a system of 8 inhomogeneous equations in R^3. The
108
first row of the matrix M encodes the inequality 8x + 8y + 8z + 7 ≥ 0.
109
Additionally we say that x, y, z should be non-negative by giving the sign
110
vector and use the total degree.
111
112
 Example 
113
gap> M := [
114
>  [ 8, 8, 8, 7 ],
115
>  [ 0, 4, 0, 1 ],
116
>  [ 0, 1, 0, 7 ],
117
>  [ 0, -2, 0, 7 ],
118
>  [ 0, -2, 0, 1 ],
119
>  [ 8, 48, 8, 17 ],
120
>  [ 1, 6, 1, 34 ],
121
>  [ 2,-12, -2, 37 ],
122
>  [ 4,-24, -4, 14 ]
123
> ];
124
[ [ 8, 8, 8, 7 ], [ 0, 4, 0, 1 ], [ 0, 1, 0, 7 ], [ 0, -2, 0, 7 ],
125
 [ 0, -2, 0, 1 ], [ 8, 48, 8, 17 ], [ 1, 6, 1, 34 ],
126
 [ 2, -12, -2, 37 ], [ 4, -24, -4, 14 ] ]
127
gap> D := NmzCone(["inhom_inequalities", M,
128
>  "signs", [[1,1,1]],
129
>  "grading", [[1,1,1]]]);
130
<a Normaliz cone>
131
gap> NmzCompute(D,["DualMode","HilbertBasis","ModuleGenerators"]);
132
true
133
gap> NmzHilbertBasis(D);
134
[ [ 1, 0, 0, 0 ], [ 1, 0, 1, 0 ] ]
135
gap> NmzModuleGenerators(D);
136
[ [ 0, 0, 0, 1 ], [ 0, 0, 1, 1 ], [ 0, 0, 2, 1 ], [ 0, 0, 3, 1 ] ]
137

138
139
As result we get the Hilbert basis of the cone of the solutions to the
140
homogeneous system and the module generators which are the base solutions to
141
the inhomogeneous system.
142
143
144