def field_isomorphism_factor(a, b):
    'Construct field isomorphism via factorization.'
    p = a.minpoly.set_domain(b)
    (_, factors) = p.factor_list()
    for (f, _) in factors:
        if (f.degree() == 1):
            root = ((- f.rep[(0,)]) / f.rep[(1,)])
            if ((a.ext - b.to_expr(root)).evalf(chop=True) == 0):
                return root.rep.all_coeffs()
Construct field isomorphism via factorization.
def field_isomorphism_factor(a, b):
    
    p = a.minpoly.set_domain(b)
    (_, factors) = p.factor_list()
    for (f, _) in factors:
        if (f.degree() == 1):
            root = ((- f.rep[(0,)]) / f.rep[(1,)])
            if ((a.ext - b.to_expr(root)).evalf(chop=True) == 0):
                return root.rep.all_coeffs()