Mathematica Mathematica: Matrix product Modulus an integer

AI Thread Summary
To multiply two matrices in Mathematica with a modulus applied to the result, the "Modulus->n" option cannot be used directly with the "Dot" function. Instead, users can utilize the "Inner" function, which allows for specifying a multiplication operator. A suggested approach involves calculating the product of the matrices normally and then applying the modulus using the Mod function. For example, after defining the matrices and the modulus, one can compute the product and then apply Mod to the result. However, it's important to note that the modulus of the product does not equal the product of the modded matrices, highlighting a key distinction in matrix operations under modular arithmetic.
zplot
Messages
17
Reaction score
0
I need to multiply 2 matrix in Mathematica but modulus an Integer.

The "Modulus->n" option cannot be used with "Dot" function. You can use Modulus-> n with "Inverse" or even "Det" but not with "Dot". It is something strange.

How should I do it, then? Any idea?
Thank you.
 
Physics news on Phys.org
Well, it is crude but you can do

Inverse[Inverse[A,Modulus->n],Modulus->n]
 
Sorry DaleSpam but I don't catch you. I need the product of A and B modulus->n.
 
Inverse[Inverse[A.B,Modulus->n],Modulus->n] would that work? If not then you can always use Inner which is a generalization of Dot where you are allowed to specify your multiplication operator.
 
Thank you DaleSpam but it would not work. I will see how could I use Inner.
Thanks a lot
 
You can use this code:

matrixa = {{4, 3}, {1, 2}};
matrixb = {18, 11};
modulo = 26;
som = matrixa.matrixb
Mod[som, modulo]
 
I am sorry but (a.b Mod m) is not iqual to (a Mod m).(b Mod m) being a and b matrix

thank you very much
 

Similar threads

Replies
5
Views
3K
Replies
4
Views
3K
Replies
4
Views
2K
Replies
0
Views
2K
Replies
3
Views
2K
Replies
1
Views
3K
Replies
13
Views
2K
Back
Top