def _minpoly_rootof(ex, x):
    """Returns the minimal polynomial of a ``RootOf`` object."""
    domain = ex.poly.domain
    if domain.is_IntegerRing:
        return ex.poly(x)
    else:
        return ex.poly.sqf_norm()[-1](x)
