smichr's gfactor branch at github has a (hopefully) more robust method
for factoring. It relies on the standard factor that is part of polys
but it does pre-processing of an expression with a gcdfactor routine.
The gcdfactor pulls out terms that can be removed multiplicatively
from all terms in an Add. Preprocessing also includes removing (in
hopefully a non-destructive manner) terms that would cause the polys
factor function to fail.

>>> factor(1/x-1/x**2)
-(1 - x)/x**2

>>> factor(0.2+0.44*x)
1/5 + 11*x/25
>>> gcdfactors(_) # see below
(1, 1/25, 1, 5 + 11*x)

new functions:
==========

o gcdfactors - returns a tuple: (sign, constant, gcd factors, residual
expression)
>>> gcdfactors(x**2*exp(x)+exp(x+y)*x/y)
(1, 1, x*exp(x), x + exp(y)/y)

o gcdfactor - returns the product of the gcdfactors tuple
>>> gcdfactor(x**2*exp(x)+exp(x+y)*x/y)
x*(x + exp(y)/y)*exp(x)

o rgcd - returns the gcd of two rationals (igcd does not handle this
if one of the terms is an integer)--perhaps igcd should just be
changed to recognize the case when one of the terms has a non-trivial
denominator

If factoring is important to what you are doing perhaps you can throw
some of your work at this branch and feed back any comments/failures.

--

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


Reply via email to