Opened 6 years ago
Last modified 21 months ago
#17197 needs_work defect
document Polyhedron defined over number field
Reported by: | mbell | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-7.4 |
Component: | number theory | Keywords: | Polyhedron, Number field |
Cc: | chapoton, jipilab, jakobkroeker | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | #21105 | Stopgaps: |
Description (last modified by )
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
Change History (17)
comment:1 Changed 6 years ago by
comment:2 Changed 6 years ago by
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
comment:3 follow-up: ↓ 4 Changed 6 years ago by
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
comment:4 in reply to: ↑ 3 Changed 6 years ago by
Thanks for tracking this down. Should I file a separate ticket for this under the number theory?
comment:5 Changed 6 years ago by
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.
comment:6 Changed 6 years ago by
- Component changed from geometry to number theory
- Description modified (diff)
comment:7 Changed 6 years ago by
comment:8 Changed 5 years ago by
- Milestone changed from sage-6.4 to sage-duplicate/invalid/wontfix
- Status changed from new to needs_review
All of these tests in description and comments seem to working in 7.3.beta9.
comment:9 Changed 5 years ago by
- Milestone changed from sage-duplicate/invalid/wontfix to sage-7.3
- Status changed from needs_review to needs_work
yes because comparison in number fields is now working... (#17830). Instead of making it invalid, it would be much better to add doctests!
comment:10 Changed 5 years ago by
- Description modified (diff)
- Summary changed from Bug creating Polyhedron from lines in number field to document Polyhedron defined over number field
comment:11 Changed 5 years ago by
- Dependencies set to #21105
comment:12 Changed 5 years ago by
- Cc chapoton added
- Milestone changed from sage-7.3 to sage-7.4
comment:13 Changed 4 years ago by
- Cc jipilab added
comment:14 Changed 4 years ago by
- Cc jakobkroeker added
comment:15 Changed 3 years ago by
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.
comment:16 Changed 3 years ago by
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.
comment:17 Changed 21 months ago by
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.
With 6.4.beta6 I get