Opened 13 months ago

Last modified 3 weeks ago

#31687 new defect

factor() does not work in a simple case

Reported by: gh-GMS103 Owned by:
Priority: major Milestone: sage-9.7
Component: factorization Keywords:
Cc: slelievre Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by slelievre)

In Sage 9.2 on SageCell and CoCalc (same on Sage 9.3.rc2):

sage: version()
'SageMath version 9.2, Release Date: 2020-10-24'

sage: x, y = var('x, y')

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
(x - 5)*y/x - (x - 6)*y/x

sage: (f*x).factor()  # does not work either
x*((x - 5)*y/x - (x - 6)*y/x)

sage: (f*x).expand()/x  # expected result

Of course, this is a very simple example showing the problem.

Change History (5)

comment:1 Changed 13 months ago by slelievre

  • Cc slelievre added
  • Description modified (diff)

A workaround is to factor the numerator and denominator:

sage: f.numerator().factor() / f.denominator().factor()

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)
sage: F(f).factor()
x^-1 * y

comment:2 Changed 13 months ago by gh-GMS103

Well, actually in this case it suffices to expand:

sage: f.expand()                                                                                                        

But I was wondering about the cause of this behaviour (I do not think I would be able to find it myself).

comment:3 Changed 9 months ago by mkoeppe

  • Milestone changed from sage-9.4 to sage-9.5

comment:4 Changed 5 months ago by mkoeppe

  • Milestone changed from sage-9.5 to sage-9.6

comment:5 Changed 3 weeks ago by mkoeppe

  • Milestone changed from sage-9.6 to sage-9.7
Note: See TracTickets for help on using tickets.