Ask Your Question
1

How can I reduce the coefficients modulo a certain integer in a matrix of polynomials?

asked 2022-08-09 16:13:11 +0100

AM gravatar image

For eg, if I have a 2x1 matrix of polynomials,

A = matrix([[25x^3+50x^2+1],[18x+11]])

how do I reduce all the coefficients modulo 2 so that I have the matrix,

A = matrix([[x^3+1],[1]])
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2022-08-11 22:31:52 +0100

slelievre gravatar image

Starting from an already defined matrix, use its change_ring method to produce a matrix over a different ring.

Suppose we have defined our initial matrix:

sage: A = matrix([[25*x^3 + 50*x^2 + 1], [18*x + 11]])
sage: A
[25*x^3 + 50*x^2 + 1]
[          18*x + 11]

Consider it over the polynomial ring over integers modulo two:

sage: B = A.change_ring(GF(2)['x'])
sage: B
[x^3 + 1]
[      1]

If needed, move entries from there to polynomials over the integers:

sage: C = B.change_ring(ZZ['x'])
sage: C
[x^3 + 1]
[      1]

One of them behaves modulo two, the other does not:

sage: 3 * B
[x^3 + 1]
[      1]

sage: 3 * C
[3*x^3 + 3]
[        3]
edit flag offensive delete link more
0

answered 2022-08-10 00:19:44 +0100

tmonteil gravatar image

You just have to define your polynomials as elements of the polynomial ring $\mathbb{F}_2[x]$ as follows:

sage: R.<x> = GF(2)[]
sage: x.parent()
Univariate Polynomial Ring in x over Finite Field of size 2 (using GF2X)
sage: A = matrix([[25*x^3+50*x^2+1],[18*x+11]])
sage: A
[x^3 + 1]
[      1]
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

Stats

Asked: 2022-08-09 16:13:11 +0100

Seen: 270 times

Last updated: Aug 11 '22