

def nthroot(expr, n, max_len=4, prec=15):
    '\n    compute a real nth-root of a sum of surds\n\n    Parameters\n    ==========\n\n    expr : sum of surds\n    n : integer\n    max_len : maximum number of surds passed as constants to ``nsimplify``\n\n    Algorithm\n    =========\n\n    First ``nsimplify`` is used to get a candidate root; if it is not a\n    root the minimal polynomial is computed; the answer is one of its\n    roots.\n\n    Examples\n    ========\n\n    >>> from sympy.simplify.simplify import nthroot\n    >>> from sympy import Rational, sqrt\n    >>> nthroot(90 + 34*sqrt(7), 3)\n    sqrt(7) + 3\n\n    '
    expr = sympify(expr)
    n = sympify(n)
    p = (expr ** Rational(1, n))
    if (not n.is_integer):
        return p
    if (not _is_sum_surds(expr)):
        return p
    surds = []
    coeff_muls = [x.as_coeff_Mul() for x in expr.args]
    for (x, y) in coeff_muls:
        if (not x.is_rational):
            return p
        if (y is S.One):
            continue
        if (not (y.is_Pow and (y.exp == S.Half) and y.base.is_integer)):
            return p
        surds.append(y)
    surds.sort()
    surds = surds[:max_len]
    if ((expr < 0) and ((n % 2) == 1)):
        p = ((- expr) ** Rational(1, n))
        a = nsimplify(max_len, constants=surds)
        res = (a if (_mexpand((a ** n)) == _mexpand((- expr))) else p)
        return (- res)
    a = nsimplify(p, constants=surds)
    if ((_mexpand(a) is not _mexpand(p)) and (_mexpand((a ** n)) == _mexpand(expr))):
        return _mexpand(a)
    expr = _nthroot_solve(expr, n, prec)
    if (expr is None):
        return p
    return expr

dataset/ETHPy150Open sympy/sympy/sympy/simplify/simplify.py nthroot/VarMisuse@233/525 `p`->`max_len`