bernstein_coefficients: factorize domain if possible