First time here? Check out the FAQ!

Ask Your Question
1

variable size exponent for Polynomial Ring

asked 3 years ago

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

Preview: (hide)

Comments

Why not define it as function?

def mypow(k):
  return expr^k
Max Alekseyev gravatar imageMax Alekseyev ( 3 years ago )

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

kev gravatar imagekev ( 3 years ago )

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

Max Alekseyev gravatar imageMax Alekseyev ( 3 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 3 years ago

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.

Preview: (hide)
link

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: 3 years ago

Seen: 249 times

Last updated: Dec 06 '21