# Plotting point when coordinate involves symbolic and numerical values

Consider the following single piece of code:

point([real_part(zeta(I))+1,0])


When trying to compile it, I get the following error message:

Error in lines 1-1
Traceback (most recent call last):
File "/projects/sage/sage-7.3/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 957, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 1, in <module>
File "/projects/sage/sage-7.3/local/lib/python2.7/site-packages/sage/plot/point.py", line 353, in point
return point3d(points, **kwds)
File "/projects/sage/sage-7.3/local/lib/python2.7/site-packages/sage/plot/plot3d/shapes2.py", line 1143, in point3d
A = sum([Point(z, size, **kwds) for z in v])
File "/projects/sage/sage-7.3/local/lib/python2.7/site-packages/sage/plot/plot3d/shapes2.py", line 720, in __init__
self.loc = (float(center[0]), float(center[1]), float(center[2]))
TypeError: 'sage.symbolic.expression.Expression' object does not support indexing


Is there some simple way to fix this?

Interesting note: I have played around with this error, and it is very unclear to me when it does or doesn't appear. Here are some examples of when the error does appear (as far as I've checked, the traceback is always the same):

point([real_part(zeta(I))+1,0])
point([real_part(zeta(I))*2,0])
point([real_part(zeta(I))+real_part(zeta(I)),0])
point([real_part(zeta(I))/2,0])
point([real_part(zeta(I))-real_part(zeta(2*I)),0])


Here are some examples where it doesn't appear:

point([real_part(zeta(I))+0,0])
point([real_part(zeta(I))*1,0])
point([real_part(zeta(I))*real_part(zeta(I)),0])
point([real_part(zeta(I))+real_part(zeta(2*I)),0])
point([real_part(zeta(I))+imag_part(zeta(I)),0])


(edit: the error doesn't seem to ever occur if we give the zeta function a real argument)

I'd be interested if someone figured out under what conditions the error appears or not, because I fail to see any pattern. Thank you in advance.

edit retag close merge delete

Sort by » oldest newest most voted

First, i can not reproduce your problem on Sage 7.4.beta6. Which version are you using ? Perhaps upgrading will solve your issue.

Meanwhile, you should fix your problem by explicitely transforming your symbolic expression into a floating-point number:

sage: point([RDF(real_part(zeta(I))+1),0])
Launched png viewer for Graphics object consisting of 1 graph

more

I can reproduce the problem with Sage 7.3 and Sage 7.4.beta1, so probably it has been fixed somewhere between 7.4.beta1 and 7.4.beta6.

( 2016-09-26 02:39:10 -0500 )edit

Hello, sorry for a late reply, I was away from home. I am using SageMathCloud, and I'm not sure what version it's running (my guess is 7.3, latest stable). I also have version 7.2 downloaded on a Windows machine, but I didn't try running the code there, and I don't know where I could download beta versions. Anyways, using RDF fixed the problem, so I am willing to accept this answer.

( 2016-10-02 03:34:09 -0500 )edit