Chenjie Gu wrote: >> Thanks, "make_list" works! >> >> Now my code becomes >> >> y = x0 * x1 * exp(40*x0) >> non_poly_terms = [a for a in make_list(y, Add) if (not >> a.is_polynomial())] >> print non_poly_terms # [x0*x1*exp(40*x0)] >> non_poly_terms = [a for a in make_list(non_poly_terms[0], Mul) if >> (not a.is_polynomial())] >> print non_poly_terms # [exp(40*x0)]
You can put those both together and return only unique occurances as follows: h[8] >>> set([m for a in make_list(eq, Add) for m in make_list(a, Mul) if m.is_polyn omial()]) set([x + y, y, x, 1 + x, 1, 1 + 3**(1/2)]) If you only want terms with Symbols in them (and no things like 1 and 1 + sqrt(3)) then you can use "if m.has(Symbol) and m.is_polynomial()" /c -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
