On 18/10/2012 15:00, Kenneth A. Ribet wrote:
Hi Sage Gurus,

Am I doing something stupid here:

sage: print 1/2 < 3/7
sage: L=[]
sage: for i in range(2,3):
...       for j in range(1,2):
...           L.append([i,j])
...
sage: print L
sage: for P in L:
...       print P[1], P[0]
...       P[1]/P[0] < 3/7
False
[[2, 1]]
1 2
True

----

In plain language:

I ask sage whether 1/2 is less than 3/7, and sage tells me "false."

I then create the list L = [[2,1]] and loop through L (which has only one element).  For P=[2,1], I ask sage 
whether P[1]/P[0] is less than 3/7 and get "true".  The conundrum is that P[1]/P[0] is 1/2, so 
mathematically I'm getting the answers "false" and then "true" for the same question.

I don't have time to check, but I think the problem is that your list elements are created as Python integers rather than Sage integers. Therefore, the / operator does integer part tivision, that is p[1]/p[0] is evaluating to 0, hence the comparison is correct.

Alastair Irving

--
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.


Reply via email to