Ask Your Question

Solving modular systems of equation

asked 2017-04-02 10:31:52 -0500

anonymous user


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

answered 2017-04-02 14:24:13 -0500

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)


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)))

edit flag offensive delete link more


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

Sasha-dpt gravatar imageSasha-dpt ( 2017-04-02 15:27:03 -0500 )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


Asked: 2017-04-02 10:31:52 -0500

Seen: 109 times

Last updated: Apr 02