Ask Your Question
1

How do I retrieve the variables that appear in a polynomial?

asked 2020-03-15 14:28:15 +0100

mcmug gravatar image

Hello, I'd like to know I can retrieve the list of variables that appear in $g$ in the following example.

A.<x,y> = InfinitePolynomialRing(QQ)
g=x_[0]+x_[1]+y_[0]

Thanks in advance!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2020-03-15 16:00:41 +0100

rburing gravatar image

In SageMath 9.0:

sage: A.<x,y> = InfinitePolynomialRing(QQ)
sage: g=x[0]+x[1]+y[0]
sage: g.variables()
(x_1, x_0, y_0)
edit flag offensive delete link more

Comments

1

Thanks. Do you know how I can get a list like [0,1] for x and [0] for y?

mcmug gravatar imagemcmug ( 2020-03-15 16:16:42 +0100 )edit

@mcmug That's tricky. I don't see a clean way to do it right now. You can do it by converting to/from a string though.

rburing gravatar imagerburing ( 2020-03-15 19:07:13 +0100 )edit

I see. Thanks!

mcmug gravatar imagemcmug ( 2020-03-16 02:19:07 +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: 2020-03-15 14:28:15 +0100

Seen: 653 times

Last updated: Mar 15 '20