Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 2366 by pub...@mjh.name: factor() doesn't work on fractions.
http://code.google.com/p/sympy/issues/detail?id=2366
Hello, I want to transform 1/(b + b**2) -> 1/(b * (b + 1)). Is there a way
to do this? collect() doesn't do it, and factor() fails:
$ python
Python 2.6.6 (r266:84292, Mar 10 2011, 22:18:04)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
from sympy import __version__, collect, factor, Symbol
__version__
'0.6.7'
a = Symbol('a')
collect(1/(a + a**2), a)
1/(a + a**2)
factor(a + a**2)
a*(1 + a)
factor(1/(a + a**2))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.6/site-packages/sympy/polys/factortools.py",
line 80, in factor
coeff, factors = poly_factors(f, *symbols, **flags)
File "/usr/lib64/python2.6/site-packages/sympy/polys/factortools.py",
line 20, in poly_factors
f = Poly(f, *symbols)
File "/usr/lib64/python2.6/site-packages/sympy/polys/polynomial.py", line
454, in __new__
terms = Poly._decompose(poly, *symbols)
File "/usr/lib64/python2.6/site-packages/sympy/polys/polynomial.py", line
598, in _decompose
raise PolynomialError("Can't decompose %s" % factor)
sympy.polys.polynomial.PolynomialError: Can't decompose 1/(a + a**2)
A similar issue is:
factor(1/a + 1/a**2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.6/site-packages/sympy/polys/factortools.py",
line 80, in factor
coeff, factors = poly_factors(f, *symbols, **flags)
File "/usr/lib64/python2.6/site-packages/sympy/polys/factortools.py",
line 20, in poly_factors
f = Poly(f, *symbols)
File "/usr/lib64/python2.6/site-packages/sympy/polys/polynomial.py", line
454, in __new__
terms = Poly._decompose(poly, *symbols)
File "/usr/lib64/python2.6/site-packages/sympy/polys/polynomial.py", line
598, in _decompose
raise PolynomialError("Can't decompose %s" % factor)
sympy.polys.polynomial.PolynomialError: Can't decompose 1/a
An expected value might be 1/a * (1 + 1/a) here, but this is not as
important to me.
Regards,
Milan
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to sympy-issues@googlegroups.com.
To unsubscribe from this group, send email to
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.