0

Show that $$a^2 \mathrm{\ mod \ } b = (a \mathrm{\ mod \ } b)^2 \mathrm{\ mod\ } b$$ for $ a, b \in \mathbb{Z}^+ $.

this was derived from an Informatics olympiad question.

  • it is unclear what exactly the notation means. – Rene Schipperus Aug 08 '14 at 16:33
  • @ReneSchipperus This is just that awkward convention the computer disciplines carry of thinking of $a\pmod{b}$ as the remainder of $a$ after division by $b$, rather than an equivalence relation on integers. – rschwieb Aug 08 '14 at 16:35
  • @rschwieb maybe it could be edited so a mathematician can interpret it. I am still unclear about it. – Rene Schipperus Aug 08 '14 at 16:39
  • @ReneSchipperus "The remainder of the square is equal to the remainder of the square of the remainder." – rschwieb Aug 08 '14 at 16:43

2 Answers2

2

$$a=kb+n\\a^2=k^2b^2+2kbn+n^2\\a^2=n^2\mod{b}$$ Now since $a=n \mod{b}$ this is the proof

kingW3
  • 13,496
  • 1
    It's not clear, but it seems that the above is intended to be a proof of the first implication in my answer (directly, without CPR). But you need to say more than that to obtain a complete, correct proof. My doubt stems from the ambiguity as to whether "mod" denotes a congruence or remainder operation (in both cases). For congruences you should use the form $,j\equiv k\pmod n,,$ to avoid confusion with $, j = k\ {\rm mod\ n},$ i.e. $,j = (k\ {\rm mod}\ n.\ $ – Bill Dubuque Aug 08 '14 at 18:46
  • The argument of @kingW3 is sufficient. By definition, $a = b(a \ div\ b)+a\ mod b$. Then $a^2\ mod\ b=((b(a\ div\ b)+(a\ mod\ b))^2\ mod\ b=(b(a\ div\ b))^2 + 2 b(a\ div\ b)(a\ mod\ b)+(a\ mod\ b)^2)\ mod\ b = (a\ mod\ b)^2\ mod\ b$. –  Aug 08 '14 at 18:50
  • 1
    @Yves I don't agree. And what you wrote is not a proof without any justification of those abstruse equalities. Instead, look how strikingly simple it is using congruences as in my answer. – Bill Dubuque Aug 08 '14 at 18:51
  • What you contemptuously call "abstruse equalities" are the square of a binomial. –  Aug 08 '14 at 19:01
1

Hint $ $ let $\ \bar a := a\ {\rm mod}\ b.\ $ Then $\ {\rm mod}\ b\!:\ a\equiv \bar a\,\overset{\rm\color{#c00}{CPR}}\Rightarrow\, a^2\equiv {\bar a}^2\,$ thus $\, a^2\,{\rm mod}\ b = {\bar a}^2\,{\rm mod}\ b$

Above we employed $\rm\color{#c00}{CPR} =$ Congruence Product Rule. You will need to justify the congruence after "Then" and the equality after "thus" - both of which are straightforward.

Remark $ $ Generally, as above, to prove an identity about mod as an operator it is usually easiest to first convert it into the more flexible congruence form, using $\color{#c00}\Longleftarrow$ in the equivalence, then prove it using congruences, then at the end, convert it back to operator form, using $\color{#c00}\Longrightarrow$ in the equivalence.

For a similar example consider equivalence of fractions, $\,\frac{a}b \equiv \frac{c}d\iff ad = bc.\,$ It would be quite cumbersome to do fraction arithmetic if we required that all fractions always be in normal (reduced) form, i.e. in least terms. Instead, it proves more convenient to have the flexibility to work with arbitrary equivalent fractions. For example, this allows us to state the fraction addition rule in very simple form by first choosing convenient reps having a common denominator.

See here for further discussion on $\!\bmod\!$ as a binary operator vs. equivalence relation.

Bill Dubuque
  • 272,048