Strangeness in complex plotting

17 views
Skip to first unread message

Emmanuel Charpentier

unread,
Aug 12, 2014, 8:47:36 AM8/12/14
to sage-s...@googlegroups.com


This I don't understand :

sage: var("z")
z
sage: points(map(lambda x:x[0].N(),(z^20+1).roots()), figsize=4, aspect_ratio=1)

[ Gives the expected result (enclosed) ]



sage: points(map(lambda x:x[0].N(),(z^20-1).roots()), figsize=4, aspect_ratio=1)
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-8-9d1343466bbc> in <module>()
----> 1 points(map(lambda x:x[Integer(0)].N(),(z**Integer(20)-Integer(1)).roots()), figsize=Integer(4), aspect_ratio=Integer(1))

/usr/local/sage-6.3/local/lib/python2.7/site-packages/sage/plot/point.pyc in point(points, **kwds)
    312     except (ValueError, TypeError):
    313         from sage.plot.plot3d.shapes2 import point3d
--> 314         return point3d(points, **kwds)
    315
    316 @rename_keyword(color='rgbcolor', pointsize='size')

/usr/local/sage-6.3/local/lib/python2.7/site-packages/sage/plot/plot3d/shapes2.pyc in point3d(v, size, **kwds)
   1042             pass
   1043
-> 1044     A = sum([Point(z, size, **kwds) for z in v])
   1045     A._set_extra_kwds(kwds)
   1046     return A

/usr/local/sage-6.3/local/lib/python2.7/site-packages/sage/plot/plot3d/shapes2.pyc in __init__(self, center, size, **kwds)
    684         """
    685         PrimitiveObject.__init__(self, **kwds)
--> 686         self.loc = (float(center[0]), float(center[1]), float(center[2]))
    687         self.size = size
    688         self._set_extra_kwds(kwds)

/usr/local/sage-6.3/local/lib/python2.7/site-packages/sage/rings/complex_number.so in sage.rings.complex_number.ComplexNumber.__getitem__ (build/cythonized/sage/rings/complex_number.c:5225)()

IndexError: i must be between 0 and 1.

Seems to be a problem with points().

Advice ? Ticket to create ?

HTH,

--
Emmanuel Charpentier

tmp_HT3Lpm.png

kcrisman

unread,
Aug 12, 2014, 9:26:34 AM8/12/14
to sage-s...@googlegroups.com
sage: points(map(lambda x:x[0].N(),(z^20+1).roots()), figsize=4, aspect_ratio=1)



These are all "complex".

 

sage: points(map(lambda x:x[0].N(),(z^20-1).roots()), figsize=4, aspect_ratio=1)

map(lambda x:x[0].N(),(z^20-1).roots())
[0.951056516295154 + 0.309016994374947*I, 0.809016994374947 +
0.587785252292473*I, 0.587785252292473 + 0.809016994374947*I,
0.309016994374947 + 0.951056516295154*I, 1.00000000000000*I,
-0.309016994374947 + 0.951056516295154*I, -0.587785252292473 +
0.809016994374947*I, -0.809016994374947 + 0.587785252292473*I,
-0.951056516295154 + 0.309016994374948*I, -1.00000000000000,
-0.951056516295154 - 0.309016994374948*I, -0.809016994374947 -
0.587785252292473*I, -0.587785252292473 - 0.809016994374947*I,
-0.309016994374947 - 0.951056516295154*I, -1.00000000000000*I,
0.309016994374947 - 0.951056516295154*I, 0.587785252292473 -
0.809016994374947*I, 0.809016994374947 - 0.587785252292473*I,
0.951056516295154 - 0.309016994374947*I, 1.00000000000000]

Notice that several are 'imaginary' or 'real'.  So point must be getting confused by this; indeed,
points(map(lambda x:x[0].N(),(z^20-1).roots())[:4], figsize=4, aspect_ratio=1)
works fine.
 
Advice ? Ticket to create ?


Yes, please create a ticket!  In the meantime,

points(map(lambda x:CC(x[0].N()),(z^20-1).roots()), figsize=4, aspect_ratio=1)

works nicely, I think. 

Emmanuel Charpentier

unread,
Aug 12, 2014, 1:58:49 PM8/12/14
to sage-s...@googlegroups.com
Trac#16804 created.

It seems (see second example in the ticket) that pure imaginary (i. e. real(x)==0) are plotted without problem.

HTH,

--
Emmanuel Charpentier
Reply all
Reply to author
Forward
0 new messages