You need to type Rational(1, 2)
, or, more concisely, S(1)/2
.
See http://docs.sympy.org/latest/tutorial/gotchas.html#two-final-notes-and. 1/2
is entirely Python: no SymPy types are involved. The only way to get Python from doing what it does with int/int (integer division in Python 2 and float division in Python 3 or Python 2 with from __future__ import division
) is to use a SymPy type somewhere, which is what both of the above do.