Mateusz's new polys module, when we get it pushed in, will let you do this (see 
git://github.com/mattpap/sympy-polys.git).  Until then, the easiest way to do 
that is to temporarily substitute each non-symbol with a symbol:

In [3]: a = S('x**2*cos(x)+x*cos(x)')

In [4]: a.subs(cos(x), y)
Out[4]: 
         2
x⋅y + y⋅x 

In [5]: a = factor(a.subs(cos(x), y))

In [6]: a
Out[6]: x⋅y⋅(1 + x)

In [8]: a = a.subs(y, cos(x))

In [9]: a
Out[9]: x⋅(1 + x)⋅cos(x)

Sorry about the difficulty.  Hopefully we can get the new module in by the next 
release to make this easier.  

Aaron Meurer
On Jan 13, 2010, at 3:26 AM, czbebe wrote:

> Dear member,
> 
> x = sympy.symbols('x')
> sympy.factor('x**2+x)
> =x(1+x)
> 
> sympy.factor('x**2*cos(x)+x*cos(x)')
> sympy.polys.polynomial.PolynomialError: Can't decompose cos(x)
> 
> How can I factorize above term ?
> maybe  x(1+x)cos(x)
> 
> czbebe
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To post to this group, send email to sy...@googlegroups.com.
> To unsubscribe from this group, send email to 
> sympy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sympy?hl=en.
> 
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.


Reply via email to