(expr, n, max_len=4, prec=15)
return expr
compute a real nth-root of a sum of surds

    Parameters
    ==========

    expr : sum of surds
    n : integer
    max_len : maximum number of surds passed as constants to ``nsimplify``

    Algorithm
    =========

    First ``nsimplify`` is used to get a candidate root; if it is not a
    root the minimal polynomial is computed; the answer is one of its
    roots.

    Examples
    ========

    >>> from sympy.simplify.simplify import nthroot
    >>> from sympy import Rational, sqrt
    >>> nthroot(90 + 34*sqrt(7), 3)
    sqrt(7) + 3
compute a real nth-root of a sum of surds
compute a real nth - root of a sum of surds
def nthroot(expr, n, max_len=4, prec=15):
    """
    compute a real nth-root of a sum of surds

    Parameters
    ==========

    expr : sum of surds
    n : integer
    max_len : maximum number of surds passed as constants to ``nsimplify``

    Algorithm
    =========

    First ``nsimplify`` is used to get a candidate root; if it is not a
    root the minimal polynomial is computed; the answer is one of its
    roots.

    Examples
    ========

    >>> from sympy.simplify.simplify import nthroot
    >>> from sympy import Rational, sqrt
    >>> nthroot(90 + 34*sqrt(7), 3)
    sqrt(7) + 3

    """
    from sympy.simplify.sqrtdenest import sqrt_depth, is_algebraic
    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(p, 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
def nthroot ( expr , n , max_len = 4 , prec = 15 ) : from sympy . simplify . sqrtdenest import sqrt_depth , is_algebraic 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 ( p , 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