Comment #2 on issue 2852 by smi...@gmail.com: is_constant(wrt) is needed
http://code.google.com/p/sympy/issues/detail?id=2852

And even if we can't prove that something is zero at least we can know if it's constant (see last example):


    >>> def is_constant(self, *wrt):
    ...     if self.is_Number or self.is_number:
    ...         return True
    ...     if not wrt:
    ...         free = self.free_symbols
    ...         if not free:
    ...             return True
    ...         # maybe false
    ...         free =list(free)
    ...         for i in range(len(free)):
    ...             deriv = self.diff(free[0])
... if expand_mul(deriv) != 0 and not is_constant(deriv, *free):
    ...                 return False
    ...             free.pop(0)
    ...         return True
    ...     if not self.has(*wrt) or not set(wrt) & self.free_symbols:
    ...         return True
    ...     # maybe true
    ...     return all(expand_mul(self.diff(v)) == 0 for v in wrt)
    ...
    >>> is_constant(Sum(x, (x, 1, 10)))
    True
    >>> is_constant(Sum(x, (x, 1, n)))
    False
    >>> is_constant(Sum(x, (x, 1, n)), y)
    True
    >>> is_constant(Sum(x, (x, 1, n)), n)
    False
    >>> is_constant(Sum(x, (x, 1, n)), x)
    True
    >>> is_constant(a*cos(x)**2+a*sin(x)**2-a)
    True
    >>> is_constant(a*cos(x)**2+a*sin(x)**2-1)
    True
    >>> (a*cos(x)**2+a*sin(x)**2-a).is_zero



--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to sympy-issues@googlegroups.com.
To unsubscribe from this group, send email to 
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to