Ask Your Question

# Revision history [back]

Yes, you should be able to plot prime_pi, using just the code you tried! Unfortunately it seems that plot can not always figure out what to evaluate, so you have to help it a little, using a lambda function:

sage: plot(lambda x: prime_pi(x),3,10)


or, equivalently,

sage: f = lambda x: prime_pi(x)
sage: plot(f,3,10)


There have been a number of similar problems with similar solutions mentioned on this site . . . maybe eventually someone will extend plot so that the code you tried first will work. At least in the meantime someone could change the error message to suggest trying lambda functions . . .

Yes, you should be able to plot prime_pi, using just the code you tried! Unfortunately it seems that plot can not always figure out what to evaluate, so you have to help it a little, using a lambda function:

sage: plot(lambda x: prime_pi(x),3,10)


or, equivalently,

sage: f = lambda x: prime_pi(x)
sage: plot(f,3,10)


There have been a number of similar problems with similar solutions mentioned on this site . . . maybe eventually someone will extend plot so that the code you tried first will work. At least in the meantime someone could change the error message to suggest trying lambda functions . . .

Also, could you tell us where you read about the plot function? It could be very useful to include an example like this somewhere that people will find it :)