Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 0c5ed4c

Browse files
author
Matthias Koeppe
committed
src/doc/en/thematic_tutorials/geometry/polyhedra_tutorial.rst: Add # optional - sage.rings.number_field, sage.symbolic
1 parent 8085729 commit 0c5ed4c

File tree

1 file changed

+42
-28
lines changed

1 file changed

+42
-28
lines changed

src/doc/en/thematic_tutorials/geometry/polyhedra_tutorial.rst

+42-28
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,22 @@ The following example demonstrates the limitations of :code:`RDF`.
162162

163163
::
164164

165-
sage: D = polytopes.dodecahedron()
166-
sage: D
167-
A 3-dimensional polyhedron in (Number Field in sqrt5 with defining polynomial x^2 - 5 with sqrt5 = 2.236067977499790?)^3 defined as the convex hull of 20 vertices
168-
sage: D_RDF = Polyhedron(vertices = [n(v.vector(),digits=6) for v in D.vertices()], base_ring=RDF)
165+
sage: D = polytopes.dodecahedron() # optional - sage.rings.number_field
166+
sage: D # optional - sage.rings.number_field
167+
A 3-dimensional polyhedron
168+
in (Number Field in sqrt5 with defining polynomial x^2 - 5
169+
with sqrt5 = 2.236067977499790?)^3
170+
defined as the convex hull of 20 vertices
171+
172+
sage: vertices_RDF = [n(v.vector(),digits=6) for v in D.vertices()] # optional - sage.rings.number_field
173+
sage: D_RDF = Polyhedron(vertices=vertices_RDF, base_ring=RDF) # optional - sage.rings.number_field
169174
doctest:warning
170175
...
171176
UserWarning: This polyhedron data is numerically complicated; cdd
172177
could not convert between the inexact V and H representation
173178
without loss of data. The resulting object might show
174179
inconsistencies.
175-
sage: D_RDF = Polyhedron(vertices = sorted([n(v.vector(),digits=6) for v in D.vertices()]), base_ring=RDF)
180+
sage: D_RDF = Polyhedron(vertices=sorted(vertices_RDF), base_ring=RDF) # optional - sage.rings.number_field
176181
Traceback (most recent call last):
177182
...
178183
ValueError: *Error: Numerical inconsistency is found. Use the GMP exact arithmetic.
@@ -189,15 +194,15 @@ automatically converts the data to :code:`RDF`:
189194

190195
.. end of output
191196
192-
It is also possible to define polyhedron over algebraic numbers.
197+
It is also possible to define a polyhedron over algebraic numbers.
193198

194199
::
195200

196-
sage: sqrt_2 = AA(2)^(1/2)
197-
sage: cbrt_2 = AA(2)^(1/3)
198-
sage: timeit('Polyhedron(vertices = [[sqrt_2, 0], [0, cbrt_2]])') # random
201+
sage: sqrt_2 = AA(2)^(1/2) # optional - sage.rings.number_field
202+
sage: cbrt_2 = AA(2)^(1/3) # optional - sage.rings.number_field
203+
sage: timeit('Polyhedron(vertices = [[sqrt_2, 0], [0, cbrt_2]])') # optional - sage.rings.number_field # random
199204
5 loops, best of 3: 43.2 ms per loop
200-
sage: P4 = Polyhedron(vertices = [[sqrt_2, 0], [0, cbrt_2]]); P4
205+
sage: P4 = Polyhedron(vertices = [[sqrt_2, 0], [0, cbrt_2]]); P4 # optional - sage.rings.number_field
201206
A 1-dimensional polyhedron in AA^2 defined as the convex hull of 2 vertices
202207

203208
.. end of output
@@ -206,11 +211,11 @@ There is another way to create a polyhedron over algebraic numbers:
206211

207212
::
208213

209-
sage: K.<a> = NumberField(x^2 - 2, embedding=AA(2)**(1/2))
210-
sage: L.<b> = NumberField(x^3 - 2, embedding=AA(2)**(1/3))
211-
sage: timeit('Polyhedron(vertices = [[a, 0], [0, b]])') # random
214+
sage: K.<a> = NumberField(x^2 - 2, embedding=AA(2)**(1/2)) # optional - sage.rings.number_field
215+
sage: L.<b> = NumberField(x^3 - 2, embedding=AA(2)**(1/3)) # optional - sage.rings.number_field
216+
sage: timeit('Polyhedron(vertices = [[a, 0], [0, b]])') # optional - sage.rings.number_field # random
212217
5 loops, best of 3: 39.9 ms per loop
213-
sage: P5 = Polyhedron(vertices = [[a, 0], [0, b]]); P5
218+
sage: P5 = Polyhedron(vertices = [[a, 0], [0, b]]); P5 # optional - sage.rings.number_field
214219
A 1-dimensional polyhedron in AA^2 defined as the convex hull of 2 vertices
215220

