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.Fri, 08 Dec 2017 09:06:39 -0600How can I recurse a power series in two variables?http://ask.sagemath.org/question/39960/how-can-i-recurse-a-power-series-in-two-variables/ I would like very much to express, for example,
R.<x, y> = PowerSeriesRing(QQ, default_prec = 20)
g(x, g(x, g(x, x)))
Or,
f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, (f(x, (f(x, f(x,y))))))))))))))))).expand()
In a more elegant way, for a specified number of self-compositions in one variable. I have only been able to find the sage function of composition for one variable polynomials, not for nesting two variable power series.Tue, 05 Dec 2017 18:59:43 -0600http://ask.sagemath.org/question/39960/how-can-i-recurse-a-power-series-in-two-variables/Comment by slelievre for <p>I would like very much to express, for example, </p>
<pre><code>R.<x, y> = PowerSeriesRing(QQ, default_prec = 20)
g(x, g(x, g(x, x)))
</code></pre>
<p>Or, </p>
<pre><code>f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, (f(x, (f(x, f(x,y))))))))))))))))).expand()
</code></pre>
<p>In a more elegant way, for a specified number of self-compositions in one variable. I have only been able to find the sage function of composition for one variable polynomials, not for nesting two variable power series.</p>
http://ask.sagemath.org/question/39960/how-can-i-recurse-a-power-series-in-two-variables/?comment=40010#post-id-40010Note: with `R` as in the question, `R.random_element()` gave a starting point for exploration.Fri, 08 Dec 2017 09:03:27 -0600http://ask.sagemath.org/question/39960/how-can-i-recurse-a-power-series-in-two-variables/?comment=40010#post-id-40010Comment by slelievre for <p>I would like very much to express, for example, </p>
<pre><code>R.<x, y> = PowerSeriesRing(QQ, default_prec = 20)
g(x, g(x, g(x, x)))
</code></pre>
<p>Or, </p>
<pre><code>f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, (f(x, (f(x, f(x,y))))))))))))))))).expand()
</code></pre>
<p>In a more elegant way, for a specified number of self-compositions in one variable. I have only been able to find the sage function of composition for one variable polynomials, not for nesting two variable power series.</p>
http://ask.sagemath.org/question/39960/how-can-i-recurse-a-power-series-in-two-variables/?comment=40011#post-id-40011In general though, providing a working example helps other Ask Sage users to explore a question.
This question had `g(x, g(x, g(x, x)))` but no definition of `g` to make that work.Fri, 08 Dec 2017 09:06:39 -0600http://ask.sagemath.org/question/39960/how-can-i-recurse-a-power-series-in-two-variables/?comment=40011#post-id-40011Comment by slelievre for <p>I would like very much to express, for example, </p>
<pre><code>R.<x, y> = PowerSeriesRing(QQ, default_prec = 20)
g(x, g(x, g(x, x)))
</code></pre>
<p>Or, </p>
<pre><code>f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, (f(x, (f(x, f(x,y))))))))))))))))).expand()
</code></pre>
<p>In a more elegant way, for a specified number of self-compositions in one variable. I have only been able to find the sage function of composition for one variable polynomials, not for nesting two variable power series.</p>
http://ask.sagemath.org/question/39960/how-can-i-recurse-a-power-series-in-two-variables/?comment=39966#post-id-39966Could you provide a definition of `f` and `g` that one could use to explore your question?Wed, 06 Dec 2017 01:29:35 -0600http://ask.sagemath.org/question/39960/how-can-i-recurse-a-power-series-in-two-variables/?comment=39966#post-id-39966Answer by slelievre for <p>I would like very much to express, for example, </p>
<pre><code>R.<x, y> = PowerSeriesRing(QQ, default_prec = 20)
g(x, g(x, g(x, x)))
</code></pre>
<p>Or, </p>
<pre><code>f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, f(x, (f(x, (f(x, f(x,y))))))))))))))))).expand()
</code></pre>
<p>In a more elegant way, for a specified number of self-compositions in one variable. I have only been able to find the sage function of composition for one variable polynomials, not for nesting two variable power series.</p>
http://ask.sagemath.org/question/39960/how-can-i-recurse-a-power-series-in-two-variables/?answer=39967#post-id-39967Defining a function would give you a nice syntax for this kind of iteration.
For example, let us define `right_iterate` as follows.
def right_iterate(n, g):
x, y = g.parent().gens()
gg = y
for k in xrange(n):
gg = g(x, gg)
return gg
Suppose we defined
sage: g = x*y^3 + x^3*y^11 - 1/21*x^11*y^5 - 2/5*x^3*y^13 + O(x, y)^60
then, instead of writing
sage: g(x, g(x, g(x, y)))
x^13*y^27 + 9*x^15*y^35 - 3/7*x^23*y^29 - 18/5*x^15*y^37 - 1/7*x^25*y^33 + O(x, y)^60
one can write
sage: right_iterate(3, g)
x^13*y^27 + 9*x^15*y^35 - 3/7*x^23*y^29 - 18/5*x^15*y^37 - 1/7*x^25*y^33 + O(x, y)^60
and instead of
sage: g(x, g(x, g(x, x)))
x^40 + 9*x^50 - 141/35*x^52 - 1/7*x^58 + O(x, y)^60
one can write
sage: right_iterate(3, g)(x, x)
x^40 + 9*x^50 - 141/35*x^52 - 1/7*x^58 + O(x, y)^60
Of course, you could modify the function to directly use `(x, x)` if you always want that.
Wed, 06 Dec 2017 01:45:08 -0600http://ask.sagemath.org/question/39960/how-can-i-recurse-a-power-series-in-two-variables/?answer=39967#post-id-39967