{"action":"opened","issue":{"url":"https://api.github.com/repos/sympy/sympy/issues/10086","labels_url":"https://api.github.com/repos/sympy/sympy/issues/10086/labels{/name}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/10086/comments","events_url":"https://api.github.com/repos/sympy/sympy/issues/10086/events","html_url":"https://github.com/sympy/sympy/issues/10086","id":114378375,"number":10086,"title":"solve generates a NaN comparison error","user":{"login":"smichr","id":90703,"avatar_url":"https://avatars.githubusercontent.com/u/90703?v=3","gravatar_id":"","url":"https://api.github.com/users/smichr","html_url":"https://github.com/smichr","followers_url":"https://api.github.com/users/smichr/followers","following_url":"https://api.github.com/users/smichr/following{/other_user}","gists_url":"https://api.github.com/users/smichr/gists{/gist_id}","starred_url":"https://api.github.com/users/smichr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smichr/subscriptions","organizations_url":"https://api.github.com/users/smichr/orgs","repos_url":"https://api.github.com/users/smichr/repos","events_url":"https://api.github.com/users/smichr/events{/privacy}","received_events_url":"https://api.github.com/users/smichr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-31T00:52:27Z","updated_at":"2015-10-31T00:52:27Z","closed_at":null,"body":"```python\r\n>>> solve(Abs(x-4)-(x-1)/(x+2)-(x-3)/(x+1))\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"sympy\\solvers\\solvers.py\", line 1194, in solve\r\n    solution.sort(key=default_sort_key)\r\n  File \"sympy\\core\\numbers.py\", line 1807, in __lt__\r\n    return Rational.__lt__(self, other)\r\n  File \"sympy\\core\\numbers.py\", line 1485, in __lt__\r\n    return Expr.__lt__(expr, other)\r\n  File \"sympy\\core\\expr.py\", line 301, in __lt__\r\n    raise TypeError(\"Invalid NaN comparison\")\r\nTypeError: Invalid NaN comparison\r\n```\r\n\r\nIt looks like the problem is that it is trying to sort the solution which contains a nan. One can see the solutions it is working with by requesting a set:\r\n\r\n```\r\n>>> print filldedent(solve(Abs(x-4)-(x-1)/(x+2)-(x-3)/(x+1), set=True))\r\n\r\n([x], set([(1 + sqrt(6),), (Piecewise((2**(2/3)*(-4 + (1 +\r\nsqrt(3)*I)*(2 + (-1 - sqrt(3)*I)*(6 + 2*sqrt(7)*I)**(1/3))*(6 +\r\n2*sqrt(7)*I)**(1/3)/4)/((1 + sqrt(3)*I)*(3 + sqrt(7)*I)**(1/3)),\r\n2**(2/3)*(4 + (1 + sqrt(3)*I)*(6 + 2*sqrt(7)*I)**(1/3)*(6 + (1 +\r\nsqrt(3)*I)*(6 + 2*sqrt(7)*I)**(1/3))/4)/((1 + sqrt(3)*I)*(3 +\r\nsqrt(7)*I)**(1/3)) <= 0), (nan, True)),), (-sqrt(6) + 1,), (nan,),\r\n(-3,), (Piecewise((1 + 2*2**(2/3)/(3 + sqrt(7)*I)**(1/3) + 2**(1/3)*(3\r\n+ sqrt(7)*I)**(1/3), -3 + 2*2**(2/3)/(3 + sqrt(7)*I)**(1/3) +\r\n2**(1/3)*(3 + sqrt(7)*I)**(1/3) >= 0), (nan, True)),)]))\r\n```\r\n\r\nIt's interesting to see that a Piecewise is present because it couldn't decide the sign of an expression.\r\n\r\n\r\nBTW, the actual solutions (confirmed visually) are:\r\n\r\n```\r\n>>> nsolve(eq,-3)\r\nmpf('-3.0')\r\n>>> nsolve(eq,-1.5)\r\nmpf('-1.4494897427831781')\r\n>>> nsolve(eq,3.2)\r\nmpf('3.4494897427831781')\r\n>>> nsolve(eq,5)\r\nmpf('4.8844837019393323')\r\n```"}}