Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Well yes, of course. The sage environment uses a preparser. That is why the sage command line is not the same as the ipython command line. You can see what the preparser does by running it manually, like this:

sage: preparse('integrate(x^2,x)')

As you can see ** is the actual python command for taking powers. Whereas ^ does only xor operation. Similarly, the number 2 is not of type 'int' anymore. It is actually of type 'Integer', which is a sage object. The difference is quite stark - in particular, fractions are automatically changed to type QQ in sage, but not in ipython:

sage: preparser(False) # Turn off preparser
sage: 1/2
sage: preparser(True)  # This is the default when you start sage
sage: 1/2

If you want to use sage commands inside ipython then you have to stick to python commands. You can use sage commands, but not everything will automatically work unless coerced/typecast into the correct type. You can get more examples and information here.