ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 09 Nov 2021 19:26:15 +0100Substituting vars of PowerSeries over RRhttps://ask.sagemath.org/question/59637/substituting-vars-of-powerseries-over-rr/ What is the intended way to substitute variables of PowerSeries (or equivalently LaurentSeries) over RR?
The following code does not produce the correct result:
sage: P.<x> = PowerSeriesRing(RR)
sage: p = x**2+2*x+3
sage: p.subs(x=x**2)
3.00000000000000 + 2.00000000000000*x + 1.00000000000000*x^2
In ZZ, the previous example works correctly:
sage: P.<x> = PowerSeriesRing(ZZ)
sage: p = x**2+2*x+3
sage: p.subs(x=x**2)
3 + 2*x^2 + x^4
Working with PolynomialRings over RR also seems to work correctly, I do however need to work with negative exponents (i.e., LaurentSeries) and therefore cannot easily convert my expressions to polynomials before substituting.Mon, 08 Nov 2021 11:30:20 +0100https://ask.sagemath.org/question/59637/substituting-vars-of-powerseries-over-rr/Answer by Max Alekseyev for <p>What is the intended way to substitute variables of PowerSeries (or equivalently LaurentSeries) over RR?
The following code does not produce the correct result:</p>
<pre><code>sage: P.<x> = PowerSeriesRing(RR)
sage: p = x**2+2*x+3
sage: p.subs(x=x**2)
3.00000000000000 + 2.00000000000000*x + 1.00000000000000*x^2
</code></pre>
<p>In ZZ, the previous example works correctly:</p>
<pre><code>sage: P.<x> = PowerSeriesRing(ZZ)
sage: p = x**2+2*x+3
sage: p.subs(x=x**2)
3 + 2*x^2 + x^4
</code></pre>
<p>Working with PolynomialRings over RR also seems to work correctly, I do however need to work with negative exponents (i.e., LaurentSeries) and therefore cannot easily convert my expressions to polynomials before substituting.</p>
https://ask.sagemath.org/question/59637/substituting-vars-of-powerseries-over-rr/?answer=59662#post-id-59662Use `p.subs({x:x**2})` rather than `p.subs(x=x**2)`.Tue, 09 Nov 2021 19:26:15 +0100https://ask.sagemath.org/question/59637/substituting-vars-of-powerseries-over-rr/?answer=59662#post-id-59662