(a, b, r, d2)
Helper that denest expr = a + b*sqrt(r), with d2 = a**2 - b**2*r > 0
    or returns None if not denested.
Helper that denest expr = a + b*sqrt(r), with d2 = a**2 - b**2*r > 0
    or returns None if not denested.
Helper that denest expr = a + b * sqrt ( r ) with d2 = a ** 2 - b ** 2 * r > 0 or returns None if not denested .
def _sqrt_numeric_denest(a, b, r, d2):
    """Helper that denest expr = a + b*sqrt(r), with d2 = a**2 - b**2*r > 0
    or returns None if not denested.
    """
    from sympy.simplify.simplify import radsimp
    depthr = sqrt_depth(r)
    d = sqrt(d2)
    vad = a + d
    # sqrt_depth(res) <= sqrt_depth(vad) + 1
    # sqrt_depth(expr) = depthr + 2
    # there is denesting if sqrt_depth(vad)+1 < depthr + 2
    # if vad**2 is Number there is a fourth root
    if sqrt_depth(vad) < depthr + 1 or (vad**2).is_Rational:
        vad1 = radsimp(1/vad)
        return (sqrt(vad/2) + sign(b)*sqrt((b**2*r*vad1/2).expand())).expand()
def _sqrt_numeric_denest ( a , b , r , d2 ) : from sympy . simplify . simplify import radsimp depthr = sqrt_depth ( r ) d = sqrt ( d2 ) vad = a + d # sqrt_depth(res) <= sqrt_depth(vad) + 1 # sqrt_depth(expr) = depthr + 2 # there is denesting if sqrt_depth(vad)+1 < depthr + 2 # if vad**2 is Number there is a fourth root if sqrt_depth ( vad ) < depthr + 1 or ( vad ** 2 ) . is_Rational : vad1 = radsimp ( 1 / vad ) return ( sqrt ( vad / 2 ) + sign ( b ) * sqrt ( ( b ** 2 * r * vad1 / 2 ) . expand ( ) ) ) . expand ( )