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

Closed
Shekharrajak opened this Issue Aug 19, 2016 · 2 comments

Projects

None yet

2 participants

@Shekharrajak
Member
In [1]: solveset(-y + x/sqrt(-x**2 + 1),x ,S.Reals)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-3da20c9df9b9> in <module>()
----> 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

Original : https://groups.google.com/forum/#!msg/sympy/YtQYNVQGGqY/8dAEcQwkAgAJ

@Shekharrajak
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 ⎬⎟
⎝                ⎩  ⎭⎠
@nikoskaragiannakis
Contributor

I'd like to work on this. I think I have a solution

@nikoskaragiannakis nikoskaragiannakis added a commit to nikoskaragiannakis/sympy that referenced this issue Aug 21, 2016
@nikoskaragiannakis 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
@smichr smichr closed this in #11537 Sep 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment