passagemath-polyhedra 10.6.31rc3__cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of passagemath-polyhedra might be problematic. Click here for more details.

Files changed (206) hide show
  1. passagemath_polyhedra-10.6.31rc3.dist-info/METADATA +367 -0
  2. passagemath_polyhedra-10.6.31rc3.dist-info/METADATA.bak +369 -0
  3. passagemath_polyhedra-10.6.31rc3.dist-info/RECORD +206 -0
  4. passagemath_polyhedra-10.6.31rc3.dist-info/WHEEL +6 -0
  5. passagemath_polyhedra-10.6.31rc3.dist-info/top_level.txt +2 -0
  6. passagemath_polyhedra.libs/libgmp-6e109695.so.10.5.0 +0 -0
  7. passagemath_polyhedra.libs/libgomp-e985bcbb.so.1.0.0 +0 -0
  8. sage/all__sagemath_polyhedra.py +50 -0
  9. sage/game_theory/all.py +8 -0
  10. sage/game_theory/catalog.py +6 -0
  11. sage/game_theory/catalog_normal_form_games.py +923 -0
  12. sage/game_theory/cooperative_game.py +844 -0
  13. sage/game_theory/matching_game.py +1181 -0
  14. sage/game_theory/normal_form_game.py +2697 -0
  15. sage/game_theory/parser.py +275 -0
  16. sage/geometry/all__sagemath_polyhedra.py +22 -0
  17. sage/geometry/cone.py +6940 -0
  18. sage/geometry/cone_catalog.py +847 -0
  19. sage/geometry/cone_critical_angles.py +1027 -0
  20. sage/geometry/convex_set.py +1119 -0
  21. sage/geometry/fan.py +3743 -0
  22. sage/geometry/fan_isomorphism.py +389 -0
  23. sage/geometry/fan_morphism.py +1884 -0
  24. sage/geometry/hasse_diagram.py +202 -0
  25. sage/geometry/hyperplane_arrangement/affine_subspace.py +390 -0
  26. sage/geometry/hyperplane_arrangement/all.py +1 -0
  27. sage/geometry/hyperplane_arrangement/arrangement.py +3895 -0
  28. sage/geometry/hyperplane_arrangement/check_freeness.py +145 -0
  29. sage/geometry/hyperplane_arrangement/hyperplane.py +773 -0
  30. sage/geometry/hyperplane_arrangement/library.py +825 -0
  31. sage/geometry/hyperplane_arrangement/ordered_arrangement.py +642 -0
  32. sage/geometry/hyperplane_arrangement/plot.py +520 -0
  33. sage/geometry/integral_points.py +35 -0
  34. sage/geometry/integral_points_generic_dense.cpython-314-x86_64-linux-gnu.so +0 -0
  35. sage/geometry/integral_points_generic_dense.pyx +7 -0
  36. sage/geometry/lattice_polytope.py +5894 -0
  37. sage/geometry/linear_expression.py +773 -0
  38. sage/geometry/newton_polygon.py +767 -0
  39. sage/geometry/point_collection.cpython-314-x86_64-linux-gnu.so +0 -0
  40. sage/geometry/point_collection.pyx +1008 -0
  41. sage/geometry/polyhedral_complex.py +2616 -0
  42. sage/geometry/polyhedron/all.py +8 -0
  43. sage/geometry/polyhedron/backend_cdd.py +460 -0
  44. sage/geometry/polyhedron/backend_cdd_rdf.py +231 -0
  45. sage/geometry/polyhedron/backend_field.py +347 -0
  46. sage/geometry/polyhedron/backend_normaliz.py +2503 -0
  47. sage/geometry/polyhedron/backend_number_field.py +168 -0
  48. sage/geometry/polyhedron/backend_polymake.py +765 -0
  49. sage/geometry/polyhedron/backend_ppl.py +582 -0
  50. sage/geometry/polyhedron/base.py +1206 -0
  51. sage/geometry/polyhedron/base0.py +1444 -0
  52. sage/geometry/polyhedron/base1.py +886 -0
  53. sage/geometry/polyhedron/base2.py +812 -0
  54. sage/geometry/polyhedron/base3.py +1845 -0
  55. sage/geometry/polyhedron/base4.py +1262 -0
  56. sage/geometry/polyhedron/base5.py +2700 -0
  57. sage/geometry/polyhedron/base6.py +1741 -0
  58. sage/geometry/polyhedron/base7.py +997 -0
  59. sage/geometry/polyhedron/base_QQ.py +1258 -0
  60. sage/geometry/polyhedron/base_RDF.py +98 -0
  61. sage/geometry/polyhedron/base_ZZ.py +934 -0
  62. sage/geometry/polyhedron/base_mutable.py +215 -0
  63. sage/geometry/polyhedron/base_number_field.py +122 -0
  64. sage/geometry/polyhedron/cdd_file_format.py +155 -0
  65. sage/geometry/polyhedron/combinatorial_polyhedron/all.py +1 -0
  66. sage/geometry/polyhedron/combinatorial_polyhedron/base.cpython-314-x86_64-linux-gnu.so +0 -0
  67. sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd +76 -0
  68. sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx +3859 -0
  69. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.cpython-314-x86_64-linux-gnu.so +0 -0
  70. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd +39 -0
  71. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx +1038 -0
  72. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.cpython-314-x86_64-linux-gnu.so +0 -0
  73. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pxd +9 -0
  74. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pyx +501 -0
  75. sage/geometry/polyhedron/combinatorial_polyhedron/face_data_structure.pxd +207 -0
  76. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.cpython-314-x86_64-linux-gnu.so +0 -0
  77. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd +102 -0
  78. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx +2274 -0
  79. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.cpython-314-x86_64-linux-gnu.so +0 -0
  80. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd +370 -0
  81. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pyx +84 -0
  82. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.cpython-314-x86_64-linux-gnu.so +0 -0
  83. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pxd +31 -0
  84. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx +587 -0
  85. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.cpython-314-x86_64-linux-gnu.so +0 -0
  86. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd +52 -0
  87. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx +560 -0
  88. sage/geometry/polyhedron/constructor.py +773 -0
  89. sage/geometry/polyhedron/double_description.py +753 -0
  90. sage/geometry/polyhedron/double_description_inhomogeneous.py +564 -0
  91. sage/geometry/polyhedron/face.py +1060 -0
  92. sage/geometry/polyhedron/generating_function.py +1810 -0
  93. sage/geometry/polyhedron/lattice_euclidean_group_element.py +178 -0
  94. sage/geometry/polyhedron/library.py +3502 -0
  95. sage/geometry/polyhedron/misc.py +121 -0
  96. sage/geometry/polyhedron/modules/all.py +1 -0
  97. sage/geometry/polyhedron/modules/formal_polyhedra_module.py +155 -0
  98. sage/geometry/polyhedron/palp_database.py +447 -0
  99. sage/geometry/polyhedron/parent.py +1279 -0
  100. sage/geometry/polyhedron/plot.py +1986 -0
  101. sage/geometry/polyhedron/ppl_lattice_polygon.py +556 -0
  102. sage/geometry/polyhedron/ppl_lattice_polytope.py +1257 -0
  103. sage/geometry/polyhedron/representation.py +1723 -0
  104. sage/geometry/pseudolines.py +515 -0
  105. sage/geometry/relative_interior.py +445 -0
  106. sage/geometry/toric_plotter.py +1103 -0
  107. sage/geometry/triangulation/all.py +2 -0
  108. sage/geometry/triangulation/base.cpython-314-x86_64-linux-gnu.so +0 -0
  109. sage/geometry/triangulation/base.pyx +963 -0
  110. sage/geometry/triangulation/data.h +147 -0
  111. sage/geometry/triangulation/data.pxd +4 -0
  112. sage/geometry/triangulation/element.py +914 -0
  113. sage/geometry/triangulation/functions.h +10 -0
  114. sage/geometry/triangulation/functions.pxd +4 -0
  115. sage/geometry/triangulation/point_configuration.py +2256 -0
  116. sage/geometry/triangulation/triangulations.h +49 -0
  117. sage/geometry/triangulation/triangulations.pxd +7 -0
  118. sage/geometry/voronoi_diagram.py +319 -0
  119. sage/interfaces/all__sagemath_polyhedra.py +1 -0
  120. sage/interfaces/polymake.py +2028 -0
  121. sage/numerical/all.py +13 -0
  122. sage/numerical/all__sagemath_polyhedra.py +11 -0
  123. sage/numerical/backends/all.py +1 -0
  124. sage/numerical/backends/all__sagemath_polyhedra.py +1 -0
  125. sage/numerical/backends/cvxopt_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  126. sage/numerical/backends/cvxopt_backend.pyx +1006 -0
  127. sage/numerical/backends/cvxopt_backend_test.py +19 -0
  128. sage/numerical/backends/cvxopt_sdp_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  129. sage/numerical/backends/cvxopt_sdp_backend.pyx +382 -0
  130. sage/numerical/backends/cvxpy_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  131. sage/numerical/backends/cvxpy_backend.pxd +41 -0
  132. sage/numerical/backends/cvxpy_backend.pyx +934 -0
  133. sage/numerical/backends/cvxpy_backend_test.py +13 -0
  134. sage/numerical/backends/generic_backend_test.py +24 -0
  135. sage/numerical/backends/interactivelp_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  136. sage/numerical/backends/interactivelp_backend.pxd +36 -0
  137. sage/numerical/backends/interactivelp_backend.pyx +1231 -0
  138. sage/numerical/backends/interactivelp_backend_test.py +12 -0
  139. sage/numerical/backends/logging_backend.py +391 -0
  140. sage/numerical/backends/matrix_sdp_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  141. sage/numerical/backends/matrix_sdp_backend.pxd +15 -0
  142. sage/numerical/backends/matrix_sdp_backend.pyx +478 -0
  143. sage/numerical/backends/ppl_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  144. sage/numerical/backends/ppl_backend.pyx +1126 -0
  145. sage/numerical/backends/ppl_backend_test.py +13 -0
  146. sage/numerical/backends/scip_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  147. sage/numerical/backends/scip_backend.pxd +22 -0
  148. sage/numerical/backends/scip_backend.pyx +1289 -0
  149. sage/numerical/backends/scip_backend_test.py +13 -0
  150. sage/numerical/interactive_simplex_method.py +5338 -0
  151. sage/numerical/knapsack.py +665 -0
  152. sage/numerical/linear_functions.cpython-314-x86_64-linux-gnu.so +0 -0
  153. sage/numerical/linear_functions.pxd +31 -0
  154. sage/numerical/linear_functions.pyx +1648 -0
  155. sage/numerical/linear_tensor.py +470 -0
  156. sage/numerical/linear_tensor_constraints.py +448 -0
  157. sage/numerical/linear_tensor_element.cpython-314-x86_64-linux-gnu.so +0 -0
  158. sage/numerical/linear_tensor_element.pxd +6 -0
  159. sage/numerical/linear_tensor_element.pyx +459 -0
  160. sage/numerical/mip.cpython-314-x86_64-linux-gnu.so +0 -0
  161. sage/numerical/mip.pxd +40 -0
  162. sage/numerical/mip.pyx +3667 -0
  163. sage/numerical/sdp.cpython-314-x86_64-linux-gnu.so +0 -0
  164. sage/numerical/sdp.pxd +39 -0
  165. sage/numerical/sdp.pyx +1433 -0
  166. sage/rings/all__sagemath_polyhedra.py +3 -0
  167. sage/rings/polynomial/all__sagemath_polyhedra.py +10 -0
  168. sage/rings/polynomial/omega.py +982 -0
  169. sage/schemes/all__sagemath_polyhedra.py +2 -0
  170. sage/schemes/toric/all.py +10 -0
  171. sage/schemes/toric/chow_group.py +1248 -0
  172. sage/schemes/toric/divisor.py +2082 -0
  173. sage/schemes/toric/divisor_class.cpython-314-x86_64-linux-gnu.so +0 -0
  174. sage/schemes/toric/divisor_class.pyx +322 -0
  175. sage/schemes/toric/fano_variety.py +1606 -0
  176. sage/schemes/toric/homset.py +650 -0
  177. sage/schemes/toric/ideal.py +451 -0
  178. sage/schemes/toric/library.py +1322 -0
  179. sage/schemes/toric/morphism.py +1958 -0
  180. sage/schemes/toric/points.py +1032 -0
  181. sage/schemes/toric/sheaf/all.py +1 -0
  182. sage/schemes/toric/sheaf/constructor.py +302 -0
  183. sage/schemes/toric/sheaf/klyachko.py +921 -0
  184. sage/schemes/toric/toric_subscheme.py +905 -0
  185. sage/schemes/toric/variety.py +3460 -0
  186. sage/schemes/toric/weierstrass.py +1078 -0
  187. sage/schemes/toric/weierstrass_covering.py +457 -0
  188. sage/schemes/toric/weierstrass_higher.py +288 -0
  189. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.info +10 -0
  190. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v03 +0 -0
  191. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v04 +0 -0
  192. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v05 +1 -0
  193. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v06 +1 -0
  194. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.info +22 -0
  195. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v04 +0 -0
  196. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v05 +0 -0
  197. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v06 +0 -0
  198. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v07 +0 -0
  199. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v08 +0 -0
  200. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v09 +0 -0
  201. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v10 +0 -0
  202. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v11 +1 -0
  203. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v12 +1 -0
  204. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v13 +1 -0
  205. sage_wheels/share/reflexive_polytopes/reflexive_polytopes_2d +80 -0
  206. sage_wheels/share/reflexive_polytopes/reflexive_polytopes_3d +37977 -0
