Ask Your Question
1

How to truncate a power series in two variables?

asked 2017-12-06 17:09:09 -0600

masseygirl gravatar image

I would like to truncate power-series by setting $y$ to 0, in order to express $y = x^3 - xy^2$ as a power series in $x$ by recursively plugging in the equation for $y$, then truncating.

R.<x, y> = PowerSeriesRing(QQ, default_prec = 20)
f = x^3 + x*y^2
j = f(x, f(x, f(x, f(x, f(x,y))))).expand()
j + O(y)
---------------------------------------------------------------------------
ArithmeticError                           Traceback (most recent call last)
<ipython-input-20-fe9380f2a091> in <module>()
----> 1 j + O(y)

/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/rings/big_oh.py in O(*x, **kwds)
    154     elif hasattr(x, 'O'):
    155         return x.O(**kwds)
--> 156     raise ArithmeticError("O(%s) not defined" % (x,))

ArithmeticError: O(y) not defined

I have found that other variants, such asj + O(x, y)^{31}, j.truncate(31), and j + R.O(31) also do not work.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2017-12-06 18:34:53 -0600

tmonteil gravatar image

I do not know which version of Sage you have, but for me (i am using the latest develop banch), there is no expand method for such power series:

sage: R.<x, y> = PowerSeriesRing(QQ, default_prec = 20)
....: f = x^3 + x*y^2
....: j = f(x, f(x, f(x, f(x, f(x,y))))).expand()
AttributeError: 'MPowerSeriesRing_generic_with_category.element_class' object has no attribute 'expand'

You can simply write:

sage: R.<x, y> = PowerSeriesRing(QQ, default_prec = 20)
....: f = x^3 + x*y^2
....: j = f(x, f(x, f(x, f(x, f(x,y)))))
....: j
x^3 + x^7 + 2*x^11 + 5*x^15 + 14*x^19 + 16*x^17*y^2 + 8*x^15*y^4 + 26*x^23 + 48*x^21*y^2 + 40*x^19*y^4 + 16*x^17*y^6 + 4*x^15*y^8 + 44*x^27 + 112*x^25*y^2 + 120*x^23*y^4 + 64*x^21*y^6 + 16*x^19*y^8 + 69*x^31 + 240*x^29*y^2 + 360*x^27*y^4 + 304*x^25*y^6 + 156*x^23*y^8 + 48*x^21*y^10 + 8*x^19*y^12 + 94*x^35 + 416*x^33*y^2 + 784*x^31*y^4 + 832*x^29*y^6 + 560*x^27*y^8 + 256*x^25*y^10 + 80*x^23*y^12 + 16*x^21*y^14 + 2*x^19*y^16 + 114*x^39 + 640*x^37*y^2 + 1536*x^35*y^4 + 2048*x^33*y^6 + 1648*x^31*y^8 + 816*x^29*y^10 + 248*x^27*y^12 + 48*x^25*y^14 + 6*x^23*y^16 + 116*x^43 + 816*x^41*y^2 + 2520*x^39*y^4 + 4480*x^37*y^6 + 5040*x^35*y^8 + 3696*x^33*y^10 + 1736*x^31*y^12 + 480*x^29*y^14 + 60*x^27*y^16 + 94*x^47 + 800*x^45*y^2 + 3040*x^43*y^4 + 6800*x^41*y^6 + 9940*x^39*y^8 + 9968*x^37*y^10 + 7000*x^35*y^12 + 3440*x^33*y^14 + 1150*x^31*y^16 + 240*x^29*y^18 + 24*x^27*y^20 + 60*x^51 + 608*x^49*y^2 + 2784*x^47*y^4 + 7600*x^45*y^6 + 13740*x^43*y^8 + 17280*x^41*y^10 + 15456*x^39*y^12 + 9888*x^37*y^14 + 4500*x^35*y^16 + 1440*x^33*y^18 + 320*x^31*y^20 + 48*x^29*y^22 + 4*x^27*y^24 + 28*x^55 + 336*x^53*y^2 + 1848*x^51*y^4 + 6160*x^49*y^6 + 13860*x^47*y^8 + 22176*x^45*y^10 + 25872*x^43*y^12 + 22176*x^41*y^14 + 13860*x^39*y^16 + 6160*x^37*y^18 + 1848*x^35*y^20 + 336*x^33*y^22 + 28*x^31*y^24 + 8*x^59 + 112*x^57*y^2 + 728*x^55*y^4 + 2912*x^53*y^6 + 8008*x^51*y^8 + 16016*x^49*y^10 + 24024*x^47*y^12 + 27456*x^45*y^14 + 24024*x^43*y^16 + 16016*x^41*y^18 + 8008*x^39*y^20 + 2912*x^37*y^22 + 728*x^35*y^24 + 112*x^33*y^26 + 8*x^31*y^28 + x^63 + 16*x^61*y^2 + 120*x^59*y^4 + 560*x^57*y^6 + 1820*x^55*y^8 + 4368*x^53*y^10 + 8008*x^51*y^12 + 11440*x^49*y^14 + 12870*x^47*y^16 + 11440*x^45*y^18 + 8008*x^43*y^20 + 4368*x^41*y^22 + 1820*x^39*y^24 + 560*x^37*y^26 + 120*x^35*y^28 + 16*x^33*y^30 + x^31*y^32

