invert is not working for x**2*y**2 + x**2 - y**2=0, x #11534

Closed
opened this Issue Aug 19, 2016 · 2 comments

None yet

2 participants

Member
 ``````In [1]: solveset(-y + x/sqrt(-x**2 + 1),x ,S.Reals) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) in () ----> 1 solveset(-y + x/sqrt(-x**2 + 1),x ,S.Reals) /root/sympy/sympy/solvers/solveset.pyc in solveset(f, symbol, domain) 865 return result 866 --> 867 return _solveset(f, symbol, domain, _check=True) 868 869 /root/sympy/sympy/solvers/solveset.pyc in _solveset(f, symbol, domain, _check) 686 result += _solve_radical(equation, 687 symbol, --> 688 solver) 689 elif equation.has(Abs): 690 result += _solve_abs(f, symbol, domain) /root/sympy/sympy/solvers/solveset.pyc in _solve_radical(f, symbol, solveset_solver) 510 for g_y in g_y_s]) 511 --> 512 return FiniteSet(*[s for s in result if checksol(f, symbol, s) is True]) 513 514 TypeError: 'Complement' object is not iterable ``````
Member
 solveset should be able to solve this : ``````In [ ]: solveset(x**2*y**2 + x**2 - y**2,x,S.Reals) Out[ ]: ⎧ 2 2 2 2 ⎫ ⎨x | x ∊ ℝ ∧ x ⋅y + x - y = 0⎬ ⎩ ⎭ `````` Ans : `x = ±y/sqrt(y^2+1) and y^2+1!=0` In other words : `invert` should work(lhs side only `x`) for this simple case: ``````In [13]: invert_real(x**2*y**2 + x**2 - y**2, 0, x) Out[13]: ⎛ 2 2 2 ⎧ 2⎫⎞ ⎜x ⋅y + x , ℝ ∩ ⎨y ⎬⎟ ⎝ ⎩ ⎭⎠ ``````
Contributor
 I'd like to work on this. I think I have a solution
added a commit to nikoskaragiannakis/sympy that referenced this issue Aug 21, 2016
 nikoskaragiannakis `Fix for #11534` ```In case of equations with radicals, the result is a FiniteSet consisted of checked solutions of the 'result' calculated inside _solve_radical helper function. If the equation to solve does not satisfy the requirements needed in order to remove the radicals (defined inside sympy.solvers.unrad function), 'cov' is empty and, therefore, the 'result' gets to be a Complement object. In such a case, the Comlplement needs to be returned, instead of a FiniteSet object. For example: eq1 = -y + x/sqrt(-x**2 + 1) and eq2 = -y**2 + x**2/(-x**2 +1) should have the same solution, which is sol = Complement(FiniteSet(-y/sqrt(y**2 + 1), y/sqrt(y**2 + 1)), FiniteSet(-1, 1))``` `58aac51`
referenced this issue Aug 21, 2016
Merged

11534: Solutions for equations with radicals #11537

closed this in #11537 Sep 5, 2016