Ask Your Question

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

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

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)

Thanks in advance!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

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

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



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 +0200 )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 +0200 )edit

I see. Thanks!

mcmug gravatar imagemcmug ( 2020-03-16 02:19:07 +0200 )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


Asked: 2020-03-15 14:28:15 +0200

Seen: 376 times

Last updated: Mar 15 '20