Ask Your Question
0

Solving modular systems of equation

asked 2017-04-02 17:31:52 +0200

anonymous user

Anonymous

I am trying to solve a system of equations mod $p$, for $p$ prime. I have build matrices $A$ and $b$ and I am using the function solve_right() to solve $Ax = b$. But I need to solve $Ax = b$ mod $p$. Is there any functions that could do that ? thanks !

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-04-02 21:24:13 +0200

B r u n o gravatar image

If you define your matrices containing elements of the field $\mathbb Z/p\mathbb Z$, solve_right does what you need.

sage: A = matrix(GF(17), [[6,3], [3,8]])
sage: b = matrix(GF(17), [1, 2]).transpose()
sage: A.solve_right(b)

[14]
[12]

If for some reason you need matrices over (say) $\mathbb Z$ but still need to solve modulo some prime $p$, you can use change_ring.

sage: A = matrix(ZZ, [[1,2], [3,4]])
sage: b = matrix(ZZ, [5, 6]).transpose()
sage: A.change_ring(GF(17)).solve_right(b.change_ring(GF(17)))

[13]
[13]
edit flag offensive delete link more

Comments

great, thanks. I'll try the last option.

Sasha-dpt gravatar imageSasha-dpt ( 2017-04-02 22:27:03 +0200 )edit

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: 2017-04-02 17:31:52 +0200

Seen: 4,114 times

Last updated: Apr 02 '17