{"action":"created","issue":{"url":"https://api.github.com/repos/sympy/sympy/issues/12873","repository_url":"https://api.github.com/repos/sympy/sympy","labels_url":"https://api.github.com/repos/sympy/sympy/issues/12873/labels{/name}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/12873/comments","events_url":"https://api.github.com/repos/sympy/sympy/issues/12873/events","html_url":"https://github.com/sympy/sympy/issues/12873","id":240040211,"number":12873,"title":"Eq with Poly object immediately evaulates to False","user":{"login":"user234683","id":28744867,"avatar_url":"https://avatars0.githubusercontent.com/u/28744867?v=3","gravatar_id":"","url":"https://api.github.com/users/user234683","html_url":"https://github.com/user234683","followers_url":"https://api.github.com/users/user234683/followers","following_url":"https://api.github.com/users/user234683/following{/other_user}","gists_url":"https://api.github.com/users/user234683/gists{/gist_id}","starred_url":"https://api.github.com/users/user234683/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/user234683/subscriptions","organizations_url":"https://api.github.com/users/user234683/orgs","repos_url":"https://api.github.com/users/user234683/repos","events_url":"https://api.github.com/users/user234683/events{/privacy}","received_events_url":"https://api.github.com/users/user234683/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-07-02T23:00:16Z","updated_at":"2017-07-09T21:44:53Z","closed_at":null,"body":"```\r\n>>> Eq(Poly((x-1)*(x-2),x),0)\r\nFalse\r\n```\r\n```\r\n>>> Eq((x-1)*(x-2),0)\r\nEq((x - 2)*(x - 1), 0)\r\n```\r\nThis happens because in the `Equality` class, this code calls `is_zero` on the `Poly`:\r\n```python\r\nif all(isinstance(i, Expr) for i in (lhs, rhs)):\r\n    # see if the difference evaluates\r\n    dif = lhs - rhs\r\n    z = dif.is_zero\r\n    if z is not None:\r\n        if z is False and dif.is_commutative:  # issue 10728\r\n            return S.false\r\n        if z:\r\n            return S.true\r\n```\r\nAnd `is_zero` in `Poly` returns `True` if the poly is a zero-polynomial, and `False` if it's not, rather than returning whether it is *equal* to 0, which it still might be depending on the variables even if it's not a zero polynomial. I think this is an accidental name-collision.\r\n\r\nNote: This bug doesn't reveal itself in the 1.0 release because `Equality` checks `if lhs.is_complex and rhs.is_complex`, which always gives `None`, before calling `is_zero`"},"comment":{"url":"https://api.github.com/repos/sympy/sympy/issues/comments/313967513","html_url":"https://github.com/sympy/sympy/issues/12873#issuecomment-313967513","issue_url":"https://api.github.com/repos/sympy/sympy/issues/12873","id":313967513,"user":{"login":"user234683","id":28744867,"avatar_url":"https://avatars0.githubusercontent.com/u/28744867?v=3","gravatar_id":"","url":"https://api.github.com/users/user234683","html_url":"https://github.com/user234683","followers_url":"https://api.github.com/users/user234683/followers","following_url":"https://api.github.com/users/user234683/following{/other_user}","gists_url":"https://api.github.com/users/user234683/gists{/gist_id}","starred_url":"https://api.github.com/users/user234683/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/user234683/subscriptions","organizations_url":"https://api.github.com/users/user234683/orgs","repos_url":"https://api.github.com/users/user234683/repos","events_url":"https://api.github.com/users/user234683/events{/privacy}","received_events_url":"https://api.github.com/users/user234683/received_events","type":"User","site_admin":false},"created_at":"2017-07-09T21:44:53Z","updated_at":"2017-07-09T21:44:53Z","body":"Ah ok. Perhaps the documentation should clarify this, because I was thinking of Poly objects as a more efficient representation of polynomial expressions with specialized methods and as interchangeable with expressions, rather than a different kind of mathematical object.\r\n\r\nBut I'm still a bit confused. \r\n```\r\n>>> Eq(Poly(x**2+1,x), x**2+1)\r\nTrue\r\n```\r\nShouldn't this evaluate to False, since \" x**2+1 \" isn't part of a polynomial ring? Or what if it is, and x is actually Poly( x - 1, x) for instance?\r\n```\r\nEq( Poly(x**2 + 1, x),  Poly(x**2 - 2*x + 2, x) )\r\n```\r\nWould this be false?"}}
{"actor":{"display_login":"user234683"}}