+ return lcmcoeff(e, _num1());
+}
+
+/** Bring polynomial from Q[X] to Z[X] by multiplying in the previously
+ * determined LCM of the coefficient's denominators.
+ *
+ * @param e multivariate polynomial (need not be expanded)
+ * @param lcm LCM to multiply in */
+
+static ex multiply_lcm(const ex &e, const ex &lcm)
+{
+ if (is_ex_exactly_of_type(e, mul)) {
+ ex c = _ex1();
+ for (int i=0; i<e.nops(); i++)
+ c *= multiply_lcm(e.op(i), lcmcoeff(e.op(i), _num1()));
+ return c;
+ } else if (is_ex_exactly_of_type(e, add)) {
+ ex c = _ex0();
+ for (int i=0; i<e.nops(); i++)
+ c += multiply_lcm(e.op(i), lcm);
+ return c;
+ } else if (is_ex_exactly_of_type(e, power)) {
+ return pow(multiply_lcm(e.op(0), pow(lcm, 1/e.op(1))), e.op(1));
+ } else
+ return e * lcm;