Mathematica: Matrix product Modulus an integer

Click For Summary

Discussion Overview

The discussion revolves around performing matrix multiplication in Mathematica while applying a modulus operation with an integer. Participants explore various methods to achieve this, given the limitations of the built-in functions.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant notes that the "Modulus->n" option cannot be used with the "Dot" function for matrix multiplication.
  • Another participant suggests using the inverse function as a workaround, proposing the expression "Inverse[Inverse[A,Modulus->n],Modulus->n]."
  • A different participant expresses confusion regarding the suggestion and clarifies the need for the product of two matrices A and B with modulus applied.
  • Another suggestion is made to use "Inner," which allows specifying a multiplication operator, as an alternative to "Dot."
  • A participant provides a specific code example for matrix multiplication followed by modulus operation, indicating a practical approach.
  • One participant challenges the assumption that the modulus operation can be distributed over matrix multiplication, stating that "(a.b Mod m) is not equal to (a Mod m).(b Mod m)" for matrices.

Areas of Agreement / Disagreement

Participants express differing views on the methods to apply modulus in matrix multiplication, with no consensus reached on a definitive solution. Some approaches are proposed, but their effectiveness is debated.

Contextual Notes

Participants highlight limitations in the Mathematica functions available for this task, particularly regarding the application of modulus in matrix operations.

Who May Find This Useful

This discussion may be useful for Mathematica users interested in matrix operations, particularly those needing to apply modulus in their calculations.

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 ·
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 13 ·
Replies
13
Views
3K