On Fri, Oct 19, 2012 at 5:42 AM, Dima Pasechnik <[email protected]> wrote: > > > On Friday, 19 October 2012 05:13:55 UTC+8, Ken Ribet wrote: >> >> Thanks to everyone for the explanation of why my comparison of rational >> numbers did not work. I'd like to make two comments: >> >> 1. I got into this mess by trying to count points above and below the line >> in the standard textbook proof of quadratic reciprocity. You have two odd >> primes p and q, make the grid of integers whose x-coordinates run between 1 >> and (p-1)/2 and whose y-coordinates run between 1 and (q-1)/2, and draw the >> line through the origin with slope q/p. I drew a beautiful picture for my >> students but then miscounted the points below the line by using a rational >> number comparison instead of the apparently equivalent integer comparison >> (gotten by cross-multiplying). The count looked more realistic after I >> cross-multiplied! >> >> 2. It occurred to me that the integers that I was dividing were of the >> wrong "type." I asked sage what was going on and interpreted the output >> <type 'int'> >> as referring to a standard sage integer. I had no clue that I should have >> been looking for >> <type 'sage.rings.integer.Integer'> > > > it's possible to handle this in "plain" Python 2, as follows: > $ python > Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) > [GCC 4.4.5] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> from __future__ import division >>>> 1/3 > 0.33333333333333331 >>>>
Yep, and: blastoff:svr wstein$ sage ---------------------------------------------------------------------- | Sage Version 5.2, Release Date: 2012-07-25 | | Type "notebook()" for the browser-based notebook interface. | | Type "help()" for help. | ---------------------------------------------------------------------- sage: from __future__ import division sage: len([1,2])/len([1,2,3]) 0.6666666666666666 -- You received this message because you are subscribed to the Google Groups "sage-support" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-support?hl=en.
