Ask Your Question
0

simplify coefficients of laurent series?

asked 2013-02-21 10:55:37 +0200

sdkwok gravatar image

updated 2015-01-14 14:29:27 +0200

FrédéricC gravatar image

I am working with a Laurent series f. My goal is to calculate the principal part of f^3. The code I am using is this:

R.<u> = LaurentSeriesRing(SR, 'u'); R

b2, b1, a0, a1, a2, a3, a4 = var('b2 b1 a0 a1 a2 a3 a4')

f = b2*u^-2 + b1*u^-1 + a0 + a1*u + a2*u^2 + a3*u^3 + a4*u^4 + O(u^5)

f^3

The answer I get is:

b2^3*u^-6 + 3*b1*b2^2*u^-5 + (a0*b2^2 + 2*b1^2*b2 + (2*a0*b2 + b1^2)*b2)*u^-4 + (2*a0*b1*b2 + a1*b2^2 + (2*a0*b2 + b1^2)*b1 + 2*(a0*b1 + a1*b2)*b2)*u^-3 + (2*a1*b1*b2 + a2*b2^2 + (2*a0*b2 + b1^2)*a0 + 2*(a0*b1 + a1*b2)*b1 + (a0^2 + 2*a1*b1 + 2*a2*b2)*b2)*u^-2 + (2*a2*b1*b2 + a3*b2^2 + (2*a0*b2 + b1^2)*a1 + 2*(a0*b1 + a1*b2)*a0 + 2*(a0*a1 + a2*b1 + a3*b2)*b2 + (a0^2 + 2*a1*b1 + 2*a2*b2)*b1)*u^-1 + (2*a3*b1*b2 + a4*b2^2 + (2*a0*b2 + b1^2)*a2 + 2*(a0*b1 + a1*b2)*a1 + 2*(a0*a1 + a2*b1 + a3*b2)*b1 + (a0^2 + 2*a1*b1 + 2*a2*b2)*a0 + (2*a0*a2 + a1^2 + 2*a3*b1 + 2*a4*b2)*b2) + O(u)

SAGE does not simplify the coefficients of the result. Is there some command that I can enter that will allow me to simultaneously simplify the coefficients of each power of u and output the result up to O(u)? The simplify command does not seem to work.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2013-02-22 03:08:06 +0200

benjaminfjones gravatar image

updated 2013-02-22 13:44:07 +0200

Yep, see the coefficients() method:

...
sage: g = f^3
sage: g.coefficients() 
[b2^3, 3*b1*b2^2, a0*b2^2 + 2*b1^2*b2 + (2*a0*b2 + b1^2)*b2, 2*a0*b1*b2 + a1*b2^2 + (2*a0*b2 + b1^2)*b1 + 2*(a0*b1 + a1*b2)*b2, 2*a1*b1*b2 + a2*b2^2 + (2*a0*b2 + b1^2)*a0 + 2*(a0*b1 + a1*b2)*b1 + (a0^2 + 2*a1*b1 + 2*a2*b2)*b2, 2*a2*b1*b2 + a3*b2^2 + (2*a0*b2 + b1^2)*a1 + 2*(a0*b1 + a1*b2)*a0 + 2*(a0*a1 + a2*b1 + a3*b2)*b2 + (a0^2 + 2*a1*b1 + 2*a2*b2)*b1, 2*a3*b1*b2 + a4*b2^2 + (2*a0*b2 + b1^2)*a2 + 2*(a0*b1 + a1*b2)*a1 + 2*(a0*a1 + a2*b1 + a3*b2)*b1 + (a0^2 + 2*a1*b1 + 2*a2*b2)*a0 + (2*a0*a2 + a1^2 + 2*a3*b1 + 2*a4*b2)*b2]

--- edit

Sorry, I answered the wrong question. If you want to simplify the coefficients, you can map the simplify function over your list:

