def field_isomorphism_pslq(a, b):
    'Construct field isomorphism using PSLQ algorithm.'
    if (not all(((_.domain.is_RationalField and _.ext.is_real) for _ in (a, b)))):
        raise NotImplementedError("PSLQ doesn't support complex coefficients")
    f = a.minpoly
    x = f.gen
    g = b.minpoly.replace(x)
    m = g.degree()
    (a, b) = (a.ext, b.ext)
    for n in mpmath.libmp.libintmath.giant_steps(32, 256):
        with mpmath.workdps(n):
            (A, B) = lambdify((), [a, b], 'mpmath')()
            basis = ([(B ** i) for i in range(m)] + [A])
            coeffs = mpmath.pslq(basis, maxcoeff=(10 ** 10), maxsteps=(10 ** 3))
        if coeffs:
            assert coeffs[(- 1)]
            h = (- Poly(coeffs[:(- 1)], x, field=True).quo_ground(coeffs[(- 1)]))
            if f.compose(h).rem(g).is_zero:
                return h.rep.all_coeffs()
        else:
            break
Construct field isomorphism using PSLQ algorithm.
def field_isomorphism_pslq(a, b):
    
    if (not all(((_.domain.is_RationalField and _.ext.is_real) for _ in (a, b)))):
        raise NotImplementedError("PSLQ doesn't support complex coefficients")
    f = a.minpoly
    x = f.gen
    g = b.minpoly.replace(x)
    m = g.degree()
    (a, b) = (a.ext, b.ext)
    for n in mpmath.libmp.libintmath.giant_steps(32, 256):
        with mpmath.workdps(n):
            (A, B) = lambdify((), [a, b], 'mpmath')()
            basis = ([(B ** i) for i in range(m)] + [A])
            coeffs = mpmath.pslq(basis, maxcoeff=(10 ** 10), maxsteps=(10 ** 3))
        if coeffs:
            assert coeffs[(- 1)]
            h = (- Poly(coeffs[:(- 1)], x, field=True).quo_ground(coeffs[(- 1)]))
            if f.compose(h).rem(g).is_zero:
                return h.rep.all_coeffs()
        else:
            break