On Aug 29, 2009, at 12:44 PM, Rolandb wrote: > > On 29 aug, 18:43, John H Palmieri <jhpalmier...@gmail.com> wrote: >> On Aug 29, 8:51 am, Simon King <simon.k...@nuigalway.ie> wrote: >> >>> Note that expon uses Maxima, because you use the logarithm. So, I >>> reckon that your problem is related withhttp://trac.sagemath.org/ >>> sage_trac/ticket/4731 >>> andhttp://trac.sagemath.org/sage_trac/ticket/6818. >>> If not, you might try to work around by thinking what "expon" really >>> does. For example, one of my first problems with Sage occurred >>> when I >>> used the logarithm for determining the number of digits of a natural >>> number n -- len(str(n)) is much faster! >> >> Or you can use "math.log" instead of "log" -- this should use the >> Python log function rather than the Maxima one: use >> >> def expon(mx,g): return floor(math.log(mx)/math.log(g))+1 >> >> John > > Hi, > > The whole issue boils down to: > > floor(log(256)/log(2))+1 > > which takes 'ages' to compute (Sage 4.1). > > print floor(ln(256)/ln(2))+1 is no improvement; floor(math.log(mx)/ > math.log(g))+1 is.
Ah, that makes sense. It is numerically computing this to higher and higher precision, trying to figure out whether or not it is greater than or less than 8. Of course, you can't do this with high precision arithmetic, so eventually it gives up. What we should do is also try to check to see if it is exactly equal to an integer symbolically before computing out too far...maybe even do both in parallel. sage: bool(log(256)/log(2) == 8) True - Robert --~--~---------~--~----~------------~-------~--~----~ 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 For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---