Sage: Ticket #17197: document Polyhedron defined over number field
https://trac.sagemath.org/ticket/17197
<p>
As reported in this google group (<a class="ext-link" href="https://groups.google.com/forum/#!topic/sage-support/ew0bnGzjm98"><span class="icon"></span>https://groups.google.com/forum/#!topic/sage-support/ew0bnGzjm98</a>), it was not possible to create Polyhedron defined over number fields. Now that <a class="closed ticket" href="https://trac.sagemath.org/ticket/17830" title="#17830: enhancement: Comparison of number field elements dependent of real embedding (closed: fixed)">#17830</a> is merged it does work and it should be documented and even advertised in the documentation!
</p>
<hr />
<p>
from the previous report:
</p>
<p>
To create polyhedra quickly, the final suggestion in the Polyhedron documentation (<a class="ext-link" href="http://www.sagemath.org/doc/reference/geometry/sage/geometry/polyhedron/constructor.html#base-rings"><span class="icon"></span>http://www.sagemath.org/doc/reference/geometry/sage/geometry/polyhedron/constructor.html#base-rings</a>) 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).
</p>
<p>
For example:
</p>
<pre class="wiki">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))
</pre><p>
This should be compared with:
</p>
<pre class="wiki">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
</pre><p>
and
</p>
<pre class="wiki">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
</pre><p>
Additionally, how can a "1-dimensional polyhedron" be "defined as the convex hull of 1 vertex and 2 rays"?
</p>
<p>
As pointed out below this is an issue with Polyhedron using a number fields < comparison
</p>
<pre class="wiki">sage: K.<x> = NumberField(x^3 - 1001, embedding=10)
sage: x > x + 1
True
</pre>en-usSagehttps://trac.sagemath.org/chrome/site/logo_sagemath_trac.png
https://trac.sagemath.org/ticket/17197
Trac 1.2Volker BraunWed, 22 Oct 2014 16:03:45 GMT
https://trac.sagemath.org/ticket/17197#comment:1
https://trac.sagemath.org/ticket/17197#comment:1
<p>
With 6.4.beta6 I get
</p>
<pre class="wiki">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
</pre>
TicketVolker BraunWed, 22 Oct 2014 16:09:51 GMT
https://trac.sagemath.org/ticket/17197#comment:2
https://trac.sagemath.org/ticket/17197#comment:2
<p>
Though the original example fails:
</p>
<pre class="wiki">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
</pre><p>
Slightly simpler failure:
</p>
<pre class="wiki">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
</pre>
TicketVolker BraunWed, 22 Oct 2014 17:01:24 GMT
https://trac.sagemath.org/ticket/17197#comment:3
https://trac.sagemath.org/ticket/17197#comment:3
<p>
This originates at the following comparison:
</p>
<pre class="wiki">sage: v = -1/392*L^2 - 45/392*L - 239/392
sage: v > 0
True
sage: v.n()
-2.29356924372991
</pre>
TicketMark BellThu, 23 Oct 2014 21:09:34 GMT
https://trac.sagemath.org/ticket/17197#comment:4
https://trac.sagemath.org/ticket/17197#comment:4
<p>
Thanks for tracking this down. Should I file a separate ticket for this under the number theory?
</p>
TicketVolker BraunFri, 24 Oct 2014 16:36:23 GMT
https://trac.sagemath.org/ticket/17197#comment:5
https://trac.sagemath.org/ticket/17197#comment:5
<p>
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.
</p>
TicketMark BellFri, 24 Oct 2014 16:51:03 GMTcomponent, description changed
https://trac.sagemath.org/ticket/17197#comment:6
https://trac.sagemath.org/ticket/17197#comment:6
<ul>
<li><strong>component</strong>
changed from <em>geometry</em> to <em>number theory</em>
</li>
<li><strong>description</strong>
modified (<a href="/ticket/17197?action=diff&version=6">diff</a>)
</li>
</ul>
TicketVincent DelecroixWed, 15 Apr 2015 22:57:50 GMT
https://trac.sagemath.org/ticket/17197#comment:7
https://trac.sagemath.org/ticket/17197#comment:7
<p>
Comparison is fixed for quadratic fields since <a class="closed ticket" href="https://trac.sagemath.org/ticket/13213" title="#13213: enhancement: Comparisons in quadratic number field (closed: fixed)">#13213</a>. To have it working on higher degree number field you could review <a class="closed ticket" href="https://trac.sagemath.org/ticket/17830" title="#17830: enhancement: Comparison of number field elements dependent of real embedding (closed: fixed)">#17830</a>.
</p>
<p>
Vincent
</p>
TicketMatthias KöppeTue, 26 Jul 2016 22:38:35 GMTstatus, milestone changed
https://trac.sagemath.org/ticket/17197#comment:8
https://trac.sagemath.org/ticket/17197#comment:8
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>needs_review</em>
</li>
<li><strong>milestone</strong>
changed from <em>sage-6.4</em> to <em>sage-duplicate/invalid/wontfix</em>
</li>
</ul>
<p>
All of these tests in description and comments seem to working in 7.3.beta9.
</p>
TicketVincent DelecroixTue, 26 Jul 2016 22:40:13 GMTstatus, milestone changed
https://trac.sagemath.org/ticket/17197#comment:9
https://trac.sagemath.org/ticket/17197#comment:9
<ul>
<li><strong>status</strong>
changed from <em>needs_review</em> to <em>needs_work</em>
</li>
<li><strong>milestone</strong>
changed from <em>sage-duplicate/invalid/wontfix</em> to <em>sage-7.3</em>
</li>
</ul>
<p>
yes because comparison in number fields is now working... (<a class="closed ticket" href="https://trac.sagemath.org/ticket/17830" title="#17830: enhancement: Comparison of number field elements dependent of real embedding (closed: fixed)">#17830</a>). Instead of making it invalid, it would be much better to add doctests!
</p>
TicketVincent DelecroixTue, 26 Jul 2016 22:49:18 GMTdescription, summary changed
https://trac.sagemath.org/ticket/17197#comment:10
https://trac.sagemath.org/ticket/17197#comment:10
<ul>
<li><strong>description</strong>
modified (<a href="/ticket/17197?action=diff&version=10">diff</a>)
</li>
<li><strong>summary</strong>
changed from <em>Bug creating Polyhedron from lines in number field</em> to <em>document Polyhedron defined over number field</em>
</li>
</ul>
TicketMatthias KöppeWed, 03 Aug 2016 23:39:46 GMTdependencies set
https://trac.sagemath.org/ticket/17197#comment:11
https://trac.sagemath.org/ticket/17197#comment:11
<ul>
<li><strong>dependencies</strong>
set to <em>#21105</em>
</li>
</ul>
TicketMatthias KöppeWed, 17 Aug 2016 19:54:23 GMTmilestone changed; cc set
https://trac.sagemath.org/ticket/17197#comment:12
https://trac.sagemath.org/ticket/17197#comment:12
<ul>
<li><strong>cc</strong>
<em>Frédéric Chapoton</em> added
</li>
<li><strong>milestone</strong>
changed from <em>sage-7.3</em> to <em>sage-7.4</em>
</li>
</ul>
TicketJean-Philippe LabbéMon, 06 Feb 2017 09:11:20 GMTcc changed
https://trac.sagemath.org/ticket/17197#comment:13
https://trac.sagemath.org/ticket/17197#comment:13
<ul>
<li><strong>cc</strong>
<em>Jean-Philippe Labbé</em> added
</li>
</ul>
TicketJakob KroekerSat, 04 Mar 2017 01:53:59 GMTcc changed
https://trac.sagemath.org/ticket/17197#comment:14
https://trac.sagemath.org/ticket/17197#comment:14
<ul>
<li><strong>cc</strong>
<em>Jakob Kroeker</em> added
</li>
</ul>
TicketJean-Philippe LabbéThu, 12 Apr 2018 00:14:14 GMT
https://trac.sagemath.org/ticket/17197#comment:15
https://trac.sagemath.org/ticket/17197#comment:15
<p>
Since the Polyhedron evolved quite a bit in the last year, here is an update on Sage8.2.rc1:
</p>
<pre class="wiki">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
</pre><p>
The value error above will be changed in <a class="closed ticket" href="https://trac.sagemath.org/ticket/24835" title="#24835: enhancement: Change error message in construction of polyhedron object (closed: fixed)">#24835</a> to a more appropriate error message, for which:
</p>
<pre class="wiki">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
</pre><p>
is the only way to get a symbolic expression to pass on to the constructor of Polyhedron.
</p>
<p>
Concerning documenting the Polyhedron class usage through <a class="missing wiki">NumberFields?</a>, I believe that <a class="closed ticket" href="https://trac.sagemath.org/ticket/22572" title="#22572: enhancement: Add a thematic tutorial on the polyhedron class (closed: fixed)">#22572</a> does the job.
</p>
<p>
Hence, once <a class="closed ticket" href="https://trac.sagemath.org/ticket/22572" title="#22572: enhancement: Add a thematic tutorial on the polyhedron class (closed: fixed)">#22572</a> is merged, I would set this ticket to won't fix: the bug is fixed.
</p>
TicketDima PasechnikSat, 18 Aug 2018 08:46:30 GMT
https://trac.sagemath.org/ticket/17197#comment:16
https://trac.sagemath.org/ticket/17197#comment:16
<p>
An improvement of the doc is posted on <a class="closed ticket" href="https://trac.sagemath.org/ticket/26077" title="#26077: defect: document and doctest constructing polyhedra over number fields (closed: fixed)">#26077</a>, 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.
</p>
TicketJean-Philippe LabbéMon, 22 Jul 2019 16:29:49 GMT
https://trac.sagemath.org/ticket/17197#comment:17
https://trac.sagemath.org/ticket/17197#comment:17
<p>
Just an update of the current situation in <code>8.9beta3</code>:
</p>
<pre class="wiki">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
</pre><p>
and it is still possible to do:
</p>
<pre class="wiki">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
</pre><p>
Similar examples should now complete the docstring, now that <a class="closed ticket" href="https://trac.sagemath.org/ticket/25097" title="#25097: enhancement: Algebraic polyhedra with Normaliz / e-antic (closed: fixed)">#25097</a> is merged.
</p>
Ticket