# multivariate power series computation with recognition

I would like to do a computation in Sage involving formal power series but I believe some (all?) steps may be impossible:

1. define a couple of formal power series in two variables (x,y) by defining the coefficient function a(m,n) (the coefficients involve gamma functions and such, and are rational). As far as I can see there is no way to do even this step in Sage.

2. do a change of variables, something like (x,y) = (g(x,y),y), obtaining new power series. The function g(x,y) may be a polynomial or possibly itself an infinite power series.

3. multiply the resulting power series

4. Simplify the expression for the coefficients of the resulting power series c(m,n) in terms of classical quantities like gamma functions.

Which of these steps do you believe is possible in Sage? I could write my own software to deal with formal power series properly, but then I would not be able to recognize or simplify the resulting coefficients.

As an example:

1. h(x,y) is a sum of (m!)(4^n)x^m y^n with indices running from 0 to infinity, and k(x,y) is a sum of (m+n)x^m y^n,

2. do a substitution H(x,y) = h(x,exp(xy)y)

3. multiply H*k

4. simplify the coefficients of H*k.

edit retag close merge delete

Sort by » oldest newest most voted

First, a personal comment:

For technical implementation of power series, there is a difference between "lazy" power series and "truncated" power series. It sounds like you're interested in the former, but Sage implements the latter. There are different tradeoffs for the two approaches; please don't suggest that one is "improper" unless you're prepared to make a very thorough case that it is uniformly inferior. To have real weight, such a case would probably need to be accompanied by an actual implementation of the other approach.

Now on to your specific question:

I think the calculations you're interested in can be done just fine with truncated power series. The essential paradigm change is that you need to decide at the outset how many coefficients you're interested in actually computing. This will be the "precision" of the power series that you work with. For multivariable power series, the precision limits the total degree of terms. So in a power series with precision 5, terms like x^3*y^3 would be dropped because they have total degree greater than 5. Some elements can have infinite precision, but only those which are actually polynomials (that is, they have only finitely many nonzero coefficients).

Every power series ring (in Sage) has a default precision -- the precision that it assigns by default to elements that don't already have one. This is only important in your case because exp uses the default precision for the parent ring of its arguments.

Here is some code that would carry out your calculation through total degree 4:

sage: prec = 5
sage: R.<x,y> = PowerSeriesRing(QQ, default_prec=prec); R
Multivariate Power Series Ring in x, y over Rational Field
sage: h = sum(factorial(m)*4^n*x^m*y^n for m in range(prec) for n in range(pre>
sage: k = sum((m+n)*x^m*y^n for m in range(prec) for n in range(prec))
sage: exp(x*y)
1 + x*y + 1/2*x^2*y^2 + O(x, y)^5
sage: H = h(x,exp(x*y)*y)
sage: H
1 + x + 4*y + 2*x^2 + 4*x*y + 16*y^2 + 6*x^3 + 8*x^2*y + 20*x*y^2 + 64*y^3 + 24*x^4 + 24*x^3*y + 36*x^2*y^2 + 96*x*y^3 + 256*y^4 + O(x, y)^5
sage: H*k
x + y + 3*x^2 + 7*x*y + 6*y^2 + 7*x^3 + 19*x^2*y + 33*x*y^2 + 27*y^3 + 17*x^4 + 45*x^3*y + 91*x^2*y^2 + 143*x*y^3 + 112*y^4 + 46*x^5 + 119*x^4*y + 219*x^3*y^2 + 407*x^2*y^3 + 605*x*y^4 + 448*y^5 + O(x, y)^6


If you really only need exp(x*y), you could define this just as h and k are defined, and thereby avoid ...

more

I don't know if 1 and 4 can be done, but 2 and 3 can.

See the documentation on Power Series Rings, Power Series, Power Series Methods, Multivariate Power Series Rings, Multivariate Power Series.

For instance

sage: R.<x,y> = PowerSeriesRing(QQ); R
Multivariate Power Series Ring in x, y over Rational Field
sage: h = (exp(x) - 1)*(1/(1-4*y))
sage: H = h(x,exp(x*y)*y)


If you feel ready to write your own software, why not instead write a class in Sage for multivariate power series with coefficients expressed as symbolic expressions in the exponents? You could then use all the simplification tools already in Sage.

more