Ask Your Question

Sage is not returning all solutions to equations modulo n

asked 2015-06-24 18:05:16 +0200

Acanti gravatar image

updated 2015-06-24 18:25:08 +0200

calc314 gravatar image

I am trying to find all 2x2 matrices $S$ over $Z/9Z$ such that $S^3=I$, where I is the identity matrix. I am currently using the following procedure:

S = matrix(SR, 2, [[a,b],[c,d]]);
l=solve_mod([S3[0,0]==1,S3[0,1]==0,S3[1,0]==0,S3[1,1]==1], 9);

The list of solutions (there are 207) I receive does not include S=[[1,3],[3,1]], for example, which does in fact satisfy $S^3=I$. I am new to Sage, is there something I am missing? How can I get a complete list of solutions?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-06-24 18:35:32 +0200

fidbc gravatar image

Trying to find them using brute force isn't that bad. The following worked for me

import itertools
for a,b,c,d in itertools.product(Z9,repeat=4):
    if I==M^3:

The length of the list seems to be 297 though, but the 39th element seems to be the one that was missing from your list.

edit flag offensive delete link more


Thanks! This will fix my current problem, but I am still concerned for when I use larger matrices, and/or a different modulus. If anyone has ideas on a really efficient way to do this in general, I would love to hear them.

Acanti gravatar imageAcanti ( 2015-06-24 18:44:09 +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


Asked: 2015-06-24 18:05:16 +0200

Seen: 258 times

Last updated: Jun 24 '15