

def separatevars(expr, symbols=[], dict=False, force=False):
    "\n    Separates variables in an expression, if possible.  By\n    default, it separates with respect to all symbols in an\n    expression and collects constant coefficients that are\n    independent of symbols.\n\n    If dict=True then the separated terms will be returned\n    in a dictionary keyed to their corresponding symbols.\n    By default, all symbols in the expression will appear as\n    keys; if symbols are provided, then all those symbols will\n    be used as keys, and any terms in the expression containing\n    other symbols or non-symbols will be returned keyed to the\n    string 'coeff'. (Passing None for symbols will return the\n    expression in a dictionary keyed to 'coeff'.)\n\n    If force=True, then bases of powers will be separated regardless\n    of assumptions on the symbols involved.\n\n    Notes\n    =====\n    The order of the factors is determined by Mul, so that the\n    separated expressions may not necessarily be grouped together.\n\n    Although factoring is necessary to separate variables in some\n    expressions, it is not necessary in all cases, so one should not\n    count on the returned factors being factored.\n\n    Examples\n    ========\n\n    >>> from sympy.abc import x, y, z, alpha\n    >>> from sympy import separatevars, sin\n    >>> separatevars((x*y)**y)\n    (x*y)**y\n    >>> separatevars((x*y)**y, force=True)\n    x**y*y**y\n\n    >>> e = 2*x**2*z*sin(y)+2*z*x**2\n    >>> separatevars(e)\n    2*x**2*z*(sin(y) + 1)\n    >>> separatevars(e, symbols=(x, y), dict=True)\n    {'coeff': 2*z, x: x**2, y: sin(y) + 1}\n    >>> separatevars(e, [x, y, alpha], dict=True)\n    {'coeff': 2*z, alpha: 1, x: x**2, y: sin(y) + 1}\n\n    If the expression is not really separable, or is only partially\n    separable, separatevars will do the best it can to separate it\n    by using factoring.\n\n    >>> separatevars(x + x*y - 3*x**2)\n    -x*(3*x - y - 1)\n\n    If the expression is not separable then expr is returned unchanged\n    or (if dict=True) then None is returned.\n\n    >>> eq = 2*x + y*sin(x)\n    >>> separatevars(eq) == eq\n    True\n    >>> separatevars(2*x + y*sin(x), symbols=(x, y), dict=True) == None\n    True\n\n    "
    expr = sympify(expr)
    if dict:
        return _separatevars_dict(_separatevars(expr, force), symbols)
    else:
        return _separatevars(expr, force)

dataset/ETHPy150Open sympy/sympy/sympy/simplify/simplify.py separatevars/original