{"action":"created","issue":{"url":"https://api.github.com/repos/sympy/sympy/issues/10161","labels_url":"https://api.github.com/repos/sympy/sympy/issues/10161/labels{/name}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/10161/comments","events_url":"https://api.github.com/repos/sympy/sympy/issues/10161/events","html_url":"https://github.com/sympy/sympy/issues/10161","id":117916245,"number":10161,"title":"factor gives an invalid expression","user":{"login":"asmeurer","id":71486,"avatar_url":"https://avatars.githubusercontent.com/u/71486?v=3","gravatar_id":"","url":"https://api.github.com/users/asmeurer","html_url":"https://github.com/asmeurer","followers_url":"https://api.github.com/users/asmeurer/followers","following_url":"https://api.github.com/users/asmeurer/following{/other_user}","gists_url":"https://api.github.com/users/asmeurer/gists{/gist_id}","starred_url":"https://api.github.com/users/asmeurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmeurer/subscriptions","organizations_url":"https://api.github.com/users/asmeurer/orgs","repos_url":"https://api.github.com/users/asmeurer/repos","events_url":"https://api.github.com/users/asmeurer/events{/privacy}","received_events_url":"https://api.github.com/users/asmeurer/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sympy/sympy/labels/core","name":"core","color":"0000FF"},{"url":"https://api.github.com/repos/sympy/sympy/labels/polys","name":"polys","color":"0000FF"},{"url":"https://api.github.com/repos/sympy/sympy/labels/Wrong%20Result","name":"Wrong Result","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-19T21:54:46Z","updated_at":"2015-11-19T22:11:55Z","closed_at":null,"body":"This was reported on the mailing list a while back\r\n\r\n```\r\nIn [29]: h = 2*x*(-2*x + Abs(x))*(x**2 - 1)/Abs(x**2 - 1) + (x/Abs(x) - 2)*Abs(x**2 - 1)\r\n\r\nIn [30]: print(factor(h))\r\n(x - 1)*(x**4 - 6*x**3*Abs(x) + x**3 - 6*x**2*Abs(x) + x**2 + 2*x*Abs(x) - x + 2*Abs(x))/(Abs(x)*Abs(x**2 - 1))\r\n\r\nIn [31]: h.subs(x, 2)\r\nOut[31]: -11\r\n\r\nIn [32]: factor(h).subs(x, 2)\r\nOut[32]: -53/3\r\n```"},"comment":{"url":"https://api.github.com/repos/sympy/sympy/issues/comments/158216647","html_url":"https://github.com/sympy/sympy/issues/10161#issuecomment-158216647","issue_url":"https://api.github.com/repos/sympy/sympy/issues/10161","id":158216647,"user":{"login":"asmeurer","id":71486,"avatar_url":"https://avatars.githubusercontent.com/u/71486?v=3","gravatar_id":"","url":"https://api.github.com/users/asmeurer","html_url":"https://github.com/asmeurer","followers_url":"https://api.github.com/users/asmeurer/followers","following_url":"https://api.github.com/users/asmeurer/following{/other_user}","gists_url":"https://api.github.com/users/asmeurer/gists{/gist_id}","starred_url":"https://api.github.com/users/asmeurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmeurer/subscriptions","organizations_url":"https://api.github.com/users/asmeurer/orgs","repos_url":"https://api.github.com/users/asmeurer/repos","events_url":"https://api.github.com/users/asmeurer/events{/privacy}","received_events_url":"https://api.github.com/users/asmeurer/received_events","type":"User","site_admin":false},"created_at":"2015-11-19T22:11:55Z","updated_at":"2015-11-19T22:11:55Z","body":"It used to work. I bisected it to \r\n\r\n\r\ncommit 246f52e36141783bdee253b518d8faad9366c44b\r\nAuthor: Aaron Meurer <asmeurer@gmail.com>\r\nDate:   Mon Jul 23 00:20:26 2012 -0600\r\n\r\n    Refactor expand() (again)\r\n\r\n    This is a continuation of the work that was started in\r\n    d166080d296249281289ec957ad2ef887dc43ed4.  This commit goes even further than\r\n    that one.\r\n\r\n    expand() now completely handles all the deep logic (i.e., recursion).\r\n    _eval_expand_hint() methods now are responsible only for expanding the\r\n    top-level expression.  This simplifies the code by a lot, removing duplicate\r\n    \"if deep: ...\" logic and putting it into expand() itself.  Old methods that\r\n    still do this should still work, albeit less efficiently, with the exception\r\n    that deep is no longer included as a keyword argument to _eval_expand_hint()\r\n    methods, so calls like _eval_expand_hint(deep, **hints) (as opposed to\r\n    _eval_expand_hint(deep=deep, **hints)) may fail.\r\n\r\n    Some _eval_expand_* methods had to be refactored a little to make things\r\n    still work.\r\n\r\n    Expr no longer defines no-op _eval_expand_* methods, meaning that only\r\n    relevant subclasses of Expr will have _eval_expand_hint defined for any hint.\r\n    Therefore, any calls to an _eval_expand_* method outside of an _eval_expand_*\r\n    method should be replaced with a call to the public expand() or expand_hint()\r\n    functions.\r\n\r\n    Like its predecessor, this commit does not yet touch expand_complex(), as\r\n    there are difficulties there with as_real_imag().\r\n\r\n    The updated expand() docstring explains more, especially the API section.\r\n"}}