Ask Your Question
1

Monomial with power modulo n

asked 2020-06-09 04:15:48 -0500

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
2

answered 2020-06-09 05:36:28 -0500

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
xbar^2

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

edit flag offensive delete link more

Comments

Thanks a lot! This is exactly what I needed.

only1sale gravatar imageonly1sale ( 2020-06-09 06:38:55 -0500 )edit

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

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2020-06-09 14:39:05 -0500 )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-09 19:38:36 -0500 )edit
2

answered 2020-06-09 05:42:03 -0500

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

Stats

Asked: 2020-06-09 04:15:48 -0500

Seen: 50 times

Last updated: Jun 09