# What does it mean to multiply a matrix by $\bmod{p}$

I am reading a research paper and in one step they have done $S = B \pmod{19}$ where $S$ and $B$ are both matrices. What does it mean? How do I calculate this?

-

First of all, concerning the title, you're not multiplying.

The meaning of "modulo $p$" is somewhat ambiguous, that is, it is used in two different senses.

It may indicate a binary relation. As noted by @lkat, this is the relation on the integers given by $$a \equiv b \pmod{p} \qquad\text{if and only if}\qquad p \mid a - b.$$ This is actually an equivalence relation.

However, you will find fairly often the symbol $r = a \pmod{p}$ to mean that $r$ is the remainder of Euclidean division of $b$ by $p \ne 0$, that is, $r$ is uniquely determined by $$\begin{cases} a = q p + r\\ 0 \le r < \lvert p \rvert \end{cases}$$ for some $q$. In fact one always has for this $r$ that $r \equiv a \pmod{p}$, but in general there are many $b$ such that $b \equiv a \pmod{p}$, namely all $b$ of the form $a + t p$, for $t \in \mathbf{Z}$.

Anyway, I assume you were given an integer matrix $B = [b_{ij}]$, and required to compute a matrix $S = [s_{ij}]$, such that $s_{ij} = b_{ij} \pmod{b}$ is the remainder of the division of $b_{ij}$ by $p$, for all $i, j$.

For instance, for $$B =\begin{bmatrix} 3&-2\\ 6&-7 \end{bmatrix}$$ you will have for $p = 2$ (sorry, I had forgotten to mention that) $$S = \begin{bmatrix} 1&0\\ 0&1 \end{bmatrix}.$$

-
In your illustration, what is the value of b in mod b – Wildling Feb 18 '13 at 17:21
are you saying taht I must simply divide each element of Matrix B by p and put the remainder in the place ? – Wildling Feb 18 '13 at 17:23
@RitwikG Not necessarily; $a\equiv b\bmod p$ might not be a "calculation" as much as could be a generic statement. For matrices, $A\equiv B\bmod p$ would state that for each $i,j$, the difference $a_{ij}-b_{ij}$ is a multiple of $p$. This is useful since if $A\equiv B$ and $C\equiv D$, then $A+C\equiv B+D$ and $AC\equiv BD$ (in abstract terms, this says the quotient map $Z\to Z/pZ$ is a ring homomorphism, but this is perhaps too much language to digest at first). – anon Feb 18 '13 at 17:37
@RitwikG, sorry, I meant $p = 2$. – Andreas Caranti Feb 18 '13 at 17:44
@RitwikG, and yes, replace the elements of $B$ with their remainders. – Andreas Caranti Feb 18 '13 at 18:03

Given two integers $a$, $b$, we have the equivalence $a\equiv b$ (mod $p$) if $a-b$ is divisible by $p$ (usually $p$ will be a prime number). In terms of matrices, $A\equiv B$ (mod $p$) means that $a_{ij}\equiv b_{ij}$ (mod $p$) for every entry in $A$ and $B$.

Edit: To compute an integer mod $p$, you may successively subtract $p$ and compute its remainder. e.g. $21\equiv 16\equiv 11\equiv 6\equiv 1$ (mod $5$).

-
Sorry, I did not understand your illustration. Are you saying that if I want to calculate 21(mod 5), I must subtract 5 from 21 five times ? Is 21(mod 5) = 1 ? Similarly is 48 (mod 2) =44 ? – Wildling Feb 18 '13 at 17:09