sage: g = f^3
sage: map(simplify, g.coefficients())
[b2^3,
 3*b1*b2^2,
 a0*b2^2 + 2*b1^2*b2 + (2*a0*b2 + b1^2)*b2,
 2*a0*b1*b2 + a1*b2^2 + (2*a0*b2 + b1^2)*b1 + 2*(a0*b1 + a1*b2)*b2,
 2*a1*b1*b2 + a2*b2^2 + (2*a0*b2 + b1^2)*a0 + 2*(a0*b1 + a1*b2)*b1 + (a0^2 + 2*a1*b1 + 2*a2*b2)*b2,
 2*a2*b1*b2 + a3*b2^2 + (2*a0*b2 + b1^2)*a1 + 2*(a0*b1 + a1*b2)*a0 + 2*(a0*a1 + a2*b1 + a3*b2)*b2 + (a0^2 + 2*a1*b1 + 2*a2*b2)*b1,
 2*a3*b1*b2 + a4*b2^2 + (2*a0*b2 + b1^2)*a2 + 2*(a0*b1 + a1*b2)*a1 + 2*(a0*a1 + a2*b1 + a3*b2)*b1 + (a0^2 + 2*a1*b1 + 2*a2*b2)*a0 + (2*a0*a2 + a1^2 + 2*a3*b1 + 2*a4*b2)*b2]

But, if you look at the resulting list you'll see that it's identical to g.coefficients(), so the coefficients are "simplified". Maybe what you really want is to expand the coefficients (which is less simple that the factored form by some definition):

sage: map(expand, g.coefficients())
[b2^3,
 3*b1*b2^2,
 3*a0*b2^2 + 3*b1^2*b2,
 6*a0*b1*b2 + 3*a1*b2^2 + b1^3,
 3*a0^2*b2 + 3*a0*b1^2 + 6*a1*b1*b2 + 3*a2*b2^2,
 3*a0^2*b1 + 6*a0*a1*b2 + 3*a1*b1^2 + 6*a2*b1*b2 + 3*a3*b2^2,
 a0^3 + 6*a0*a1*b1 + 6*a0*a2*b2 + 3*a1^2*b2 + 3*a2*b1^2 + 6*a3*b1*b2 + 3*a4*b2^2]

If you're curious about other powerful list operations, check out map, reduce, and filter here.

edit flag offensive delete link more

Comments

The coefficients command doesn't simplify the coefficients, it only puts them in a list. If you notice, for instance, the third coefficient in your answer (a0*b2^2 + 2*b1^2*b2 + (2*a0*b2 + b1^2)*b2) is not in a simplified form. Perhaps there is a command that simplifies all entries in a list?

sdkwok gravatar imagesdkwok ( 2013-02-22 06:22:54 +0200 )edit

You can do a little better: `[SR(gx).full_simplify() for gx in g.coefficients()]`.

DSM gravatar imageDSM ( 2013-02-22 14:36:32 +0200 )edit

Thanks everyone!

sdkwok gravatar imagesdkwok ( 2013-02-23 16:38:23 +0200 )edit
0

answered 2013-02-22 18:51:48 +0200

lftabera gravatar image

updated 2013-02-22 18:52:38 +0200

In this case, I think it would be better to work with coefficients in a polynomial ring

sage: K = QQ['b2,b1,a0,a1,a2,a3,a4']
sage: K.inject_variables()
Defining b2, b1, a0, a1, a2, a3, a4         
sage: R = K[['u']]
sage: u = R.gen() 
sage: f = b2*u^-2 + b1*u^-1 + a0 + a1*u + a2*u^2 + a3*u^3 + a4*u^4 + O(u^5)
sage: f^3
b2^3*u^-6 + 3*b2^2*b1*u^-5 + (3*b2*b1^2 + 3*b2^2*a0)*u^-4 + (b1^3 + 6*b2*b1*a0 + 3*b2^2*a1)*u^-3 + (3*b1^2*a0 + 3*b2*a0^2 + 6*b2*b1*a1 + 3*b2^2*a2)*u^-2 + (3*b1*a0^2 + 3*b1^2*a1 + 6*b2*a0*a1 + 6*b2*b1*a2 + 3*b2^2*a3)*u^-1 + (a0^3 + 6*b1*a0*a1 + 3*b2*a1^2 + 3*b1^2*a2 + 6*b2*a0*a2 + 6*b2*b1*a3 + 3*b2^2*a4) + O(u)
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

Stats

Asked: 2013-02-21 10:55:37 +0200

Seen: 573 times

Last updated: Feb 22 '13