#NEWLINE# def test_sqrt_symbolic_denest( ) : #NEWLINE# #INDENT# x = Symbol ( 'x' ) #NEWLINE# z = sqrt ( ( ( 1 + sqrt ( ( sqrt ( ( 2 + x ) ) + 3 ) ) ) ** 2 ) . expand ( ) ) #NEWLINE# assert ( sqrtdenest ( z ) == sqrt ( ( ( 1 + sqrt ( ( sqrt ( ( 2 + x ) ) + 3 ) ) ) ** 2 ) ) ) #NEWLINE# z = sqrt ( ( ( 1 + sqrt ( ( sqrt ( ( 2 + cos ( 1 ) ) ) + 3 ) ) ) ** 2 ) . expand ( ) ) #NEWLINE# assert ( sqrtdenest ( z ) == ( 1 + sqrt ( ( sqrt ( ( 2 + cos ( 1 ) ) ) + 3 ) ) ) ) #NEWLINE# z = ( ( ( 1 + cos ( 2 ) ) ** 4 ) + 1 ) . expand ( ) #NEWLINE# assert ( sqrtdenest ( z ) == z ) #NEWLINE# z = sqrt ( ( ( ( 1 + sqrt ( ( sqrt ( ( 2 + cos ( ( 3 * x ) ) ) ) + 3 ) ) ) ** 2 ) + 1 ) . expand ( ) ) #NEWLINE# assert ( sqrtdenest ( z ) == z ) #NEWLINE# c = cos ( 3 ) #NEWLINE# c2 = ( c ** 2 ) #NEWLINE# assert ( sqrtdenest ( sqrt ( ( ( ( ( ( 2 * sqrt ( ( 1 + r3 ) ) ) * c ) + c2 ) + 1 ) + ( r3 * c2 ) ) ) ) == ( ( - 1 ) - ( sqrt ( ( 1 + r3 ) ) * c ) ) ) #NEWLINE# ra = sqrt ( ( 1 + r3 ) ) #NEWLINE# z = sqrt ( ( ( ( ( ( 20 * ra ) * sqrt ( ( 3 + ( 3 * r3 ) ) ) ) + ( ( ( 12 * r3 ) * ra ) * sqrt ( ( 3 + ( 3 * r3 ) ) ) ) ) + ( 64 * r3 ) ) + 112 ) ) #NEWLINE# assert ( sqrtdenest ( z ) == z )