- // This could be made better, since series expansion at x==1 might print
- // -1+2*x+Order((-1+x)^2) instead of 1+2*(-1+x)+Order((-1+x)^2), which is
- // correct but can be rather confusing.
- convert_to_poly().print(os, upper_precedence);
+ for (epvector::const_iterator i=seq.begin(); i!=seq.end(); i++) {
+ // omit zero terms
+ if (i->rest.is_zero())
+ continue;
+ // print a sign, if needed
+ if (i!=seq.begin())
+ os << '+';
+ if (!is_order_function(i->rest)) {
+ // print 'rest', i.e. the expansion coefficient
+ if (i->rest.info(info_flags::numeric) &&
+ i->rest.info(info_flags::positive)) {
+ os << i->rest;
+ } else
+ os << "(" << i->rest << ')';
+ // print 'coeff', something like (x-1)^42
+ if (!i->coeff.is_zero()) {
+ os << '*';
+ if (!point.is_zero())
+ os << '(' << var-point << ')';
+ else
+ os << var;
+ if (i->coeff.compare(_ex1())) {
+ os << '^';
+ if (i->coeff.info(info_flags::negative))
+ os << '(' << i->coeff << ')';
+ else
+ os << i->coeff;
+ }
+ }
+ } else {
+ os << Order(power(var-point,i->coeff));
+ }
+ }