Ask Your Question
1

How to extract exponents from a monomial in a FreeAlgebra

asked 2017-04-05 01:34:43 +0100

paragon gravatar image

I want something like this, or a way to get the equivalent information:

sage: S.<X,Y> = FreeAlgebra(QQ)
sage: m = X*Y*X^2
sage: m.my_exponents_function()
[(X,1),(Y,1),(X,2)]

or

sage: m.my_factor_function()
[X,Y,X,X]

would be as good or maybe better.

How can I get that information? I've looked over the available methods and can't seem to find anything. This is easy to do with Polynomial Rings.

I guess I could parse the string representation, but shouldn't there be a better way?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-04-05 17:10:14 +0100

Here are two options:

sage: S.<X,Y> = FreeAlgebra(QQ)
sage: m = X*Y*X^2
sage: a = m.leading_support()
sage: a.to_list()
[X, Y, X, X]

So if you have more than one term:

sage: m = X*Y*X**2 + 3*X**4*Y
sage: [a.to_list() for a in m.support()]
[[X, Y, X, X], [X, X, X, X, Y]]

You can also access raw exponent information:

sage: S.<X,Y> = FreeAlgebra(QQ)
sage: m = X*Y*X^2
sage: a = m.leading_support()
sage: a.__dict__
{'_element_list': [(0, 1), (1, 1), (0, 2)]}
sage: a.__dict__.values()[0]
[(0, 1), (1, 1), (0, 2)]

Each entry in this list is of the form (gen, power), where gen=0 corresponds to X and gen=1 corresponds to Y.

edit flag offensive delete link more

Comments

Perfect! It is hidden pretty deep, I would not have found that.

paragon gravatar imageparagon ( 2017-04-05 20:08:51 +0100 )edit

I agree, it's not at all obvious.

John Palmieri gravatar imageJohn Palmieri ( 2017-04-06 16:31:10 +0100 )edit

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-04-05 01:34:43 +0100

Seen: 6,567 times

Last updated: Apr 05 '17