Simplifying expressions with rational coefficients