Ask Your Question

Monomial with power modulo n

asked 2020-06-09 11:15:48 +0200

only1sale gravatar image

I need to implement the following formal structure $$ax^\gamma, \gamma \in \mathbb{Z}/n\mathbb{Z}, a \in \mathbb{R}$$ and $x$ is a formal variable.

I tried

ZZ6 = Integers(6) x = var('x') x^ZZ6(9) + x^ZZ6(11)

And get value x^8, whereas I need x^ZZ6(8).

How can I do this in sage?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2020-06-09 12:36:28 +0200

tmonteil gravatar image

You can make a polynomial quotient ring:

sage: R.<x> = RR[]
sage: R
Univariate Polynomial Ring in x over Real Field with 53 bits of precision
sage: S = R.quotient(x^6-1)
sage: S
Univariate Quotient Polynomial Ring in xbar over Real Field with 53 bits of precision with modulus x^6 - 1.00000000000000
sage: S.inject_variables()
Defining xbar

Then, you can do

sage: xbar^9 + xbar^11
xbar^5 + xbar^3
sage: xbar^9 * xbar^11

Also, if your coefficients turn out to be rational, i would sugest to define sage: R.<x> = QQ[]

edit flag offensive delete link more


Thanks a lot! This is exactly what I needed.

only1sale gravatar imageonly1sale ( 2020-06-09 13:38:55 +0200 )edit

This solution has the drawback of introducing an inexact ring in otherwise exact computations...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2020-06-09 21:39:05 +0200 )edit

@emmanuel-charpentier : i used RR to stay close to @only1sale question, I then explained that QQ could be used otherwise, i do not get your point.

tmonteil gravatar imagetmonteil ( 2020-06-10 02:38:36 +0200 )edit

answered 2020-06-09 12:42:03 +0200

FrédéricC gravatar image

another way

sage: R = Zmod(6)
sage: A = R.algebra(QQ,category=CommutativeAdditiveSemigroups())
sage: x = A.gens()[1]
sage: 3*x+x**4
3*B[1] + B[4]
sage: _**4
120*B[1] + 136*B[4]
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: 2020-06-09 11:15:48 +0200

Seen: 298 times

Last updated: Jun 09 '20