ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 15 Nov 2017 22:09:44 +0100Visualizing Toric fans in Sagehttps://ask.sagemath.org/question/39468/visualizing-toric-fans-in-sage/I am learning basics of toric geometry as applied to physics. I would like to know if there's a way to visualize toric fans using Sagemath, and also draw dual toric diagrams.
For example, if I give explicit coordinates of vectors defining a fan, can I visualize the fan and also its dual toric fan using Sage?
I have found resources on the net about using Sage for toric varieties, but I am currently looking for answers to much simpler questions.Thu, 09 Nov 2017 21:42:47 +0100https://ask.sagemath.org/question/39468/visualizing-toric-fans-in-sage/Answer by dan_fulea for <p>I am learning basics of toric geometry as applied to physics. I would like to know if there's a way to visualize toric fans using Sagemath, and also draw dual toric diagrams.</p>
<p>For example, if I give explicit coordinates of vectors defining a fan, can I visualize the fan and also its dual toric fan using Sage?</p>
<p>I have found resources on the net about using Sage for toric varieties, but I am currently looking for answers to much simpler questions.</p>
https://ask.sagemath.org/question/39468/visualizing-toric-fans-in-sage/?answer=39488#post-id-39488
The following did not fit as a comment, so it became an answer.
In such cases it is always a good idea to provide a minimal, non-trivial,
relevant example, give the expectation, and references for the definition of the involved objects,
if not standard.
(I was somehow puzzled about the meaning of a "dual toric diagram" and "dual toric fan"...
Please give definitions or links to their meanings.)
Of course, sage code that initializes sample data would be wonderful
for potential helpers to get immediately in the matter.
If i understand the post, we want the following:
- (0) not given / specified, but implicitly needed, fix some vectors.
- (1) given explicit coordinates of vectors, associate the corresponding fan.
- (2) vizualize a fan. (Simple after construction. Just `plot` it!)
- (3) associate the toric variety of a fan.
- (4) associate the dual (toric?) fan (?) of a fan.
- (5) = (3*) associate the toric variety of the dual fan.
Here is some sample lines of code addressing these points, for more we need more (input).
import pprint
# (0) construct some vertices and the polyhedron determined by them
R = [ 0,
+3, +4, +5,
-3, -4, -5, ]
V = [ (s,t,u)
for (s,t,u) in cartesian_product( [R,R,R] )
if s^2 + t^2 + u^2 == 5^2 ]
P = Polyhedron( vertices = V )
L = P.lattice_polytope()
print "P has the following vertices:"
pprint.pprint( P.vertices_list() )
print "A plot of P..."
P.plot()
# (1) associate the fan of the polyhedron P
F = FaceFan( L )
# (2) plot the fan
print "The fan of the lattice L is as follows..."
F.plot()
print "The rays of the fan F are as follows:"
print F.rays()
# (3) associate the toric variety of the fan
T = ToricVariety( F )
print "A plot of the associated toric variety T..."
T.plot()
# (4) dual fan (?)
# there is only a dual lattice, that i can associate to a given lattice.
# or we may pass from a cone to its dual cone,
# but this is an operation that may map
# disjoint (open) cones to intersecting dual cones.
# example
c = F.cones()[3][0] # first cone in the fan F
print "The rays of the first cone are:\n", c.rays()
plot(c)
cd = c.dual()
print "The rays of its dual cone are:\n", cd.rays()
plot(cd)
Methods of the constructed objects can be detected by using `dir`, e.g. `dir(F)`, or
using in the sage console the TAB-extensions list. (For this, type `F.`, then hit the TAB (twice).) Fri, 10 Nov 2017 21:17:21 +0100https://ask.sagemath.org/question/39468/visualizing-toric-fans-in-sage/?answer=39488#post-id-39488Comment by toricweb for <p>The following did not fit as a comment, so it became an answer.
In such cases it is always a good idea to provide a minimal, non-trivial,
relevant example, give the expectation, and references for the definition of the involved objects,
if not standard.
(I was somehow puzzled about the meaning of a "dual toric diagram" and "dual toric fan"...
Please give definitions or links to their meanings.)</p>
<p>Of course, sage code that initializes sample data would be wonderful
for potential helpers to get immediately in the matter.</p>
<p>If i understand the post, we want the following:</p>
<ul>
<li>(0) not given / specified, but implicitly needed, fix some vectors.</li>
<li>(1) given explicit coordinates of vectors, associate the corresponding fan.</li>
<li>(2) vizualize a fan. (Simple after construction. Just <code>plot</code> it!)</li>
<li>(3) associate the toric variety of a fan.</li>
<li>(4) associate the dual (toric?) fan (?) of a fan.</li>
<li>(5) = (3*) associate the toric variety of the dual fan.</li>
</ul>
<p>Here is some sample lines of code addressing these points, for more we need more (input).</p>
<pre><code>import pprint
# (0) construct some vertices and the polyhedron determined by them
R = [ 0,
+3, +4, +5,
-3, -4, -5, ]
V = [ (s,t,u)
for (s,t,u) in cartesian_product( [R,R,R] )
if s^2 + t^2 + u^2 == 5^2 ]
P = Polyhedron( vertices = V )
L = P.lattice_polytope()
print "P has the following vertices:"
pprint.pprint( P.vertices_list() )
print "A plot of P..."
P.plot()
# (1) associate the fan of the polyhedron P
F = FaceFan( L )
# (2) plot the fan
print "The fan of the lattice L is as follows..."
F.plot()
print "The rays of the fan F are as follows:"
print F.rays()
# (3) associate the toric variety of the fan
T = ToricVariety( F )
print "A plot of the associated toric variety T..."
T.plot()
# (4) dual fan (?)
# there is only a dual lattice, that i can associate to a given lattice.
# or we may pass from a cone to its dual cone,
# but this is an operation that may map
# disjoint (open) cones to intersecting dual cones.
# example
c = F.cones()[3][0] # first cone in the fan F
print "The rays of the first cone are:\n", c.rays()
plot(c)
cd = c.dual()
print "The rays of its dual cone are:\n", cd.rays()
plot(cd)
</code></pre>
<p>Methods of the constructed objects can be detected by using <code>dir</code>, e.g. <code>dir(F)</code>, or
using in the sage console the TAB-extensions list. (For this, type <code>F.</code>, then hit the TAB (twice).) </p>
https://ask.sagemath.org/question/39468/visualizing-toric-fans-in-sage/?comment=39588#post-id-39588Thank you, Dan! Sorry for my late reply. This is indeed helpful. I meant "dual toric diagram" not "dual fan" (thanks for correcting me). What if I had to go backward (dual of dual toric diagram)? Would this method still work?
If you see https://arxiv.org/pdf/0706.1310.pdf, essentially what I want to do is generate either one of Figure 2.3 given the other.Wed, 15 Nov 2017 22:09:44 +0100https://ask.sagemath.org/question/39468/visualizing-toric-fans-in-sage/?comment=39588#post-id-39588