You can also use the assumptions system to learn about the attributes of an expression. There was a recent question about this here , where Nair gives good links. But for your case, just try
>>> from sympy import * >>> var('x', real=True) x >>> (sin(x)+1).is_positive >>> (sin(x)+1).is_nonnegative
The result will be either True or False, or (in this case) None. None means that the result is unknown or that the definition was not implemented. In this case, the result for non-negative should be True. Improving the assumptions system is an active work with SymPy.
source share