Now, if you want to set y to zero, you can do:

sage: j(x,0)
x^3 + x^7 + 2*x^11 + 5*x^15 + 14*x^19 + 26*x^23 + 44*x^27 + 69*x^31 + 94*x^35 + 114*x^39 + 116*x^43 + 94*x^47 + 60*x^51 + 28*x^55 + 8*x^59 + x^63

Or,

sage: j.substitute(y=0)
x^3 + x^7 + 2*x^11 + 5*x^15 + 14*x^19 + 26*x^23 + 44*x^27 + 69*x^31 + 94*x^35 + 114*x^39 + 116*x^43 + 94*x^47 + 60*x^51 + 28*x^55 + 8*x^59 + x^63
edit flag offensive delete link more
0

answered 2017-12-07 13:07:49 -0600

dan_fulea gravatar image

This is more a comment, addressing rather the optimal setting to get many iterations in time. (It became an answer since there is no fit in space.)

The short answert to the question is to take j( x, 0 ), which is still has the parent Multivariate Power Series Ring in x, y over Rational Field. See the detailed answer of tmonteil .

The long answer following is hopefully not so long. The limit is of course known, we solve in the fix point equation $y=f(x,y)$ for $y$. I will take for $f$ the version with the plus sign, $f(x,y)=x^3+xy^2$. The solution to this equation, rewritten as $xy^2 -y +x^3=0$ is formally $$ y =frac 1{2x}( 1\pm \sqrt{ 1-4x^4} )\ ,$$ which can also be easily implemented. The nonsingular solution is obtained for the choice of the minus sign above. The following is the code for the iterations $$y_0=y\ , \qquad y_{n+1}=f(x,y_n)\ ,$$ showing from them the terms that are established from the expected formal limit, plus a four in the valuation. (Next, unestablished term is also shown.) It is important in code to have a truncation when defining f, else the 8.th iteration is still hard to compute in a glance.

The following code, written in the spirit of the posted question shows the linear convergence:

Code:

PREC  = 50
STEPS = 7

R.<x, y> = PowerSeriesRing( QQ, default_prec=PREC )
f = x^3 + x*y^2 + R.O( PREC )
LIM = ( 1 - exp( log( 1-4*x^4 ) / 2 ) ) / 2 / x + R.O( PREC )

print "Expected limit:\nLIM = %s" % LIM
fn = y    # f0 - the start of the iteration process

for n in [ 1..STEPS ]:
    fn  = f( x, fn )
    yn  = fn( x, 0 )
    val = ( LIM - yn ).valuation()
    print "f%s = %s" % ( n, yn + R.O( val+4 ) )

Results:

Expected limit:
LIM = x^3 + x^7 + 2*x^11 + 5*x^15 + 14*x^19 + 42*x^23 + 132*x^27 + 429*x^31 + 1430*x^35 + 4862*x^39 + 16796*x^43 + 58786*x^47 + O(x, y)^49
f1 = x^3 + O(x, y)^11
f2 = x^3 + x^7 + O(x, y)^15
f3 = x^3 + x^7 + 2*x^11 + x^15 + O(x, y)^19
f4 = x^3 + x^7 + 2*x^11 + 5*x^15 + 6*x^19 + O(x, y)^23
f5 = x^3 + x^7 + 2*x^11 + 5*x^15 + 14*x^19 + 26*x^23 + O(x, y)^27
f6 = x^3 + x^7 + 2*x^11 + 5*x^15 + 14*x^19 + 42*x^23 + 100*x^27 + O(x, y)^31
f7 = x^3 + x^7 + 2*x^11 + 5*x^15 + 14*x^19 + 42*x^23 + 132*x^27 + 365*x^31 + O(x, y)^35

Only seven iterations that fit in the line were done and shown here.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-12-06 17:09:09 -0600

Seen: 29 times

Last updated: Dec 07