@@ -0,0 +1,457 @@
1
+ # sage_setup: distribution = sagemath-polyhedra
2
+ # sage.doctest: needs sage.geometry.polyhedron sage.graphs
3
+ r"""
4
+ Map to the Weierstrass form of a toric elliptic curve
5
+
6
+ There are 16 reflexive polygons in 2-d. Each defines a toric Fano
7
+ variety, which (since it is 2-d) has a unique crepant resolution to a smooth
8
+ toric surface. An anticanonical hypersurface defines a genus one curve
9
+ `C` in this ambient space, with Jacobian elliptic curve `J(C)` which
10
+ can be defined by the Weierstrass model `y^2 = x^3 + f x + g`. The
11
+ coefficients `f` and `g` can be computed with the
12
+ :mod:`~sage.schemes.toric.weierstrass` module. The purpose of this
13
+ model is to give an explicit rational map `C \to J(C)`. This is an
14
+ `n^2`-cover, where `n` is the minimal multi-section of `C`.
15
+
16
+ Since it is technically often easier to deal with polynomials than
17
+ with fractions, we return the rational map in terms of homogeneous
18
+ coordinates. That is, the ambient space for the Weierstrass model is
19
+ the weighted projective space `\mathbb{P}^2[2,3,1]` with homogeneous
20
+ coordinates `[X:Y:Z] = [\lambda^2 X, \lambda^3 Y, \lambda Z]`. The
21
+ homogenized Weierstrass equation is
22
+
23
+ .. MATH::
24
+
25
+ Y^2 = X^3 + f X Z^4 + g Z^6
26
+
27
+ EXAMPLES::
28
+
29
+ sage: R.<x,y> = QQ[]
30
+ sage: cubic = x^3 + y^3 + 1
31
+ sage: f, g = WeierstrassForm(cubic); (f,g)
32
+ (0, -27/4)
33
+
34
+ That is, this hypersurface `C \in \mathbb{P}^2` has a Weierstrass
35
+ equation `Y^2 = X^3 + 0 \cdot X Z^4 - \frac{27}{4} Z^6` where
36
+ `[X:Y:Z]` are projective coordinates on `\mathbb{P}^2[2,3,1]`. The
37
+ form of the map `C\to J(C)` is::
38
+
39
+ sage: X,Y,Z = WeierstrassForm(cubic, transformation=True); (X,Y,Z)
40
+ (-x^3*y^3 - x^3 - y^3,
41
+ 1/2*x^6*y^3 - 1/2*x^3*y^6 - 1/2*x^6 + 1/2*y^6 + 1/2*x^3 - 1/2*y^3,
42
+ x*y)
43
+
44
+ Note that plugging in `[X:Y:Z]` to the Weierstrass equation is a
45
+ complicated polynomial, but contains the hypersurface equation as a
46
+ factor::
47
+
48
+ sage: -Y^2 + X^3 + f*X*Z^4 + g*Z^6
49
+ -1/4*x^12*y^6 - 1/2*x^9*y^9 - 1/4*x^6*y^12 + 1/2*x^12*y^3
50
+ - 7/2*x^9*y^6 - 7/2*x^6*y^9 + 1/2*x^3*y^12 - 1/4*x^12 - 7/2*x^9*y^3
51
+ - 45/4*x^6*y^6 - 7/2*x^3*y^9 - 1/4*y^12 - 1/2*x^9 - 7/2*x^6*y^3
52
+ - 7/2*x^3*y^6 - 1/2*y^9 - 1/4*x^6 + 1/2*x^3*y^3 - 1/4*y^6
53
+ sage: cubic.divides(-Y^2 + X^3 + f*X*Z^4 + g*Z^6)
54
+ True
55
+
56
+ If you prefer you can also use homogeneous coordinates for `C \in
57
+ \mathbb{P}^2` ::
58
+
59
+ sage: R.<x,y,z> = QQ[]
60
+ sage: cubic = x^3 + y^3 + z^3
61
+ sage: f, g = WeierstrassForm(cubic); (f,g)
62
+ (0, -27/4)
63
+ sage: X,Y,Z = WeierstrassForm(cubic, transformation=True)
64
+ sage: cubic.divides(-Y^2 + X^3 + f*X*Z^4 + g*Z^6)
65
+ True
66
+
67
+ The 16 toric surfaces corresponding to the 16 reflexive polygons can
68
+ all be blown down to `\mathbb{P}^2`, `\mathbb{P}^1\times\mathbb{P}^1`,
69
+ or `\mathbb{P}^{2}[1,1,2]`. Their (and hence in all 16 cases)
70
+ anticanonical hypersurface can equally be brought into Weierstrass
71
+ form. For example, here is an anticanonical hypersurface in
72
+ `\mathbb{P}^{2}[1,1,2]` ::
73
+
74
+ sage: P2_112 = toric_varieties.P2_112()
75
+ sage: C = P2_112.anticanonical_hypersurface(coefficients=[1]*4); C
76
+ Closed subscheme of 2-d CPR-Fano toric variety
77
+ covered by 3 affine patches defined by:
78
+ z0^4 + z2^4 + z0*z1*z2 + z1^2
79
+ sage: eq = C.defining_polynomials()[0]
80
+ sage: f, g = WeierstrassForm(eq)
81
+ sage: X,Y,Z = WeierstrassForm(eq, transformation=True)
82
+ sage: (-Y^2 + X^3 + f*X*Z^4 + g*Z^6).reduce(C.defining_ideal())
83
+ 0
84
+
85
+ Finally, you sometimes have to manually specify the variables to
86
+ use. This is either because the equation is degenerate or because it
87
+ contains additional variables that you want to treat as coefficients::
88
+
89
+ sage: R.<a, x,y,z> = QQ[]
90
+ sage: cubic = x^3 + y^3 + z^3 + a*x*y*z
91
+ sage: f, g = WeierstrassForm(cubic, variables=[x,y,z])
92
+ sage: X,Y,Z = WeierstrassForm(cubic, variables=[x,y,z], transformation=True)
93
+ sage: cubic.divides(-Y^2 + X^3 + f*X*Z^4 + g*Z^6)
94
+ True
95
+
96
+ REFERENCES:
97
+
98
+ - [AKMMMP2002]_
99
+ """
100
+
101
+ ########################################################################
102
+ # Copyright (C) 2012 Volker Braun <vbraun.name@gmail.com>
103
+ #
104
+ # Distributed under the terms of the GNU General Public License (GPL)
105
+ #
106
+ # https://www.gnu.org/licenses/
107
+ ########################################################################
108
+
109
+ from sage.rings.integer_ring import ZZ
110
+ from sage.modules.free_module_element import vector
111
+ from sage.rings.invariants.invariant_theory import invariant_theory
112
+ from sage.schemes.toric.weierstrass import (
113
+ _partial_discriminant,
114
+ _check_polynomial_P2,
115
+ _check_polynomial_P1xP1,
116
+ _check_polynomial_P2_112,
117
+ )
118
+
119
+
120
+ ######################################################################
121
+
122
+ def WeierstrassMap(polynomial, variables=None):
123
+ r"""
124
+ Return the Weierstrass form of an anticanonical hypersurface.
125
+
126
+ You should use
127
+ :meth:`sage.schemes.toric.weierstrass.WeierstrassForm` with
128
+ ``transformation=True`` to get the transformation. This function
129
+ is only for internal use.
130
+
131
+ INPUT:
132
+
133
+ - ``polynomial`` -- a polynomial. The toric hypersurface
134
+ equation. Can be either a cubic, a biquadric, or the
135
+ hypersurface in `\mathbb{P}^2[1,1,2]`. The equation need not be
136
+ in any standard form, only its Newton polyhedron is used.
137
+
138
+ - ``variables`` -- list of variables of the parent polynomial
139
+ ring or ``None`` (default). In the latter case, all variables
140
+ are taken to be polynomial ring variables. If a subset of
141
+ polynomial ring variables are given, the Weierstrass form is
142
+ determined over the function field generated by the remaining
143
+ variables.
144
+
145
+ OUTPUT:
146
+
147
+ A triple `(X,Y,Z)` of polynomials defining a rational map of the
148
+ toric hypersurface to its Weierstrass form in
149
+ `\mathbb{P}^2[2,3,1]`. That is, the triple satisfies
150
+
151
+ .. MATH::
152
+
153
+ Y^2 = X^3 + f X Z^4 + g Z^6
154
+
155
+ when restricted to the toric hypersurface.
156
+
157
+ EXAMPLES::
158
+
159
+ sage: R.<x,y,z> = QQ[]
160
+ sage: cubic = x^3 + y^3 + z^3
161
+ sage: X,Y,Z = WeierstrassForm(cubic, transformation=True); (X,Y,Z)
162
+ (-x^3*y^3 - x^3*z^3 - y^3*z^3,
163
+ 1/2*x^6*y^3 - 1/2*x^3*y^6 - 1/2*x^6*z^3 + 1/2*y^6*z^3
164
+ + 1/2*x^3*z^6 - 1/2*y^3*z^6,
165
+ x*y*z)
166
+ sage: f, g = WeierstrassForm(cubic); (f,g)
167
+ (0, -27/4)
168
+ sage: cubic.divides(-Y^2 + X^3 + f*X*Z^4 + g*Z^6)
169
+ True
170
+
171
+ Only the affine span of the Newton polytope of the polynomial
172
+ matters. For example::
173
+
174
+ sage: WeierstrassForm(cubic.subs(z=1), transformation=True)
175
+ (-x^3*y^3 - x^3 - y^3,
176
+ 1/2*x^6*y^3 - 1/2*x^3*y^6 - 1/2*x^6
177
+ + 1/2*y^6 + 1/2*x^3 - 1/2*y^3,
178
+ x*y)
179
+ sage: WeierstrassForm(x * cubic, transformation=True)
180
+ (-x^3*y^3 - x^3*z^3 - y^3*z^3,
181
+ 1/2*x^6*y^3 - 1/2*x^3*y^6 - 1/2*x^6*z^3 + 1/2*y^6*z^3
182
+ + 1/2*x^3*z^6 - 1/2*y^3*z^6,
183
+ x*y*z)
184
+
185
+ This allows you to work with either homogeneous or inhomogeneous
186
+ variables. For example, here is the del Pezzo surface of degree 8::
187
+
188
+ sage: dP8 = toric_varieties.dP8()
189
+ sage: dP8.inject_variables()
190
+ Defining t, x, y, z
191
+ sage: WeierstrassForm(x*y^2 + y^2*z + t^2*x^3 + t^2*z^3, transformation=True)
192
+ (-1/27*t^4*x^6 - 2/27*t^4*x^5*z - 5/27*t^4*x^4*z^2
193
+ - 8/27*t^4*x^3*z^3 - 5/27*t^4*x^2*z^4 - 2/27*t^4*x*z^5
194
+ - 1/27*t^4*z^6 - 4/81*t^2*x^4*y^2 - 4/81*t^2*x^3*y^2*z
195
+ - 4/81*t^2*x*y^2*z^3 - 4/81*t^2*y^2*z^4 - 2/81*x^2*y^4
196
+ - 4/81*x*y^4*z - 2/81*y^4*z^2,
197
+ 0,
198
+ 1/3*t^2*x^2*z + 1/3*t^2*x*z^2 - 1/9*x*y^2 - 1/9*y^2*z)
199
+ sage: WeierstrassForm(x*y^2 + y^2 + x^3 + 1, transformation=True)
200
+ (-1/27*x^6 - 4/81*x^4*y^2 - 2/81*x^2*y^4 - 2/27*x^5
201
+ - 4/81*x^3*y^2 - 4/81*x*y^4 - 5/27*x^4 - 2/81*y^4 - 8/27*x^3
202
+ - 4/81*x*y^2 - 5/27*x^2 - 4/81*y^2 - 2/27*x - 1/27,
203
+ 0,
204
+ -1/9*x*y^2 + 1/3*x^2 - 1/9*y^2 + 1/3*x)
205
+
206
+ By specifying only certain variables we can compute the
207
+ Weierstrass form over the function field generated by the
208
+ remaining variables. For example, here is a cubic over `\QQ[a]` ::
209
+
210
+ sage: R.<a, x,y,z> = QQ[]
211
+ sage: cubic = x^3 + a*y^3 + a^2*z^3
212
+ sage: WeierstrassForm(cubic, variables=[x,y,z], transformation=True)
213
+ (-a^9*y^3*z^3 - a^8*x^3*z^3 - a^7*x^3*y^3,
214
+ -1/2*a^14*y^3*z^6 + 1/2*a^13*y^6*z^3 + 1/2*a^13*x^3*z^6
215
+ - 1/2*a^11*x^3*y^6 - 1/2*a^11*x^6*z^3 + 1/2*a^10*x^6*y^3,
216
+ a^3*x*y*z)
217
+
218
+ TESTS::
219
+
220
+ sage: for P in ReflexivePolytopes(2): # needs polytopes_db
221
+ ....: S = ToricVariety(FaceFan(P))
222
+ ....: p = sum( (-S.K()).sections_monomials() )
223
+ ....: f, g = WeierstrassForm(p)
224
+ ....: X,Y,Z = WeierstrassForm(p, transformation=True)
225
+ ....: assert p.divides(-Y^2 + X^3 + f*X*Z^4 + g*Z^6)
226
+ """
227
+ if variables is None:
228
+ variables = polynomial.variables()
229
+ # switch to suitable inhomogeneous coordinates
230
+ from sage.geometry.polyhedron.ppl_lattice_polygon import (
231
+ polar_P2_polytope, polar_P1xP1_polytope, polar_P2_112_polytope)
232
+ from sage.schemes.toric.weierstrass import Newton_polygon_embedded
233
+ newton_polytope, polynomial_aff, variables_aff = \
234
+ Newton_polygon_embedded(polynomial, variables)
235
+ polygon = newton_polytope.embed_in_reflexive_polytope('polytope')
236
+ # Compute the map in inhomogeneous coordinates
237
+ if polygon is polar_P2_polytope():
238
+ X, Y, Z = WeierstrassMap_P2(polynomial_aff, variables_aff)
239
+ elif polygon is polar_P1xP1_polytope():
240
+ X, Y, Z = WeierstrassMap_P1xP1(polynomial_aff, variables_aff)
241
+ elif polygon is polar_P2_112_polytope():
242
+ X, Y, Z = WeierstrassMap_P2_112(polynomial_aff, variables_aff)
243
+ else:
244
+ assert False, 'Newton polytope is not contained in a reflexive polygon'
245
+ # homogenize again
246
+ R = polynomial.parent()
247
+ x = R.gens().index(variables_aff[0])
248
+ y = R.gens().index(variables_aff[1])
249
+ hom = newton_polytope.embed_in_reflexive_polytope('hom')
250
+
251
+ def homogenize(inhomog, degree):
252
+ e = tuple(hom._A * vector(ZZ, [inhomog[x], inhomog[y]]) + degree * hom._b)
253
+ result = list(inhomog)
254
+ for i, var in enumerate(variables):
255
+ result[R.gens().index(var)] = e[i]
256
+ result = vector(ZZ, result)
257
+ result.set_immutable()
258
+ return result
259
+ X_dict = {homogenize(e, 2): v for e, v in X.monomial_coefficients().items()}
260
+ Y_dict = {homogenize(e, 3): v for e, v in Y.monomial_coefficients().items()}
261
+ Z_dict = {homogenize(e, 1): v for e, v in Z.monomial_coefficients().items()}
262
+ # shift to nonnegative exponents if necessary
263
+ min_deg = [0] * R.ngens()
264
+ for var in variables:
265
+ i = R.gens().index(var)
266
+ min_X = min([e[i] for e in X_dict]) if X_dict else 0
267
+ min_Y = min([e[i] for e in Y_dict]) if Y_dict else 0
268
+ min_Z = min([e[i] for e in Z_dict]) if Z_dict else 0
269
+ min_deg[i] = min(min_X / 2, min_Y / 3, min_Z)
270
+ min_deg = vector(min_deg)
271
+ X_dict = {tuple(e - 2 * min_deg): v for e, v in X_dict.items()}
272
+ Y_dict = {tuple(e - 3 * min_deg): v for e, v in Y_dict.items()}
273
+ Z_dict = {tuple(e - 1 * min_deg): v for e, v in Z_dict.items()}
274
+ return (R(X_dict), R(Y_dict), R(Z_dict))
275
+
276
+
277
+ ######################################################################
278
+ #
279
+ # Weierstrass form of cubic in P^2
280
+ #
281
+ ######################################################################
282
+
283
+ def WeierstrassMap_P2(polynomial, variables=None):
284
+ r"""
285
+ Map a cubic to its Weierstrass form.
286
+
287
+ Input/output is the same as :func:`WeierstrassMap`, except that
288
+ the input polynomial must be a cubic in `\mathbb{P}^2`,
289
+
290
+ .. MATH::
291
+
292
+ \begin{split}
293
+ p(x,y) =&\;
294
+ a_{30} x^{3} + a_{21} x^{2} y + a_{12} x y^{2} +
295
+ a_{03} y^{3} + a_{20} x^{2} +
296
+ \\ &\;
297
+ a_{11} x y +
298
+ a_{02} y^{2} + a_{10} x + a_{01} y + a_{00}
299
+ \end{split}
300
+
301
+ EXAMPLES::
302
+
303
+ sage: from sage.schemes.toric.weierstrass import WeierstrassForm_P2
304
+ sage: from sage.schemes.toric.weierstrass_covering import WeierstrassMap_P2
305
+ sage: R.<x,y,z> = QQ[]
306
+ sage: equation = x^3 + y^3 + z^3 + x*y*z
307
+ sage: f, g = WeierstrassForm_P2(equation)
308
+ sage: X,Y,Z = WeierstrassMap_P2(equation)
309
+ sage: equation.divides(-Y^2 + X^3 + f*X*Z^4 + g*Z^6)
310
+ True
311
+
312
+ sage: from sage.schemes.toric.weierstrass import WeierstrassForm_P2
313
+ sage: from sage.schemes.toric.weierstrass_covering import WeierstrassMap_P2
314
+ sage: R.<x,y> = QQ[]
315
+ sage: equation = x^3 + y^3 + 1
316
+ sage: f, g = WeierstrassForm_P2(equation)
317
+ sage: X,Y,Z = WeierstrassMap_P2(equation)
318
+ sage: equation.divides(-Y^2 + X^3 + f*X*Z^4 + g*Z^6)
319
+ True
320
+ """
321
+ x, y, z = _check_polynomial_P2(polynomial, variables)
322
+ cubic = invariant_theory.ternary_cubic(polynomial, x, y, z)
323
+ H = cubic.Hessian()
324
+ Theta = cubic.Theta_covariant()
325
+ J = cubic.J_covariant()
326
+ F = polynomial.parent().base_ring()
327
+ return (Theta, J / F(2), H)
328
+
329
+
330
+ ######################################################################
331
+ #
332
+ # Weierstrass form of biquadric in P1 x P1
333
+ #
334
+ ######################################################################
335
+
336
+ def WeierstrassMap_P1xP1(polynomial, variables=None):
337
+ r"""
338
+ Map an anticanonical hypersurface in
339
+ `\mathbb{P}^1 \times \mathbb{P}^1` into Weierstrass form.
340
+
341
+ Input/output is the same as :func:`WeierstrassMap`, except that
342
+ the input polynomial must be a standard anticanonical hypersurface
343
+ in the toric surface `\mathbb{P}^1 \times \mathbb{P}^1`:
344
+
345
+ EXAMPLES::
346
+
347
+ sage: from sage.schemes.toric.weierstrass_covering import WeierstrassMap_P1xP1
348
+ sage: from sage.schemes.toric.weierstrass import WeierstrassForm_P1xP1
349
+ sage: R.<x0,x1,y0,y1,a> = QQ[]
350
+ sage: biquadric = (x0^2*y0^2 + x1^2*y0^2 + x0^2*y1^2 + x1^2*y1^2 +
351
+ ....: a * x0*x1*y0*y1*5)
352
+ sage: f, g = WeierstrassForm_P1xP1(biquadric, [x0, x1, y0, y1]); (f,g)
353
+ (-625/48*a^4 + 25/3*a^2 - 16/3, 15625/864*a^6 - 625/36*a^4 - 100/9*a^2 + 128/27)
354
+ sage: X, Y, Z = WeierstrassMap_P1xP1(biquadric, [x0, x1, y0, y1])
355
+ sage: (-Y^2 + X^3 + f*X*Z^4 + g*Z^6).reduce(R.ideal(biquadric)) # needs sage.libs.singular
356
+ 0
357
+
358
+ sage: R = PolynomialRing(QQ, 'x,y,s,t', order='lex')
359
+ sage: R.inject_variables()
360
+ Defining x, y, s, t
361
+ sage: equation = (s^2*(x^2+2*x*y+3*y^2) + s*t*(4*x^2+5*x*y+6*y^2)
362
+ ....: + t^2*(7*x^2+8*x*y+9*y^2))
363
+ sage: X, Y, Z = WeierstrassMap_P1xP1(equation, [x,y,s,t])
364
+ sage: f, g = WeierstrassForm_P1xP1(equation, variables=[x,y,s,t])
365
+ sage: (-Y^2 + X^3 + f*X*Z^4 + g*Z^6).reduce(R.ideal(equation)) # needs sage.libs.singular
366
+ 0
367
+
368
+ sage: R = PolynomialRing(QQ, 'x,s', order='lex')
369
+ sage: R.inject_variables()
370
+ Defining x, s
371
+ sage: equation = s^2*(x^2+2*x+3) + s*(4*x^2+5*x+6) + (7*x^2+8*x+9)
372
+ sage: X, Y, Z = WeierstrassMap_P1xP1(equation)
373
+ sage: f, g = WeierstrassForm_P1xP1(equation)
374
+ sage: (-Y^2 + X^3 + f*X*Z^4 + g*Z^6).reduce(R.ideal(equation)) # needs sage.libs.singular
375
+ 0
376
+ """
377
+ x, y, s, t = _check_polynomial_P1xP1(polynomial, variables)
378
+ a00 = polynomial.coefficient({s: 2})
379
+ V = polynomial.coefficient({s: 1})
380
+ U = - _partial_discriminant(polynomial, s, t) / 4
381
+ Q = invariant_theory.binary_quartic(U, x, y)
382
+ g = Q.g_covariant()
383
+ h = Q.h_covariant()
384
+ if t is None:
385
+ t = 1
386
+ return (4 * g * t**2, 4 * h * t**3, (a00 * s + V / 2))
387
+
388
+
389
+ ######################################################################
390
+ #
391
+ # Weierstrass form of anticanonical hypersurface in WP2[1,1,2]
392
+ #
393
+ ######################################################################
394
+
395
+ def WeierstrassMap_P2_112(polynomial, variables=None):
396
+ r"""
397
+ Map an anticanonical hypersurface in `\mathbb{P}^2[1,1,2]` into Weierstrass form.
398
+
399
+ Input/output is the same as :func:`WeierstrassMap`, except that
400
+ the input polynomial must be a standard anticanonical hypersurface
401
+ in weighted projective space `\mathbb{P}^2[1,1,2]`:
402
+
403
+ .. MATH::
404
+
405
+ \begin{split}
406
+ p(x,y) =&\;
407
+ a_{40} x^4 +
408
+ a_{30} x^3 +
409
+ a_{21} x^2 y +
410
+ a_{20} x^2 +
411
+ \\ &\;
412
+ a_{11} x y +
413
+ a_{02} y^2 +
414
+ a_{10} x +
415
+ a_{01} y +
416
+ a_{00}
417
+ \end{split}
418
+
419
+ EXAMPLES::
420
+
421
+ sage: from sage.schemes.toric.weierstrass_covering import WeierstrassMap_P2_112
422
+ sage: from sage.schemes.toric.weierstrass import WeierstrassForm_P2_112
423
+ sage: R = PolynomialRing(QQ, 'x,y,a0,a1,a2,a3,a4', order='lex')
424
+ sage: R.inject_variables()
425
+ Defining x, y, a0, a1, a2, a3, a4
426
+ sage: equation = y^2 + a0*x^4 + 4*a1*x^3 + 6*a2*x^2 + 4*a3*x + a4
427
+ sage: X, Y, Z = WeierstrassMap_P2_112(equation, [x,y])
428
+ sage: f, g = WeierstrassForm_P2_112(equation, variables=[x,y])
429
+ sage: (-Y^2 + X^3 + f*X*Z^4 + g*Z^6).reduce(R.ideal(equation)) # needs sage.libs.singular
430
+ 0
431
+
432
+ Another example, this time in homogeneous coordinates::
433
+
434
+ sage: fan = Fan(rays=[(1,0),(0,1),(-1,-2),(0,-1)],
435
+ ....: cones=[[0,1],[1,2],[2,3],[3,0]])
436
+ sage: P112.<x,y,z,t> = ToricVariety(fan)
437
+ sage: (-P112.K()).sections_monomials()
438
+ (z^4*t^2, x*z^3*t^2, x^2*z^2*t^2, x^3*z*t^2,
439
+ x^4*t^2, y*z^2*t, x*y*z*t, x^2*y*t, y^2)
440
+ sage: C_eqn = sum(_)
441
+ sage: C = P112.subscheme(C_eqn)
442
+ sage: WeierstrassForm_P2_112(C_eqn, [x,y,z,t])
443
+ (-97/48, 17/864)
444
+ sage: X, Y, Z = WeierstrassMap_P2_112(C_eqn, [x,y,z,t])
445
+ sage: (-Y^2 + X^3 - 97/48*X*Z^4 + 17/864*Z^6).reduce(C.defining_ideal()) # needs sage.libs.singular
446
+ 0
447
+ """
448
+ x, y, z, t = _check_polynomial_P2_112(polynomial, variables)
449
+ a00 = polynomial.coefficient({y: 2})
450
+ V = polynomial.coefficient({y: 1})
451
+ U = - _partial_discriminant(polynomial, y, t) / 4
452
+ Q = invariant_theory.binary_quartic(U, x, z)
453
+ g = Q.g_covariant()
454
+ h = Q.h_covariant()
455
+ if t is None:
456
+ t = 1
457
+ return (4 * g * t**2, 4 * h * t**3, (a00 * y + V / 2))