(x-y).could_extract_minus_sign() is supposed to do this. According to
the docstring "For any expression, the set
{e.could_extract_minus_sign(),
(-e).could_extract_minus_sign()} must be {True, False}."
So, something like
if expr.could_extract_minus_sign():
return -expr
else:
r
Luke wrote:
> It is late, but it seems to me that [2] should evaluate true, for any
> x and y, not just real x and y. Should also work for functions.
>
> In [1]: cos(x - 1) == cos(1 - x)
> Out[1]: True
>
> In [2]: cos(x - y) == cos(y - x)
> Out[2]: False
>
> In [3]: x = Symbol('x', real=True)
Aaron was correct, it was late at night (or early in the morning).
Ondrej, can you elaborate on what you mean by canonical form? Do you
mean something should be done in cos.canonize? Currently canonize
just call cls.eval(arg).
I'm unclear why it works for 1 and x, i.e. cos(1-x)==cos(x-1), but
On May 29, 2009, at 9:25 AM, Ondrej Certik wrote:
>
> On Fri, May 29, 2009 at 2:24 AM, Luke wrote:
>>
>> It is late, but it seems to me that [2] should evaluate true, for any
>
> Why is it late?
I think because he sent it at 2:30 in the morning.
Aaron Meurer
--~--~-~--~~-
On Fri, May 29, 2009 at 2:24 AM, Luke wrote:
>
> It is late, but it seems to me that [2] should evaluate true, for any
Why is it late?
> x and y, not just real x and y. Should also work for functions.
>
> In [1]: cos(x - 1) == cos(1 - x)
> Out[1]: True
>
> In [2]: cos(x - y) == cos(y - x)
> Ou