def is_isomorphism_possible(a, b):
 n = a.minpoly.degree()
 m = b.minpoly.degree()
 if ((m % n) != 0):
  return False
 if (n == m):
  return True
 da = a.minpoly.discriminant()
 db = b.minpoly.discriminant()
 (i, k, half) = (1, (m // n), (db // 2))
 while True:
  p = sieve[i]
  P = (p ** k)
  if (P > half):
   break
  if (((da % p) % 2) and (not (db % P))):
   return False
  i += 1
 return True

def is_isomorphism_possible ( a , b ) : n = a . minpoly . degree ( ) m = b . minpoly . degree ( ) if ( ( m % n ) != 0 ) : return False if ( n == m ) : return True da = a . minpoly . discriminant ( ) db = b . minpoly . discriminant ( ) ( i , k , half ) = ( 1 , ( m // n ) , ( db // 2 ) ) while True : p = sieve [ i ] P = ( p ** k ) if ( P > half ) : break if ( ( ( da % p ) % 2 ) and ( not ( db % P ) ) ) : return False i += 1 return True
returns true if there is a chance for isomorphism .