Ask Your Question
1

variable size exponent for Polynomial Ring

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

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')
expr^k

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

Comments

Why not define it as function?

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

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

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

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

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

1 Answer

Sort by ยป oldest newest most voted
0

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

Emmanuel Charpentier gravatar image

Possible workaround :

sage: var("k", domain="integer")
k
sage: assume(k>0)
sage: var("j")
j
sage: product(expr, j, 1, k)
xbar^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

Stats

Asked: 2021-12-05 20:08:53 +0100

Seen: 227 times

Last updated: Dec 06 '21