Opened 5 years ago

Closed 5 years ago

#16240 closed defect (fixed)

regression in partial_fraction_decomposition()

Reported by: rws Owned by:
Priority: major Milestone: sage-6.3
Component: commutative algebra Keywords: partial fractions, polynomials
Cc: robertwb Merged in:
Authors: Ralf Stephan Reviewers: Peter Bruin
Report Upstream: N/A Work issues:
Branch: 41fbef4 (Commits) Commit: 41fbef419f6f3d3681eefd4a8f302bd1504effe2
Dependencies: Stopgaps:

Description (last modified by rws)

This worked in 6.1.1. Maybe triggered in #15306. Note the sign of the denominator:

sage: R.<x> = ZZ['x']
sage: p=(6*x^2 - 9*x + 5)/(-x^3 + 3*x^2 - 3*x + 1)
sage: p.partial_fraction_decomposition()
(0, [6/(x - 1), 3/(x^2 - 2*x + 1), 2/(x^3 - 3*x^2 + 3*x - 1)])
sage: 6/(x - 1) + 3/(x^2 - 2*x + 1) + 2/(x^3 - 3*x^2 + 3*x - 1)
(6*x^2 - 9*x + 5)/(x^3 - 3*x^2 + 3*x - 1)

while in SR:

sage: var('x')
x
sage: p=(6*x^2 - 9*x + 5)/(-x^3 + 3*x^2 - 3*x + 1)
sage: p.partial_fraction()
-6/(x - 1) - 3/(x - 1)^2 - 2/(x - 1)^3

The minimal case, showing with odd exponents:

sage: R.<x> = ZZ['x']
sage: p=1/(-x + 1)
sage: p.partial_fraction_decomposition()
(0, [1/(x - 1)])

Change History (9)

comment:1 Changed 5 years ago by rws

  • Description modified (diff)
  • Priority changed from critical to major

comment:2 Changed 5 years ago by rws

  • Description modified (diff)
  • Summary changed from plain wrong results from partial_fraction_decomposition() to regression in partial_fraction_decomposition()

comment:3 Changed 5 years ago by rws

Before commit https://github.com/sagemath/sage/commit/807f60d859f5481a31896945555dc7e41d627cb6

sage: p=1/(-x + 1)
sage: p.partial_fraction_decomposition()
(0, [-1/(x - 1)])

After:

sage: p=1/(-x + 1)
sage: p.partial_fraction_decomposition()
(0, [1/(x - 1)])

comment:4 Changed 5 years ago by rws

  • Branch set to u/rws/regression_in_partial_fraction_decomposition__

comment:5 Changed 5 years ago by rws

  • Commit set to 41fbef419f6f3d3681eefd4a8f302bd1504effe2
  • Status changed from new to needs_review

New commits:

41fbef416240: fix sign of numerator when factor() scrambles denominators

comment:6 Changed 5 years ago by pbruin

  • Reviewers set to Peter Bruin

OK, I convinced myself that if the algorithm is correct in the case where the unit in the factorisation of the denominator is 1 (in which case this patch does not make a difference), then the algorithm is correct for arbitrary units if and only if the patch is applied.

As Knuth said, "I have only proved it correct, not tried it", so now running doctests.

comment:7 Changed 5 years ago by pbruin

  • Status changed from needs_review to positive_review

comment:8 Changed 5 years ago by rws

  • Authors set to Ralf Stephan

comment:9 Changed 5 years ago by vbraun

  • Branch changed from u/rws/regression_in_partial_fraction_decomposition__ to 41fbef419f6f3d3681eefd4a8f302bd1504effe2
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.