0

For example, if I'm in Z5, $-2$ is equivalent to $3$ which is equivalent to $8$. Also, the value of $x$ in the equation $4x = 2$ is $3$.

Note how any integer can be written as an integer that is within $\Bbb Z_5$ (ex. $-2$ and $8$ can both be written as $3$). This is how I solve arithmetic problems within certain $\Bbb Z_n$s: I find the answer normally, and then convert that answer to something that lies within the $\Bbb Z_n$ I'm working in.

For example, normally, $5 + 3 = 8$. But in $\Bbb Z_5$, $5 + 3 = 3$. I can solve this successfully using my method: first I find the answer normally (and get $8$), then I convert that answer to its $\Bbb Z_5$ form and get the answer I want (which is $3$).

The only time where I can't do this is when the answer is a decimal. Take the above equation for example. Normally, $4x = 2$ would tell you that $x = \frac 1 2$. But $\frac 1 2$ is actually already within $\Bbb Z_5$, but it is not equivalent to $3$, so my method did not give me the right answer in this scenario.

Is there some kind of flaw in my thinking that results in my method not working with decimals? What would the value of $\frac 1 2$ actually be over $\Bbb Z_5$? Do decimals not exist at all over any $\Bbb Z_n$?

Any help is greatly appreciated!

James Ronald
  • 2,331
  • "Integer modulo n" I think you answered your own question. – Rushabh Mehta Nov 01 '18 at 22:01
  • But what you are looking for is this – Rushabh Mehta Nov 01 '18 at 22:02
  • $4x \equiv 2\pmod{5}$ implies that $x\equiv 2\cdot 4^{-1}\pmod{5}$. Now, look at what $4^{-1}$ is in $\Bbb Z^5$. You will find that $4^{-1}\equiv 4\pmod{5}$ (since $4\cdot 4 = 16 = 3\cdot 5 + 1$). "Division" is generally not allowed in modular arithmetic, but multiplication by multiplicative inverses is allowed so long as the number has a multiplicative inverse in $\Bbb Z_n$ which is true iff the number is coprime to $n$. – JMoravitz Nov 01 '18 at 22:24
  • 1
    In $\Bbb Z_5$ we have $\frac12=3$. In $\Bbb Q$ we have $\frac12=0.5$. In $\Bbb Z$ there is no such thing as $\frac12$. – Arthur Nov 01 '18 at 22:26
  • Part of your problem may be in your assertion that "1/2 is actually already within $Z_5$". Maybe you're thinking of $Z_5$ as containing everything between 0 and 4 (or maybe even up to but not including 5). It actually contains only integers; the real (and in fact rational) number 1/2 is not an element of $Z_5$. (There is an element of $Z_5$ that deserves the name 1/2 in arithmetic modulo 5, namely the element 3, but this is not the real or rational number 1/2.) – Andreas Blass Nov 01 '18 at 22:51

3 Answers3

1

Other answers are correct. Let me try the same idea with a different slant or emphasis.

I think you what you mean when you think of $1/2$ as a "decimal" is like thinking of it as a fraction. But there's another point of view. You can think of $1/2$ as the solution to the equation $$ ? \times 2 = 1 . $$ In that sense, fractions can make sense in modular arithmetic. Modulo $7$ we can say $1/2$ is $4$ because $4 \times 2 \equiv 1 \pmod 7$. Modulo $8$ there is no such thing as $1/2$.

You will learn in your study of number theory that $1/a$ makes sense in $\mathbb{Z}_n$ if and only if $a$ and $n$ are relatively prime.

Related: How to make sense of fractions?

Ethan Bolker
  • 95,224
  • 7
  • 108
  • 199
0

The problem is that when you say you're doing the original calculation "in $\mathbb{Z}$", you're not - $\mathbb{Z}$ has only integers, no fractions, and you can only divide two elements if the result is an integer. In $\mathbb{Z}$, $\frac{1}{2}$ doesn't exist. You've secretly swapped to $\mathbb{Q}$, which is why you're having trouble moving to $\mathbb{Z}_n$.

If you're doing division in modulo arithmetic, what you instead normally do is look for a multiplicative inverse of the thing you're trying to divide by - for a given $a$, you're looking for a number $b$ such that $ab = 1$, because even in $\mathbb{Z}_n$ you're allowed to do things like:

$\begin{eqnarray}ax & = & m \\ (ba)x & = & bm \\ 1x & = & bm \\ \therefore x & = & bm\end{eqnarray}$

The only thing you have to be careful of is that for a general $n$, some numbers may have multiple inverses, so you may have multiple solutions for your equation. There are some rules about which ones have unique inverses for every element, which you may learn at some point. That said, if you are working in a $\mathbb{Z}_n$ with unique inverses, you can kind of go back to writing $\frac{1}{2}$ (or at least $2^{-1}$) and have it mean almost what you think it means. It's no longer a value between 0 and 1, but it is a thing you can multiply 2 by to get 1.

ConMan
  • 24,300
0

No, decimals don't exist. $\mathbb Z_n$, just like you said, is the integers taken modulo $n$, so we cannot have anything like $0.5$ which isn't an integer in the first place. However, in equations like $2x=1$ over $\mathbb Z_5$, you can still multiply by $2^{-1}$ (read as "$2$ inverse" or "the inverse of $2$", which is not the same as $0.5$), on the left of both expressions. So $2^{-1}2x=2^{-1}1$. Since "anything times $1$ is the thing itself", the RHS is just $2^{-1}$. We have that $2^{-1}2=1$, and so the LHS is $x$. We have $x=2^{-1}$, which in $\mathbb Z_5$ is actually $3$ (because $3\cdot2=1=2^{-1}2$).

YiFan Tey
  • 17,431
  • 4
  • 28
  • 66