Opened 8 years ago
Closed 8 years ago
#15698 closed enhancement (fixed)
conversion from polynomial fraction to its power series expansion
Reported by:  rws  Owned by:  rws 

Priority:  major  Milestone:  sage6.2 
Component:  algebra  Keywords:  power series, expansion, fraction 
Cc:  Merged in:  
Authors:  Ralf Stephan, Marc Mezzarobba  Reviewers:  Marc Mezzarobba, Ralf Stephan 
Report Upstream:  N/A  Work issues:  
Branch:  25f819f (Commits, GitHub, GitLab)  Commit:  25f819f748f64634177097da20cc9bbf1c2a68df 
Dependencies:  Stopgaps: 
Description (last modified by )
Original description was:
The following behaviour is not implemented, example:
sage: R.<t> = QQ[]; A=1/(1t) sage: A.expand(5) 1+t+t^2+t^3+t^4+t^5+O(t^6) sage: A+O(t^6) 1+t+t^2+t^3+t^4+t^5+O(t^6)
Add a parameter to specify the respective series variable (for derivation) then multivariate polynomial fractions can be handled. Result type being a power series. The pari function Ser() implements the same behaviour. Note: I would like to implement this.
Change History (30)
comment:1 Changed 8 years ago by
 Description modified (diff)
comment:2 Changed 8 years ago by
comment:3 Changed 8 years ago by
 Branch set to u/rws/ticket/15698
 Created changed from 01/20/14 11:00:32 to 01/20/14 11:00:32
 Modified changed from 01/22/14 17:10:05 to 01/22/14 17:10:05
comment:4 Changed 8 years ago by
 Commit set to 307871686f1f8be1ffe7ed0169b9bfa550878aef
Branch pushed to git repo; I updated commit sha1. New commits:
3078716  Trac #15698: we pass through all parameters; documentation added

comment:5 Changed 8 years ago by
Why is the first commit (creation of branch plus first patch) not viewable?
Anyway, pbruin's example works now. A.expand()
is then no longer necessary. The only thing that still does not work is addition of power series to fraction, where coercion is needed. I'll leave that for now and ask for your review.
comment:6 Changed 8 years ago by
 Status changed from new to needs_review
comment:7 Changed 8 years ago by
 Commit changed from 307871686f1f8be1ffe7ed0169b9bfa550878aef to ae77b79a1bcd0cb1f69b5b5219814b9d9ccad028
Branch pushed to git repo; I updated commit sha1. New commits:
ae77b79  remove superfluous doc line

comment:8 Changed 8 years ago by
 Status changed from needs_review to needs_work
comment:9 Changed 8 years ago by
 Status changed from needs_work to positive_review
comment:10 Changed 8 years ago by
 Status changed from positive_review to needs_review
comment:11 Changed 8 years ago by
 Description modified (diff)
 Summary changed from univariate polynomial ring fraction expansion to power series to conversion from polynomial fraction to its power series expansion
comment:12 Changed 8 years ago by
 Status changed from needs_review to needs_work
Shouldn't the following example throw an error?
sage: R.<x> = QQ[] sage: S = R.completion(x) sage: S(1/x) x^1
comment:13 Changed 8 years ago by
 Commit changed from ae77b79a1bcd0cb1f69b5b5219814b9d9ccad028 to 58396dea4393b297b4c3d549156e010915eaaa33
Branch pushed to git repo; I updated commit sha1. New commits:
58396de  trac #15698: use coercion to catch errors; with doctest

comment:14 Changed 8 years ago by
 Keywords power added; ogf removed
 Status changed from needs_work to needs_review
comment:15 Changed 8 years ago by
 Branch changed from u/rws/ticket/15698 to u/mmezzarobba/15698series_of_ratpoly
 Commit changed from 58396dea4393b297b4c3d549156e010915eaaa33 to 7913b6f9951e051e7f53e825e0e6d2de95af3730
 Reviewers set to Marc Mezzarobba
 Status changed from needs_review to positive_review
Ok, LGTM. I took the liberty of squashing your three patches and rebasing the whole on top of develop
; please protest if you disagree.
I had a doubt about the fact of computing the quotient (possibly as a Laurent series) in all cases and then checking that it was in fact a power series, but at least it helps keeping the logic that decides whether the quotient fo two power series is a power series in a single place.
New commits:
7913b6f  15698: Allow construction of power series from fractions

comment:16 Changed 8 years ago by
 Milestone changed from sage6.1 to sage6.2
