0

I have the following equation:

( ((X + Y) mod 29) - Y) mod 29 = Z

However, This can also be written as:

((X + Y) - Y) mod 29 = Z

And achieve the same answer. I have tested it mathematically, but I am not too sure what happens to the modulus since it is treated differently in comparison to a multiplication or division.

Is there any sort of a rule for this?

Thanks for all the help!

P.S Sorry if the formatting is wrong, I am new to posting Math questions.

Cail Demetri
  • 105
  • 3

3 Answers3

0
( ((X + Y) mod 29) - Y) mod 29 =( (((X + Y) mod 29) mod 29) - Y mod 29) 

Which is again:

( ((X + Y) mod 29) - Y mod 29 )

Therefore it results in

( (X + Y)  - Y) mod 29 

Please refer http://nrich.maths.org/4350 for proofs of the steps used

Cail Demetri
  • 105
  • 3
raghu
  • 171
  • 1
  • 5
0

Mathematicians prefer to define modular arithmetic in terms of congruence, rather than as an operation on natural numbers. We say that two integers $a$ and $b$ are "congruent" modulo $n$, and write $$a \equiv b \mod n$$ or $$a \cong b \mod n$$ when $n$ divides evenly into the difference $a-b$. To see how this connects to the operation way of understanding things that you're more familiar with, "$a \mod n$" is the smallest non-negative integer congruent to $a$ modulo $n$. For example, where you might be more familiar with the statement "$53 \mod 29 = 14$", we prefer to write $53 \equiv 14 \mod 29$, and $14$ doesn't really have any special significance here; it would be equally correct to write $53 \equiv 82 \mod 29$, or even $53 \equiv -15 \mod 29$.

Then the key fact at play for your question is the following theorem: if $a \equiv c \mod n$ and $b \equiv d \mod n$, then $a+b \equiv c+d\mod n$, $a-b \equiv c-d\mod n$, and $ab\equiv cd \mod n$.

This theorem says that to compute the sum, difference, or product of two numbers modulo $n$, one may substitute any other congruent number in place before computing the arithmetic operation. In particular, to compute $(X+Y)-Y$ modulo $29$, one may reduce $X+Y$ modulo $29$ before computing the difference, which is what you've observed. Mind you, $(X+Y)-Y = X$, so one could also compute this just by reducing $X$ modulo $29$ and calling it a day.

All of this is detailed in the wikipedia page on modular arithmetic.

  • Thanks, it was alright to understand, the "a+b≡c+d mod n" made it a lot clearer, glad I know this theorem now, should come in handy for the future! – Cail Demetri Jun 12 '14 at 08:08
0

If we write $$ \begin{align} (X+Y)&=q\cdot 29+r\\ Y&=s\cdot 29+t \end{align} $$ we have on one hand $$ \begin{align} (X+Y)\text{ mod }{29}-Y&=r-Y\\ &=r-(s\cdot 29+t)\\ &=-s\cdot29+(r-t) \end{align} $$ which is congruent to $(r-t)$ mod $29$. On the other hand $$ \begin{align} (X+Y)-Y&=q\cdot29+r-(s\cdot 29+t)\\ &=(q-s)\cdot 29+(r-t) \end{align} $$ which is again congruent to $(r-t)$ mod $29$. The two ways of calculating it differs by which point to disregard $q\cdot 29$ as it contributes with no remainder mod $29$.

String
  • 18,395