def _sqrt_numeric_denest(a, b, r, d2):
 from sympy.simplify.simplify import radsimp
 depthr = sqrt_depth(r)
 d = sqrt(d2)
 vad = (a + d)
 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 ) 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 ( )
helper that denest expr = a + b*sqrt(r) .