Ask Your Question
1

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

asked 2020-03-15 08:28:15 -0500

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 10:00:41 -0500

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 10:16:42 -0500 )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 13:07:13 -0500 )edit

I see. Thanks!

mcmug gravatar imagemcmug ( 2020-03-15 20:19:07 -0500 )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 08:28:15 -0500

Seen: 40 times

Last updated: Mar 15