Ticket #10981 (closed defect: fixed)
algebraic real field partial_fraction_decomposition bug
| Reported by: | mariah | Owned by: | AlexGhitza |
|---|---|---|---|
| Priority: | major | Milestone: | sage-4.7.2 |
| Component: | algebra | Keywords: | sd32 |
| Cc: | Work issues: | ||
| Report Upstream: | N/A | Reviewers: | Simon Spicer, Leif Leonhardy |
| Authors: | William Stein | Merged in: | sage-4.7.2.alpha3 |
| Dependencies: | Stopgaps: |
Description (last modified by leif) (diff)
sage: x= AA['x'].gen()
sage: P= 1/(1+x^4)
sage: P.partial_fraction_decomposition()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/home/mariah/<ipython console> in <module>()
/home/mariah/sage/sage-4.6.2-x86_64-Linux-core2-fc/local/lib/python2.6/site-packages/sage/categories/quotient_fields.pyc in partial_fraction_decomposition(self)
173 # note that the product below is non-empty, since the case
174 # of only one factor has been dealt with above
--> 175 n = numer * prod([r for r in factors if r != d]).inverse_mod(d) % d # we know the inverse exists as the two are relatively prime
176 parts.append(n/d)
177 return whole, parts
/home/mariah/sage/sage-4.6.2-x86_64-Linux-core2-fc/local/lib/python2.6/site-packages/sage/rings/polynomial/polynomial_element.so in sage.rings.polynomial.polynomial_element.Polynomial.inverse_mod (sage/rings/polynomial/polynomial_element.c:9816)()
/home/mariah/sage/sage-4.6.2-x86_64-Linux-core2-fc/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.PrincipalIdealDomainElement.xgcd (sage/structure/element.c:15524)()
/home/mariah/sage/sage-4.6.2-x86_64-Linux-core2-fc/local/lib/python2.6/site-packages/sage/rings/polynomial/polynomial_element.so in sage.rings.polynomial.polynomial_element.Polynomial._xgcd (sage/rings/polynomial/polynomial_element.c:33988)()
/home/mariah/sage/sage-4.6.2-x86_64-Linux-core2-fc/local/lib/python2.6/site-packages/sage/rings/polynomial/polynomial_element.so in sage.rings.polynomial.polynomial_element.Polynomial.__div__ (sage/rings/polynomial/polynomial_element.c:12221)()
/home/mariah/sage/sage-4.6.2-x86_64-Linux-core2-fc/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.RingElement.__mul__ (sage/structure/element.c:11449)()
/home/mariah/sage/sage-4.6.2-x86_64-Linux-core2-fc/local/lib/python2.6/site-packages/sage/structure/coerce.so in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:6105)()
/home/mariah/sage/sage-4.6.2-x86_64-Linux-core2-fc/local/lib/python2.6/site-packages/sage/structure/coerce_actions.so in sage.structure.coerce_actions.RightModuleAction._call_ (sage/structure/coerce_actions.c:5782)()
/home/mariah/sage/sage-4.6.2-x86_64-Linux-core2-fc/local/lib/python2.6/site-packages/sage/rings/polynomial/polynomial_element.so in sage.rings.polynomial.polynomial_element.Polynomial_generic_dense._lmul_ (sage/rings/polynomial/polynomial_element.c:40358)()
/home/mariah/sage/sage-4.6.2-x86_64-Linux-core2-fc/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.Element.__nonzero__ (sage/structure/element.c:5806)()
/home/mariah/sage/sage-4.6.2-x86_64-Linux-core2-fc/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.Element.__richcmp__ (sage/structure/element.c:7169)()
/home/mariah/sage/sage-4.6.2-x86_64-Linux-core2-fc/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.Element._richcmp (sage/structure/element.c:7052)()
/home/mariah/sage/sage-4.6.2-x86_64-Linux-core2-fc/local/lib/python2.6/site-packages/sage/rings/qqbar.pyc in __cmp__(self, other)
3400 if self is other: return 0
3401 if other._descr.is_rational() and other._descr.rational_value() == 0:
-> 3402 return self.sign()
3403 elif self._descr.is_rational() and self._descr.rational_value() == 0:
3404 return -other.sign()
/home/mariah/sage/sage-4.6.2-x86_64-Linux-core2-fc/local/lib/python2.6/site-packages/sage/rings/qqbar.pyc in sign(self)
3597 0
3598 """
-> 3599 if self._value.lower() > 0:
3600 return 1
3601 elif self._value.upper() < 0:
/home/mariah/sage/sage-4.6.2-x86_64-Linux-core2-fc/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.Element.__getattr__ (sage/structure/element.c:2715)()
/home/mariah/sage/sage-4.6.2-x86_64-Linux-core2-fc/local/lib/python2.6/site-packages/sage/structure/parent.so in sage.structure.parent.getattr_from_other_class (sage/structure/parent.c:2841)()
/home/mariah/sage/sage-4.6.2-x86_64-Linux-core2-fc/local/lib/python2.6/site-packages/sage/structure/parent.so in sage.structure.parent.raise_attribute_error (sage/structure/parent.c:2636)()
AttributeError: 'sage.rings.complex_interval.ComplexIntervalFieldElement' object has no attribute 'lower'
sage:
Apply
to the Sage library.
Attachments
Change History
comment:2 Changed 21 months ago by was
- Status changed from new to needs_review
The patch I'm going to post in a moment fixes this problem as well as the ones at #11728 as well (so I'm closing #11728 as a duplicate):
sage: x= AA['x'].gen() sage: P= 1/(1+x^4) sage: P.partial_fraction_decomposition() (0, [(-0.3535533905932738?*x + 1/2)/(x^2 - 1.414213562373095?*x + 1), (0.3535533905932738?*x + 1/2)/(x^2 + 1.414213562373095?*x + 1)])
comment:3 Changed 21 months ago by was
- Milestone changed from sage-5.0 to sage-4.7.2
- Authors set to William Stein
comment:4 Changed 21 months ago by spice
- Status changed from needs_review to positive_review
- Reviewers set to Simon Spicer
Seems to work as advertised. Doctests pass, behaviour described in this ticket is fixed, and every other thing I could think of to throw at it works.
comment:7 Changed 20 months ago by leif
- Status changed from positive_review to needs_work
- Reviewers changed from Simon Spicer to Simon Spicer, Leif Leonhardy
- Work issues set to Fix Sphinx warnings.
I get the following warnings due to wrong double colons before unindented blocks:
.../sage-4.7.2.alpha3-pre2/local/lib/python2.6/site-packages/sage/rings/qqbar.py:docstring of sage.rings.qqbar:476: (WARNING/2) Literal block expected; none found. .../sage-4.7.2.alpha3-pre2/local/lib/python2.6/site-packages/sage/rings/qqbar.py:docstring of sage.rings.qqbar.AlgebraicReal:5: (WARNING/2) Literal block expected; none found.
Changed 20 months ago by leif
-
attachment
trac_10981-fix_sphinx_warnings.reviewer.patch
added
Reviewer patch. Fixes Sphinx warnings. Apply on top of William's patch.
Note: See
TracTickets for help on using
tickets.

This seems to be a deeper bug than just one in partial_fraction_decomposition. I've traced it to multiplication in AA, where some weird stuff is going on:
As far as I can tell, problems arise if the representation of the AlgebraicReal? element is in term of non-real elements in QQbar.
I've opened a new ticket (#11728) for this, since it goes beyond just partial_fraction_decomposition().