Ask Your Question

variable size exponent for Polynomial Ring

asked 2021-12-05 20:08:53 +0200

kev gravatar image

Is it possible to use a positive variable size exponent in a expression from elements in a polynomial ring? I have the following expression:

P.<x> = PolynomialRing(ZZ)
R = P.quotient_by_principal_ideal(ideal(x^3 - 3))
expr = R(x)

and I want to calculate expr^k where k is some positive integer. What I have is the following:

k = var('k', domain='positive')

But I get the error: unsupported operand parent(s) for ^: 'Univariate Quotient Polynomial Ring in xbar over Integer Ring with modulus x^3 - 3' and 'Symbolic Ring'

I'm very new to sage so any help or pointers to the documentation would be appreciated

edit retag flag offensive close merge delete


Why not define it as function?

def mypow(k):
  return expr^k
Max Alekseyev gravatar imageMax Alekseyev ( 2021-12-05 21:06:36 +0200 )edit

I want a general expression for it, like when applying the binomial formula.

kev gravatar imagekev ( 2021-12-06 08:39:19 +0200 )edit

Can you give an example of what you want to achieve?

Max Alekseyev gravatar imageMax Alekseyev ( 2021-12-06 15:55:13 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-12-06 12:33:21 +0200

Emmanuel Charpentier gravatar image

Possible workaround :

sage: var("k", domain="integer")
sage: assume(k>0)
sage: var("j")
sage: product(expr, j, 1, k)

which might be wrapped in a function... But be aware that the result is a symbolic expression, not an element of R.

edit flag offensive delete link more

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: 2021-12-05 20:08:53 +0200

Seen: 156 times

Last updated: Dec 06 '21