Do decimals exist in any Z? (Z as in integer modulo n)

265 Views Asked by At

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!

3

There are 3 best solutions below

3
On

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.

0
On

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$).

0
On

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?