formal series over InfinitePolynomialRing

I apologize if the question does not belong here. This is my first try to using sage and I find the documentation hard to read/search. I am trying to work with symbolic power series over a non-Noetherian ring. So for example I have:

sage: P.<x> = InfinitePolynomialRing(QQ)
sage: R.<t> = PowerSeriesRing(P)


And I'd like to consider the series $f(t) = \sum x_n t^n$ as an element of R. But my first try


sage: sum(x[n]*t^n,(n,0,oo))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-27-d7d20df9d062> in <module>()
----> 1 sum(x[n]*t**n,(n,Integer(0),oo))

/usr/lib64/python2.7/site-packages/sage/rings/polynomial/infinite_polynomial_ring.pyc in __getitem__(self, i)
1433             alpha_1
1434         """
-> 1435         if int(i) != i:
1436             raise ValueError("The index (= %s) must be an integer" % i)
1437         i = int(i)

TypeError: int() argument must be a string or a number, not 'function'


edit retag close merge delete

Sort by » oldest newest most voted

The expression x[n] is an error because n is the Sage function numerical_approx rather than an integer. The notation for series that you try to use is valid when n is symbolic, i.e. var('n'), but that won't do here because x[n] will still be an error. It seems that PowerSeriesRing is for finite power series expansions with specified (possibly infinite) precision. So you can do e.g.

sage: sum(x[n]*t^n for n in range(5)) + O(t^5)
x_0 + x_1*t + x_2*t^2 + x_3*t^3 + x_4*t^4 + O(t^5)


Maybe you want a Lazy Power Series instead:

P.<x> = InfinitePolynomialRing(QQ)
L.<t> = LazyPowerSeriesRing(P)
f = L()
f.order = 1
f.aorder = 1
f.initialize_coefficient_stream(lambda ao: iter(x[n] for n in NN))


Then you can do:

sage: f.coefficients(5)
[0, x_1, x_2, x_3, x_4]
sage: f
x_0*1 + x_1*t + x_2*t^2 + x_3*t^3 + x_4*t^4 + O(x^5)
sage: f.coefficients(7)
[0, x_1, x_2, x_3, x_4, x_5, x_6]
sage: f
x_0*1 + x_1*t + x_2*t^2 + x_3*t^3 + x_4*t^4 + x_5*t^5 + x_6*t^6 + O(x^7)


Here the + O(x^7) is a bug in sage.combinat.species.series.LazyPowerSeries.__repr__ which forgets to use the name of the actual power series variable.

Actually I am not sure how one can properly manipulate such a LazyPowerSeries further. Things like multiplying by a constant already seem to be tricky.

more

1

Thanks, I've been using the first sum as in your post and more or less I can get by doing some computations up to each order.

( 2018-10-24 12:21:59 -0500 )edit