#NEWLINE# def solveset( f , symbol = None , domain = S . Complexes ) : #NEWLINE# #INDENT# "Solves a given inequality or equation with set as output\n\n    Parameters\n    ==========\n\n    f : Expr or a relational.\n        The target equation or inequality\n    symbol : Symbol\n        The variable for which the equation is solved\n    domain : Set\n        The domain over which the equation is solved\n\n    Returns\n    =======\n\n    Set\n        A set of values for `symbol` for which `f` is True or is equal to\n        zero. An `EmptySet` is returned if `f` is False or nonzero.\n        A `ConditionSet` is returned as unsolved object if algorithms\n        to evaluatee complete solution are not yet implemented.\n\n    `solveset` claims to be complete in the solution set that it returns.\n\n    Raises\n    ======\n\n    NotImplementedError\n        The algorithms to solve inequalities in complex domain  are\n        not yet implemented.\n    ValueError\n        The input is not valid.\n    RuntimeError\n        It is a bug, please report to the github issue tracker.\n\n\n    Notes\n    =====\n\n    Python interprets 0 and 1 as False and True, respectively, but\n    in this function they refer to solutions of an expression. So 0 and 1\n    return the Domain and EmptySet, respectively, while True and False\n    return the opposite (as they are assumed to be solutions of relational\n    expressions).\n\n\n    See Also\n    ========\n\n    solveset_real: solver for real domain\n    solveset_complex: solver for complex domain\n\n    Examples\n    ========\n\n    >>> from sympy import exp, sin, Symbol, pprint, S\n    >>> from sympy.solvers.solveset import solveset, solveset_real\n\n    * The default domain is complex. Not specifying a domain will lead\n      to the solving of the equation in the complex domain (and this\n      is not affected by the assumptions on the symbol):\n\n    >>> x = Symbol('x')\n    >>> pprint(solveset(exp(x) - 1, x), use_unicode=False)\n    {2*n*I*pi | n in Integers()}\n\n    >>> x = Symbol('x', real=True)\n    >>> pprint(solveset(exp(x) - 1, x), use_unicode=False)\n    {2*n*I*pi | n in Integers()}\n\n    * If you want to use `solveset` to solve the equation in the\n      real domain, provide a real domain. (Using `solveset\\_real`\n      does this automatically.)\n\n    >>> R = S.Reals\n    >>> x = Symbol('x')\n    >>> solveset(exp(x) - 1, x, R)\n    {0}\n    >>> solveset_real(exp(x) - 1, x)\n    {0}\n\n    The solution is mostly unaffected by assumptions on the symbol,\n    but there may be some slight difference:\n\n    >>> pprint(solveset(sin(x)/x,x), use_unicode=False)\n    ({2*n*pi | n in Integers()} \\ {0}) U ({2*n*pi + pi | n in Integers()} \\ {0})\n\n    >>> p = Symbol('p', positive=True)\n    >>> pprint(solveset(sin(p)/p, p), use_unicode=False)\n    {2*n*pi | n in Integers()} U {2*n*pi + pi | n in Integers()}\n\n    * Inequalities can be solved over the real domain only. Use of a complex\n      domain leads to a NotImplementedError.\n\n    >>> solveset(exp(x) > 1, x, R)\n    (0, oo)\n\n    " #NEWLINE# f = sympify ( f ) #NEWLINE# if ( f is S . true ) : #NEWLINE# #INDENT# return domain #NEWLINE# #UNINDENT# if ( f is S . false ) : #NEWLINE# #INDENT# return S . EmptySet #NEWLINE# #UNINDENT# if ( not isinstance ( f , ( Expr , Number ) ) ) : #NEWLINE# #INDENT# raise ValueError ( ( '%s is not a valid SymPy expression' % f ) ) #NEWLINE# #UNINDENT# free_symbols = f . free_symbols #NEWLINE# if ( not free_symbols ) : #NEWLINE# #INDENT# b = Eq ( f , 0 ) #NEWLINE# if ( b is S . true ) : #NEWLINE# #INDENT# return domain #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( b is S . false ) : #NEWLINE# #INDENT# return S . EmptySet #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise NotImplementedError ( filldedent ( ( '\n                relationship between value and 0 is unknown: %s' % b ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( symbol is None ) : #NEWLINE# #INDENT# if ( len ( free_symbols ) == 1 ) : #NEWLINE# #INDENT# symbol = free_symbols . pop ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( filldedent ( '\n                The independent variable must be specified for a\n                multivariate equation.' ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( not getattr ( symbol , 'is_Symbol' , False ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'A Symbol must be given, not type %s: %s' % ( type ( symbol ) , symbol ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if isinstance ( f , Eq ) : #NEWLINE# #INDENT# from sympy.core import Add #NEWLINE# f = Add ( f . lhs , ( - f . rhs ) , evaluate = False ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if f . is_Relational : #NEWLINE# #INDENT# if ( not domain . is_subset ( S . Reals ) ) : #NEWLINE# #INDENT# raise NotImplementedError ( filldedent ( '\n                Inequalities in the complex domain are\n                not supported. Try the real domain by\n                setting domain=S.Reals' ) ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# result = ( solve_univariate_inequality ( f , symbol , relational = False ) - _invalid_solutions ( f , symbol , domain ) ) #NEWLINE# #UNINDENT# except NotImplementedError : #NEWLINE# #INDENT# result = ConditionSet ( symbol , f , domain ) #NEWLINE# #UNINDENT# return result #NEWLINE# #UNINDENT# #UNINDENT# return _solveset ( f , symbol , domain , _check = True )