Ask Your Question
0

Plotting point when coordinate involves symbolic and numerical values

asked 2016-09-25 13:21:03 -0500

Wojowu gravatar image

updated 2016-09-25 13:28:56 -0500

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 flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-09-25 15:13:28 -0500

tmonteil gravatar image

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
edit flag offensive delete link more

Comments

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.

eric_g gravatar imageeric_g ( 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.

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-09-25 13:21:03 -0500

Seen: 49 times

Last updated: Sep 25 '16