Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
0

Solving modular systems of equation

asked 8 years ago

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 !

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 8 years ago

B r u n o gravatar image

If you define your matrices containing elements of the field Z/pZ, 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) 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]
Preview: (hide)
link

Comments

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

Sasha-dpt gravatar imageSasha-dpt ( 8 years ago )

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: 8 years ago

Seen: 4,903 times

Last updated: Apr 02 '17