Ask Your Question

Revision history [back]

I think I can address your last problem: 2 is being treated like a python int, but the exponent, apparently, is a sage.rings.real_mpfr.RealNumber. I can reproduce this error with

sage: int(2)**.5
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
...
TypeError: unsupported operand type(s) for ** or pow(): 'int' and 'sage.rings.real_mpfr.RealLiteral'

On the other hand, both of the following work:

sage: x = Integer(2)**.5; x
1.41421356237310
sage: type(x)
<type 'sage.rings.real_mpfr.RealNumber'>

sage: y = int(2)**float(.5); y
1.4142135623730951
sage: type(y)
<type 'float'>

So depending on what you need, you could either change dj to a python float, or change 2 to a sage integer.