Integer types and log()
I am working with a bunch of lists whose lengths are all powers of 2. I'd like to be able to extract the power by taking the base-2 log of the length. However, Sage wasn't able to simplify an expression like log(len(L),2), because apparently len() returns the wrong kind of integer:
sage: A=list(range(8)) sage: len(A) 8 sage: log(len(A),2) log(8)/log(2) sage: log(8,2) 3 sage: type(len(A)) <type 'int'> sage: type(8) <type 'sage.rings.integer.Integer'> sage: log(Integer(len(A)),2) 3
This is the first math function I've come across that seems to care about the distinction between these two kinds of integers, and it would be nice if it didn't, since it took me quite a while to figure out why Sage wouldn't simplify an expression like log(len(A),2).