Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document Polyhedron defined over number field #17197

Open
sagetrac-mbell mannequin opened this issue Oct 22, 2014 · 14 comments
Open

document Polyhedron defined over number field #17197

sagetrac-mbell mannequin opened this issue Oct 22, 2014 · 14 comments

Comments

@sagetrac-mbell
Copy link
Mannequin

sagetrac-mbell mannequin commented Oct 22, 2014

As reported in this google group (https://groups.google.com/forum/#!topic/sage-support/ew0bnGzjm98), it was not possible to create Polyhedron defined over number fields. Now that #17830 is merged it does work and it should be documented and even advertised in the documentation!


from the previous report:

To create polyhedra quickly, the final suggestion in the Polyhedron documentation (http://www.sagemath.org/doc/reference/geometry/sage/geometry/polyhedron/constructor.html#base-rings) is to work in a set number field. Although this appears to work for setting vertices, it does not appear to work for lines (or rays).

For example:

sage: var('x')
x
sage: K.<sqrt3> = NumberField(x^2-3, embedding=1.732)
sage: P = Polyhedron(lines=[(1,sqrt3)])
sage: P
A 1-dimensional polyhedron in (Number Field in sqrt3 with defining polynomial x^10 + x^2 - 3)^2 defined as the convex hull of 1 vertex and 2 rays
sage: P.rays()
(A ray in the direction (0, -sqrt3), A ray in the direction (1, sqrt3))

This should be compared with:

sage: P = Polyhedron(lines=[(1, sqrt(3))])
sage: P
A 1-dimensional polyhedron in (Symbolic Ring)^2 defined as the convex hull of 1 vertex and 1 line

and

sage: P = Polyhedron(lines=[(1, sqrt(3))], base_ring=AA)
sage: P
A 1-dimensional polyhedron in AA^2 defined as the convex hull of 1 vertex and 1 line

Additionally, how can a "1-dimensional polyhedron" be "defined as the convex hull of 1 vertex and 2 rays"?

As pointed out below this is an issue with Polyhedron using a number fields < comparison

sage: K.<x> = NumberField(x^3 - 1001, embedding=10)
sage: x > x + 1
True

Depends on #21105

CC: @fchapoton @jplab @sagetrac-jakobkroeker

Component: number theory

Keywords: Polyhedron

Issue created by migration from https://trac.sagemath.org/ticket/17197

@sagetrac-mbell sagetrac-mbell mannequin added this to the sage-6.4 milestone Oct 22, 2014
@vbraun
Copy link
Member

vbraun commented Oct 22, 2014

comment:1

With 6.4.beta6 I get

sage: Polyhedron(lines=[(1,sqrt3)])
A 1-dimensional polyhedron in (Number Field in sqrt3 with defining polynomial x^2 - 3)^2 defined as the convex hull of 1 vertex and 1 line

@vbraun
Copy link
Member

vbraun commented Oct 22, 2014

comment:2

Though the original example fails:

sage: K.<L> = NumberField(x^3 + 3*x^2 - 83*x - 1022, embedding=11.6515)
sage: Polyhedron(eqns=[[0, -L - 2, -8, 2], [0, -2, -L + 6, 9], [0, -9, 5, -L - 7]])
A 3-dimensional polyhedron in (Number Field in L with defining polynomial x^3 + 3*x^2 - 83*x - 1022)^3 defined as the convex hull of 1 vertex, 2 rays, 1 line

Slightly simpler failure:

sage: Polyhedron(eqns=[[0, -L - 2, -8], [0, -2, -L + 6], [0, -9, 5]])
A 2-dimensional polyhedron in (Number Field in L with defining polynomial x^3 + 3*x^2 - 83*x - 1022)^2 defined as the convex hull of 1 vertex and 2 rays

@vbraun
Copy link
Member

vbraun commented Oct 22, 2014

comment:3

This originates at the following comparison:

sage: v = -1/392*L^2 - 45/392*L - 239/392
sage: v > 0
True
sage: v.n()
-2.29356924372991

@sagetrac-mbell
Copy link
Mannequin Author

sagetrac-mbell mannequin commented Oct 23, 2014

comment:4

Thanks for tracking this down. Should I file a separate ticket for this under the number theory?

@vbraun
Copy link
Member

vbraun commented Oct 24, 2014

comment:5

You can just change the description and use this ticket. I think we agree that this is not a bug in polyhedra. See also the discussion on sage-devel.

@sagetrac-mbell

This comment has been minimized.

@videlec
Copy link
Contributor

videlec commented Apr 15, 2015

comment:7

Comparison is fixed for quadratic fields since #13213. To have it working on higher degree number field you could review #17830.

Vincent

@mkoeppe
Copy link
Contributor

mkoeppe commented Jul 26, 2016

comment:8

All of these tests in description and comments seem to working in 7.3.beta9.

@mkoeppe mkoeppe removed this from the sage-6.4 milestone Jul 26, 2016
@videlec
Copy link
Contributor

videlec commented Jul 26, 2016

comment:9

yes because comparison in number fields is now working... (#17830). Instead of making it invalid, it would be much better to add doctests!

@videlec videlec added this to the sage-7.3 milestone Jul 26, 2016
@videlec

This comment has been minimized.

@videlec videlec changed the title Bug creating Polyhedron from lines in number field document Polyhedron defined over number field Jul 26, 2016
@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 3, 2016

Dependencies: #21105

@mkoeppe mkoeppe modified the milestones: sage-7.3, sage-7.4 Aug 17, 2016
@jplab
Copy link

jplab commented Apr 12, 2018

comment:15

Since the Polyhedron evolved quite a bit in the last year, here is an update on Sage8.2.rc1:

sage: var('x')
x
sage: K.<sqrt3> = NumberField(x^2-3, embedding=1.732)
sage: P = Polyhedron(lines=[(1,sqrt3)])
sage: P.rays()
()
sage: P.lines()
(A line in the direction (1, sqrt3),)

sage: P = Polyhedron(lines=[(1, sqrt(3))])
Traceback (most recent call last):
...
ValueError: for polyhedra with floating point numbers, the only allowed ring is RDF with backend 'cdd'

sage: P = Polyhedron(lines=[(1, sqrt(3))], base_ring=AA)
sage: P
A 1-dimensional polyhedron in AA^2 defined as the convex hull of 1 vertex and 1 line

The value error above will be changed in #24835 to a more appropriate error message, for which:

sage: P = Polyhedron(lines=[(1, sqrt(3))],backend='cdd',base_ring=RDF)
sage: P
A 1-dimensional polyhedron in RDF^2 defined as the convex hull of 1 vertex and 1 line

is the only way to get a symbolic expression to pass on to the constructor of Polyhedron.

Concerning documenting the Polyhedron class usage through NumberFields, I believe that #22572 does the job.

Hence, once #22572 is merged, I would set this ticket to won't fix: the bug is fixed.

@dimpase
Copy link
Member

dimpase commented Aug 18, 2018

comment:16

An improvement of the doc is posted on #26077, where I also point out that
it is not sufficient to have a tutorial doc: the docstring of Polyhedron should have a real example with NF entries.

@jplab
Copy link

jplab commented Jul 22, 2019

comment:17

Just an update of the current situation in 8.9beta3:

sage: var('x')
x
sage: K.<sqrt3> = NumberField(x^2-3, embedding=1.732)
sage: P = Polyhedron(lines=[(1,sqrt3)])
sage: P.rays()
()
sage: P.lines()
(A line in the direction (1, sqrt3),)
sage: P = Polyhedron(lines=[(1, sqrt(3))])
Traceback (most recent call last):
...
ValueError: no default backend for computations with Symbolic Ring
sage: P = Polyhedron(lines=[(1, sqrt(3))], base_ring=AA); P
A 1-dimensional polyhedron in AA^2 defined as the convex hull of 1 vertex and 1 line
sage: Q = Polyhedron(lines=[(1, sqrt(3))], backend='normaliz'); Q
A 1-dimensional polyhedron in (Symbolic Ring)^2 defined as the convex hull of 1 vertex and 1 line

and it is still possible to do:

sage: R = Polyhedron(lines=[(1, sqrt(3))],backend='cdd',base_ring=RDF);R
A 1-dimensional polyhedron in RDF^2 defined as the convex hull of 1 vertex and 1 line

Similar examples should now complete the docstring, now that #25097 is merged.

@mkoeppe mkoeppe removed this from the sage-7.4 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants