Open GMS103 opened 3 years ago
A workaround is to factor the numerator and denominator:
sage: f.numerator().factor() / f.denominator().factor()
y/x
Or, in this case, to work in the fraction field of a polynomial ring.
sage: R = PolynomialRing(QQ, ['x', 'y'])
sage: F = R.fraction_field()
sage: F(f)
y/x
sage: F(f).factor()
x^-1 * y
Description changed:
---
+++
@@ -1,23 +1,22 @@
-Tested with https://sagecell.sagemath.org and CoCalc:
+In Sage 9.2 on SageCell and CoCalc (same on Sage 9.3.rc2):
```python
sage: version()
'SageMath version 9.2, Release Date: 2020-10-24'
-sage: x,y=var('x,y')
+sage: x, y = var('x, y')
-sage: f=(x-5)*y/x-(x-6)*y/x ; f
+sage: f = (x - 5)*y/x - (x - 6)*y/x ; f
(x - 5)*y/x - (x - 6)*y/x
-sage: f.factor() # does not work
+sage: f.factor() # does not work
(x - 5)*y/x - (x - 6)*y/x
-sage: (f*x).factor() # does not work either
+sage: (f*x).factor() # does not work either
x*((x - 5)*y/x - (x - 6)*y/x)
-sage: (f*x).expand()/x # expected result
+sage: (f*x).expand()/x # expected result
y/x
Of course, this is a very simple example showing the problem.
-(I am sorry, I do not have any Sage 9.3.* to test.)
Well, actually in this case it suffices to expand:
sage: f.expand()
y/x
But I was wondering about the cause of this behaviour (I do not think I would be able to find it myself).
In Sage 9.2 on SageCell and CoCalc (same on Sage 9.3.rc2):
Of course, this is a very simple example showing the problem.
CC: @slel
Component: factorization
Issue created by migration from https://trac.sagemath.org/ticket/31687