comment:17 Changed 8 years ago by
comment:18 followup: ↓ 19 Changed 8 years ago by
Please fill in real names under authors.
comment:19 in reply to: ↑ 18 Changed 8 years ago by
Replying to vbraun:
Please fill in real names under authors.
Done. I also removed myself since I only reorganized the patches without changing the code at all.
comment:20 Changed 8 years ago by
doctests fail with
sage t long src/sage/rings/power_series_poly.pyx ********************************************************************** File "src/sage/rings/power_series_poly.pyx", line 987, in sage.rings.power_series_poly.PowerSeries_poly.__richcmp__.reversion Failed example: g(f) Exception raised: Traceback (most recent call last): File "/home/release/Sage/local/lib/python2.7/sitepackages/sage/doctest/forker.py", line 480, in _run self.execute(example, compiled, test.globs) File "/home/release/Sage/local/lib/python2.7/sitepackages/sage/doctest/forker.py", line 839, in execute exec compiled in globs File "<doctest sage.rings.power_series_poly.PowerSeries_poly.__richcmp__.reversion[32]>", line 1, in <module> g(f) File "power_series_poly.pyx", line 373, in sage.rings.power_series_poly.PowerSeries_poly.__call__ (sage/rings/power_series_poly.c:4951) File "polynomial_element.pyx", line 655, in sage.rings.polynomial.polynomial_element.Polynomial.__call__ (sage/rings/polynomial/polynomial_element.c:8408) File "element.pyx", line 1539, in sage.structure.element.RingElement.__add__ (sage/structure/element.c:13873) File "coerce.pyx", line 782, in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:7311) File "coerce.pyx", line 900, in sage.structure.coerce.CoercionModel_cache_maps.canonical_coercion (sage/structure/coerce.c:8549) ... File "/home/release/Sage/local/lib/python2.7/sitepackages/sage/rings/polynomial/polynomial_element_generic.py", line 734, in __init__ Polynomial_generic_dense.__init__(self, parent, x, check, is_gen) File "polynomial_element.pyx", line 6914, in sage.rings.polynomial.polynomial_element.Polynomial_generic_dense.__init__ (sage/rings/polynomial/polynomial_element.c:48031) File "polynomial_element.pyx", line 209, in sage.rings.polynomial.polynomial_element.Polynomial.__init__ (sage/rings/polynomial/polynomial_element.c:4700) RuntimeError: maximum recursion depth exceeded while calling a Python object
comment:21 Changed 8 years ago by
 Status changed from positive_review to needs_work
comment:22 Changed 8 years ago by
 Commit changed from 7913b6f9951e051e7f53e825e0e6d2de95af3730 to 4c16ab0a03bcf158df0caa956863a0a805dcdba5
comment:23 Changed 8 years ago by
 Commit changed from 4c16ab0a03bcf158df0caa956863a0a805dcdba5 to 50defe27ea0129109f5c42213f98bd83b6d10eb8
Branch pushed to git repo; I updated commit sha1. New commits:
50defe2  Fraction to power series: doctests

comment:24 Changed 8 years ago by
 Status changed from needs_work to needs_review
comment:25 followup: ↓ 28 Changed 8 years ago by
Patchbot says:
File "src/sage/rings/power_series_ring.py", line 671, in sage.rings.power_series_ring.PowerSeriesRing_generic._element_constructor_ Failed example: PowerSeriesRing(PowerSeriesRing(QQ,'x'),'y')(1/(1+x), 5) Expected: 1  x + x^2  x^3 + x^4 + O(x^5) Got: 1  x + x^2  x^3 + x^4  x^5 + x^6  x^7 + x^8  x^9 + x^10  x^11 + x^12  x^13 + x^14  x^15 + x^16  x^17 + x^18  x^19 + O(x^20) + O(y^5)
comment:26 Changed 8 years ago by
 Status changed from needs_review to needs_work
comment:27 Changed 8 years ago by
 Commit changed from 50defe27ea0129109f5c42213f98bd83b6d10eb8 to 25f819f748f64634177097da20cc9bbf1c2a68df
comment:28 in reply to: ↑ 25 Changed 8 years ago by
 Status changed from needs_work to needs_review
Replying to rws:
Patchbot says:
File "src/sage/rings/power_series_ring.py", line 671, in sage.rings.power_series_ring.PowerSeriesRing_generic._element_constructor_ Failed example: PowerSeriesRing(PowerSeriesRing(QQ,'x'),'y')(1/(1+x), 5) Expected: 1  x + x^2  x^3 + x^4 + O(x^5) Got: 1  x + x^2  x^3 + x^4  x^5 + x^6  x^7 + x^8  x^9 + x^10  x^11 + x^12  x^13 + x^14  x^15 + x^16  x^17 + x^18  x^19 + O(x^20) + O(y^5)
Thanks. That was a stupid copypaste mistake, I believe.
New commits:
c523068  15698: Allow construction of power series from fractions

f38e82f  Fraction to power series conversion when the fraction coerces into the base ring

25f819f  Fraction to power series: doctests

comment:29 Changed 8 years ago by
 Reviewers changed from Marc Mezzarobba to Marc Mezzarobba, Ralf Stephan
 Status changed from needs_review to positive_review
Thanks, it tested long okay in rings/ so let's roll.
comment:30 Changed 8 years ago by
 Branch changed from u/mmezzarobba/15698series_of_ratpoly to 25f819f748f64634177097da20cc9bbf1c2a68df
 Resolution set to fixed
 Status changed from positive_review to closed
The "canonical" syntax for this kind of conversion would be
However, the last two lines currently fail with
The following does work:
Unfortunately, this does not currently accept a precision argument.
I think the easiest solution for
S(A)
is to fixPowerSeriesRing._element_constructor_()
to accept rational functions.