-
Notifications
You must be signed in to change notification settings - Fork 1
/
Example5.3_PM.m2
159 lines (121 loc) · 6.15 KB
/
Example5.3_PM.m2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
-- Authors: Nida Obatake, Elise Walker
-- Last Updated: Jan 2, 2022
-- This code is supplemental to the paper:
-- "Newton-Okounkov bodies of chemical reaction systems"
--
-- Example 5.3
-- Example 6.5.3 from Perez Millan's Thesis
-- This computes the birationally invariant self-intersection index for Example 6.5.3
------------------------------------------------------------------------------------------
restart
needsPackage "SubalgebraBases"
needsPackage "Polyhedra"
needsPackage "Cremona"
needsPackage "PHCpack"
needs "./Procedures.m2"
-- Chemical reaction network in Example 6.5.3, where 's' is a grading variable
------------------------------------------------------------------------------
R = QQ[x_1, x_2, s]
system = {x_1*((x_1-1)^2+(x_2-2)^2)*s, x_2*((x_1-1)^2+(x_2-2)^2)*s}
-----Computing a Newton-Okounkov Body-----
------------------------------------------
-- Choose a vector space basis such that each polynomial 'system' is in the vector space
-- Here, we select trinomials from each polynomial in 'system'
basisV = createTrinomials system --basis has 4 elements
-- In this case, 'basisV' is a SAGBI basis already, which we verify in the following:
(verifySagbi basisV)#"isSAGBI"
-- Next we compute the Newton-Okounkov body as the convex hull of the semigroup generators
semigroupGenerators = for i in basisV list flatten exponents leadTerm i
semigroupGenerators = for i in semigroupGenerators list drop(i/(last i), -1)
P = convexHull transpose matrix semigroupGenerators
-- The volume of the Newton-Okounkov body P is 1
NObodyVol = volume P
-----Computing the Degree of the Kodaira Map-----
-------------------------------------------------
-- Homogenize polynomials so grading is captured by total degree
dehomBasisV = for i in basisV list sub(i, s=>1_R);
basisVHomToSameDegree = homToSameDegree(dehomBasisV, s)
-- Create Kodaira map
S = QQ[y_1..y_(#dehomBasisV)]
phi = map(R, S, basisVHomToSameDegree)
kodairaDegree = degreeMap phi --returns 2
-----Computing the Index of the Lattice-----
--------------------------------------------
latticeIndex = computeIndexSNF(basisV) -- returns 1
-----Computing the Birationally Invariant Self-Intersection Index-----
----------------------------------------------------------------------
2! * kodairaDegree * NObodyVol / latticeIndex -- biii of 4
-----Computing the Base Locus-----
----------------------------------
complexR = CC[drop(gens R, -1)];
complexBasisV = for i in basisV list sub(sub(i, s=>1_R), complexR);
baseLocus = solveSystem(complexBasisV)
#baseLocus --3 solutions
-----Comparing to Mixed Volume-----
-----------------------------------
-- The mixed volume of a general system pulled from vector space V is:
generalSystem = makeRandomSystem(complexBasisV);
mixedVolume(generalSystem) --returns 8
-- The mixed volume of our original system is:
mixedVolume(for i in system list sub(sub(i, s=>1_R), complexR)) --returns 4
------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
-- There are several different choices for the vector space, and different choices give
-- different Newton-Okounkov bodies, as seen below.
------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
restart
needsPackage "SubalgebraBases"
needsPackage "Polyhedra"
needsPackage "Cremona"
needsPackage "PHCpack"
needs "./Procedures.m2"
-- Chemical reaction network in Example 6.5.3, where 's' is a grading variable
------------------------------------------------------------------------------
R = QQ[x_1, x_2, s]
system = {x_1*((x_1-1)^2+(x_2-2)^2)*s, x_2*((x_1-1)^2+(x_2-2)^2)*s}
-----Computing a Newton-Okounkov Body-----
------------------------------------------
-- Choose a vector space basis such that each polynomial 'system' is in the vector space
-- Here, we select binomials from each polynomial in 'system'
basisV = createBinomials system
-- In this case, 'basisV' is not a SAGBI basis already, which we verify in the following:
(verifySagbi basisV)#"isSAGBI"
-- We compute a SAGBI basis by the following:
Sag = sagbi(basisV, Limit=> 20) --computes SAGBI basis
SB = flatten entries gens Sag -- SAGBI basis has 8 elements
-- Next we compute the Newton-Okounkov body as the convex hull of the semigroup generators
semigroupGenerators = for i in SB list flatten exponents leadTerm i
semigroupGenerators = for i in semigroupGenerators list drop(i/(last i), -1)
P = convexHull transpose matrix semigroupGenerators
-- The volume of the Newton-Okounkov body P is 1
NObodyVol = volume P
-----Computing the Degree of the Kodaira Map-----
-------------------------------------------------
-- Homogenize polynomials so grading is captured by total degree
dehomBasisV = for i in basisV list sub(i, s=>1_R);
basisVHomToSameDegree = homToSameDegree(dehomBasisV, s)
-- Create Kodaira map
S = QQ[y_1..y_(#dehomBasisV)]
phi = map(R, S, basisVHomToSameDegree)
kodairaDegree = degreeMap phi --returns 1
-----Computing the Birationally Invariant Self-Intersection Index-----
----------------------------------------------------------------------
2! * kodairaDegree * NObodyVol -- biii of 6
-----Computing the Base Locus-----
----------------------------------
complexR = CC[drop(gens R, -1)];
complexBasisV = for i in basisV list sub(sub(i, s=>1_R), complexR);
baseLocus = solveSystem(complexBasisV)
#baseLocus --1 solution, (0,0)
-----Comparing to Mixed Volume-----
-----------------------------------
-- The mixed volume of a general system pulled from vector space V is:
generalSystem = makeRandomSystem(complexBasisV);
mixedVolume(generalSystem) --returns 8
-- The mixed volume of our original system is:
mixedVolume(for i in system list sub(sub(i, s=>1_R), complexR)) --returns 4