Ask Your Question
0

Return index of variable

asked 2022-11-18 18:28:43 +0100

Thrash gravatar image

I have the following

R.<a> = InfinitePolynomialRing(QQ)
b = a[3]    # 3 or any arbitrary non-negative integer

Is there a function that takes b as the input and gives the 3 back?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-11-18 18:46:18 +0100

Emmanuel Charpentier gravatar image

This seems to work :

sage: R1.<a>=InfinitePolynomialRing(QQ)
sage: reset()
sage: R1.<a>=InfinitePolynomialRing(QQ)
sage: b=a[3]
sage: R1.varname_key(str(b))[1]
3

See R1.varname_key? for further enlightment... ;-)

HTH,

edit flag offensive delete link more

Comments

Thanks! Do you know how I can get the degree back, for example: p = a[1]*a[2]^2, but p.degree(a[1]) doesn't work.

Thrash gravatar imageThrash ( 2022-11-19 00:00:18 +0100 )edit

OK, I found it, it's p.degree(a[1].variable()).

Thrash gravatar imageThrash ( 2022-11-19 00:12:25 +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: 2022-11-18 18:28:43 +0100

Seen: 138 times

Last updated: Nov 18 '22