{"action":"created","issue":{"url":"https://api.github.com/repos/sympy/csympy/issues/371","labels_url":"https://api.github.com/repos/sympy/csympy/issues/371/labels{/name}","comments_url":"https://api.github.com/repos/sympy/csympy/issues/371/comments","events_url":"https://api.github.com/repos/sympy/csympy/issues/371/events","html_url":"https://github.com/sympy/csympy/issues/371","id":54688406,"number":371,"title":"(1/(x+y)).expand() should do nothing","user":{"login":"certik","id":20568,"avatar_url":"https://avatars.githubusercontent.com/u/20568?v=3","gravatar_id":"","url":"https://api.github.com/users/certik","html_url":"https://github.com/certik","followers_url":"https://api.github.com/users/certik/followers","following_url":"https://api.github.com/users/certik/following{/other_user}","gists_url":"https://api.github.com/users/certik/gists{/gist_id}","starred_url":"https://api.github.com/users/certik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/certik/subscriptions","organizations_url":"https://api.github.com/users/certik/orgs","repos_url":"https://api.github.com/users/certik/repos","events_url":"https://api.github.com/users/certik/events{/privacy}","received_events_url":"https://api.github.com/users/certik/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sympy/csympy/labels/bug","name":"bug","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-18T06:42:48Z","updated_at":"2015-01-19T16:46:35Z","closed_at":null,"body":"Currently it raises this unhelpful exception:\r\n```\r\nIn [6]: (1/(x+y)).expand()\r\n---------------------------------------------------------------------------\r\nRuntimeError                              Traceback (most recent call last)\r\n<ipython-input-6-5a1624685c2a> in <module>()\r\n----> 1 (1/(x+y)).expand()\r\n\r\n/home/ondrej/repos/csympy/csympy/lib/csympy_wrapper.so in csympy.lib.csympy_wrapper.Basic.expand (/home/ondrej/repos/csympy/csympy/lib/csympy_wrapper.cpp:5842)()\r\n\r\nRuntimeError: multinomial_coefficients: n >= 0 must hold.\r\n```"},"comment":{"url":"https://api.github.com/repos/sympy/csympy/issues/comments/70524335","html_url":"https://github.com/sympy/csympy/issues/371#issuecomment-70524335","issue_url":"https://api.github.com/repos/sympy/csympy/issues/371","id":70524335,"user":{"login":"shivamvats","id":6918975,"avatar_url":"https://avatars.githubusercontent.com/u/6918975?v=3","gravatar_id":"","url":"https://api.github.com/users/shivamvats","html_url":"https://github.com/shivamvats","followers_url":"https://api.github.com/users/shivamvats/followers","following_url":"https://api.github.com/users/shivamvats/following{/other_user}","gists_url":"https://api.github.com/users/shivamvats/gists{/gist_id}","starred_url":"https://api.github.com/users/shivamvats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shivamvats/subscriptions","organizations_url":"https://api.github.com/users/shivamvats/orgs","repos_url":"https://api.github.com/users/shivamvats/repos","events_url":"https://api.github.com/users/shivamvats/events{/privacy}","received_events_url":"https://api.github.com/users/shivamvats/received_events","type":"User","site_admin":false},"created_at":"2015-01-19T16:46:35Z","updated_at":"2015-01-19T16:46:35Z","body":"The issue is actually a  little more general. multinomial_coefficients_mpz can handle only positive exponents but pow_expand doesn't do any check on the exponent. So any expression having an over-all negative power will fail:\r\n```\r\nIn [15]: (1/(x+y)**2).expand()\r\n---------------------------------------------------------------------------\r\nRuntimeError                              Traceback (most recent call last)\r\n<ipython-input-15-5ebf383efd62> in <module>()\r\n----> 1 (1/(x+y)**2).expand()\r\n\r\n/home/aries/gsoc/csympy/csympy/lib/csympy_wrapper.so in csympy.lib.csympy_wrapper.Basic.expand (/home/aries/gsoc/csympy/csympy/lib/csympy_wrapper.cpp:6627)()\r\n\r\nRuntimeError: multinomial_coefficients: n >= 0 must hold.\r\n```\r\nThough the easy solution is to return an unevaluated expression, expanding the denominator seems better."}}