ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 02 May 2018 09:08:01 -0500Why is this polar polytope incorrect?http://ask.sagemath.org/question/34852/why-is-this-polar-polytope-incorrect/I have a polytope
sage: P = Polyhedron([
....: [-1, -1, -1, -1, -1],
....: [-1, -1, -1, -1, 6],
....: [-1, -1, -1, 6, -1],
....: [-1, -1, 6, -1, -1],
....: [-1, 6, -1, -1, -1],
....: [5/2, -1, -1, -1, -1]
....: ])
The polar can be constructed manually with
sage: Pd = Polyhedron(ieqs=[vector([1]+v)for v in P.vertices_list()])
sage: Pd.vertices()
(A vertex at (1, 0, 0, 0, 0),
A vertex at (0, 1, 0, 0, 0),
A vertex at (-2, -1, -1, -1, -1),
A vertex at (0, 0, 0, 0, 1),
A vertex at (0, 0, 0, 1, 0),
A vertex at (0, 0, 1, 0, 0))
This yields a result different from `P.polar()`
sage: P.polar().vertices()
(A vertex at (12/7, 6/7, 6/7, 6/7, 6/7),
A vertex at (0, 0, 0, 0, -6/7),
A vertex at (-12/7, 0, 0, 0, 0),
A vertex at (0, 0, 0, -6/7, 0),
A vertex at (0, -6/7, 0, 0, 0),
A vertex at (0, 0, -6/7, 0, 0))
Why am I getting different results? Is this a bug?Sun, 18 Sep 2016 18:23:35 -0500http://ask.sagemath.org/question/34852/why-is-this-polar-polytope-incorrect/Answer by Sébastien for <p>I have a polytope </p>
<pre><code>sage: P = Polyhedron([
....: [-1, -1, -1, -1, -1],
....: [-1, -1, -1, -1, 6],
....: [-1, -1, -1, 6, -1],
....: [-1, -1, 6, -1, -1],
....: [-1, 6, -1, -1, -1],
....: [5/2, -1, -1, -1, -1]
....: ])
</code></pre>
<p>The polar can be constructed manually with</p>
<pre><code>sage: Pd = Polyhedron(ieqs=[vector([1]+v)for v in P.vertices_list()])
sage: Pd.vertices()
(A vertex at (1, 0, 0, 0, 0),
A vertex at (0, 1, 0, 0, 0),
A vertex at (-2, -1, -1, -1, -1),
A vertex at (0, 0, 0, 0, 1),
A vertex at (0, 0, 0, 1, 0),
A vertex at (0, 0, 1, 0, 0))
</code></pre>
<p>This yields a result different from <code>P.polar()</code></p>
<pre><code>sage: P.polar().vertices()
(A vertex at (12/7, 6/7, 6/7, 6/7, 6/7),
A vertex at (0, 0, 0, 0, -6/7),
A vertex at (-12/7, 0, 0, 0, 0),
A vertex at (0, 0, 0, -6/7, 0),
A vertex at (0, -6/7, 0, 0, 0),
A vertex at (0, 0, -6/7, 0, 0))
</code></pre>
<p>Why am I getting different results? Is this a bug?</p>
http://ask.sagemath.org/question/34852/why-is-this-polar-polytope-incorrect/?answer=34867#post-id-34867I am not an expert of polytopes, but I see that the documentation of `P.polar()` says that the "original vertices are translated so that their barycenter is at the origin".
I can confirm this by doing:
sage: Pcentred = P - P.center()
sage: Pcentred = - Pcentred # I don't know why, but Sage .polar() method does this
sage: Pd = Polyhedron(ieqs=[vector([1]+v) for v in Pcentred.vertices_list()])
sage: Pd.vertices()
(A vertex at (12/7, 6/7, 6/7, 6/7, 6/7),
A vertex at (0, 0, 0, 0, -6/7),
A vertex at (-12/7, 0, 0, 0, 0),
A vertex at (0, 0, 0, -6/7, 0),
A vertex at (0, -6/7, 0, 0, 0),
A vertex at (0, 0, -6/7, 0, 0))
Tue, 20 Sep 2016 03:13:47 -0500http://ask.sagemath.org/question/34852/why-is-this-polar-polytope-incorrect/?answer=34867#post-id-34867Comment by jipilab for <p>I am not an expert of polytopes, but I see that the documentation of <code>P.polar()</code> says that the "original vertices are translated so that their barycenter is at the origin".</p>
<p>I can confirm this by doing:</p>
<pre><code>sage: Pcentred = P - P.center()
sage: Pcentred = - Pcentred # I don't know why, but Sage .polar() method does this
sage: Pd = Polyhedron(ieqs=[vector([1]+v) for v in Pcentred.vertices_list()])
sage: Pd.vertices()
(A vertex at (12/7, 6/7, 6/7, 6/7, 6/7),
A vertex at (0, 0, 0, 0, -6/7),
A vertex at (-12/7, 0, 0, 0, 0),
A vertex at (0, 0, 0, -6/7, 0),
A vertex at (0, -6/7, 0, 0, 0),
A vertex at (0, 0, -6/7, 0, 0))
</code></pre>
http://ask.sagemath.org/question/34852/why-is-this-polar-polytope-incorrect/?comment=42245#post-id-42245Indeed, polarity of polyhedron requires compactness (to get a good duality property, for example that taking twice the dual gives back the original object) and that the origin is in the interior of the (then compact) polyhedron.
Hence, in order to allow polarity of polytope that do not contain the origin, it is automatically shifted so that its barycenter is the origin. This allows for a somehow "canonical" polar object. Taking another point in the interior as the origin would also work, but not implemented.Wed, 02 May 2018 09:08:01 -0500http://ask.sagemath.org/question/34852/why-is-this-polar-polytope-incorrect/?comment=42245#post-id-42245Comment by done_with_fish for <p>I am not an expert of polytopes, but I see that the documentation of <code>P.polar()</code> says that the "original vertices are translated so that their barycenter is at the origin".</p>
<p>I can confirm this by doing:</p>
<pre><code>sage: Pcentred = P - P.center()
sage: Pcentred = - Pcentred # I don't know why, but Sage .polar() method does this
sage: Pd = Polyhedron(ieqs=[vector([1]+v) for v in Pcentred.vertices_list()])
sage: Pd.vertices()
(A vertex at (12/7, 6/7, 6/7, 6/7, 6/7),
A vertex at (0, 0, 0, 0, -6/7),
A vertex at (-12/7, 0, 0, 0, 0),
A vertex at (0, 0, 0, -6/7, 0),
A vertex at (0, -6/7, 0, 0, 0),
A vertex at (0, 0, -6/7, 0, 0))
</code></pre>
http://ask.sagemath.org/question/34852/why-is-this-polar-polytope-incorrect/?comment=34868#post-id-34868I guess this has the advantage of working for any polytope (the polar is only defined for polytopes containing the origin, I think).Tue, 20 Sep 2016 09:47:46 -0500http://ask.sagemath.org/question/34852/why-is-this-polar-polytope-incorrect/?comment=34868#post-id-34868