216221
.. end of output
@@ -219,11 +224,15 @@ If the base ring is known it may be a good option to use the proper :meth:`sage.
219224

220225
::
221226

222-
sage: J = K.composite_fields(L)[0]
223-
sage: timeit('Polyhedron(vertices = [[J(a), 0], [0, J(b)]])') # random
227+
sage: J = K.composite_fields(L)[0] # optional - sage.rings.number_field
228+
sage: timeit('Polyhedron(vertices = [[J(a), 0], [0, J(b)]])') # optional - sage.rings.number_field # random
224229
25 loops, best of 3: 9.8 ms per loop
225-
sage: P5_comp = Polyhedron(vertices = [[J(a), 0], [0, J(b)]]); P5_comp
226-
A 1-dimensional polyhedron in (Number Field in ab with defining polynomial x^6 - 6*x^4 - 4*x^3 + 12*x^2 - 24*x - 4 with ab = -0.1542925124782219?)^2 defined as the convex hull of 2 vertices
230+
sage: P5_comp = Polyhedron(vertices = [[J(a), 0], [0, J(b)]]); P5_comp # optional - sage.rings.number_field
231+
A 1-dimensional polyhedron
232+
in (Number Field in ab with defining polynomial
233+
x^6 - 6*x^4 - 4*x^3 + 12*x^2 - 24*x - 4
234+
with ab = -0.1542925124782219?)^2
235+
defined as the convex hull of 2 vertices
227236

228237
.. end of output
229238
@@ -232,9 +241,9 @@ It is not possible to define a polyhedron over it:
232241

233242
::
234243

235-
sage: sqrt_2s = sqrt(2)
236-
sage: cbrt_2s = 2^(1/3)
237-
sage: Polyhedron(vertices = [[sqrt_2s, 0], [0, cbrt_2s]])
244+
sage: sqrt_2s = sqrt(2) # optional - sage.symbolic
245+
sage: cbrt_2s = 2^(1/3) # optional - sage.symbolic
246+
sage: Polyhedron(vertices = [[sqrt_2s, 0], [0, cbrt_2s]]) # optional - sage.symbolic
238247
Traceback (most recent call last):
239248
...
240249
ValueError: no default backend for computations with Symbolic Ring
@@ -567,12 +576,12 @@ but not algebraic or symbolic values:
567576

568577
::
569578

570-
sage: P4_cdd = Polyhedron(vertices = [[sqrt_2, 0], [0, cbrt_2]], backend='cdd')
579+
sage: P4_cdd = Polyhedron(vertices = [[sqrt_2, 0], [0, cbrt_2]], backend='cdd') # optional - sage.rings.number_field
571580
Traceback (most recent call last):
572581
...
573582
ValueError: No such backend (=cdd) implemented for given basering (=Algebraic Real Field).
574583

575-
sage: P5_cdd = Polyhedron(vertices = [[sqrt_2s, 0], [0, cbrt_2s]], backend='cdd')
584+
sage: P5_cdd = Polyhedron(vertices = [[sqrt_2s, 0], [0, cbrt_2s]], backend='cdd') # optional - sage.symbolic
576585
Traceback (most recent call last):
577586
...
578587
ValueError: No such backend (=cdd) implemented for given basering (=Symbolic Ring).
@@ -646,9 +655,11 @@ An example with quadratic field:
646655

647656
::
648657

649-
sage: V = polytopes.dodecahedron().vertices_list()
650-
sage: Polyhedron(vertices=V, backend='polymake') # optional - polymake
651-
A 3-dimensional polyhedron in (Number Field in sqrt5 with defining polynomial x^2 - 5)^3 defined as the convex hull of 20 vertices
658+
sage: V = polytopes.dodecahedron().vertices_list() # optional - sage.rings.number_field
659+
sage: Polyhedron(vertices=V, backend='polymake') # optional - polymake # optional - sage.rings.number_field
660+
A 3-dimensional polyhedron
661+
in (Number Field in sqrt5 with defining polynomial x^2 - 5)^3
662+
defined as the convex hull of 20 vertices
652663

653664
.. end of output
654665
@@ -775,8 +786,11 @@ polytope is already defined!
775786

776787
::
777788

778-
sage: A = polytopes.buckyball(); A # can take long
779-
A 3-dimensional polyhedron in (Number Field in sqrt5 with defining polynomial x^2 - 5 with sqrt5 = 2.236067977499790?)^3 defined as the convex hull of 60 vertices
789+
sage: A = polytopes.buckyball(); A # can take long # optional - sage.rings.number_field
790+
A 3-dimensional polyhedron
791+
in (Number Field in sqrt5 with defining polynomial x^2 - 5
792+
with sqrt5 = 2.236067977499790?)^3
793+
defined as the convex hull of 60 vertices
780794
sage: B = polytopes.cross_polytope(4); B
781795
A 4-dimensional polyhedron in ZZ^4 defined as the convex hull of 8 vertices
782796
sage: C = polytopes.cyclic_polytope(3,10); C

0 commit comments

Comments
 (0)