Processing math: 100%
Ask Your Question
0

Assumptions on symbolic expressions

asked 1 year ago

kejv2 gravatar image
a, b = var('a,b')
((a + b)^2).expand()

How can I compute/expand the last expression assuming that ab=0? I.e. I would like the result to be a2+b2. I tried with assuming(..) but that doesn't have any effect.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 1 year ago

Max Alekseyev gravatar image

It's easy for polynomial (rather than symbolic) variables:

K.<a,b> = QQ[]
J = K.ideal( [a*b] )
((a+b)^2).reduce(J)
Preview: (hide)
link

Comments

Thanks, makes sense. What if the base field is more complicated, though? E.g. E.<w> = CyclotomicField(3) and I would like to assume a+b+c=0 in the expression (a+bw+cw2)3 and would like to group the monomials by the powers of w instead of the monomials in a,b,c.

kejv2 gravatar imagekejv2 ( 1 year ago )

Something like this will do the job:

K.<w,a,b,c> = QQ[]
J = K.ideal( [cyclotomic_polynomial(3,w), a+b+c] )
f = ((a+b*w+c*w^2)^3).reduce(J)

Then you can extract the coefficients of powers of w as f.coefficient({w:0}) and f.coefficient({w:1}).

Max Alekseyev gravatar imageMax Alekseyev ( 1 year ago )

That's great! The only downside to this approach is the false symmetry between w,a,b,c in the poly ring definition. This doesn't correspond to reality and brings additional problems. For instance, I want to express various combinations of the w-coefficients as elementary symmetric polynomials. Is there a better way than this?

ABC.<a,b,c> = QQ[]
fABC = ABC(f.coefficient({w:0}))
SymK = SymmetricFunctions(QQ).e()
SymK.from_polynomial(fABC)

Plugging in f to SymK directly doesn't work because f.coefficient({w:0}) is of course not symmetric in K.<w,a,b,c>.

kejv2 gravatar imagekejv2 ( 1 year ago )

Instead of ABC(f.coefficient({w:0})) you can use f.coefficient({w:0}).specialization({w:0}). In fact for w^0 you can have simply f.specialization({w:0}) but for w^1 it has to be f.coefficient({w:1}).specialization({w:0}).

Max Alekseyev gravatar imageMax Alekseyev ( 1 year ago )

For an alternative approach, see my answer in https://ask.sagemath.org/question/75522/

Max Alekseyev gravatar imageMax Alekseyev ( 1 year ago )

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: 1 year ago

Seen: 241 times

Last updated: Jan 18 '24