ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 22 Oct 2018 16:08:51 -0500Valuation error when composing power serieshttp://ask.sagemath.org/question/43999/valuation-error-when-composing-power-series/ I'm trying to work with power series with coefficients in a ring consisting of elements $f/g$, where $f$ is a polynomial in several variables over the integers and g is a polynomial in one of those variables with unit constant coefficient. Ultimately, I'd like to be able to do all of the following:
- Compose power series over this ring
- Invert single-variable power series over this ring whose degree-1 coefficients are units
- Reduce the coefficients of a power series modulo some ideal of the ring
I thought I would do this by starting with the Laurent series over $\mathbf{Z}$ in the variable that occurs in the denominator, constructing a polynomial ring over this by adjoining the other variables, and letting my power series take coefficients in this ring. But I'm getting an error I don't understand when I try to compose series. The following example illustrates the problem:
M1.<b> = LaurentSeriesRing(ZZ)
M.<a,c> = PolynomialRing(M1)
R.<t1,t2> = PowerSeriesRing(M)
X = t1 + t2 + O(t1,t2)^3
R1.<t> = PowerSeriesRing(M)
f = X(t,t^2); f
This returns the type error `Substitution defined only for elements of positive valuation, unless self has infinite precision` despite the fact that replacing the last line by `t.valuation()` or `(t^2).valuation()` returns `1` or `2`, respectively.
The problem seems to result from a combination of factors. If I replace the second line with either
M.<a,c> = PolynomialRing(ZZ)
or
M.<a> = PolynomialRing(M1)
the error vanishes and the code returns the expected `t + t^2 + O(t)^3`. It also gives no error if I define `R` and `R1` to be polynomial rings, rather than power series rings, over `M` (and correspondingly delete the big-O notation).
Any ideas about what is triggering the error, or another way to construct these power series?Fri, 19 Oct 2018 19:03:23 -0500http://ask.sagemath.org/question/43999/valuation-error-when-composing-power-series/Answer by rburing for <p>I'm trying to work with power series with coefficients in a ring consisting of elements $f/g$, where $f$ is a polynomial in several variables over the integers and g is a polynomial in one of those variables with unit constant coefficient. Ultimately, I'd like to be able to do all of the following:</p>
<ul>
<li>Compose power series over this ring</li>
<li>Invert single-variable power series over this ring whose degree-1 coefficients are units</li>
<li>Reduce the coefficients of a power series modulo some ideal of the ring</li>
</ul>
<p>I thought I would do this by starting with the Laurent series over $\mathbf{Z}$ in the variable that occurs in the denominator, constructing a polynomial ring over this by adjoining the other variables, and letting my power series take coefficients in this ring. But I'm getting an error I don't understand when I try to compose series. The following example illustrates the problem:</p>
<pre><code>M1.<b> = LaurentSeriesRing(ZZ)
M.<a,c> = PolynomialRing(M1)
R.<t1,t2> = PowerSeriesRing(M)
X = t1 + t2 + O(t1,t2)^3
R1.<t> = PowerSeriesRing(M)
f = X(t,t^2); f
</code></pre>
<p>This returns the type error <code>Substitution defined only for elements of positive valuation, unless self has infinite precision</code> despite the fact that replacing the last line by <code>t.valuation()</code> or <code>(t^2).valuation()</code> returns <code>1</code> or <code>2</code>, respectively.</p>
<p>The problem seems to result from a combination of factors. If I replace the second line with either</p>
<pre><code>M.<a,c> = PolynomialRing(ZZ)
</code></pre>
<p>or</p>
<pre><code>M.<a> = PolynomialRing(M1)
</code></pre>
<p>the error vanishes and the code returns the expected <code>t + t^2 + O(t)^3</code>. It also gives no error if I define <code>R</code> and <code>R1</code> to be polynomial rings, rather than power series rings, over <code>M</code> (and correspondingly delete the big-O notation).</p>
<p>Any ideas about what is triggering the error, or another way to construct these power series?</p>
http://ask.sagemath.org/question/43999/valuation-error-when-composing-power-series/?answer=44032#post-id-44032Looking at the source of `sage.rings.multi_power_series_ring_element.MPowerSeries.__call__` we find that Sage is parsing the arguments to `X` incorrectly. Namely it first tries to cast each argument to an element of `X.parent()` which is `R`. When doing this with `t` we would expect it to fail. There is no natural way in which `t` is an element of `R`, right? But according to Sage, there is:
sage: R(t)
b
I can only guess that it somehow finds a power series parent object (underlying `R`) which has a single generator, and maps to it. Furthermore:
sage: R(t).valuation()
0
This explains the error, and why the replacements succeed in removing the error: in those cases there is no power series parent object with a single generator underlying `R` which we can map `t` to:
sage: R(t)
....
TypeError: Cannot coerce input to polynomial ring.
In this case, `X(t,t^2)` evaluates correctly to `X._subs_formal(t,t^2)` which gives the result you want.
So a workaround is to call `X._subs_formal(t,t^2)` directly to avoid the faulty argument parsing.
This could also be reported as a bug. Maybe `_subs_formal` should be made public (with documentation).Mon, 22 Oct 2018 16:08:51 -0500http://ask.sagemath.org/question/43999/valuation-error-when-composing-power-series/?answer=44032#post-id-44032