Ask Your Question
0

simplify coefficients of laurent series?

asked 12 years ago

sdkwok gravatar image

updated 10 years ago

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.

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 12 years ago

benjaminfjones gravatar image

updated 12 years ago

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.

Preview: (hide)
link

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 ( 12 years ago )

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

DSM gravatar imageDSM ( 12 years ago )

Thanks everyone!

sdkwok gravatar imagesdkwok ( 12 years ago )
0

answered 12 years ago

lftabera gravatar image

updated 12 years ago

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)
Preview: (hide)
link

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: 12 years ago

Seen: 746 times

Last updated: Feb 22 '13