Loading [MathJax]/jax/output/HTML-CSS/jax.js
Ask Your Question
1

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

asked 5 years ago

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!

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
3

answered 5 years ago

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

Comments

1

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

mcmug gravatar imagemcmug ( 5 years ago )

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

I see. Thanks!

mcmug gravatar imagemcmug ( 5 years 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: 5 years ago

Seen: 758 times

Last updated: Mar 15 '20